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

📄 mail.c

📁 unix高级编程源代码.<<unix高级编程>>
💻 C
字号:
#include	"lprps.h"

static FILE	*mailfp;
static char	temp_file[L_tmpnam];
static void	open_mailfp(void);

/* Called by proc_input_char() when it encounters characters
 * that are not message characters.  We have to send these
 * characters back to the user. */

void
mail_char(int c)
{
	static int	done_intro = 0;

	if (in_job && (done_intro || c != '\n')) {
		open_mailfp();
		if (done_intro == 0) {
			fputs("Your PostScript printer job "
				  "produced the following output:\n", mailfp);
			done_intro = 1;
		}
		putc(c, mailfp);
	}
}

/* Called by proc_msg() when an "Error" or "OffendingCommand" key
 * is returned by the PostScript interpreter.  Send the key and
 * val to the user. */

void
mail_line(const char *msg, const char *val)
{
	if (in_job) {
    	open_mailfp();
  		fprintf(mailfp, msg, val);
	}
}

/* Create and open a temporary mail file, if not already open.
 * Called by mail_char() and mail_line() above. */

static void
open_mailfp(void)
{
	if (mailfp == NULL) {
		if ( (mailfp = fopen(tmpnam(temp_file), "w")) == NULL)
			log_sys("open_mailfp: fopen error");
	}
}

/* Close the temporary mail file and send it to the user.
 * Registered to be called on exit() by atexit() in main(). */

void
close_mailfp(void)
{
	char	command[1024];

	if (mailfp != NULL) {
		if (fclose(mailfp) == EOF)
			log_sys("close_mailfp: fclose error");
		sprintf(command, MAILCMD, loginname, hostname, temp_file);
		system(command);
		unlink(temp_file);
	}
}

⌨️ 快捷键说明

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