/* ACREATE.C: Program to create alias files from text files */ #include #define MAX_BUFFER 256 /* Maximum capacity of the command line buffer -1 */ /* My Apple is 200, so it is 199 here. The ZCPR */ /* utility SHOW.COM will report the command line */ /* size if it is not known. If you can not */ /* compile the program again, then you will have */ /* to remember the availiable size to insure that */ /* there are no "Ovfl" errors. */ char ibuf[BUFSIZ], obuf[BUFSIZ], file_name[40], command[256]; int a, c, i; main(argc, argv) char **argv; { if (argc != 3) { printf("\nUsage: A>acreate source_file alias_file \n"); exit(); } if (fopen(argv[1], ibuf) == ERROR) { printf("\nCan't open source file %s\n", argv[1]); exit(); } for (i=0; i < 256; i++) { command[i] = getc(ibuf); if (command[i] == 10) i--; if (command[i] == 13) command[i] = ';'; if (command[i] == CPMEOF) break; } if (command[i-1] == ';') i--; command[i] = 0; if (i > MAX_BUFFER) { printf("\n** ERROR ** %S = %d bytes.", argv[1], i); printf(" %d bytes too long.\n", i-MAX_BUFFER); exit(); } fabort(ibuf); if (fopen("alias.mas", ibuf) == ERROR) { if (fopen("0/a:alias.mas", ibuf) == ERROR) { if (fopen("15/a:alias.mas", ibuf) == ERROR) { printf("\nCan't open alias master file 'ALIAS.MAS'\n"); printf("on A0:, A15:, or the currently logged drive.\n"); exit(); } } } if (strlen(argv[2]) > 16) { printf("\nThat's an awfully long file name. Try again...\n"); exit(); } strcpy(file_name, argv[2]); c = FALSE; for (i=0; file_name[i] != 0; i++) if (file_name[i] == '.') c = TRUE; if (c == FALSE) strcat(file_name, ".COM"); if (fcreat(file_name, obuf) == ERROR) { printf("\nCan't create %s\n", file_name); exit(); } for (i=0; i < 28; i++) putc(getc(ibuf), obuf); for (i=0; i < 256; i++) { getc(ibuf); putc(command[i], obuf); } while ((c = getc(ibuf)) != EOF) putc(c, obuf); fclose(obuf); printf("\n** Done **\n\n"); } buf); } while ((c = g