/* -*-c,save-*- */ /* * SQMAIN.C - main line for standalone SQ * Robert Heller. Created: Sat Nov 8, 1986 17:41:12.10 * Last Mod: * */ #include #define CPM68K 1 /* CP/M-68K *RPH* */ #ifdef CPM68K #define FNM_LEN 15 #else #define FNM_LEN 35 #define UNIX /* comment out for CP/M, MS-DOS versions */ #endif #ifdef CPM68K #define VERSION "3.3A (CP/M-68K) Nov 8, 1986" #else #define VERSION "3.3 12/13/85" #endif /* Definitions and external declarations */ #ifdef CPM68K #define void #endif extern char sq_dbg; /* Boolean flag */ main(argc, argv) int argc; char *argv[]; { #ifndef CPM68K void obey(); #endif int i,c; char inparg[128]; /* parameter from input */ sq_dbg = FALSE; printf("File squeezer version %s (original author: R. Greenlaw)\n\n", VERSION); /* Process the parameters in order */ for(i = 1; i < argc; ++i) obey(argv[i]); if(argc < 2) { printf("Enter file names, one line at a time, or type to quit."); do { printf("\n*"); for(i = 0; i < 16; ++i) { if((c = getchar()) == EOF) c = '\n'; /* fake empty (exit) command */ if((inparg[i] = c) == '\n') { inparg[i] = '\0'; break; } } if(inparg[0] != '\0') obey(inparg); } while(inparg[0] != '\0'); } } /* eject eject */ void obey(p) char *p; { #ifndef CPM68K void squeeze(); #endif char *q; char *rindex(); char outfile[128]; /* output file spec. */ if(*p == '-') { /* toggle debug option */ sq_dbg = !sq_dbg; return; } /* Check for ambiguous (wild-card) name */ for(q = p; *q != '\0'; ++q) if(*q == '*' || *q == '?') { printf("\nAmbiguous name %s ignored\n", p); return; } /* First build output file name */ strcpy(outfile, p); /* copy input name to output */ /* Find and change output file suffix */ if ((q = rindex(outfile, '.')) == NULL) /* if no '.' in name */ strcat(outfile, ".qq"); else { strcat(q, " "); /* extend end of string marks */ if (*++q == ' ') /* if no next character */ *q = 'q'; *++q = 'q'; /* make file .?q? */ if (*++q == ' ') /* if no next character */ *q = '\0'; /* terminate early */ else *++q = '\0'; /* terminate filename */ } squeeze(p, outfile); }