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/print_aix.c | 111 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 source3/printing/print_aix.c (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c new file mode 100644 index 0000000000..6ed3510ee4 --- /dev/null +++ b/source3/printing/print_aix.c @@ -0,0 +1,111 @@ +/* + AIX-specific printcap loading + Copyright (C) Jean-Pierre.Boulard@univ-rennes1.fr 1996 + + 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. +*/ + +/* + * This module implements AIX-specific printcap loading. Most of the code + * here was originally provided by Jean-Pierre.Boulard@univ-rennes1.fr in + * the Samba 1.9.14 release, and was formerly contained in pcap.c. It has + * been moved here and condensed as part of a larger effort to clean up and + * simplify the printcap code. -- Rob Foehl, 2004/12/06 + */ + +#include "includes.h" + +#ifdef AIX +BOOL aix_cache_reload(void) +{ + int iEtat; + XFILE *pfile; + char *line = NULL, *p; + pstring name, comment; + + *name = 0; + *comment = 0; + + DEBUG(5, ("reloading aix printcap cache\n")); + + if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) { + DEBUG(0,( "Unable to open qconfig file %s for read!\n", lp_printcapname())); + return False; + } + + 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 ??? */ + iEtat = 0; + if (!pcap_cache_add(name, NULL)) { + safe_free(line); + x_fclose(pfile); + return False; + } + continue; + } + + if (strstr_m(line, "backend")) { + /* it's a device, not a virtual printer */ + iEtat = 0; + } else if (strstr_m(line, "device")) { + /* it's a good virtual printer */ + iEtat = 0; + if (!pcap_cache_add(name, NULL)) { + safe_free(line); + x_fclose(pfile); + return False; + } + continue; + } + break; + } + } + + x_fclose(pfile); + return True; +} + +#else +/* this keeps fussy compilers happy */ + void print_aix_dummy(void); + void print_aix_dummy(void) {} +#endif /* AIX */ -- 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/print_aix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index 6ed3510ee4..c7150acd95 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -4,7 +4,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/print_aix.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index c7150acd95..63a1592499 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -13,8 +13,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/print_aix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index 63a1592499..15d0740fd2 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -27,7 +27,7 @@ #include "includes.h" #ifdef AIX -BOOL aix_cache_reload(void) +bool aix_cache_reload(void) { int iEtat; XFILE *pfile; -- 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/print_aix.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index 15d0740fd2..bb125530df 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -32,21 +32,26 @@ bool aix_cache_reload(void) int iEtat; XFILE *pfile; char *line = NULL, *p; - pstring name, comment; + char *name; + TALLOC_CTX *ctx = talloc_init("aix_cache_reload"); + + if (!ctx) { + return false; + } *name = 0; - *comment = 0; DEBUG(5, ("reloading aix printcap cache\n")); if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) { DEBUG(0,( "Unable to open qconfig file %s for read!\n", lp_printcapname())); - return False; + TALLOC_FREE(ctx); + return false; } iEtat = 0; /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL, sizeof(pstring), pfile)); safe_free(line)) { + for (;(line = fgets_slash(NULL, 1024, pfile)); safe_free(line)) { if (*line == '*' || *line == 0) continue; @@ -59,7 +64,13 @@ bool aix_cache_reload(void) *p = '\0'; p = strtok(line, ":"); if (strcmp(p, "bsh") != 0) { - pstrcpy(name, p); + name = talloc_strdup(ctx, p); + if (!name) { + safe_free(line); + x_fclose(pfile); + TALLOC_FREE(ctx); + return false; + } iEtat = 1; continue; } @@ -77,11 +88,12 @@ bool aix_cache_reload(void) if (!pcap_cache_add(name, NULL)) { safe_free(line); x_fclose(pfile); - return False; + TALLOC_FREE(ctx); + return false; } continue; } - + if (strstr_m(line, "backend")) { /* it's a device, not a virtual printer */ iEtat = 0; @@ -91,7 +103,8 @@ bool aix_cache_reload(void) if (!pcap_cache_add(name, NULL)) { safe_free(line); x_fclose(pfile); - return False; + TALLOC_FREE(ctx); + return false; } continue; } @@ -100,7 +113,8 @@ bool aix_cache_reload(void) } x_fclose(pfile); - return True; + TALLOC_FREE(ctx); + return true; } #else -- cgit From 29c104fd60081756d734e21aeb4b865951e06948 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 13:43:12 -0800 Subject: Fix bug leftover from pstring conversion noticed by ceez on irc. Jeremy. (This used to be commit 70950b419a57465c38bb36722644b95b1d14f76d) --- source3/printing/print_aix.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index bb125530df..fd85ca0833 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -32,15 +32,13 @@ bool aix_cache_reload(void) int iEtat; XFILE *pfile; char *line = NULL, *p; - char *name; + char *name = NULL; TALLOC_CTX *ctx = talloc_init("aix_cache_reload"); if (!ctx) { return false; } - *name = 0; - DEBUG(5, ("reloading aix printcap cache\n")); if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) { -- cgit From 587cf54c61c9f1f7bcae431a82035fd942716c32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Jan 2008 11:04:10 +0100 Subject: strtok -> strtok_r (This used to be commit fd34ce437057bb34cdc37f4b066e424000d36789) --- source3/printing/print_aix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/printing/print_aix.c') diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index fd85ca0833..57590cc39e 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -59,8 +59,9 @@ bool aix_cache_reload(void) continue; if ((p = strchr_m(line, ':'))) { + char *saveptr; *p = '\0'; - p = strtok(line, ":"); + p = strtok_r(line, ":", &saveptr); if (strcmp(p, "bsh") != 0) { name = talloc_strdup(ctx, p); if (!name) { -- cgit