/* This program implements a filter for PostScript files generated by Netscape, which adds a footer at each page, with an optional URL (to be supplied at the command line), and a page number. This filter can be used in the "Print Command" field of the "Netscape: Print" window, as for example: add_footer "the-URL-of-the-page" |lpr Alternatively you can print the page to a file, say out.ps, and issue the following command: add_footer "the-URL-of-the-page" int main(int argc, char *argv[]) { char *footer = ""; char ch; int pagenr = 1; if (argc > 1) footer = argv[1]; ch = (char)fgetc(stdin); while (!feof(stdin)) { char buffer[15]; int i = 0; while (!feof(stdin) && ch != '\n') { fputc(ch, stdout); if (i < 14) buffer[i++] = ch; ch = (char)fgetc(stdin); } buffer[i] = '\0'; fputc('\n', stdout); if (!strcmp(buffer, "%%EndPageSetup")) { int j; printf("10 20 moveto 10 f0 ("); if (*footer != '\0') { char *f; printf("URL: "); for (f = footer; *f != '\0'; f++) if (ch == '(' || ch == '\\' || ch == ')') printf("\\%c", *f); else fputc(*f, stdout); printf(", "); } printf("page %d) show\n", pagenr++); } ch = (char)fgetc(stdin); } return 0; }