# ifndef lint static char Sccs_id[] = "%W% (NTUA hackers) (%G%)"; # endif #include #include #define boolean char #define true 1 #define false 0 char buf[BUFSIZ]; int XF = 1; /* X-scale factor */ int YF = 1; /* Y-scale factor */ int lineno = 0; /* Input line no. */ /* * readline(s): read the next input line into s and return its length * or 0 if EOF is encountered. */ readline (s) register char *s; { register int i = 0; while ((*s = getchar ()) != EOF) { i++; if (*s++ == '\n') break; } *s = '\0'; lineno++; return (i); } /* * enlarge(): expand the input file */ enlarge () { register int i, j, k, l; while (l = readline (buf)) { for (i = 0; i < YF; i++) { for (j = 0; j < l - 1; j++) for (k = 0; k < XF; k++) putchar (buf[j]); putchar ('\n'); } } } /* * compress(): compress the input file */ compress () { register int j, l; while (l = readline (buf)) if (lineno % YF == 0) { for (j = 0; j < l - 1; j++) if (j % XF == 0) putchar (buf[j]); putchar ('\n'); } } /* * chsiz : enlarge or compress its input */ main (argc, argv) register int argc; register char **argv; { boolean doenlarge = false; char *s; while (--argc > 0 && (*++argv)[0] == '-') for (s = argv[0] + 1; *s; s++) switch (*s) { case 'x': case 'X': XF = atoi (s + 1); while (isdigit (*++s)); s--; break; case 'y': case 'Y': YF = atoi (s + 1); while (isdigit (*++s)); s--; break; case 'e': doenlarge = true; break; case 'c': doenlarge = false; break; } if (doenlarge) enlarge (); else compress (); exit (0); }