]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - doc/utils/rfc_pg.c
2 * $Header: /var/cvsroot/strongswan/doc/utils/rfc_pg.c,v 1.1 2004/03/15 20:35:24 as Exp $
4 * from 2-nroff.template file.
6 * Remove N lines following any line that contains a form feed (^L).
7 * (Why can't this be done with awk or sed?)
10 * -n# Number of lines to delete following each ^L (0 default).
12 * Revision 1.1 2004/03/15 20:35:24 as
13 * added files from freeswan-2.04-x509-1.5.3
15 * Revision 1.1 2002/07/23 18:42:43 mcr
16 * required utility from IETF to help with formatting of drafts.
21 #define FORM_FEED '\f'
22 #define OPTION "n:N:" /* for getopt() */
31 int c
, /* next input char */
32 nlines
= 0; /* lines to delete after ^L */
33 void print_and_delete(); /* print line starting with ^L,
34 then delete N lines */
36 /*********************** Process option (-nlines) ***********************/
38 while ((c
= getopt(argc
, argv
, OPTION
)) != EOF
)
42 case 'N' : nlines
= atoi(optarg
);
45 /************************* READ AND PROCESS CHARS **********************/
47 while ((c
= getchar()) != EOF
)
49 print_and_delete(nlines
); /* remove N lines after this one */
51 putchar(c
); /* we write the form feed */
57 * Print rest of line, then delete next N lines.
59 void print_and_delete(n
)
60 int n
; /* nbr of lines to delete */
62 int c
, /* next input char */
63 cntr
= 0; /* count of deleted lines */
65 while ((c
= getchar()) != '\n') /* finish current line */
67 putchar('\n'); /* write the last CR */
70 for ( ; cntr
< n
; cntr
++)
71 while ((c
= getchar()) != '\n')
73 exit(0); /* exit on EOF */
74 putchar(c
); /* write that last CR */