[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.1, Tue Dec 21 02:47:29 1999 UTC (24 years, 5 months ago) by noro
Branch: MAIN
CVS Tags: maekawa-ipv6, RELEASE_20000124, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2, KNOPPIX_2006, DEB_REL_1_2_3-9

Now 'asir-doc' can produce both English and Japanese versions of
manuals, help files and HTML files. See README for detail.
Though Takayama-san's effort to enhance 'oxweave', it is still
difficult to use it as is for 'asir-doc', so currently 'extract_man.c'
is used to extract manual sources for a specific language.

/* $OpenXM: OpenXM/src/asir-doc/extract_man.c,v 1.1 1999/12/21 02:47:29 noro Exp $ */

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

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],"JP") ) {
		ok = "\\JP";
		bok = "\\BJP";
		eok = "\\E";
		ng = "\\EG";
		bng = "\\BEG";
		eng = "\\E";
	} else if ( !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");
}