Annotation of OpenXM/src/asir-doc/extract_man.c, Revision 1.3
1.3 ! ohara 1: /* $OpenXM: OpenXM/src/asir-doc/extract_man.c,v 1.2 2009/02/22 16:40:05 ohara Exp $ */
1.1 noro 2:
3: #include <stdio.h>
4: #include <string.h>
1.3 ! ohara 5: #include <stdlib.h>
1.1 noro 6:
1.3 ! ohara 7: int
1.1 noro 8: main(argc,argv)
9: int argc;
10: char **argv;
11: {
12: int c;
13: FILE *in,*fp;
14: char buf[BUFSIZ*100];
15: char *ok,*ng,*bok,*eok,*bng,*eng;
16:
17: if ( argc != 3 )
18: goto usage;
1.2 ohara 19: if ( !strcmp(argv[1],"ja") || !strcmp(argv[1],"JP") ) {
1.1 noro 20: ok = "\\JP";
21: bok = "\\BJP";
22: eok = "\\E";
23: ng = "\\EG";
24: bng = "\\BEG";
25: eng = "\\E";
1.2 ohara 26: } else if ( !strcmp(argv[1],"en") || !strcmp(argv[1],"EG") ) {
1.1 noro 27: ok = "\\EG";
28: bok = "\\BEG";
29: eok = "\\E";
30: ng = "\\JP";
31: bng = "\\BJP";
32: eng = "\\E";
33: } else
34: goto usage;
35:
36: in = fopen(argv[2],"rb");
37: if ( !in ) {
38: fprintf(stderr,"%s : not found",argv[2]);
39: exit(0);
40: }
41: while ( 1 ) {
42: if ( !fgets(buf,BUFSIZ,in) )
43: exit(0);
44: if ( !strncmp(buf,ok,3) )
45: fputs(buf+4,stdout);
46: else if ( !strncmp(buf,bok,4) ) {
47: while ( 1 ) {
48: if ( !fgets(buf,BUFSIZ,in) ) {
49: fprintf(stderr,"%s : EOF while %s is active.",argv[2],bok);
50: exit(0);
51: }
52: if ( !strncmp(buf,eok,2) )
53: break;
54: else
55: fputs(buf,stdout);
56: }
57: } else if ( !strncmp(buf,bng,4) ) {
58: while ( 1 ) {
59: if ( !fgets(buf,BUFSIZ,in) ) {
60: fprintf(stderr,"%s : EOF while %s is active.",argv[2],bng);
61: exit(0);
62: }
63: if ( !strncmp(buf,eng,2) )
64: break;
65: }
66: } else if ( strncmp(buf,ng,3) )
67: fputs(buf,stdout);
68: }
69: usage:
70: fprintf(stderr,"usage : extract_man JP|EG texinfofile\n");
71: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>