Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site cp1.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!aplvax!cp1!hart From: hart@cp1.UUCP Newsgroups: net.sources Subject: file format programs Message-ID: <763@cp1.UUCP> Date: Sun, 19-Aug-84 00:38:15 EDT Article-I.D.: cp1.763 Posted: Sun Aug 19 00:38:15 1984 Date-Received: Tue, 21-Aug-84 05:22:36 EDT Organization: C & P Tel. Co., Balto., Md. Lines: 111 echo fix.c sed 's/^ //' > fix.c << 'Rod Hart was here' #include#define LINEWIDTH 80 /* * fix - Convert files to fix format. * * Fix format files use a single character to represent four bit * nibbles. The characters start at character 0 (30H) and extend * through the character ? (3FH). The first line contains the * name of the original file (excluding path or disk specification) * preceeded by a minus sign. The rest of the file contains 80 * characters per line. */ main(argc,argv) int argc; char **argv; { int c,column; FILE *fd; if (argc != 2) { fprintf(stderr,"usage: fix file\n"); exit(-1); } argv++; /* skip command name */ if ((fd = fopen(*argv,"r")) == NULL) { fprintf(stderr,"cannot open %s\n",*argv); exit(-1); } printf("-%s\n",*argv); /* write filename line */ column=0; for (c=fgetc(fd); c != EOF; c=fgetc(fd)) { putchar(((c>>4) & 0xF)+'0'); putchar((c & 0xF)+'0'); column += 2; if (column == LINEWIDTH) { putchar('\n'); column=0; } } } Rod Hart was here echo unfix.c sed 's/^ //' > unfix.c << 'Rod Hart was here' #include #define LINEWIDTH 80 /* * unfix - Convert fix format files back to original form. * * Fix format files use a single character to represent four bit * nibbles. The characters start at character 0 (30H) and extend * through the character ? (3FH). The first line contains the * name of the original file (excluding path or disk specification) * preceeded by a minus sign. The rest of the file contains 80 * characters per line. */ main(argc,argv) int argc; char **argv; { int c,cout; char filename[128]; char line[LINEWIDTH+1]; char *cp; FILE *fd,*ofd; if (argc != 2) { fprintf(stderr,"usage: fix file\n"); exit(-1); } argv++; /* skip command name */ if ((fd = fopen(*argv,"r")) == NULL) { fprintf(stderr,"cannot open %s\n",*argv); exit(-1); } fgets(filename,128,fd); /* read filename line */ for (cp=filename; *cp != '\n' && cp < filename+128; cp++) ; if (*cp == '\n') /* remove newline at end of line */ *cp = '\0'; if (filename[0] != '-') { fprintf(stderr,"file is not in fix format\n"); exit(-1); } if ((ofd = fopen(&filename[1],"w")) == NULL) { fprintf(stderr,"cannot open output file %s\n",&filename[1]); exit(-1); } for (c=fgetc(fd); c != EOF; c=fgetc(fd)) { if (c == '\n') continue; cout = (c-'0') << 4; c = fgetc(fd); cout |= c-'0'; putc(cout,ofd); } } Rod Hart was here -- ====================================================================== signed: Rod Hart (wa3mez) Chesapeake & Potomac Tel. Co. Bell Atlantic Inc. Silver Spring, Md. gamma!cp1!hart - umcp-cs!cp1!hart - aplvax!cp1!hart ======================================================================