/* $Id: RdOffFile.c,v 1.1 2004/05/05 21:44:46 tl Exp $ */ #include #include #include #include int RdOffFile(char *fn, int *offset) { /* process time alignment cal files */ /* declarations */ FILE *fp; int i1, i2, nn; char *st, str[64]; /* open file */ fp = fopen(fn, "r"); if (fp == NULL) { printf("could not open \"%s\"\n", fn); exit(1); }; printf("\"%s\" open \n", fn); /* read values */ nn = 0; st = fgets(str, 64, fp); while (st != NULL) { if (str[0] == 35) { /* '#' comment line, do nothing */ } else if (str[0] == 59) { /* ';' comment line, do nothing */ } else if (str[0] == 10) { /* empty line, do nothing */ } else { sscanf(str, "%i %i", &i1, &i2); printf("det %3.3i: time offset=%5i\n", i1, i2); fflush(stdout); offset[i1] = i2; nn++; }; /* attempt to read next line */ st = fgets(str, 64, fp); }; printf("read %i time offsets\n", nn); /* done */ fclose(fp); return (0); };