snprintf(buff, sizeof buff, "%s/lpq -P%s", LPRDIR, pn);
snprintf(buff, sizeof buff, "%s/lpq '-P%s'", LPRDIR, pn);
build_pr_queue(pn, user, just_mine, p_qlen, p_qshown)printername     pn;username        user;int            just_mine;int            *p_qlen;int            *p_qshown;{pr_queue last = NULL;pr_queue curr = NULL;char buff[256];FILE *p;char *cp;int i;char *rank;char *owner;char *job;char *files;char *totsize;	if(queue) {		free_pr_queue_item(queue);		queue = NULL;	}	*p_qlen = 0;	*p_qshown = 0;	pn = map_printer_name(pn);	if(pn == NULL || suspicious(pn))		return(PI_RES_NO_SUCH_PRINTER);	snprintf(buff, sizeof buff, "%s/lpq -P%s", LPRDIR, pn);	p = su_popen(user, buff, MAXTIME_FOR_QUEUE);	if(p == NULL) {		msg_out("rpc.pcnfsd: unable to popen() lpq");		return(PI_RES_FAIL);	}		while(fgets(buff, 255, p) != NULL) {		i = strlen(buff) - 1;		buff[i] = '\0';		/* zap trailing NL */		if(i < SIZECOL)			continue;		if(!mystrncasecmp(buff, "rank", 4))			continue;		totsize = &buff[SIZECOL-1];		files = &buff[FILECOL-1];		cp = totsize;		cp--;		while(cp > files && isspace(*cp))			*cp-- = '\0';		buff[FILECOL-2] = '\0';		cp = strtok(buff, delims);		if(!cp)			continue;		rank = cp;		cp = strtok(NULL, delims);		if(!cp)			continue;		owner = cp;		cp = strtok(NULL, delims);		if(!cp)			continue;		job = cp;		*p_qlen += 1;		if(*p_qshown > QMAX)			continue;		if(just_mine && mystrcasecmp(owner, user))			continue;		*p_qshown += 1;		curr = (struct pr_queue_item *)			grab(sizeof (struct pr_queue_item));		curr->position = atoi(rank); /* active -> 0 */		curr->id = strdup(job);		curr->size = strdup(totsize);		curr->status = strdup(rank);		curr->system = strdup("");		curr->user = strdup(owner);		curr->file = strdup(files);		curr->cm = strdup("-");		curr->pr_next = NULL;		if(last == NULL)			queue = curr;		else			last->pr_next = curr;		last = curr;	}	(void) su_pclose(p);	return(PI_RES_OK);}