[BACK]Return to extract_man.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc

File: [local] / OpenXM / src / asir-doc / extract_man.c (download)

Revision 1.3, Sun Feb 22 22:48:15 2009 UTC (15 years, 2 months ago) by ohara
Branch: MAIN
CVS Tags: R_1_3_1-2, RELEASE_1_3_1_13b, RELEASE_1_2_3_12, HEAD
Changes since 1.2: +3 -1 lines

Add headers.

/* $OpenXM: OpenXM/src/asir-doc/extract_man.c,v 1.3 2009/02/22 22:48:15 ohara Exp $ */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int
main(argc,argv)
int argc;
char **argv;
{
	int c;
	FILE *in,*fp;
	char buf[BUFSIZ*100];
	char *ok,*ng,*bok,*eok,*bng,*eng;

	if ( argc != 3 )
		goto usage;
	if ( !strcmp(argv[1],"ja") || !strcmp(argv[1],"JP") ) {
		ok = "\\JP";
		bok = "\\BJP";
		eok = "\\E";
		ng = "\\EG";
		bng = "\\BEG";
		eng = "\\E";
	} else if ( !strcmp(argv[1],"en") || !strcmp(argv[1],"EG") ) {
		ok = "\\EG";
		bok = "\\BEG";
		eok = "\\E";
		ng = "\\JP";
		bng = "\\BJP";
		eng = "\\E";
	} else
		goto usage;

	in = fopen(argv[2],"rb");
	if ( !in ) {
		fprintf(stderr,"%s : not found",argv[2]);
		exit(0);
	}
	while ( 1 ) {
		if ( !fgets(buf,BUFSIZ,in) )
			exit(0);
		if ( !strncmp(buf,ok,3) )
			fputs(buf+4,stdout);
		else if ( !strncmp(buf,bok,4) ) {
			while ( 1 ) {
				if  ( !fgets(buf,BUFSIZ,in) ) {
					fprintf(stderr,"%s : EOF while %s is active.",argv[2],bok);
					exit(0);
				}
				if ( !strncmp(buf,eok,2) )
					break;
				else
					fputs(buf,stdout);
			}
		} else if ( !strncmp(buf,bng,4) ) {
			while ( 1 ) {
				if  ( !fgets(buf,BUFSIZ,in) ) {
					fprintf(stderr,"%s : EOF while %s is active.",argv[2],bng);
					exit(0);
				}
				if ( !strncmp(buf,eng,2) )
					break;
			}
		} else if ( strncmp(buf,ng,3) )
			fputs(buf,stdout);
	}
usage:
	fprintf(stderr,"usage : extract_man JP|EG texinfofile\n");
}