printcap.c (68253) | printcap.c (78146) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 26 unchanged lines hidden (view full) --- 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * From: @(#)common.c 8.5 (Berkeley) 4/28/95 39 */ 40 41#ifndef lint 42static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 26 unchanged lines hidden (view full) --- 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * From: @(#)common.c 8.5 (Berkeley) 4/28/95 39 */ 40 41#ifndef lint 42static const char rcsid[] = |
43 "$FreeBSD: head/usr.sbin/lpr/common_source/printcap.c 68253 2000-11-02 19:22:06Z gad $"; | 43 "$FreeBSD: head/usr.sbin/lpr/common_source/printcap.c 78146 2001-06-12 16:38:20Z gad $"; |
44#endif /* not lint */ 45 46#include <errno.h> 47#include <stdio.h> 48#include <stdlib.h> 49#include <string.h> 50#include <unistd.h> 51 52#include <sys/param.h> /* required for lp.h, but not used here */ 53#include <sys/dirent.h> /* ditto */ 54#include "lp.h" 55#include "lp.local.h" 56#include "pathnames.h" 57 58/* 59 * Routines and data used in processing the printcap file. 60 */ | 44#endif /* not lint */ 45 46#include <errno.h> 47#include <stdio.h> 48#include <stdlib.h> 49#include <string.h> 50#include <unistd.h> 51 52#include <sys/param.h> /* required for lp.h, but not used here */ 53#include <sys/dirent.h> /* ditto */ 54#include "lp.h" 55#include "lp.local.h" 56#include "pathnames.h" 57 58/* 59 * Routines and data used in processing the printcap file. 60 */ |
61static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */ | 61static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */ |
62 | 62 |
63static char *capdb_canonical_name(const char *); 64static int capdb_getaltlog(char *, const char *, const char *); 65static int capdb_getaltnum(char *, const char *, const char *, long, long *); 66static int capdb_getaltstr(char *, const char *, const char *, const char *, 67 char **); 68static int getprintcap_int(char *bp, struct printer *pp); | 63static char *capdb_canonical_name(const char *_bp); 64static int capdb_getaltlog(char *_bp, const char *_shrt, 65 const char *_lng); 66static int capdb_getaltnum(char *_bp, const char *_shrt, 67 const char *_lng, long _dflt, long *_result); 68static int capdb_getaltstr(char *_bp, const char *_shrt, 69 const char *lng, const char *_dflt, char **_result); 70static int getprintcap_int(char *_bp, struct printer *_pp); |
69 70/* 71 * Change the name of the printcap file. Used by chkprintcap(8), 72 * but could be used by other members of the suite with appropriate 73 * security measures. 74 */ 75void 76setprintcap(char *newfile) --- 128 unchanged lines hidden (view full) --- 205 206/* 207 * Internal routine for both getprintcap() and nextprinter(). 208 * Actually parse the printcap entry using cget* functions. 209 * Also attempt to figure out the canonical name of the printer 210 * and store a malloced copy of it in pp->printer. 211 */ 212static int | 71 72/* 73 * Change the name of the printcap file. Used by chkprintcap(8), 74 * but could be used by other members of the suite with appropriate 75 * security measures. 76 */ 77void 78setprintcap(char *newfile) --- 128 unchanged lines hidden (view full) --- 207 208/* 209 * Internal routine for both getprintcap() and nextprinter(). 210 * Actually parse the printcap entry using cget* functions. 211 * Also attempt to figure out the canonical name of the printer 212 * and store a malloced copy of it in pp->printer. 213 */ 214static int |
213getprintcap_int(bp, pp) 214 char *bp; 215 struct printer *pp; | 215getprintcap_int(char *bp, struct printer *pp) |
216{ 217 enum lpd_filters filt; 218 char *rp_name; 219 int error; 220 221 if ((pp->printer = capdb_canonical_name(bp)) == 0) 222 return PCAPERR_OSERR; 223 --- 142 unchanged lines hidden (view full) --- 366 367/* 368 * It provides similar functionality to cgetstr(), 369 * except that it provides for both a long and a short 370 * capability name and allows for a default to be specified. 371 */ 372static int 373capdb_getaltstr(char *bp, const char *shrt, const char *lng, | 216{ 217 enum lpd_filters filt; 218 char *rp_name; 219 int error; 220 221 if ((pp->printer = capdb_canonical_name(bp)) == 0) 222 return PCAPERR_OSERR; 223 --- 142 unchanged lines hidden (view full) --- 366 367/* 368 * It provides similar functionality to cgetstr(), 369 * except that it provides for both a long and a short 370 * capability name and allows for a default to be specified. 371 */ 372static int 373capdb_getaltstr(char *bp, const char *shrt, const char *lng, |
374 const char *dflt, char **result) | 374 const char *dflt, char **result) |
375{ 376 int status; 377 378 status = cgetstr(bp, (char *)/*XXX*/lng, result); 379 if (status >= 0 || status == PCAPERR_OSERR) 380 return status; 381 status = cgetstr(bp, (char *)/*XXX*/shrt, result); 382 if (status >= 0 || status == PCAPERR_OSERR) --- 7 unchanged lines hidden (view full) --- 390 return PCAPERR_NOTFOUND; 391} 392 393/* 394 * The same, only for integers. 395 */ 396static int 397capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt, | 375{ 376 int status; 377 378 status = cgetstr(bp, (char *)/*XXX*/lng, result); 379 if (status >= 0 || status == PCAPERR_OSERR) 380 return status; 381 status = cgetstr(bp, (char *)/*XXX*/shrt, result); 382 if (status >= 0 || status == PCAPERR_OSERR) --- 7 unchanged lines hidden (view full) --- 390 return PCAPERR_NOTFOUND; 391} 392 393/* 394 * The same, only for integers. 395 */ 396static int 397capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt, |
398 long *result) | 398 long *result) |
399{ 400 int status; 401 402 status = cgetnum(bp, (char *)/*XXX*/lng, result); 403 if (status >= 0) 404 return status; 405 status = cgetnum(bp, (char *)/*XXX*/shrt, result); 406 if (status >= 0) --- 42 unchanged lines hidden --- | 399{ 400 int status; 401 402 status = cgetnum(bp, (char *)/*XXX*/lng, result); 403 if (status >= 0) 404 return status; 405 status = cgetnum(bp, (char *)/*XXX*/shrt, result); 406 if (status >= 0) --- 42 unchanged lines hidden --- |