Deleted Added
full compact
ctlinfo.c (139462) ctlinfo.c (220586)
1/*
2 * ------+---------+---------+---------+---------+---------+---------+---------*
1/*
2 * ------+---------+---------+---------+---------+---------+---------+---------*
3 * Copyright (c) 2001 - Garance Alistair Drosehn .
3 * Copyright (c) 2001,2011 - Garance Alistair Drosehn <gad@FreeBSD.org>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

27 * The views and conclusions contained in the software and documentation
28 * are those of the authors and should not be interpreted as representing
29 * official policies, either expressed or implied, of the FreeBSD Project.
30 *
31 * ------+---------+---------+---------+---------+---------+---------+---------*
32 */
33
34#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

27 * The views and conclusions contained in the software and documentation
28 * are those of the authors and should not be interpreted as representing
29 * official policies, either expressed or implied, of the FreeBSD Project.
30 *
31 * ------+---------+---------+---------+---------+---------+---------+---------*
32 */
33
34#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
35__FBSDID("$FreeBSD: head/usr.sbin/lpr/common_source/ctlinfo.c 139462 2004-12-31 00:18:42Z gad $");
35__FBSDID("$FreeBSD: head/usr.sbin/lpr/common_source/ctlinfo.c 220586 2011-04-13 00:36:19Z gad $");
36
37/*
38 * ctlinfo - This collection of routines will know everything there is to
39 * know about the information inside a control file ('cf*') which is used
40 * to describe a print job in lpr & friends. The eventual goal is that it
41 * will be the ONLY source file to know what's inside these control-files.
42 */
43

--- 199 unchanged lines hidden (view full) ---

243
244 FREESTR(cpriv->pub.cji_accthost);
245 FREESTR(cpriv->pub.cji_acctuser);
246 FREESTR(cpriv->pub.cji_class);
247 FREESTR(cpriv->pub.cji_curqueue);
248 /* [cpriv->pub.cji_fname is part of cpriv-malloced area] */
249 FREESTR(cpriv->pub.cji_jobname);
250 FREESTR(cpriv->pub.cji_mailto);
36
37/*
38 * ctlinfo - This collection of routines will know everything there is to
39 * know about the information inside a control file ('cf*') which is used
40 * to describe a print job in lpr & friends. The eventual goal is that it
41 * will be the ONLY source file to know what's inside these control-files.
42 */
43

--- 199 unchanged lines hidden (view full) ---

243
244 FREESTR(cpriv->pub.cji_accthost);
245 FREESTR(cpriv->pub.cji_acctuser);
246 FREESTR(cpriv->pub.cji_class);
247 FREESTR(cpriv->pub.cji_curqueue);
248 /* [cpriv->pub.cji_fname is part of cpriv-malloced area] */
249 FREESTR(cpriv->pub.cji_jobname);
250 FREESTR(cpriv->pub.cji_mailto);
251 FREESTR(cpriv->pub.cji_username);
251 FREESTR(cpriv->pub.cji_headruser);
252
253 if (cpriv->cji_fstream != NULL) {
254 fclose(cpriv->cji_fstream);
255 cpriv->cji_fstream = NULL;
256 }
257
258 cjinf->cji_priv = NULL;
259 free(cpriv);

--- 78 unchanged lines hidden (view full) ---

338 if (*lbuff == '\0')
339 break;
340 cpriv->pub.cji_accthost = strdup(lbuff);
341 break;
342 case 'J':
343 cpriv->pub.cji_jobname = strdup(lbuff);
344 break;
345 case 'L':
252
253 if (cpriv->cji_fstream != NULL) {
254 fclose(cpriv->cji_fstream);
255 cpriv->cji_fstream = NULL;
256 }
257
258 cjinf->cji_priv = NULL;
259 free(cpriv);

--- 78 unchanged lines hidden (view full) ---

338 if (*lbuff == '\0')
339 break;
340 cpriv->pub.cji_accthost = strdup(lbuff);
341 break;
342 case 'J':
343 cpriv->pub.cji_jobname = strdup(lbuff);
344 break;
345 case 'L':
346 cpriv->pub.cji_username = strdup(lbuff);
346 cpriv->pub.cji_headruser = strdup(lbuff);
347 break;
348 case 'M':
349 /*
350 * No valid mail-to address would start with a minus.
351 * If this one does, it is probably some trickster who
352 * is trying to trigger options on sendmail. Ignore.
353 */
354 if (*lbuff == '-')

--- 226 unchanged lines hidden (view full) ---

581 else
582 fprintf(newcf, "P%s\n", cjinf->cji_acctuser);
583
584 /* No need for sanity checks on class, jobname, "literal" user. */
585 if (cjinf->cji_class != NULL)
586 fprintf(newcf, "C%s\n", cjinf->cji_class);
587 if (cjinf->cji_jobname != NULL)
588 fprintf(newcf, "J%s\n", cjinf->cji_jobname);
347 break;
348 case 'M':
349 /*
350 * No valid mail-to address would start with a minus.
351 * If this one does, it is probably some trickster who
352 * is trying to trigger options on sendmail. Ignore.
353 */
354 if (*lbuff == '-')

--- 226 unchanged lines hidden (view full) ---

581 else
582 fprintf(newcf, "P%s\n", cjinf->cji_acctuser);
583
584 /* No need for sanity checks on class, jobname, "literal" user. */
585 if (cjinf->cji_class != NULL)
586 fprintf(newcf, "C%s\n", cjinf->cji_class);
587 if (cjinf->cji_jobname != NULL)
588 fprintf(newcf, "J%s\n", cjinf->cji_jobname);
589 if (cjinf->cji_username != NULL)
590 fprintf(newcf, "L%s\n", cjinf->cji_username);
589 if (cjinf->cji_headruser != NULL)
590 fprintf(newcf, "L%s\n", cjinf->cji_headruser);
591
592 /*
593 * This should probably add more sanity checks on mailto value.
594 * Note that if the mailto value is "wrong", then there's no good
595 * way to know what the "correct" value would be, and we should not
596 * semd email to some random address. At least for now, just ignore
597 * any invalid values.
598 */

--- 228 unchanged lines hidden (view full) ---

827
828 PRINTSTR("accthost.H", cpriv->pub.cji_accthost);
829 PRINTSTR("acctuser.P", cpriv->pub.cji_acctuser);
830 PRINTSTR("class.C", cpriv->pub.cji_class);
831 PRINTSTR("cf-qname", cpriv->pub.cji_curqueue);
832 PRINTSTR("cf-fname", cpriv->pub.cji_fname);
833 PRINTSTR("jobname.J", cpriv->pub.cji_jobname);
834 PRINTSTR("mailto.M", cpriv->pub.cji_mailto);
591
592 /*
593 * This should probably add more sanity checks on mailto value.
594 * Note that if the mailto value is "wrong", then there's no good
595 * way to know what the "correct" value would be, and we should not
596 * semd email to some random address. At least for now, just ignore
597 * any invalid values.
598 */

--- 228 unchanged lines hidden (view full) ---

827
828 PRINTSTR("accthost.H", cpriv->pub.cji_accthost);
829 PRINTSTR("acctuser.P", cpriv->pub.cji_acctuser);
830 PRINTSTR("class.C", cpriv->pub.cji_class);
831 PRINTSTR("cf-qname", cpriv->pub.cji_curqueue);
832 PRINTSTR("cf-fname", cpriv->pub.cji_fname);
833 PRINTSTR("jobname.J", cpriv->pub.cji_jobname);
834 PRINTSTR("mailto.M", cpriv->pub.cji_mailto);
835 PRINTSTR("hdruser.L", cpriv->pub.cji_username);
835 PRINTSTR("headruser.L", cpriv->pub.cji_headruser);
836
837 ctl_dbgline++;
838 fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, "*cjprivate");
839 if (cpriv->pub.cji_priv == NULL)
840 fprintf(dbg_stream, "NULL !!\n");
841 else
842 fprintf(dbg_stream, "%p\n", (void *)cpriv->pub.cji_priv);
843

--- 71 unchanged lines hidden ---
836
837 ctl_dbgline++;
838 fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, "*cjprivate");
839 if (cpriv->pub.cji_priv == NULL)
840 fprintf(dbg_stream, "NULL !!\n");
841 else
842 fprintf(dbg_stream, "%p\n", (void *)cpriv->pub.cji_priv);
843

--- 71 unchanged lines hidden ---