⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rt2ps.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	return(rc);}/* * a keyword has been matched in the input stream, so it's time to * process the associated operation. the key value + 1 is passed in. * if the key is negative, it represents turning an attribute off, e.g. /bold. * if it's positive, it represents turning an attribute on, e.g. italic. * some keywords don't have an off attribute, e.g. there's no /nl. if one of * these is encountered, the "off" is silently ignored. */#define AttrOff (key < 0)voidcontrolOutput( int key ){	int k = abs(key)-1;	/*	 * special case: check for inside <comment>	 */	if( !((g.suppress) && (k != K_COMMENT))) {	  switch(k) {	  /* <nl> */	  case K_NL:		printf("NL\n");		if(g.justifyOff) {			g.justify &= ~g.justifyOff;			g.justifyOff = 0;			printf("/JU %i def\n", jtab[g.justify]);		}		g.atMargin = 1;		break;	  /* <lt> */	  case K_LT:		printf("[(<) 0 x 0] C\n");		break;	  /* <bold> */	  case K_BOLD:		if AttrOff			g.mask &= ~BOLD;		else			g.mask |= BOLD;		break;	  /* <italic */	  case K_ITALIC:		if AttrOff			g.mask &= ~ITALIC;		else			g.mask |= ITALIC;		break;	  /* <fixed> */	  case K_FIXED:		if AttrOff			g.mask &= ~FIXED;		else			g.mask |= FIXED;		break;	  /* <underline> */	  case K_UNDERLINE:		if AttrOff			g.underline = 0;		else			g.underline = 1;		break;	  /* <center> */	  case K_CENTER:		if AttrOff {			g.justifyOff |= CENTER;			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;				printf("/JU %i def\n", jtab[g.justify]);			}		}		else {			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;			}			g.justify |= CENTER;			printf("/JU %i def\n", jtab[g.justify]);		}		break;	  /* <superscript> */	  case K_SUPER:		if AttrOff {			g.super = 0;			if(g.scaled) {				g.fs = g.ffs;				g.scaled = 0;			}		}		else {			g.super = 1;			if(g.scaled == 0) {				g.fs /= 2;				g.scaled = 1;			}			g.sub = 0;			g.space = 0;		}		break;	  /* <subscript> */	  case K_SUB:		if AttrOff {			g.sub = 0;			if(g.scaled) {				g.fs = g.ffs;				g.scaled = 0;			}		}		else {			g.sub = 1;			if(g.scaled == 0) {				g.fs /= 2;				g.scaled = 1;			}			g.super = 0;			g.space = 0;		}		break;	  /* <flushleft> */	  case K_FL:		if AttrOff {			g.justifyOff |= L_JUST;			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;				printf("/JU %i def\n", jtab[g.justify]);			}		}		else {			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;			}			g.justify |= L_JUST;			printf("/JU %i def\n", jtab[g.justify]);		}		break;	  /* <flushright> */	  case K_FR:		if AttrOff {			g.justifyOff |= R_JUST;			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;				printf("/JU %i def\n", jtab[g.justify]);			}		}		else {			if(g.atMargin) {				g.justify &= ~g.justifyOff;				g.justifyOff = 0;			}			g.justify |= R_JUST;			printf("/JU %i def\n", jtab[g.justify]);		}		break;	  /* <indent> */	  case K_INDENT:		if AttrOff {			if(g.atMargin)				puts("DLM\n");			else				puts("DDLM\n");		}		else {			if(g.atMargin)				puts("ILM\n");			else				puts("DILM\n");		}		break;	  /* <indentright> */	  case K_INDENTR:		if AttrOff {			if(g.atMargin)				puts("DRM\n");			else				puts("DDRM\n");		}		else {			if(g.atMargin)				puts("IRM\n");			else				puts("DIRM\n");		}		break;	  /* <outdent> */	  case K_OUTDENT:		if AttrOff {			if(g.atMargin)				puts("ILM\n");			else				puts("DILM\n");		}		else {			if(g.atMargin)				puts("DLM\n");			else				puts("DDLM\n");		}		break;	  /* <outdentright> */	  case K_OUTDENTR:		if AttrOff {			if(g.atMargin)				puts("IRM\n");			else				puts("DIRM\n");		}		else {			if(g.atMargin)				puts("DRM\n");			else				puts("DDRM\n");		}		break;	  /* <comment> */	  case K_COMMENT:		if AttrOff			g.suppress = 0;		else			g.suppress = 1;		break;	  /* <np> */	  case K_NP:		printf("NP\n");		break;	  /* <bigger> */	  case K_BIGGER:		if AttrOff			g.fs -=2;		else			g.fs +=2;		g.ffs = g.fs;		break;	  /* <smaller> */	  case K_SMALLER:		if AttrOff			g.fs +=2;		else			g.fs -=2;		g.ffs = g.fs;		break;	  default:		fprintf(stderr, "INVALID KEYWORD\n");  	  }	}	g.c = 0;	g.keyword = 0;}/* * fold alphabetic characters to upper case * note: VERY dependant on ASCII encoding */voidfoldLow( char *x ){	for ( ; *x != '>'; x++ ) {		if ( ( *x >= 'A' ) && ( *x <= 'Z' ) )			x[0] = (char)((int)(x[0]) + 32);	}}/* * Output PostScript prolog code * * The main body of the prolog is read from a static data structure, which * contains the pagination macros. The data structure is in prolog.h,  * which is built by the Perl program mkincl. The source for the prolog is * paginate.ps. This is a "stripped" version of the PostScript code. The * human-readable source is in paginate.ps.verbose. This latter file is the * one which should be edited if PostScript code changes are required. The * Perl program pstrip converts paginate.ps.verbose to paginate.ps. The * purpose for doing all this is to make the program self contained, rather * than require shipping an extra file with it, containing the PostScript code. */static time_t tloc;voidprolog(){	char *c = &pscode[0];	if(g.prolog) {		puts("%!PS");		puts("%Copyright (c) 1996 H&L Software, Inc.");		puts("%All rights reserved");		puts("%%BeginProlog");		/*		 * copy the PostScript macros from the static data		 * structure to standard output.		 */		while( *c != (char) NULL ) {			putchar((int) *c++);		}		puts("\n%%EndProlog\n%%BeginSetup");		/*		 * set flag for drawing box (or not) around each page		 */		if(g.box)			puts("/BOX true def\nDB	% draw box for first page"); 		else			puts("/BOX false def"); 		/*		 * set flag for running header (or not) 		 */		if(g.hdr) {			puts("/HDR true def\n/PG 1 def"); 			time(&tloc);			printf("/MSG (Message converted on %s) def\n",  ctime(&tloc));			puts("PH	% print header for first page"); 		}		else			puts("/HDR false def"); 		/*		 * define short-hand literal names for fonts		 */		if (g.altFont) {			strcpy(buff, "(Times-Roman) cvlit /f1 exch def ");			strcat(buff, "(Times-Bold) cvlit /f1b exch def ");			strcat(buff, "(Times-Italic) cvlit /f1i exch def ");			strcat(buff, "(Times-BoldItalic) cvlit /f1bi exch def ");		}		else {			strcpy(buff, "(Helvetica) cvlit /f1 exch def ");			strcat(buff, "(Helvetica-Bold) cvlit /f1b exch def ");			strcat(buff, "(Helvetica-Oblique) cvlit /f1i exch def ");			strcat(buff, "(Helvetica-BoldOblique) cvlit /f1bi exch def ");		}		strcat(buff, "(Courier) cvlit /f2 exch def ");		strcat(buff, "(Courier-Bold) cvlit /f2b exch def ");		strcat(buff, "(Courier-Oblique) cvlit /f2i exch def ");		strcat(buff, "(Courier-BoldOblique) cvlit /f2bi exch def\n");		puts( buff );		/*		 * set the page margins		 *//*** to override the stuff in the PostScript prolog, this is the place ***/		puts("%%EndSetup");	}}/* * wrap up the PostScript output */voidepilog(){	/*	 * if text in the buffer, dump it out	 */	if (g.atMargin == 0)		tokenOutput(buff);	/*	 * cause final "showpage"	 */	puts("/BOX false def\n/HDR false def"); 	puts("NP");	puts("%%EOF");}/* * this routine parses command line flags and arguments */intgetArgs( int argc, char **argv ){	int c;	int fs;	int rc = 0;	extern char     *optarg;	extern int      optind;	int		opterr = 0;	/*	 * get program name (for error msgs) and directory name (for	 * finding PostScript prolog file.	 */	g.n = baseName( g.n, argv[0] );	g.d = dirName( g.d, argv[0] );	/*	 * parse arguments	 */	while ((c=getopt(argc, argv, "bpts:h?")) != EOF)		switch(c) {					/*		 * 'b' flag causes a box to be drawn around the margins		 *	on each page.		 */		case 'b':			g.box = 1;			break;		/*		 * 'p' flag suppresses pre-pending the PostScript prolog		 * 	to the output. this is useful when debugging, using		 *	the program as a filter for standard input and 		 *	interactively writing conversions to standard output.		 */		case 'p':			g.prolog = 0;			break;		/*		 * 't' flag changes default font to "Times",		 *     rather than "Helvetica."		 */		case 't':			g.altFont = 1;			break;		/*		 * 'u' flag causes unrecognized MIME tags to be shown		 *     in the output. useful for debugging.		 */		case 'u':			g.showTags = 1;			break;		/*		 * 's' flag followed by an integer overrides the		 * default font size (10 pt)		 */		case 's':			fs = atoi(optarg);			if(errno)				perror(g.n);			if(fs > 0 && fs < 36) {				g.fs = fs;				g.ffs = fs;			}			break;		/*		 * 'h' flag causes printing of running headers		 */		case 'h':			g.hdr = 1;			break;		case '?':			opterr++;			break;		}	if(opterr) {		showHelp();		rc = 1;	}	/*	 * discard command line arguments	 */	for ( ; optind < argc; optind++) {		fprintf(stderr, "%s: Unrecognized parameter: %s\n", g.n, argv[optind]);		rc = 1;	}	return(rc);}/* * get program name, for error messages * simulate the "basename()" function, so as to avoid using libgen, *   since not always available. */char *baseName( char *n, char *a ){	extern char *strrchr( const char *, int);	n = strrchr(a, (int)'/');	if( n == NULL)		n = a;	else		++n;	return(n);}char *dirName( char *n, char *a ){	char *end;	extern char *strrchr( const char *, int);	end = strrchr(a, (int)'/');	if( end != NULL ) {		strncpy(n, a, (int)(end-a+1));		n[(int)(end-a+1)] = (char)NULL;	}	else		n[0] = (char)NULL;	return(n);}/* * display some help text */voidshowHelp(){	fprintf(stderr,"usage: %s [-b] [-p] [-t] [-h] [-s nn]\n",g.n);	fprintf(stderr,"\nThe -b flag causes a box to be drawn along the page margins.\n");	fprintf(stderr,"\nThe -p flag suppresses output of the PostScript prolog code, an option probably only useful for debugging.\n");	fprintf(stderr,"\nThe -t flag changes the default font from Helvetica to Times-Roman.\n");	fprintf(stderr,"\nThe -h flag causes running headers to be printed on each page.\n");	fprintf(stderr,"\nThe -s flag changes the default font size from 10 pt to the value of \"nn\", up to a maximum of 36 pt.\n");	fprintf(stderr,"\nThe -u flag causes unrecognized MIME tags to be shown in the output.\n");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -