/*************************************************************************** * Copyright (C) 1991,1992 by Wei Sun (william@cs.anu.edu.au) * All Rights Reserved * Version 2.02 * *File:gbinit.c * * DISTRIBUTION: * This program is NOT in public domain. * It can be freely distributed for non-commercial purposes only, * and THERE IS NO WARRANTY FOR THIS PROGRAM. ****************************************************************************/ #include "gb2ps.h" char pathname[50]; int init(arg,arglist) int arg; char **arglist; { char** i; int k=0; *cfont_name=0; out = stdout; for (i=arglist+1; i %s\n",*i); exit (1); } k++; break; case 1: if ((out=fopen(*i,"w"))==NULL) { printf("Can't open output file -> %s\n",*i); exit (1); } k++; break; } } if (k<2) { printf("gb2ps\t[-h][-y year][-m month][-i issue][-p][-t][-f][-b page_no]\n\ \t[-e page_no] input_file [output_file]\n\n"); if (k<1) printf("Input file name not supplied.\n"); else printf("Output file name not supplied.\n"); exit (1); } if (*pathname==0) if (getenv("CFONT")!=NULL) strcpy(pathname,getenv("CFONT")); else strcpy (pathname,CFONT); strcpy(cfont_name,pathname); strcat(cfont_name,SONGTI); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[0].fp=cfont; strcpy(CHFONT[0].name,"SONG 24"); CHFONT[0].height=10; CHFONT[0].width=10; } else { fprintf(stderr,"Cannot open the chinese font file -> %s\n", cfont_name); exit (1); } strcpy(cfont_name,pathname); strcat(cfont_name,KEITI); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[1].fp=cfont; strcpy(CHFONT[1].name,"KEI 24"); CHFONT[1].height=10; CHFONT[1].width=10; } else { fprintf(stderr,"Warnning: cannot open the chinese font file -> %s, use %s instead.\n",cfont_name,SONGTI); CHFONT[1]=CHFONT[0]; } strcpy(cfont_name,pathname); strcat(cfont_name,FANGSONGTI); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[2].fp=cfont; strcpy(CHFONT[2].name,"FANG SONG 24"); CHFONT[2].height=10; CHFONT[2].width=10; } else { fprintf(stderr,"Warnning: cannot open the chinese font file -> %s, use %s instead.\n",cfont_name,SONGTI); CHFONT[2]=CHFONT[0]; } strcpy(cfont_name,pathname); strcat(cfont_name,HEITI); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[3].fp=cfont; strcpy(CHFONT[3].name,"HEI 24"); CHFONT[3].height=10; CHFONT[3].width=10; } else { fprintf(stderr,"Warnning: cannot open the chinese font file -> %s, use %s instead.\n",cfont_name,SONGTI); CHFONT[3]=CHFONT[0]; } strcpy(cfont_name,pathname); strcat(cfont_name,FANTI); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[4].fp=cfont; strcpy(CHFONT[4].name,"FAN 24"); CHFONT[4].height=10; CHFONT[4].width=10; } else { fprintf(stderr,"Warnning: cannot open the chinese font file -> %s, use %s instead.\n",cfont_name,SONGTI); CHFONT[4]=CHFONT[0]; } strcpy(cfont_name,pathname); strcat(cfont_name,USERDEF); if ((cfont = fopen (cfont_name, "r"))!=NULL) { CHFONT[5].fp=cfont; strcpy(CHFONT[5].name,"USER 24"); CHFONT[5].height=10; CHFONT[5].width=10; } else { CHFONT[5]=CHFONT[0]; } return k; } cleanup(i) int i; { switch(i) { case 2: fclose(out); case 1: fclose(in); } cfont=CHFONT[0].fp; fclose (CHFONT[0].fp); if (cfont!=CHFONT[1].fp) fclose(CHFONT[1].fp); if (cfont!=CHFONT[2].fp) fclose(CHFONT[2].fp); if (cfont!=CHFONT[3].fp) fclose(CHFONT[3].fp); if (cfont!=CHFONT[4].fp) fclose(CHFONT[4].fp); if (cfont!=CHFONT[5].fp) fclose(CHFONT[5].fp); }