snprintf(cmdbuf, sizeof cmdbuf, "%s/lpr -P%s %s",
snprintf(cmdbuf, sizeof cmdbuf, "%s/lpr '-P%s' '%s'",
psrstat pr_start2(system, pr, user, fname, opts, id)char *system;char *pr;char *user;char *fname;char *opts;char **id;{char            snum[20];static char     req_id[256];char            cmdbuf[256];char            resbuf[256];FILE *fd;int i;char *xcmd;char *cp;int failed = 0;#ifdef HACK_FOR_ROTATED_TRANSCRIPTchar            scratch[512];#endif	if(suspicious(system) || 		suspicious(pr) ||		suspicious(user) ||		suspicious(fname))		return(PS_RES_FAIL);	(void)snprintf(pathname, sizeof pathname, "%s/%s/%s",sp_name,	                         system,	                         fname);		*id = &req_id[0];	req_id[0] = '\0';	if (stat(pathname, &statbuf))            {	   /*           **-----------------------------------------------------------------	   ** We can't stat the file. Let's try appending '.spl' and	   ** see if it's already in progress.           **-----------------------------------------------------------------	   */	   (void)strcat(pathname, ".spl");	   if (stat(pathname, &statbuf)) 	      {	      /*              **----------------------------------------------------------------	      ** It really doesn't exist.              **----------------------------------------------------------------	      */	      return(PS_RES_NO_FILE);	      }	      /*              **-------------------------------------------------------------	      ** It is already on the way.              **-------------------------------------------------------------	      */		return(PS_RES_ALREADY);	     }	if (statbuf.st_size == 0) 	   {	   /*           **-------------------------------------------------------------	   ** Null file - don't print it, just kill it.           **-------------------------------------------------------------	   */	   (void)unlink(pathname);	    return(PS_RES_NULL);	    }	 /*         **-------------------------------------------------------------	 ** The file is real, has some data, and is not already going out.	 ** We rename it by appending '.spl' and exec "lpr" to do the	 ** actual work.         **-------------------------------------------------------------	 */	if (snprintf(new_pathname, sizeof new_pathname, "%s.spl",	    pathname) >= sizeof new_pathname) {		snprintf(tempstr, sizeof tempstr,		    "rpc.pcnfsd: spool file rename (%s->%s) failed.\n",		    pathname, new_pathname);		msg_out(tempstr);		return(PS_RES_FAIL);	}	/*        **-------------------------------------------------------------	** See if the new filename exists so as not to overwrite it.        **-------------------------------------------------------------	*/	if (!stat(new_pathname, &statbuf)) {		if (snprintf(new_pathname, sizeof new_pathname, "%s%d.spl",		    rand(), pathname) >= sizeof new_pathname) {			snprintf(tempstr, sizeof tempstr,			    "rpc.pcnfsd: spool file rename (%s->%s) failed.\n",			    pathname, new_pathname);			msg_out(tempstr);			return(PS_RES_FAIL);		}	}	if (rename(pathname, new_pathname)) 	   {	   /*           **---------------------------------------------------------------	   ** Should never happen.           **---------------------------------------------------------------           */	   (void)snprintf(tempstr, sizeof tempstr,		"rpc.pcnfsd: spool file rename (%s->%s) failed.\n",			pathname, new_pathname);                msg_out(tempstr);		return(PS_RES_FAIL);	    }		if (*opts == 'd') 	           {		   /*                   **------------------------------------------------------		   ** This is a Diablo print stream. Apply the ps630		   ** filter with the appropriate arguments.                   **------------------------------------------------------		   */		   (void)snprintf(tempstr, sizeof tempstr,			"rpc.pcnfsd: ps630 filter disabled for %s\n", pathname);			msg_out(tempstr);			return(PS_RES_FAIL);		   }		/*		** Try to match to an aliased printer		*/		xcmd = expand_alias(pr, new_pathname, user, system);		if(!xcmd) {#ifdef	SVR4	        /*			 * Use the copy option so we can remove the orignal			 * spooled nfs file from the spool directory.			 */			snprintf(cmdbuf, sizeof cmdbuf, "/usr/bin/lp -c -d%s %s",				pr, new_pathname);#else	/* SVR4 */			/* BSD way: lpr */			snprintf(cmdbuf, sizeof cmdbuf, "%s/lpr -P%s %s",				LPRDIR, pr, new_pathname);#endif	/* SVR4 */			xcmd = cmdbuf;		}		if ((fd = su_popen(user, xcmd, MAXTIME_FOR_PRINT)) == NULL) {			msg_out("rpc.pcnfsd: su_popen failed");			return(PS_RES_FAIL);		}		req_id[0] = '\0';	/* asume failure */		while(fgets(resbuf, 255, fd) != NULL) {			i = strlen(resbuf);			if(i)				resbuf[i-1] = '\0'; /* trim NL */			if(!strncmp(resbuf, "request id is ", 14))				/* New - just the first word is needed */				strcpy(req_id, strtok(&resbuf[14], delims));			else if (strembedded("disabled", resbuf))				failed = 1;		}		if(su_pclose(fd) == 255)			msg_out("rpc.pcnfsd: su_pclose alert");		(void)unlink(new_pathname);		return((failed | interrupted)? PS_RES_FAIL : PS_RES_OK);}