/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "bookends.p" */ #include /* bookends: report the endpoint coordinates of pieces in a book Elaine Bucheimer NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) bucheime@ncifcrf.gov http://www-lecb.ncifcrf.gov/~bucheime/ National Cancer Institute Laboratory of Experimental and Computational Biology */ /* end of program */ /* begin module version */ #define version 1.01 /* of bookends.p 1998 June 4 origin 1998 June 4 */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ /* end module version */ /* begin module describe.bookends */ /* name bookends: report the endpoint coordinates of pieces in a book synopsis bookends(book: in, bookends: in, pairs: out, output: out) files book: the book generated by delila using inst pairs: listing of the coordinates of the pieces in the book as a series of pairs: one beginning and one ending per line output: messages to the user description This program reads in a book and extracts the coordinates of the pieces for use in the live program. examples documentation see also live.p author Elaine Bucheimer bugs technical notes */ /* end module describe.bookends */ Static _TEXT book; /* file used by this program */ Static _TEXT pairs; /* file used by this program */ Static jmp_buf _JL1; /* begin module halt */ Static Void halt() { /* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. */ printf(" program halt.\n"); longjmp(_JL1, 1); } /* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; */ /* begin module getcoords */ Static Void getcoords(afile, bfile) _TEXT *afile, *bfile; { /* procedure to find the coords of a piece, read them, and write them into the pairs file */ Char ch = ' '; long firstnum, lastnum; /* reads book until beginning of piece is found */ while (!BUFEOF(afile->f) && ch != 'p') { fscanf(afile->f, "%c%*[^\n]", &ch); getc(afile->f); if (ch == '\n') ch = ' '; } if (BUFEOF(afile->f)) return; fscanf(afile->f, "%*[^\n]"); getc(afile->f); /* reads short name */ fscanf(afile->f, "%*[^\n]"); getc(afile->f); /* reads long name */ /* read a char to see if a note exists. If it does, read until the end of the note is found */ fscanf(afile->f, "%c%*[^\n]", &ch); getc(afile->f); if (ch == '\n') ch = ' '; if (ch == 'n') { do { fscanf(afile->f, "%c%*[^\n]", &ch); getc(afile->f); if (ch == '\n') ch = ' '; } while (ch != 'n'); fscanf(afile->f, "%c%*[^\n]", &ch); getc(afile->f); if (ch == '\n') ch = ' '; } /* read in the piece coordinate information */ fscanf(afile->f, "%*[^\n]"); getc(afile->f); fscanf(afile->f, "%*[^\n]"); getc(afile->f); fscanf(afile->f, "%*[^\n]"); getc(afile->f); fscanf(afile->f, "%*[^\n]"); getc(afile->f); fscanf(afile->f, "%*[^\n]"); getc(afile->f); fscanf(afile->f, "%*[^\n]"); getc(afile->f); /* read the beginning and ending coordinates */ fscanf(afile->f, "%c%ld%*[^\n]", &ch, &firstnum); getc(afile->f); if (ch == '\n') ch = ' '; fscanf(afile->f, "%c%ld%*[^\n]", &ch, &lastnum); getc(afile->f); /* write the beginning and ending coordinates */ if (ch == '\n') ch = ' '; fprintf(bfile->f, "%ld %ld\n", firstnum, lastnum); /* read to the end of the piece for which the coordinates were reported */ do { fscanf(afile->f, "%c%*[^\n]", &ch); getc(afile->f); if (ch == '\n') ch = ' '; } while (ch != 'p'); } /* end module getcoords */ /* begin module bookends.themain */ Static Void themain(book, pairs) _TEXT *book, *pairs; { /* the main procedure of the program */ double parameterversion; /* parameter version number */ printf("bookends %4.2f\n", version); /* reset(bookends); readln(bookends, parameterversion); if parameterversion < updateversion then begin writeln(output, 'You have an old parameter file!'); halt end; */ if (*book->name != '\0') { if (book->f != NULL) book->f = freopen(book->name, "r", book->f); else book->f = fopen(book->name, "r"); } else rewind(book->f); if (book->f == NULL) _EscIO2(FileNotFound, book->name); RESETBUF(book->f, Char); if (*pairs->name != '\0') { if (pairs->f != NULL) pairs->f = freopen(pairs->name, "w", pairs->f); else pairs->f = fopen(pairs->name, "w"); } else { if (pairs->f != NULL) rewind(pairs->f); else pairs->f = tmpfile(); } if (pairs->f == NULL) _EscIO2(FileNotFound, pairs->name); SETUPBUF(pairs->f, Char); while (!BUFEOF(book->f)) getcoords(book, pairs); } /* end module bookends.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; pairs.f = NULL; strcpy(pairs.name, "pairs"); book.f = NULL; strcpy(book.name, "book"); themain(&book, &pairs); _L1: if (book.f != NULL) fclose(book.f); if (pairs.f != NULL) fclose(pairs.f); exit(EXIT_SUCCESS); } /* End. */