if(pn == NULL || suspicious(pn))
if(pn == NULL || suspicious(pn) || !valid_pr(pn))
get_pr_status(pn, avail, printing, qlen, needs_operator, status)printername   pn;bool_t       *avail;bool_t       *printing;int          *qlen;bool_t       *needs_operator;char         *status;{	char cmd[128];	char buff[256];	char buff2[256];	char pname[64];	FILE *p;	char *cp;	char *cp1;	char *cp2;	int n;	pirstat stat = PI_RES_NO_SUCH_PRINTER;	/* assume the worst */	*avail = FALSE;	*printing = FALSE;	*needs_operator = FALSE;	*qlen = 0;	*status = '\0';	pn = map_printer_name(pn);	if(pn == NULL || suspicious(pn))		return(PI_RES_NO_SUCH_PRINTER);	snprintf(pname, sizeof pname, "%s:", pn);	n = strlen(pname);	snprintf(cmd, sizeof cmd, "%s/lpc status %s", LPCDIR, pn);	p = popen(cmd, "r");	if(p == NULL) {		msg_out("rpc.pcnfsd: unable to popen() lp status");		return(PI_RES_FAIL);	}		while(fgets(buff, 255, p) != NULL) {		if(strncmp(buff, pname, n))			continue;/*** We have a match. The only failure now is PI_RES_FAIL if** lpstat output cannot be decoded*/		stat = PI_RES_FAIL;/*** The next four lines are usually if the form****     queuing is [enabled|disabled]**     printing is [enabled|disabled]**     [no entries | N entr[y|ies] in spool area]**     <status message, may include the word "attention">*/		while(fgets(buff, 255, p) != NULL && isspace(buff[0])) {			cp = buff;			while(isspace(*cp))				cp++;			if(*cp == '\0')				break;			cp1 = cp;			cp2 = buff2;			while(*cp1 && *cp1 != '\n') {				*cp2++ = tolower(*cp1);				cp1++;			}			*cp1 = '\0';			*cp2 = '\0';/*** Now buff2 has a lower-cased copy and cp points at the original;** both are null terminated without any newline*/						if(!strncmp(buff2, "queuing", 7)) {				*avail = (strstr(buff2, "enabled") != NULL);				continue;			}			if(!strncmp(buff2, "printing", 8)) {				*printing = (strstr(buff2, "enabled") != NULL);				continue;			}			if(isdigit(buff2[0]) && (strstr(buff2, "entr") !=NULL)) {				*qlen = atoi(buff2);				continue;			}			if(strstr(buff2, "attention") != NULL ||			   strstr(buff2, "error") != NULL)				*needs_operator = TRUE;			if(*needs_operator || strstr(buff2, "waiting") != NULL)				strcpy(status, cp);		}		stat = PI_RES_OK;		break;	}	(void) pclose(p);	return(stat);}