Date: Thu, 28 Jun 2001 18:47:17 -0400 (EDT) From: Mike Heffner <mheffner@novacoxmail.com> To: Garance A Drosihn <drosih@rpi.edu> Cc: freebsd-audit@freebsd.org, freebsd-print@bostonradio.org Subject: RE: Initial ctlinfo, for checking incoming jobs to lpd Message-ID: <XFMail.20010628184717.mheffner@novacoxmail.com> In-Reply-To: <p0510100db760298f4bb4@[128.113.24.47]>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 28-Jun-2001 Garance A Drosihn wrote:
| The following patch would add a new source file to lpr/common_source,
| called ctlinfo.c. While I have several plans for ctlinfo.c, this first
| cut just replaces calls to link & unlink in lpd/recvjob.c with a call
| to a new routine which does a whole bunch of work.
I'm not too familiar with the code. It's looks pretty good altogether. Here's
just a few little things I noticed:
| +
| +struct cjobinfo *
style(9) bug, extra spaces before asterick
| +ctl_readcf(const char *ptrname, const char *cfname)
| +{
| + int id;
| + char *lbuff;
| + FILE *cfile;
| + struct cjprivate *cpriv;
| + size_t msize, sroom, sroom2;
| +
| + cfile = fopen(cfname, "r");
| + if (cfile == NULL) {
| + syslog(LOG_ERR, "%s: ctl_readcf error open(%s): %s",
| + ptrname, cfname, strerror(errno));
| + return NULL;
| + }
should be `return (NULL);'
| +
| + sroom = roundup(sizeof(struct cjprivate), 8);
| + sroom2 = sroom + strlen(cfname) + 1;
| + sroom2 = roundup(sroom2, 8);
| + msize = sroom2 + CTI_LINEMAX;
| + msize = roundup(msize, 8);
| + cpriv = (struct cjprivate *)malloc(msize);
| + if (cpriv == NULL)
| + return NULL;
| + memset(cpriv, 0, msize);
| +
| + cpriv->pub.cji_fname = (char *)(cpriv + sroom);
| + strcpy(cpriv->pub.cji_fname, cfname);
| + cpriv->cji_buff = (char *)(cpriv + sroom2);
| + cpriv->cji_eobuff = (char *)(cpriv + msize - 1);
| +
| + cpriv->cji_fstream = cfile;
| +
| + /*
| + * Copy job-attribute values from control file to the struct of
| + * "public" information. In some cases, it is invalid for the
| + * value to be a null-string, so that is ignored.
| + */
| + while ((lbuff = ctl_getline(&(cpriv->pub)))) {
should test against != NULL.
[snip]
| + /*
| + * Some lpr implementations on PC's set a null-string for their
| + * hostname. A MacOS 10 system which has not correctly setup
| + * /etc/hostconfig will claim a hostname of 'localhost'. Anything
| + * with blanks in it would be an invalid value for hostname. For
| + * any of these invalid hostname values, replace the given value
| + * with the name of the host that this job is coming from.
| + */
| + nogood = 0;
| + if (cjinf->cji_orighost == NULL)
| + nogood = 1;
| + else if (strcmp(cjinf->cji_orighost, ".na.") == NULL)
| + nogood = 1;
| + else if (strcmp(cjinf->cji_orighost, "localhost") == NULL)
| + nogood = 1;
strcmp() returns 0 for match
[snip]
| +++ common_source/lp.h 2001/06/28 00:22:01
| @@ -267,6 +267,7 @@
| char *pcaperr(int _error);
| void prank(int _n);
| void process(const struct printer *_pp, char *_file);
| +void ctl_renametf(const char *_ptrname, const char *_tfname);
This should line up.
Later,
Mike
--
Mike Heffner <mheffner@[acm.]vt.edu>
Fredericksburg, VA <mikeh@FreeBSD.org>
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE7O7P0FokZQs3sv5kRAp1HAJ4hZek92fT5zdo+/sdeFRkPCSQLfwCgmGeQ
9GHuuyUMqoMDdmf8Y7HCAe8=
=HU12
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20010628184717.mheffner>
