From 5711f1f196a9caf4dc0de4c3121e920995ebe1bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 06:20:02 +0000 Subject: the bulk of the changes. Also split the loadparm related code into printing/load.c so swat can get it without linking to the backend code ------------ The following series of commits are for the new tdb based printing backend. This completely replaces our old printing backend. Major changes include: - all print ops are now done in printing/*.c rather than scattered all over the place - system job ids are decoupled from SMB job ids - the lpq parsers don't need to be nearly so smart, they only need to parse the filename, the status and system job id - we can store lots more info about a job, including the full job name - the queue cache control is much better I also added a new utility routine file_lines_load() that loads a text file and parses it into lines. This is used in out lpq parsing and I also want to use it to replace all of our fgets() based code in other places. (This used to be commit a902caf8d78ae4cb11ea3776d10273cb37d5fcd0) --- source3/printing/load.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 source3/printing/load.c (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c new file mode 100644 index 0000000000..3d50f6d42a --- /dev/null +++ b/source3/printing/load.c @@ -0,0 +1,69 @@ +/* + Unix SMB/Netbios implementation. + Version 3.0 + load printer lists + Copyright (C) Andrew Tridgell 1992-2000 + + 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. +*/ + +#include "includes.h" + + +/*************************************************************************** +auto-load printer services +***************************************************************************/ +static void add_all_printers(void) +{ + int printers = lp_servicenumber(PRINTERS_NAME); + + if (printers < 0) return; + + pcap_printer_fn(lp_add_one_printer); +} + +/*************************************************************************** +auto-load some homes and printer services +***************************************************************************/ +static void add_auto_printers(void) +{ + char *p; + int printers; + char *str = lp_auto_services(); + + if (!str) return; + + printers = lp_servicenumber(PRINTERS_NAME); + + if (printers < 0) return; + + for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { + if (lp_servicenumber(p) >= 0) continue; + + if (pcap_printername_ok(p,NULL)) { + lp_add_printer(p,printers); + } + } +} + +/*************************************************************************** +load automatic printer services +***************************************************************************/ +void load_printers(void) +{ + add_auto_printers(); + if (lp_load_printers()) + add_all_printers(); +} -- cgit From 49fcb300de40d6da8682b485fd2c51236bcbb3dd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Jul 2000 20:41:51 +0000 Subject: Added John Reilly's enumports/addprinter/delprinter scripting code plus the fix for the Win9x printer drivers. Changed command names to add "command" string on the end for some consistancy with the other scripting commands. Added '%P' option to tdbpack/unpack to store long comment string. Made port name be "Samba Printer Port" if no enum port script given. Fixed prs_uint32_pre code to cope with null args. Jeremy. (This used to be commit 902ada63799cf27924c72e24e7593a8c9fb5eba9) --- source3/printing/load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index 3d50f6d42a..fbf10d22b8 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -25,7 +25,7 @@ /*************************************************************************** auto-load printer services ***************************************************************************/ -static void add_all_printers(void) +void add_all_printers(void) { int printers = lp_servicenumber(PRINTERS_NAME); -- 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/load.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index fbf10d22b8..275ffa21ed 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -41,13 +41,16 @@ static void add_auto_printers(void) { char *p; int printers; - char *str = lp_auto_services(); + char *str = strdup(lp_auto_services()); if (!str) return; printers = lp_servicenumber(PRINTERS_NAME); - if (printers < 0) return; + if (printers < 0) { + free(str); + return; + } for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { if (lp_servicenumber(p) >= 0) continue; @@ -56,6 +59,8 @@ static void add_auto_printers(void) lp_add_printer(p,printers); } } + + free(str); } /*************************************************************************** -- cgit From da3053048c3d224a20d6383ac6682d31059cd46c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 00:32:10 +0000 Subject: Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMR RPC code to merge with new passdb code. Currently rpcclient doesn't compile. I'm working on it... Jeremy. (This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549) --- source3/printing/load.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index 275ffa21ed..c4fc3377c3 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -48,9 +48,9 @@ static void add_auto_printers(void) printers = lp_servicenumber(PRINTERS_NAME); if (printers < 0) { - free(str); - return; - } + free(str); + return; + } for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { if (lp_servicenumber(p) >= 0) continue; @@ -60,7 +60,7 @@ static void add_auto_printers(void) } } - free(str); + free(str); } /*************************************************************************** -- cgit From 091dbaa00bfb970137290a306ee77b4c5255b6c2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 09:25:57 +0000 Subject: move to SAFE_FREE() (This used to be commit 09bf4425492fd96672ddd7a31d88854adcf7f0fe) --- source3/printing/load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index c4fc3377c3..ae76229d77 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -48,7 +48,7 @@ static void add_auto_printers(void) printers = lp_servicenumber(PRINTERS_NAME); if (printers < 0) { - free(str); + SAFE_FREE(str); return; } @@ -60,7 +60,7 @@ static void add_auto_printers(void) } } - free(str); + SAFE_FREE(str); } /*************************************************************************** -- 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/load.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index ae76229d77..ed967fb0a7 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 3.0 + Unix SMB/CIFS implementation. load printer lists Copyright (C) Andrew Tridgell 1992-2000 -- cgit From 669a39fae36f8bc60753c9b352556ef8ffaeb568 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 16:31:24 +0000 Subject: Sync 3.0 branch with HEAD (This used to be commit eac75549c398f208484ae735d5a5931fed6d0e99) --- source3/printing/load.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index ed967fb0a7..cd90cbb6f3 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -38,7 +38,7 @@ auto-load some homes and printer services ***************************************************************************/ static void add_auto_printers(void) { - char *p; + const char *p; int printers; char *str = strdup(lp_auto_services()); @@ -47,9 +47,9 @@ static void add_auto_printers(void) printers = lp_servicenumber(PRINTERS_NAME); if (printers < 0) { - SAFE_FREE(str); - return; - } + SAFE_FREE(str); + return; + } for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { if (lp_servicenumber(p) >= 0) continue; -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/printing/load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index cd90cbb6f3..59306aa104 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -40,7 +40,7 @@ static void add_auto_printers(void) { const char *p; int printers; - char *str = strdup(lp_auto_services()); + char *str = SMB_STRDUP(lp_auto_services()); if (!str) return; -- 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/load.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index 59306aa104..a925a63e17 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -21,45 +21,30 @@ #include "includes.h" -/*************************************************************************** -auto-load printer services -***************************************************************************/ -void add_all_printers(void) -{ - int printers = lp_servicenumber(PRINTERS_NAME); - - if (printers < 0) return; - - pcap_printer_fn(lp_add_one_printer); -} - /*************************************************************************** auto-load some homes and printer services ***************************************************************************/ static void add_auto_printers(void) { const char *p; - int printers; - char *str = SMB_STRDUP(lp_auto_services()); + int pnum = lp_servicenumber(PRINTERS_NAME); + char *str; - if (!str) return; - - printers = lp_servicenumber(PRINTERS_NAME); + if (pnum < 0) + return; - if (printers < 0) { - SAFE_FREE(str); + if ((str = SMB_STRDUP(lp_auto_services())) == NULL) return; - } - - for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { - if (lp_servicenumber(p) >= 0) continue; + + for (p = strtok(str, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) { + if (lp_servicenumber(p) >= 0) + continue; - if (pcap_printername_ok(p,NULL)) { - lp_add_printer(p,printers); - } + if (pcap_printername_ok(p)) + lp_add_printer(p, pnum); } - SAFE_FREE(str); + SAFE_FREE(str); } /*************************************************************************** @@ -67,7 +52,12 @@ load automatic printer services ***************************************************************************/ void load_printers(void) { + if (!pcap_cache_loaded()) + pcap_cache_reload(); + add_auto_printers(); - if (lp_load_printers()) - add_all_printers(); + + /* load all printcap printers */ + if (lp_load_printers() && lp_servicenumber(PRINTERS_NAME) >= 0) + pcap_printer_fn(lp_add_one_printer); } -- 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/load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index a925a63e17..825f4da20b 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -5,7 +5,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/load.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index 825f4da20b..f8aba3996d 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -14,8 +14,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 . */ #include "includes.h" -- 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/load.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index f8aba3996d..23144d5a95 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -28,6 +28,7 @@ static void add_auto_printers(void) const char *p; int pnum = lp_servicenumber(PRINTERS_NAME); char *str; + char *saveptr; if (pnum < 0) return; @@ -35,7 +36,8 @@ static void add_auto_printers(void) if ((str = SMB_STRDUP(lp_auto_services())) == NULL) return; - for (p = strtok(str, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) { + for (p = strtok_r(str, LIST_SEP, &saveptr); p; + p = strtok_r(NULL, LIST_SEP, &saveptr)) { if (lp_servicenumber(p) >= 0) continue; -- cgit