From 0e8fd3398771da2f016d72830179507f3edda51b Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 4 May 1996 07:50:46 +0000 Subject: Initial version imported to CVS (This used to be commit 291551d80711daab7b7581720bcd9a08d6096517) --- source3/printing/pcap.c | 383 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 source3/printing/pcap.c (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c new file mode 100644 index 0000000000..8973b1627f --- /dev/null +++ b/source3/printing/pcap.c @@ -0,0 +1,383 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + printcap parsing + Copyright (C) Karl Auer 1993,1994 + + Re-working by Martin Kiff, 1994 + + Re-written again by Andrew Tridgell + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + * Parse printcap file. + * + * This module does exactly one thing - it looks into the printcap file + * and tells callers if a specified string appears as a printer name. + * + * The way this module looks at the printcap file is very simplistic. + * Only the local printcap file is inspected (no searching of NIS + * databases etc). + * + * There are assumed to be one or more printer names per record, held + * as a set of sub-fields separated by vertical bar symbols ('|') in the + * first field of the record. The field separator is assumed to be a colon + * ':' and the record separator a newline. + * + * Lines ending with a backspace '\' are assumed to flag that the following + * line is a continuation line so that a set of lines can be read as one + * printcap entry. + * + * A line stating with a hash '#' is assumed to be a comment and is ignored + * Comments are discarded before the record is strung together from the + * set of continuation lines. + * + * Opening a pipe for "lpc status" and reading that would probably + * be pretty effective. Code to do this already exists in the freely + * distributable PCNFS server code. + */ + +#include "includes.h" + +#include "smb.h" +#include "loadparm.h" +#include "pcap.h" + +extern int DEBUGLEVEL; + +#ifdef AIX +/* ****************************************** + Extend for AIX system and qconfig file + from 'boulard@univ-rennes1.fr + ****************************************** */ +static int strlocate(char *xpLine,char *xpS) +{ + int iS,iL,i,iRet; + char *p; + iS = strlen(xpS); + iL = strlen(xpLine); + + iRet = 0; + p = xpLine; + while (iL >= iS) + { + if (strncmp(p,xpS,iS) == 0) {iRet =1;break;}; + p++; + iL--; + } + /*DEBUG(3,(" strlocate %s in line '%s',ret=%d\n",xpS,xpLine,iRet));*/ + + return(iRet); +} + + +/* ******************************************************************* */ +/* * Scan qconfig and search all virtual printer (device printer) * */ +/* ******************************************************************* */ +static void ScanQconfig_fn(char *psz,void (*fn)()) +{ + int iLg,iEtat; + FILE *pfile; + char *line,*p; + pstring name,comment; + line = NULL; + *name = 0; + *comment = 0; + + if ((pfile = fopen(psz, "r")) == NULL) + { + DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); + return; + } + + iEtat = 0; + /* scan qconfig file for searching : */ + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + { + if (*line == '*' || *line == 0) + continue; + switch (iEtat) + { + case 0: /* locate an entry */ + if (*line == '\t' || *line == ' ') continue; + if ((p=strchr(line,':'))) + { + *p = '\0'; + p = strtok(line,":"); + if (strcmp(p,"bsh")!=0) + { + strcpy(name,p); + iEtat = 1; + continue; + } + } + break; + case 1: /* scanning device stanza */ + if (*line == '*' || *line == 0) continue; + if (*line != '\t' && *line != ' ') + { + /* name is found without stanza device */ + /* probably a good printer ??? */ + fn(name,comment); + iEtat = 0; + continue; + } + + if (strlocate(line,"backend")) + { + /* it's a device, not a virtual printer*/ + iEtat = 0; + } + else if (strlocate(line,"device")) + { + /* it's a good virtual printer */ + fn(name,comment); + iEtat = 0; + continue; + } + break; + } + } + fclose(pfile); +} + +/* Scan qconfig file and locate de printername */ + +static BOOL ScanQconfig(char *psz,char *pszPrintername) +{ + int iLg,iEtat; + FILE *pfile; + char *pName; + char *line; + + pName = NULL; + line = NULL; + if ((pszPrintername!= NULL) && ((iLg = strlen(pszPrintername)) > 0)) + pName = malloc(iLg+10); + if (pName == NULL) + { + DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername)); + return(False); + } + if ((pfile = fopen(psz, "r")) == NULL) + { + DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); + free(pName); + return(False); + } + sprintf(pName,"%s:",pszPrintername); + iLg = strlen(pName); + /*DEBUG(3,( " Looking for entry %s\n",pName));*/ + iEtat = 0; + /* scan qconfig file for searching : */ + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + { + if (*line == '*' || *line == 0) + continue; + switch (iEtat) + { + case 0: /* scanning entry */ + if (strncmp(line,pName,iLg) == 0) + { + iEtat = 1; + continue; + } + break; + case 1: /* scanning device stanza */ + if (*line == '*' || *line == 0) continue; + if (*line != '\t' && *line != ' ') + { + /* name is found without stanza device */ + /* probably a good printer ??? */ + free (line); + free(pName); + fclose(pfile); + return(True); + } + + if (strlocate(line,"backend")) + { + /* it's a device, not a virtual printer*/ + iEtat = 0; + } + else if (strlocate(line,"device")) + { + /* it's a good virtual printer */ + free (line); + free(pName); + fclose(pfile); + return(True); + } + break; + } + } + free (pName); + fclose(pfile); + return(False); +} + +#endif +/*************************************************************************** +Scan printcap file pszPrintcapname for a printer called pszPrintername. +Return True if found, else False. Returns False on error, too, after logging +the error at level 0. For generality, the printcap name may be passed - if +passed as NULL, the configuration will be queried for the name. +***************************************************************************/ +BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) +{ + char *line=NULL; + char *psz; + char *p,*q; + FILE *pfile; + + if (pszPrintername == NULL || pszPrintername[0] == '\0') + { + DEBUG(0,( "Attempt to locate null printername! Internal error?\n")); + return(False); + } + + /* only go looking if no printcap name supplied */ + if ((psz = pszPrintcapname) == NULL || psz[0] == '\0') + if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0')) + { + DEBUG(0,( "No printcap file name configured!\n")); + return(False); + } +#ifdef AIX + if (strlocate(psz,"/qconfig") != NULL) + return(ScanQconfig(psz,pszPrintername)); +#endif + if ((pfile = fopen(psz, "r")) == NULL) + { + DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); + return(False); + } + + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + { + if (*line == '#' || *line == 0) + continue; + + /* now we have a real printer line - cut it off at the first : */ + p = strchr(line,':'); + if (p) *p = 0; + + /* now just check if the name is in the list */ + /* NOTE: I avoid strtok as the fn calling this one may be using it */ + for (p=line; p; p=q) + { + if ((q = strchr(p,'|'))) *q++ = 0; + + if (strequal(p,pszPrintername)) + { + /* normalise the case */ + strcpy(pszPrintername,p); + free(line); + fclose(pfile); + return(True); + } + p = q; + } + } + + + fclose(pfile); + return(False); +} + + +/*************************************************************************** +run a function on each printer name in the printcap file. The function is +passed the primary name and the comment (if possible) +***************************************************************************/ +void pcap_printer_fn(void (*fn)()) +{ + pstring name,comment; + char *line; + char *psz; + char *p,*q; + FILE *pfile; + + /* only go looking if no printcap name supplied */ + if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0')) + { + DEBUG(0,( "No printcap file name configured!\n")); + return; + } + +#ifdef AIX + if (strlocate(psz,"/qconfig") != NULL) + { + ScanQconfig_fn(psz,fn); + return; + } +#endif + if ((pfile = fopen(psz, "r")) == NULL) + { + DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); + return; + } + + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + { + if (*line == '#' || *line == 0) + continue; + + /* now we have a real printer line - cut it off at the first : */ + p = strchr(line,':'); + if (p) *p = 0; + + /* now find the most likely printer name and comment + this is pure guesswork, but it's better than nothing */ + *name = 0; + *comment = 0; + for (p=line; p; p=q) + { + BOOL has_punctuation; + if ((q = strchr(p,'|'))) *q++ = 0; + + has_punctuation = (strchr(p,' ') || strchr(p,'(') || strchr(p,')')); + + if (strlen(p)>strlen(comment) && has_punctuation) + { + StrnCpy(comment,p,sizeof(comment)-1); + continue; + } + + if (strlen(p) <= 8 && strlen(p)>strlen(name) && !has_punctuation) + { + if (!*comment) strcpy(comment,name); + strcpy(name,p); + continue; + } + + if (!strchr(comment,' ') && + strlen(p) > strlen(comment)) + { + StrnCpy(comment,p,sizeof(comment)-1); + continue; + } + } + + comment[60] = 0; + name[8] = 0; + + if (*name) + fn(name,comment); + } + fclose(pfile); +} -- cgit From 7e3b4a1c0df1434eb3d02f93c736ce065f9898d8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Jun 1996 04:38:24 +0000 Subject: got rid of a lot of redundent header files as we now globally generate prototypes automatically using "make proto". This is much less prone to error than the old method of manually adding prototypes (This used to be commit b551dc98f7cc194a5fc2e67a4ebae7fd67a01bbc) --- source3/printing/pcap.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 8973b1627f..13b850b3f5 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -54,8 +54,6 @@ #include "includes.h" #include "smb.h" -#include "loadparm.h" -#include "pcap.h" extern int DEBUGLEVEL; -- cgit From 25eae02948b40667495fbb021dd130180180a05e Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Tue, 8 Jul 1997 16:54:44 +0000 Subject: Makefile: Added AIX targets from Ole Holm Nielsen chgpasswd.c: Added Samba/GPL notice (for obvious reasons). clitar.c: Updated Copyright date to include 1997 (for obvious reasons). getsmbpass.c: Updated Copyright date to include 1997 (for obvious reasons). includes.h: Added stropts for solaris. loadparm.c: Changed comment for hide files option. nameconf.c: Updated Copyright date to include 1997 (for obvious reasons). nmbd.c: Updated Copyright date to include 1997 (for obvious reasons). pcap.c: Updated Copyright date to include 1997 (for obvious reasons). proto.h: Re-added accidentaly deleted smb_shm_ calls. quotas.c: Added AIX quota patch from Ole Holm Nielsen server.c: Optimization on calling is_hidden_path. Updated Copyrights. smb.h: Changed DEFAULT_FILES_TO_HIDE from "*/.*" to ".*". smbpass.c: Updated Copyright date to include 1997 (for obvious reasons). ufc.c: Updated Copyright date to include 1997 (for obvious reasons). util.c: Added last component code to is_in_path(). Jeremy (jallison@whistle.com) (This used to be commit 9385ae1005f13c8ed51f1319e3949b5c8571e62d) --- source3/printing/pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 13b850b3f5..549ebcd70d 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. printcap parsing - Copyright (C) Karl Auer 1993,1994 + Copyright (C) Karl Auer 1993-1997 Re-working by Martin Kiff, 1994 -- cgit From cef59090bb2fd3f8a9efd1a453cb90264b891d58 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 26 Sep 1997 18:55:29 +0000 Subject: Adding Andrews buffer overflow fixes into the main branch. Jeremy (jallison@whistle.com) (This used to be commit e7eb1f044d3101679dc7a118820ea5efe0cd837c) --- source3/printing/pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 549ebcd70d..65195ab1af 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -358,8 +358,8 @@ void pcap_printer_fn(void (*fn)()) if (strlen(p) <= 8 && strlen(p)>strlen(name) && !has_punctuation) { - if (!*comment) strcpy(comment,name); - strcpy(name,p); + if (!*comment) pstrcpy(comment,name); + pstrcpy(name,p); continue; } -- cgit From 7a668a7641cd747455b7a9854dbc208a3e4bc7ef Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 3 Dec 1997 05:08:07 +0000 Subject: applied a patch from Norm Jacobs to allow "printcap name = lpstat" to use lpstat to obtain the printer list on systemV systems. I've now made this the default on all SYSV systems. Jeremy, you were a little worried about the security of this patch. I believe it's OK as the user has no control over the options given to popen() and the pipe is only open for reading. (This used to be commit 6a83de0ae954bb18d3f15382f2b0b3259fedff09) --- source3/printing/pcap.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 65195ab1af..ff0a2b5477 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -7,6 +7,8 @@ Re-working by Martin Kiff, 1994 Re-written again by Andrew Tridgell + + Modified for SVID support by Norm Jacobs, 1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,6 +51,9 @@ * Opening a pipe for "lpc status" and reading that would probably * be pretty effective. Code to do this already exists in the freely * distributable PCNFS server code. + * + * Modified to call SVID/XPG4 support if printcap name is set to "lpstat" + * in smb.conf under Solaris. */ #include "includes.h" @@ -255,10 +260,17 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) DEBUG(0,( "No printcap file name configured!\n")); return(False); } + +#ifdef SYSV + if (strequal(psz, "lpstat")) + return (sysv_printername_ok(pszPrintername)); +#endif + #ifdef AIX if (strlocate(psz,"/qconfig") != NULL) return(ScanQconfig(psz,pszPrintername)); #endif + if ((pfile = fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); @@ -292,7 +304,6 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) } } - fclose(pfile); return(False); } @@ -317,6 +328,13 @@ void pcap_printer_fn(void (*fn)()) return; } +#ifdef SYSV + if (strequal(psz, "lpstat")) { + sysv_printer_fn(fn); + return; + } +#endif + #ifdef AIX if (strlocate(psz,"/qconfig") != NULL) { @@ -324,6 +342,7 @@ void pcap_printer_fn(void (*fn)()) return; } #endif + if ((pfile = fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); -- cgit From fec28f2defa17974b2eaafdd10599cf37850ca16 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Jan 1998 06:29:38 +0000 Subject: Makefile: Added new codepage - 866. charset.c: Supporting code for codepage 866. clientutil.c: Fix compile bug in little-used #define. includes.h: Supporting code for codepage 866. make_smbcodepage.c: Supporting code for codepage 866. pcap.c: Fix bug for lpstat. Jeremy. (This used to be commit 6040d7a39e5d5ab426905aa79b871df815fb9b62) --- source3/printing/pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index ff0a2b5477..bff81b8661 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -267,7 +267,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) #endif #ifdef AIX - if (strlocate(psz,"/qconfig") != NULL) + if (strlocate(psz,"/qconfig")) return(ScanQconfig(psz,pszPrintername)); #endif @@ -336,7 +336,7 @@ void pcap_printer_fn(void (*fn)()) #endif #ifdef AIX - if (strlocate(psz,"/qconfig") != NULL) + if (strlocate(psz,"/qconfig")) { ScanQconfig_fn(psz,fn); return; -- cgit From 55f400bd84f26027f5ec9b7fa06b22895de7557c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jan 1998 13:27:43 +0000 Subject: This is *not* a big change (although it looks like one). This is merely updating the Copyright statements from 1997 to 1998. It's a once a year thing :-). NO OTHER CHANGES WERE MADE. Jeremy. (This used to be commit b9c16977231efb274e08856f7f3f4408dad6d96c) --- source3/printing/pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index bff81b8661..3698114a2f 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. printcap parsing - Copyright (C) Karl Auer 1993-1997 + Copyright (C) Karl Auer 1993-1998 Re-working by Martin Kiff, 1994 -- cgit From 1ab10eb365d8e2f5a337eea0b98956d5fd098c44 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Fri, 20 Mar 1998 13:37:46 +0000 Subject: Added MAXPRINTERLEN define in smb.h setting printer share name length to maximumof 15 characters. IF this needs to be limited to 8 characters again please do it in smb.h. (This used to be commit 3dfe0b135dd91864a81a5fadddc9151ac8812c6e) --- source3/printing/pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 3698114a2f..38c4dec3fc 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -375,7 +375,7 @@ void pcap_printer_fn(void (*fn)()) continue; } - if (strlen(p) <= 8 && strlen(p)>strlen(name) && !has_punctuation) + if (strlen(p) <= MAXPRINTERLEN && strlen(p)>strlen(name) && !has_punctuation) { if (!*comment) pstrcpy(comment,name); pstrcpy(name,p); @@ -391,7 +391,7 @@ void pcap_printer_fn(void (*fn)()) } comment[60] = 0; - name[8] = 0; + name[MAXPRINTERLEN] = 0; if (*name) fn(name,comment); -- cgit From cac6a060af598bf94e6414b06e7365ec51ca360e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Apr 1998 19:24:06 +0000 Subject: Changes to allow Samba to be compiled with -Wstrict-prototypes with gcc. (Not a big change although it looks like it :-). Jeremy. (This used to be commit cd2613c57261456485fe4eeecfda209ada70de8e) --- source3/printing/pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 38c4dec3fc..0b3ad2b136 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -313,7 +313,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) run a function on each printer name in the printcap file. The function is passed the primary name and the comment (if possible) ***************************************************************************/ -void pcap_printer_fn(void (*fn)()) +void pcap_printer_fn(void (*fn)(char *, char *)) { pstring name,comment; char *line; -- cgit From f888868f46a5418bac9ab528497136c152895305 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 May 1998 00:55:32 +0000 Subject: This is a security audit change of the main source. It removed all ocurrences of the following functions : sprintf strcpy strcat The replacements are slprintf, safe_strcpy and safe_strcat. It should not be possible to use code in Samba that uses sprintf, strcpy or strcat, only the safe_equivalents. Once Andrew has fixed the slprintf implementation then this code will be moved back to the 1.9.18 code stream. Jeremy. (This used to be commit 2d774454005f0b54e5684cf618da7060594dfcbb) --- source3/printing/pcap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 0b3ad2b136..f26f81207d 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -123,7 +123,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)()) p = strtok(line,":"); if (strcmp(p,"bsh")!=0) { - strcpy(name,p); + pstrcpy(name,p); iEtat = 1; continue; } @@ -182,7 +182,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) free(pName); return(False); } - sprintf(pName,"%s:",pszPrintername); + slprintf(pName, iLg + 9, "%s:",pszPrintername); iLg = strlen(pName); /*DEBUG(3,( " Looking for entry %s\n",pName));*/ iEtat = 0; @@ -295,7 +295,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) if (strequal(p,pszPrintername)) { /* normalise the case */ - strcpy(pszPrintername,p); + pstrcpy(pszPrintername,p); free(line); fclose(pfile); return(True); -- cgit From 64578c0589a3a741f81fb55c16eeb882128da00b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:08:05 +0000 Subject: merge from the autoconf2 branch to the main branch (This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21) --- source3/printing/pcap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index f26f81207d..d51e69ad74 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -232,8 +232,9 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) fclose(pfile); return(False); } +#endif /* AIX */ + -#endif /*************************************************************************** Scan printcap file pszPrintcapname for a printer called pszPrintername. Return True if found, else False. Returns False on error, too, after logging -- cgit From 768761820e8d7481c586c4e0ab4ac7cb36d18c4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Nov 1998 20:50:07 +0000 Subject: Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls. Tidied up some of the mess (no other word for it). Still doesn't compile cleanly. There are calls with incorrect parameters that don't seem to be doing the right thing. This code still needs surgery :-(. Jeremy. (This used to be commit 18ff93a9abbf68ee8c59c0af3e57c63e4a015dac) --- source3/printing/pcap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index d51e69ad74..242406c974 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -101,7 +101,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)()) *name = 0; *comment = 0; - if ((pfile = fopen(psz, "r")) == NULL) + if ((pfile = sys_fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); return; @@ -176,7 +176,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername)); return(False); } - if ((pfile = fopen(psz, "r")) == NULL) + if ((pfile = sys_fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); free(pName); @@ -272,7 +272,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) return(ScanQconfig(psz,pszPrintername)); #endif - if ((pfile = fopen(psz, "r")) == NULL) + if ((pfile = sys_fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); return(False); @@ -344,7 +344,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) } #endif - if ((pfile = fopen(psz, "r")) == NULL) + if ((pfile = sys_fopen(psz, "r")) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); return; -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/printing/pcap.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 242406c974..62010706bb 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -9,6 +9,8 @@ Re-written again by Andrew Tridgell Modified for SVID support by Norm Jacobs, 1997 + + Modified for CUPS support by Michael Sweet, 1999 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,6 +56,9 @@ * * Modified to call SVID/XPG4 support if printcap name is set to "lpstat" * in smb.conf under Solaris. + * + * Modified to call CUPS support if printcap name is set to "cups" + * in smb.conf. */ #include "includes.h" @@ -69,7 +74,7 @@ extern int DEBUGLEVEL; ****************************************** */ static int strlocate(char *xpLine,char *xpS) { - int iS,iL,i,iRet; + int iS,iL,iRet; char *p; iS = strlen(xpS); iL = strlen(xpLine); @@ -91,9 +96,9 @@ static int strlocate(char *xpLine,char *xpS) /* ******************************************************************* */ /* * Scan qconfig and search all virtual printer (device printer) * */ /* ******************************************************************* */ -static void ScanQconfig_fn(char *psz,void (*fn)()) +static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) { - int iLg,iEtat; + int iEtat; FILE *pfile; char *line,*p; pstring name,comment; @@ -262,6 +267,11 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) return(False); } +#ifdef HAVE_LIBCUPS + if (strequal(psz, "cups")) + return (cups_printername_ok(pszPrintername)); +#endif /* HAVE_LIBCUPS */ + #ifdef SYSV if (strequal(psz, "lpstat")) return (sysv_printername_ok(pszPrintername)); @@ -329,6 +339,13 @@ void pcap_printer_fn(void (*fn)(char *, char *)) return; } +#ifdef HAVE_LIBCUPS + if (strequal(psz, "cups")) { + cups_printer_fn(fn); + return; + } +#endif /* HAVE_LIBCUPS */ + #ifdef SYSV if (strequal(psz, "lpstat")) { sysv_printer_fn(fn); -- cgit From 5fb473fc758b5fbc1145c00dc9b95567107afd5c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 May 2000 05:42:39 +0000 Subject: handle tabs in printcap files this is needed for lprng (This used to be commit c40e0a5d3bfa11cb3699bdba1ded91515cabaf5d) --- source3/printing/pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 62010706bb..fb2409fd38 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -385,7 +385,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) BOOL has_punctuation; if ((q = strchr(p,'|'))) *q++ = 0; - has_punctuation = (strchr(p,' ') || strchr(p,'(') || strchr(p,')')); + has_punctuation = (strchr(p,' ') || strchr(p,'\t') || strchr(p,'(') || strchr(p,')')); if (strlen(p)>strlen(comment) && has_punctuation) { @@ -411,7 +411,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) comment[60] = 0; name[MAXPRINTERLEN] = 0; - if (*name) + if (*name) fn(name,comment); } fclose(pfile); -- cgit From 792ca5d98938c3c52ff4e598bcb55056565dc202 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 17 Jan 2001 18:47:46 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - Unrolled construct_notify_jobs_info() loop to only fetch printer info_2 structure once rather than num_print_jobs times. - convert command to unix codepage. - remove lp_remove_service() call as it prevents lp_killservice() from working. - Modified some DEBUG and DEBUGADD statements. source/param/loadparm.c source/param/params.c - change printer, preload, auto services to FLAG_DOS_STRING, reverted earlier changes to szPrintername et al, add comments. source/printing/load.c - fix bug with lp_auto_services() and strtok() source/printing/nt_printing.c source/printing/printing.c - remove redundant test that used SERVICE(snum) source/printing/pcap.c - add unix_to_dos() calls, add notes wrt FIXMEs for xxx_printer_fn() functions. source/web/swat.c - added FIXME comment. source/smbd/service.c - added comment re: dos codepage (This used to be commit 7b774b72c2857af9519012106714a9e2cb099da3) --- source3/printing/pcap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index fb2409fd38..e9c2e46090 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -244,7 +244,10 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) Scan printcap file pszPrintcapname for a printer called pszPrintername. Return True if found, else False. Returns False on error, too, after logging the error at level 0. For generality, the printcap name may be passed - if -passed as NULL, the configuration will be queried for the name. +passed as NULL, the configuration will be queried for the name. pszPrintername +must be in DOS codepage. +The xxx_printername_ok functions need fixing to understand they are being +given a DOS codepage. FIXME !! JRA. ***************************************************************************/ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) { @@ -293,6 +296,8 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) if (*line == '#' || *line == 0) continue; + unix_to_dos(line,True); + /* now we have a real printer line - cut it off at the first : */ p = strchr(line,':'); if (p) *p = 0; @@ -322,7 +327,9 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) /*************************************************************************** run a function on each printer name in the printcap file. The function is -passed the primary name and the comment (if possible) +passed the primary name and the comment (if possible). Note the fn() takes +strings in DOS codepage. This means the xxx_printer_fn() calls must be fixed +to return DOS codepage. FIXME !! JRA. ***************************************************************************/ void pcap_printer_fn(void (*fn)(char *, char *)) { @@ -376,6 +383,8 @@ void pcap_printer_fn(void (*fn)(char *, char *)) p = strchr(line,':'); if (p) *p = 0; + unix_to_dos(line,True); + /* now find the most likely printer name and comment this is pure guesswork, but it's better than nothing */ *name = 0; -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/printing/pcap.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index e9c2e46090..1f909d3533 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -296,8 +296,6 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) if (*line == '#' || *line == 0) continue; - unix_to_dos(line,True); - /* now we have a real printer line - cut it off at the first : */ p = strchr(line,':'); if (p) *p = 0; @@ -383,8 +381,6 @@ void pcap_printer_fn(void (*fn)(char *, char *)) p = strchr(line,':'); if (p) *p = 0; - unix_to_dos(line,True); - /* now find the most likely printer name and comment this is pure guesswork, but it's better than nothing */ *name = 0; -- cgit From 527e824293ee934ca5da0ef5424efe5ab7757248 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:36:09 +0000 Subject: strchr and strrchr are macros when compiling with optimisation in gcc, so we can't redefine them. damn. (This used to be commit c41fc06376d1a2b83690612304e85010b5e5f3cf) --- source3/printing/pcap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 1f909d3533..313e17fb1c 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -122,7 +122,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) { case 0: /* locate an entry */ if (*line == '\t' || *line == ' ') continue; - if ((p=strchr(line,':'))) + if ((p=strchr_m(line,':'))) { *p = '\0'; p = strtok(line,":"); @@ -297,14 +297,14 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) continue; /* now we have a real printer line - cut it off at the first : */ - p = strchr(line,':'); + p = strchr_m(line,':'); if (p) *p = 0; /* now just check if the name is in the list */ /* NOTE: I avoid strtok as the fn calling this one may be using it */ for (p=line; p; p=q) { - if ((q = strchr(p,'|'))) *q++ = 0; + if ((q = strchr_m(p,'|'))) *q++ = 0; if (strequal(p,pszPrintername)) { @@ -378,7 +378,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) continue; /* now we have a real printer line - cut it off at the first : */ - p = strchr(line,':'); + p = strchr_m(line,':'); if (p) *p = 0; /* now find the most likely printer name and comment @@ -388,9 +388,9 @@ void pcap_printer_fn(void (*fn)(char *, char *)) for (p=line; p; p=q) { BOOL has_punctuation; - if ((q = strchr(p,'|'))) *q++ = 0; + if ((q = strchr_m(p,'|'))) *q++ = 0; - has_punctuation = (strchr(p,' ') || strchr(p,'\t') || strchr(p,'(') || strchr(p,')')); + has_punctuation = (strchr_m(p,' ') || strchr_m(p,'\t') || strchr_m(p,'(') || strchr_m(p,')')); if (strlen(p)>strlen(comment) && has_punctuation) { @@ -405,7 +405,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) continue; } - if (!strchr(comment,' ') && + if (!strchr_m(comment,' ') && strlen(p) > strlen(comment)) { StrnCpy(comment,p,sizeof(comment)-1); -- cgit From d1f53e404496dff10df7dc5e5b58ed676982c955 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Aug 2001 19:06:20 +0000 Subject: Fixed detection of CUPS. We need to check for the presence of the cups header files as well as libcups. (This used to be commit 2dbb41a7b88e7fad63579111aaab4a1cd28c54d5) --- source3/printing/pcap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 313e17fb1c..cbafe27728 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -270,10 +270,10 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) return(False); } -#ifdef HAVE_LIBCUPS +#ifdef HAVE_CUPS if (strequal(psz, "cups")) return (cups_printername_ok(pszPrintername)); -#endif /* HAVE_LIBCUPS */ +#endif /* HAVE_CUPS */ #ifdef SYSV if (strequal(psz, "lpstat")) @@ -344,12 +344,12 @@ void pcap_printer_fn(void (*fn)(char *, char *)) return; } -#ifdef HAVE_LIBCUPS +#ifdef HAVE_CUPS if (strequal(psz, "cups")) { cups_printer_fn(fn); return; } -#endif /* HAVE_LIBCUPS */ +#endif /* HAVE_CUPS */ #ifdef SYSV if (strequal(psz, "lpstat")) { -- cgit From 79139fe8d882c39620b0d52ef081f639d1294917 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Sep 2001 12:46:42 +0000 Subject: convert more code to use XFILE (This used to be commit fe6679dffba9a92bb35933ad52172c9be0e9ef90) --- source3/printing/pcap.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index cbafe27728..0ac7600dc5 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -99,14 +99,14 @@ static int strlocate(char *xpLine,char *xpS) static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) { int iEtat; - FILE *pfile; + XFILE *pfile; char *line,*p; pstring name,comment; line = NULL; *name = 0; *comment = 0; - if ((pfile = sys_fopen(psz, "r")) == NULL) + if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); return; @@ -160,7 +160,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) break; } } - fclose(pfile); + x_fclose(pfile); } /* Scan qconfig file and locate de printername */ @@ -168,7 +168,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) static BOOL ScanQconfig(char *psz,char *pszPrintername) { int iLg,iEtat; - FILE *pfile; + XFILE *pfile; char *pName; char *line; @@ -181,7 +181,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername)); return(False); } - if ((pfile = sys_fopen(psz, "r")) == NULL) + if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); free(pName); @@ -234,7 +234,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) } } free (pName); - fclose(pfile); + x_fclose(pfile); return(False); } #endif /* AIX */ @@ -254,7 +254,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) char *line=NULL; char *psz; char *p,*q; - FILE *pfile; + XFILE *pfile; if (pszPrintername == NULL || pszPrintername[0] == '\0') { @@ -285,7 +285,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) return(ScanQconfig(psz,pszPrintername)); #endif - if ((pfile = sys_fopen(psz, "r")) == NULL) + if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); return(False); @@ -311,14 +311,14 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) /* normalise the case */ pstrcpy(pszPrintername,p); free(line); - fclose(pfile); + x_fclose(pfile); return(True); } p = q; } } - fclose(pfile); + x_fclose(pfile); return(False); } @@ -335,7 +335,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) char *line; char *psz; char *p,*q; - FILE *pfile; + XFILE *pfile; /* only go looking if no printcap name supplied */ if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0')) @@ -366,7 +366,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) } #endif - if ((pfile = sys_fopen(psz, "r")) == NULL) + if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); return; @@ -419,5 +419,5 @@ void pcap_printer_fn(void (*fn)(char *, char *)) if (*name) fn(name,comment); } - fclose(pfile); + x_fclose(pfile); } -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/printing/pcap.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 0ac7600dc5..b10dbba9c5 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -65,8 +65,6 @@ #include "smb.h" -extern int DEBUGLEVEL; - #ifdef AIX /* ****************************************** Extend for AIX system and qconfig file -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/printing/pcap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index b10dbba9c5..920c6f354e 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. printcap parsing Copyright (C) Karl Auer 1993-1998 -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/printing/pcap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 920c6f354e..4bca63fffb 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -111,7 +111,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) iEtat = 0; /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) { if (*line == '*' || *line == 0) continue; @@ -181,7 +181,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); - free(pName); + SAFE_FREE(pName); return(False); } slprintf(pName, iLg + 9, "%s:",pszPrintername); @@ -189,7 +189,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) /*DEBUG(3,( " Looking for entry %s\n",pName));*/ iEtat = 0; /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) { if (*line == '*' || *line == 0) continue; @@ -209,7 +209,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) /* name is found without stanza device */ /* probably a good printer ??? */ free (line); - free(pName); + SAFE_FREE(pName); fclose(pfile); return(True); } @@ -223,7 +223,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) { /* it's a good virtual printer */ free (line); - free(pName); + SAFE_FREE(pName); fclose(pfile); return(True); } @@ -288,7 +288,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) return(False); } - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) { if (*line == '#' || *line == 0) continue; @@ -307,7 +307,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) { /* normalise the case */ pstrcpy(pszPrintername,p); - free(line); + SAFE_FREE(line); x_fclose(pfile); return(True); } @@ -369,7 +369,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) return; } - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); free(line)) + for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) { if (*line == '#' || *line == 0) continue; -- cgit From b2edf254eda92f775e7d3d9b6793b4d77f9000b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 17:00:51 +0000 Subject: sync 3.0 branch with head (This used to be commit 3928578b52cfc949be5e0ef444fce1558d75f290) --- source3/printing/pcap.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 4bca63fffb..86489e9587 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -241,15 +241,12 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) Scan printcap file pszPrintcapname for a printer called pszPrintername. Return True if found, else False. Returns False on error, too, after logging the error at level 0. For generality, the printcap name may be passed - if -passed as NULL, the configuration will be queried for the name. pszPrintername -must be in DOS codepage. -The xxx_printername_ok functions need fixing to understand they are being -given a DOS codepage. FIXME !! JRA. +passed as NULL, the configuration will be queried for the name. ***************************************************************************/ -BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) +BOOL pcap_printername_ok(const char *pszPrintername, const char *pszPrintcapname) { char *line=NULL; - char *psz; + const char *psz; char *p,*q; XFILE *pfile; @@ -305,8 +302,6 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname) if (strequal(p,pszPrintername)) { - /* normalise the case */ - pstrcpy(pszPrintername,p); SAFE_FREE(line); x_fclose(pfile); return(True); -- cgit From f3e3a56ea9085b186af24b0b4e911863fd9ceacc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 29 Nov 2002 02:58:59 +0000 Subject: Merge a bunch of trivial changes from HEAD. The difference remaining should actual functional differences between HEAD and 3.0. - Mostly reformatting - Removal of unecessary #include "smb.h" - Merge of dyn_DRIVERFILE removal - Silly bug fix for python code (This used to be commit d3998307adc50ba50defe610cb656c73799ae3b9) --- source3/printing/pcap.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 86489e9587..c399c3c6cc 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -62,8 +62,6 @@ #include "includes.h" -#include "smb.h" - #ifdef AIX /* ****************************************** Extend for AIX system and qconfig file -- cgit From 2a3a9f0bf43c3bf99a71f7296bb5ff6199893fea Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Apr 2003 13:27:35 +0000 Subject: Merge the 'safe' parts of my StrnCpy patch - many of the users really wanted a pstrcpy/fstrcpy or at most a safe_strcpy(). These have the advantage of being compiler-verifiable. Get these out of the way, along with a rewrite of 'get_short_archi' in the spoolss client and server. (This pushes around const string pointers, rather than copied strings). Andrew Bartlett (This used to be commit 32fb801ddc035e8971e9911ed4b6e51892e9d1cc) --- source3/printing/pcap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index c399c3c6cc..1bdbf4a789 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -384,7 +384,7 @@ void pcap_printer_fn(void (*fn)(char *, char *)) if (strlen(p)>strlen(comment) && has_punctuation) { - StrnCpy(comment,p,sizeof(comment)-1); + pstrcpy(comment,p); continue; } @@ -398,8 +398,8 @@ void pcap_printer_fn(void (*fn)(char *, char *)) if (!strchr_m(comment,' ') && strlen(p) > strlen(comment)) { - StrnCpy(comment,p,sizeof(comment)-1); - continue; + pstrcpy(comment,p); + continue; } } -- cgit From a9c0fcfa371896755975b8c7267fae19203bee8e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Jul 2003 07:02:55 +0000 Subject: Some fclose -> x_fclose found by Tony Jago. Jeremy. (This used to be commit 919078cf397155ede0169ce95a726d0fdbef696a) --- source3/printing/pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 1bdbf4a789..a5fb53a320 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -208,7 +208,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) /* probably a good printer ??? */ free (line); SAFE_FREE(pName); - fclose(pfile); + x_fclose(pfile); return(True); } @@ -222,7 +222,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername) /* it's a good virtual printer */ free (line); SAFE_FREE(pName); - fclose(pfile); + x_fclose(pfile); return(True); } break; -- cgit From d097ea490525e7a35739dae6a295fd03ba52cfc0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 5 Jan 2005 16:20:35 +0000 Subject: r4539: patch from Rob -- adding real printcap name cache function to speed up printcap reloads (This used to be commit 1cad5250932b963c2eb9b775221b13db386d601b) --- source3/printing/pcap.c | 468 ++++++++++++++++-------------------------------- 1 file changed, 154 insertions(+), 314 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index a5fb53a320..0495b6fc1f 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -27,10 +27,8 @@ */ /* - * Parse printcap file. - * - * This module does exactly one thing - it looks into the printcap file - * and tells callers if a specified string appears as a printer name. + * This module contains code to parse and cache printcap data, possibly + * in concert with the CUPS/SYSV/AIX-specific code found elsewhere. * * The way this module looks at the printcap file is very simplistic. * Only the local printcap file is inspected (no searching of NIS @@ -62,352 +60,194 @@ #include "includes.h" -#ifdef AIX -/* ****************************************** - Extend for AIX system and qconfig file - from 'boulard@univ-rennes1.fr - ****************************************** */ -static int strlocate(char *xpLine,char *xpS) + +typedef struct pcap_cache { + char *name; + char *comment; + struct pcap_cache *next; +} pcap_cache_t; + +static pcap_cache_t *pcap_cache = NULL; + +BOOL pcap_cache_add(const char *name, const char *comment) { - int iS,iL,iRet; - char *p; - iS = strlen(xpS); - iL = strlen(xpLine); - - iRet = 0; - p = xpLine; - while (iL >= iS) - { - if (strncmp(p,xpS,iS) == 0) {iRet =1;break;}; - p++; - iL--; - } - /*DEBUG(3,(" strlocate %s in line '%s',ret=%d\n",xpS,xpLine,iRet));*/ - - return(iRet); + pcap_cache_t *p; + + if (name == NULL || ((p = SMB_MALLOC_P(pcap_cache_t)) == NULL)) + return False; + + p->name = SMB_STRDUP(name); + p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL; + + p->next = pcap_cache; + pcap_cache = p; + + return True; } - - -/* ******************************************************************* */ -/* * Scan qconfig and search all virtual printer (device printer) * */ -/* ******************************************************************* */ -static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *)) + +static void pcap_cache_destroy(pcap_cache_t *cache) { - int iEtat; - XFILE *pfile; - char *line,*p; - pstring name,comment; - line = NULL; - *name = 0; - *comment = 0; - - if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) - { - DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); - return; - } + pcap_cache_t *p, *next; - iEtat = 0; - /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) - { - if (*line == '*' || *line == 0) - continue; - switch (iEtat) - { - case 0: /* locate an entry */ - if (*line == '\t' || *line == ' ') continue; - if ((p=strchr_m(line,':'))) - { - *p = '\0'; - p = strtok(line,":"); - if (strcmp(p,"bsh")!=0) - { - pstrcpy(name,p); - iEtat = 1; - continue; - } - } - break; - case 1: /* scanning device stanza */ - if (*line == '*' || *line == 0) continue; - if (*line != '\t' && *line != ' ') - { - /* name is found without stanza device */ - /* probably a good printer ??? */ - fn(name,comment); - iEtat = 0; - continue; - } - - if (strlocate(line,"backend")) - { - /* it's a device, not a virtual printer*/ - iEtat = 0; - } - else if (strlocate(line,"device")) - { - /* it's a good virtual printer */ - fn(name,comment); - iEtat = 0; - continue; - } - break; - } + for (p = cache; p != NULL; p = next) { + next = p->next; + + SAFE_FREE(p->name); + SAFE_FREE(p->comment); + SAFE_FREE(p); } - x_fclose(pfile); } -/* Scan qconfig file and locate de printername */ - -static BOOL ScanQconfig(char *psz,char *pszPrintername) +BOOL pcap_cache_loaded(void) { - int iLg,iEtat; - XFILE *pfile; - char *pName; - char *line; - - pName = NULL; - line = NULL; - if ((pszPrintername!= NULL) && ((iLg = strlen(pszPrintername)) > 0)) - pName = malloc(iLg+10); - if (pName == NULL) - { - DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername)); - return(False); - } - if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) - { - DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz)); - SAFE_FREE(pName); - return(False); - } - slprintf(pName, iLg + 9, "%s:",pszPrintername); - iLg = strlen(pName); - /*DEBUG(3,( " Looking for entry %s\n",pName));*/ - iEtat = 0; - /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) - { - if (*line == '*' || *line == 0) - continue; - switch (iEtat) - { - case 0: /* scanning entry */ - if (strncmp(line,pName,iLg) == 0) - { - iEtat = 1; - continue; - } - break; - case 1: /* scanning device stanza */ - if (*line == '*' || *line == 0) continue; - if (*line != '\t' && *line != ' ') - { - /* name is found without stanza device */ - /* probably a good printer ??? */ - free (line); - SAFE_FREE(pName); - x_fclose(pfile); - return(True); - } - - if (strlocate(line,"backend")) - { - /* it's a device, not a virtual printer*/ - iEtat = 0; - } - else if (strlocate(line,"device")) - { - /* it's a good virtual printer */ - free (line); - SAFE_FREE(pName); - x_fclose(pfile); - return(True); - } - break; - } - } - free (pName); - x_fclose(pfile); - return(False); + return (pcap_cache != NULL); } -#endif /* AIX */ - -/*************************************************************************** -Scan printcap file pszPrintcapname for a printer called pszPrintername. -Return True if found, else False. Returns False on error, too, after logging -the error at level 0. For generality, the printcap name may be passed - if -passed as NULL, the configuration will be queried for the name. -***************************************************************************/ -BOOL pcap_printername_ok(const char *pszPrintername, const char *pszPrintcapname) +void pcap_cache_reload(void) { - char *line=NULL; - const char *psz; - char *p,*q; - XFILE *pfile; - - if (pszPrintername == NULL || pszPrintername[0] == '\0') - { - DEBUG(0,( "Attempt to locate null printername! Internal error?\n")); - return(False); - } - - /* only go looking if no printcap name supplied */ - if ((psz = pszPrintcapname) == NULL || psz[0] == '\0') - if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0')) - { - DEBUG(0,( "No printcap file name configured!\n")); - return(False); - } + const char *pcap_name = lp_printcapname(); + BOOL pcap_reloaded = False; + pcap_cache_t *tmp_cache = NULL; + XFILE *pcap_file; + char *pcap_line; + + DEBUG(3, ("reloading printcap cache\n")); + + /* only go looking if no printcap name supplied */ + if (pcap_name == NULL || *pcap_name == 0) { + DEBUG(0, ("No printcap file name configured!\n")); + return; + } + + tmp_cache = pcap_cache; + pcap_cache = NULL; #ifdef HAVE_CUPS - if (strequal(psz, "cups")) - return (cups_printername_ok(pszPrintername)); -#endif /* HAVE_CUPS */ + if (strequal(pcap_name, "cups")) { + pcap_reloaded = cups_cache_reload(); + goto done; + } +#endif #ifdef SYSV - if (strequal(psz, "lpstat")) - return (sysv_printername_ok(pszPrintername)); + if (strequal(pcap_name, "lpstat")) { + pcap_reloaded = sysv_cache_reload(); + goto done; + } #endif #ifdef AIX - if (strlocate(psz,"/qconfig")) - return(ScanQconfig(psz,pszPrintername)); + if (strstr_m(pcap_name, "/qconfig") != NULL) { + pcap_reloaded = aix_cache_reload(); + goto done; + } #endif - if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) - { - DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); - return(False); - } + /* handle standard printcap - moved from pcap_printer_fn() */ + + if ((pcap_file = x_fopen(pcap_name, O_RDONLY, 0)) == NULL) { + DEBUG(0, ("Unable to open printcap file %s for read!\n", pcap_name)); + goto done; + } + + for (; (pcap_line = fgets_slash(NULL, sizeof(pstring), pcap_file)) != NULL; safe_free(pcap_line)) { + pstring name, comment; + char *p, *q; - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) - { - if (*line == '#' || *line == 0) - continue; + if (*pcap_line == '#' || *pcap_line == 0) + continue; - /* now we have a real printer line - cut it off at the first : */ - p = strchr_m(line,':'); - if (p) *p = 0; + /* now we have a real printer line - cut at the first : */ + if ((p = strchr_m(pcap_line, ':')) != NULL) + *p = 0; - /* now just check if the name is in the list */ - /* NOTE: I avoid strtok as the fn calling this one may be using it */ - for (p=line; p; p=q) - { - if ((q = strchr_m(p,'|'))) *q++ = 0; - - if (strequal(p,pszPrintername)) - { - SAFE_FREE(line); - x_fclose(pfile); - return(True); - } - p = q; + /* + * now find the most likely printer name and comment + * this is pure guesswork, but it's better than nothing + */ + for (*name = *comment = 0, p = pcap_line; p != NULL; p = q) { + BOOL has_punctuation; + + if ((q = strchr_m(p, '|')) != NULL) + *q++ = 0; + + has_punctuation = (strchr_m(p, ' ') || + strchr_m(p, '\t') || + strchr_m(p, '(') || + strchr_m(p, ')')); + + if (strlen(p) > strlen(comment) && has_punctuation) { + pstrcpy(comment, p); + continue; + } + + if (strlen(p) <= MAXPRINTERLEN && + strlen(p) > strlen(name) && !has_punctuation) { + if (!*comment) + pstrcpy(comment, name); + + pstrcpy(name, p); + continue; + } + + if (!strchr_m(comment, ' ') && + strlen(p) > strlen(comment)) { + pstrcpy(comment, p); + continue; + } + } + + comment[60] = 0; + name[MAXPRINTERLEN] = 0; + + if (*name && !pcap_cache_add(name, comment)) { + x_fclose(pcap_file); + goto done; + } } - } - x_fclose(pfile); - return(False); + x_fclose(pcap_file); + pcap_reloaded = True; + +done: + DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error")); + + if (pcap_reloaded) + pcap_cache_destroy(tmp_cache); + else { + pcap_cache_destroy(pcap_cache); + pcap_cache = tmp_cache; + } + + return; } +BOOL pcap_printername_ok(const char *printername) +{ + pcap_cache_t *p; + + for (p = pcap_cache; p != NULL; p = p->next) + if (strequal(p->name, printername)) + return True; + + return False; +} + /*************************************************************************** run a function on each printer name in the printcap file. The function is passed the primary name and the comment (if possible). Note the fn() takes strings in DOS codepage. This means the xxx_printer_fn() calls must be fixed to return DOS codepage. FIXME !! JRA. + +XXX: I'm not sure if this comment still applies.. Anyone? -Rob ***************************************************************************/ void pcap_printer_fn(void (*fn)(char *, char *)) { - pstring name,comment; - char *line; - char *psz; - char *p,*q; - XFILE *pfile; - - /* only go looking if no printcap name supplied */ - if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0')) - { - DEBUG(0,( "No printcap file name configured!\n")); - return; - } - -#ifdef HAVE_CUPS - if (strequal(psz, "cups")) { - cups_printer_fn(fn); - return; - } -#endif /* HAVE_CUPS */ - -#ifdef SYSV - if (strequal(psz, "lpstat")) { - sysv_printer_fn(fn); - return; - } -#endif - -#ifdef AIX - if (strlocate(psz,"/qconfig")) - { - ScanQconfig_fn(psz,fn); - return; - } -#endif - - if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL) - { - DEBUG(0,( "Unable to open printcap file %s for read!\n", psz)); - return; - } - - for (;(line = fgets_slash(NULL,sizeof(pstring),pfile)); safe_free(line)) - { - if (*line == '#' || *line == 0) - continue; - - /* now we have a real printer line - cut it off at the first : */ - p = strchr_m(line,':'); - if (p) *p = 0; - - /* now find the most likely printer name and comment - this is pure guesswork, but it's better than nothing */ - *name = 0; - *comment = 0; - for (p=line; p; p=q) - { - BOOL has_punctuation; - if ((q = strchr_m(p,'|'))) *q++ = 0; - - has_punctuation = (strchr_m(p,' ') || strchr_m(p,'\t') || strchr_m(p,'(') || strchr_m(p,')')); - - if (strlen(p)>strlen(comment) && has_punctuation) - { - pstrcpy(comment,p); - continue; - } - - if (strlen(p) <= MAXPRINTERLEN && strlen(p)>strlen(name) && !has_punctuation) - { - if (!*comment) pstrcpy(comment,name); - pstrcpy(name,p); - continue; - } - - if (!strchr_m(comment,' ') && - strlen(p) > strlen(comment)) - { - pstrcpy(comment,p); - continue; - } - } + pcap_cache_t *p; - comment[60] = 0; - name[MAXPRINTERLEN] = 0; + for (p = pcap_cache; p != NULL; p = p->next) + fn(p->name, p->comment); - if (*name) - fn(name,comment); - } - x_fclose(pfile); + return; } -- cgit From d3e3bd77a0caa8faaf06630f03270b4ae67caafa Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 7 Mar 2005 22:10:27 +0000 Subject: r5684: BUG 2405: patch from Torsten Werner to define 'lpstat' printcap output on HPUX (This used to be commit 98596037caa47a27c4f87793f9875ec18b0f23c2) --- source3/printing/pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 0495b6fc1f..e9d8195366 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -129,7 +129,7 @@ void pcap_cache_reload(void) } #endif -#ifdef SYSV +#if defined(SYSV) || defined(HPUX) if (strequal(pcap_name, "lpstat")) { pcap_reloaded = sysv_cache_reload(); goto done; -- cgit From c762908074c45baacde1df04b633e01308030864 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Sep 2005 23:28:22 +0000 Subject: r10371: Adding iPrint printing backend written by Joel J. Smith @ Novell. Jeremy. (This used to be commit 155dc2d52a971bfb8d7565c06f3efc637e130b11) --- source3/printing/pcap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index e9d8195366..9b4b5e4f71 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -56,6 +56,9 @@ * * Modified to call CUPS support if printcap name is set to "cups" * in smb.conf. + * + * Modified to call iPrint support if printcap name is set to "iprint" + * in smb.conf. */ #include "includes.h" @@ -129,6 +132,13 @@ void pcap_cache_reload(void) } #endif +#ifdef HAVE_IPRINT + if (strequal(pcap_name, "iprint")) { + pcap_reloaded = iprint_cache_reload(); + goto done; + } +#endif + #if defined(SYSV) || defined(HPUX) if (strequal(pcap_name, "lpstat")) { pcap_reloaded = sysv_cache_reload(); -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/printing/pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 9b4b5e4f71..22125a2f1b 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -13,7 +13,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/printing/pcap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 22125a2f1b..6231edf178 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -22,8 +22,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/printing/pcap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 6231edf178..aabdb73e2e 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -71,7 +71,7 @@ typedef struct pcap_cache { static pcap_cache_t *pcap_cache = NULL; -BOOL pcap_cache_add(const char *name, const char *comment) +bool pcap_cache_add(const char *name, const char *comment) { pcap_cache_t *p; @@ -100,7 +100,7 @@ static void pcap_cache_destroy(pcap_cache_t *cache) } } -BOOL pcap_cache_loaded(void) +bool pcap_cache_loaded(void) { return (pcap_cache != NULL); } @@ -108,7 +108,7 @@ BOOL pcap_cache_loaded(void) void pcap_cache_reload(void) { const char *pcap_name = lp_printcapname(); - BOOL pcap_reloaded = False; + bool pcap_reloaded = False; pcap_cache_t *tmp_cache = NULL; XFILE *pcap_file; char *pcap_line; @@ -175,7 +175,7 @@ void pcap_cache_reload(void) * this is pure guesswork, but it's better than nothing */ for (*name = *comment = 0, p = pcap_line; p != NULL; p = q) { - BOOL has_punctuation; + bool has_punctuation; if ((q = strchr_m(p, '|')) != NULL) *q++ = 0; @@ -232,7 +232,7 @@ done: } -BOOL pcap_printername_ok(const char *printername) +bool pcap_printername_ok(const char *printername) { pcap_cache_t *p; -- cgit From 01acd4bb3833733f7487ad86ea6542239fe3c90b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Nov 2007 13:56:36 -0800 Subject: Remove pstring from printing/*.c except for the tdb_unpack requirement (I'll be making that an allocating interface later). Jeremy. (This used to be commit d2ee75326ac291ab4f1860075ba35f58703c7d9d) --- source3/printing/pcap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index aabdb73e2e..30cb254a29 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -159,8 +159,9 @@ void pcap_cache_reload(void) goto done; } - for (; (pcap_line = fgets_slash(NULL, sizeof(pstring), pcap_file)) != NULL; safe_free(pcap_line)) { - pstring name, comment; + for (; (pcap_line = fgets_slash(NULL, 1024, pcap_file)) != NULL; safe_free(pcap_line)) { + char name[MAXPRINTERLEN+1]; + char comment[62]; char *p, *q; if (*pcap_line == '#' || *pcap_line == 0) @@ -186,22 +187,22 @@ void pcap_cache_reload(void) strchr_m(p, ')')); if (strlen(p) > strlen(comment) && has_punctuation) { - pstrcpy(comment, p); + strlcpy(comment, p, sizeof(comment)); continue; } if (strlen(p) <= MAXPRINTERLEN && strlen(p) > strlen(name) && !has_punctuation) { - if (!*comment) - pstrcpy(comment, name); - - pstrcpy(name, p); + if (!*comment) { + strlcpy(comment, name, sizeof(comment)); + } + strlcpy(name, p, sizeof(name)); continue; } if (!strchr_m(comment, ' ') && strlen(p) > strlen(comment)) { - pstrcpy(comment, p); + strlcpy(comment, p, sizeof(comment)); continue; } } -- cgit