コード例 #1
0
ファイル: recvjob.c プロジェクト: dank101/4.2BSD
recvjob()
{
	struct stat stb;
	char *bp = pbuf;
	int status;

	/*
	 * Perform lookup for printer name or abbreviation
	 */
	if ((status = pgetent(line, printer)) < 0)
		fatal("cannot open printer description file");
	else if (status == 0)
		fatal("unknown printer");
	if ((LF = pgetstr("lf", &bp)) == NULL)
		LF = DEFLOGF;
	if ((SD = pgetstr("sd", &bp)) == NULL)
		SD = DEFSPOOL;
	if ((LO = pgetstr("lo", &bp)) == NULL)
		LO = DEFLOCK;

	(void) close(2);
	(void) open(LF, O_WRONLY|O_APPEND);
	if (chdir(SD) < 0)
		fatal("cannot chdir to %s", SD);
	if (stat(LO, &stb) == 0 && (stb.st_mode & 010)) {
		/* queue is disabled */
		putchar('\1');		/* return error code */
		exit(1);
	}

	if (readjob())
		printjob();
}
コード例 #2
0
ファイル: lpjob.c プロジェクト: LambdaCalculus379/SLS-1.02
void stringread( void )
{
int count;
char *result;
char *bufptr;
char *work, buffer[ 240 ];

  /* read string values */
  /* numerical values */
  
  for( count = 1; count < 9; count ++ )
    {
    work = buffer;
    result = pgetstr( string_set[ count ].spcapname, &work );
    if( result )
      {
      bufptr = strdup( result );
      if( bufptr )
        {
        message( "setting %s to %s == %s\n\r",
                 string_set[ count ].spcapname, result, bufptr );
        string_set[ count ].svalue = bufptr;
        }
      else
        {
        fprintf( stderr, "oudda da mem'ry, time ta bi mo'\n\r" );
        exit( 1 );
        }
      }   
    }
}/* makes me just want to cry! */
コード例 #3
0
recvjob()
{
	struct stat stb;
	char *bp = pbuf;
	int status, rcleanup();

	/*
	 * Perform lookup for printer name or abbreviation
	 */
	if ((status = pgetent(line, printer)) < 0)
		frecverr("cannot open printer description file");
	else if (status == 0)
		frecverr("unknown printer %s", printer);
	if ((LF = pgetstr("lf", &bp)) == NULL)
		LF = DEFLOGF;
	if ((SD = pgetstr("sd", &bp)) == NULL)
		SD = DEFSPOOL;
	if ((LO = pgetstr("lo", &bp)) == NULL)
		LO = DEFLOCK;

	(void) close(2);			/* set up log file */
	if (open(LF, O_WRONLY|O_APPEND, 0664) < 0) {
		syslog(LOG_ERR, "%s: %m", LF);
		(void) open("/dev/null", O_WRONLY);
	}

	if (chdir(SD) < 0)
		frecverr("%s: %s: %m", printer, SD);
	if (stat(LO, &stb) == 0) {
		if (stb.st_mode & 010) {
			/* queue is disabled */
			putchar('\1');		/* return error code */
			exit(1);
		}
	} else if (stat(SD, &stb) < 0)
		frecverr("%s: %s: %m", printer, SD);
	minfree = read_number("minfree");
	ddev = find_dev(stb.st_dev, S_IFBLK);
	if ((dfd = open(ddev, O_RDONLY)) < 0)
		syslog(LOG_WARNING, "%s: %s: %m", printer, ddev);
	signal(SIGTERM, rcleanup);
	signal(SIGPIPE, rcleanup);

	if (readjob())
		printjob();
}
コード例 #4
0
ファイル: gp_setcap.c プロジェクト: devsim/pisces
int
gp_setcap()
#endif
	{

	int   tcnt ;    /* number of types found in entry */
	float val;
	int   ival, n;
	int   nbytes ;
#ifdef DO_STATS
	int	 istat1, istat2 ;
#endif

	defrot("gp_setcap");

	/* first find out what type of device we are setting caps for */
	tcnt = 0;
	tcp = Tcap;
	while (tcp->ptyp >= 0) {
		if (pgetflag(tcp->nam))  {   /* got this type ?? */
			plot_type = tcp->ptyp;
			tcnt++;              /* remember how many types given*/
			}
		tcp++;
		}

	/* special case: if no device given but NULL was, then we can
	 *  continue checking this entry.  (Some enties may only be LIKEd to,
	 *   and the entry with the LIKE will have a type, but (mkpcap for
	 *    example will complain the the LIKEd entry has no type 
	 */
	if (tcnt == 0 && pgetflag("NULL")) { plot_type = T_NULL; tcnt = 1; }

	if (tcnt != 1) {   /* can only be one type of device */
#ifdef DEBUG
		if (tcnt == 0)
			gperr("must have one of: VECT, RAST, SAVE, DEBUG");
		if (tcnt >  1)
			gperr("can only have one of: VECT, RAST, SAVE, DEBUG");
#else
		if (tcnt == 0) gperr("must have one of: VECT, RAST, SAVE");
		if (tcnt >  1) gperr("can only have one of: VECT, RAST, SAVE");
#endif
		/* error already, just get out of here */
		return(-1);
		}

	/* get boolean caps */
	bcp = Bcap;
	while (bcp->ptyp >= 0) {
		if ((bcp->ptyp & plot_type) || bcp->ptyp == T_ANY) {
			*(bcp->loc) = pgetflag( bcp->nam );
			}
		bcp++ ;
		}

	/* now integer types */
	icp = Icap;
	while (icp->ptyp >= 0) {
		if ((icp->ptyp & plot_type) || icp->ptyp == T_ANY) {
			if (pgetnum(icp->nam,&val) < 0) *(icp->loc) = icp->def;
			else  *(icp->loc) = (int) (val + .00001);
			}
		icp++ ;
		}

	/* now float types */
	fcp = Fcap;
	while (fcp->ptyp >= 0) {
		if ((fcp->ptyp & plot_type) || fcp->ptyp == T_ANY) {
			if (pgetnum(fcp->nam,&val) < 0) *(fcp->loc) = fcp->def;
			else  *(fcp->loc) = val;
			}
		fcp++ ;
		}

	/* string type caps */
	scp = Scap;
	while (scp->ptyp >= 0) {
		if ((scp->ptyp & plot_type) || scp->ptyp == T_ANY) {
			if ((n=pgetstr(scp->nam,scp->loc)) >0) scp->loc[n] = 0;
			else strcpy(scp->loc, scp->def);
			}
		scp++ ;
		}

	/* programs and subroutines */
	g_poff = 0;
	g_ioff = 0;

	/* allocate the symbol table for parsing the ``programs'' */
	if (stab_mk(stabsiz, stabent) < 0) {
		gperr("PANIC: Can't allocate a symbol table! No room.") ;
		}


	/* program type caps */
	pcp = Pcap;
	while (pcp->ptyp >= 0) {
		if (pcp->ptyp & plot_type) {
			ival = pgetprg(pcp->nam, g_prog, &g_poff, 
							g_idat, &g_ioff) ;
			if (ival > 0) *pcp->loc = ival;
			else         *(pcp->loc) = pcp->def;
			}
		pcp++;
		}
	if (g_poff > MAXPROG) {
		gperr2("PANIC: plotcap program too big! MAXPROG=%d",g_poff) ;
		gperr2("       Talk to the maintainer; MAXPROG>%d",MAXPROG);
		return -1 ;
		}
	if (g_ioff > MAXIDAT) {
		gperr2("PANIC: plotcap character data too big! MAXIDAT=%d",
								g_ioff) ;
		gperr2("       Talk to the maintainer; MAXIDAT>%d",MAXIDAT);
		return -1 ;
		}

#ifdef DO_STATS
	gp_stats.st_type = plot_type ;
	gp_stats.st_psiz = g_poff ;
	gp_stats.st_dsiz = g_ioff ;
	gp_stats.st_stmx = stabsiz ;
	gp_stats.st_semx = stabent ;
	if (stab_iq(&istat1, &istat2) >= 0) {
		gp_stats.st_stsz = istat1 ;
		gp_stats.st_sesz = istat2 ;
		}
#endif

	/* More just in-casing... */
	if (C.RPXB < 0 || C.RPXB > 8) C.RPXB = 0;
	/*			   ^ Fix this. Variable */

	if (plot_type == T_RAST) {
		if (C.RPXB > 0) nbytes = C.PIXX / C.RPXB; /* bytes per line */
		else            nbytes = 0;

		/* Get a good output buffer size */
		C.BFSZ = nbytes ;  /* output buffer size */
		}

	if (plot_type == T_VECT) {
		C.BFSZ = C.BFSZ ;
		}
		
	return(0);   /* all was ok, we gone. */
	}/* of routine */