Example #1
0
File: lpd.c Project: dank101/3BSD
main(argc, argv)
{
	register char *p1, *p2;
	register int df;
	register FILE *dp;
	struct stat stb;

	signal(SIGHUP, SIG_IGN);
	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);
	signal(SIGTERM, SIG_IGN);
/*
 * Close all files, open root as 0, 1, 2
 * to assure standard environment
 */
	for (df=0; df<=15; df++)
		close(df);
	open("/", 0);
	dup(0);
	dup(0);
	if (stat("/usr/spool/lpd/lock", &stb) >= 0)
		exit(0);
	if ((df=creat("/usr/spool/lpd/lock", 0)) < 0)
		exit(0);
	close(df);
	if (fork())
		exit(0);
again:
	dp = fopen("/usr/spool/lpd", "r");
	do {
		if (fread(&dbuf, sizeof dbuf, 1, dp) != 1) {
			feedpage();
			unlink("/usr/spool/lpd/lock");
			exit(0);
		}
	} while (dbuf.d_ino==0 || dbuf.d_name[0]!='d' || dbuf.d_name[1]!='f');
	fclose(dp);
	strcpy(dfname, "/usr/spool/lpd/");
	strcatn(dfname, dbuf.d_name, DIRSIZ);
	if (trysend(dfname) == 0)
		goto again;
	sleep(waittm);
	goto again;
}
Example #2
0
static void mapunit (char *symbol, char *text)	
/* produce an entry for a map legend */
{
    if (vpos < 1.0)		/* leave 1" bottom margin */
	feedpage ();
    vpos -= vspace / 2;		/* space down a half line */
    if (strcmp (symbol, "nobox"))	/* strcmp==TRUE means `no match' */
    {
	drawbox (tab[0], vpos);	/* draw the box */
	vp_tjust (TH_CENTER, TV_HALF);	/* center the symbol in the box */
	vp_fat ((int) ((charsz - 1) / 2));	/* pick a good text fatness */
	vp_text (tab[0] + (boxsz[0] / 2),
		 vpos, charsz - 1, 0, symbol);	/* write the map symbol */
    }
    vp_fat ((int) (charsz / 2));
    vp_tjust (TH_LEFT, TV_HALF);/* reset left justification */
    vp_text (tab[1], vpos, charsz, 0, text);	/* write the explanation */
    vpos -= vspace / 2;		/* space down a half line */
}