summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-09-19 22:32:56 +0000
committerJeremy Allison <jra@samba.org>2000-09-19 22:32:56 +0000
commit13904f585cbc4ccd5a366c288e6a32af44c30d27 (patch)
treed663eeabdcd19910d8117c1e61311a2bc57c9c81
parent06e2871f7245c634d502cba12ba4a5fe9858b3ee (diff)
downloadsamba-13904f585cbc4ccd5a366c288e6a32af44c30d27.tar.gz
samba-13904f585cbc4ccd5a366c288e6a32af44c30d27.tar.bz2
samba-13904f585cbc4ccd5a366c288e6a32af44c30d27.zip
param/loadparm.c: Fix based on Damian's code to stop printer scripts getting overwritten.
rpc_parse/parse_spoolss.c: Tidyup to call function for relstring arrays. Win2000 now does "Add Printer" successfully !!!!! Jeremy. (This used to be commit d666b958bc335c7fceebeb7a6333d78bc421c30f)
-rw-r--r--source3/param/loadparm.c184
-rw-r--r--source3/rpc_parse/parse_spoolss.c53
2 files changed, 116 insertions, 121 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 129a9396f3..883d03f6a4 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -988,6 +988,92 @@ static struct parm_struct parm_table[] = {
};
+/***************************************************************************
+Initialise the sDefault parameter structure for the printer values.
+***************************************************************************/
+static void init_printer_values(void)
+{
+ string_set(&sDefault.szPrinterDriver, "");
+ string_set(&sDefault.szDriverFile, DRIVERFILE);
+
+ /* choose defaults depending on the type of printing */
+ switch (sDefault.iPrinting)
+ {
+ case PRINT_BSD:
+ case PRINT_AIX:
+ string_set(&sDefault.szLpqcommand, "lpq -P%p");
+ string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
+ string_set(&sDefault.szPrintcommand,
+ "lpr -r -P%p %s");
+ break;
+
+ case PRINT_LPRNG:
+ case PRINT_PLP:
+ string_set(&sDefault.szLpqcommand, "lpq -P%p");
+ string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
+ string_set(&sDefault.szPrintcommand,
+ "lpr -r -P%p %s");
+ string_set(&sDefault.szQueuepausecommand,
+ "lpc stop %p");
+ string_set(&sDefault.szQueueresumecommand,
+ "lpc start %p");
+ string_set(&sDefault.szLppausecommand,
+ "lpc hold %p %j");
+ string_set(&sDefault.szLpresumecommand,
+ "lpc release %p %j");
+ break;
+
+ case PRINT_CUPS:
+ string_set(&sDefault.szLpqcommand,
+ "/usr/bin/lpstat -o%p");
+ string_set(&sDefault.szLprmcommand,
+ "/usr/bin/cancel %p-%j");
+ string_set(&sDefault.szPrintcommand,
+ "/usr/bin/lp -d%p -oraw %s; rm %s");
+ string_set(&sDefault.szQueuepausecommand,
+ "/usr/bin/disable %p");
+ string_set(&sDefault.szQueueresumecommand,
+ "/usr/bin/enable %p");
+ break;
+
+ case PRINT_SYSV:
+ case PRINT_HPUX:
+ string_set(&sDefault.szLpqcommand, "lpstat -o%p");
+ string_set(&sDefault.szLprmcommand, "cancel %p-%j");
+ string_set(&sDefault.szPrintcommand,
+ "lp -c -d%p %s; rm %s");
+ string_set(&sDefault.szQueuepausecommand,
+ "disable %p");
+ string_set(&sDefault.szQueueresumecommand,
+ "enable %p");
+#ifndef HPUX
+ string_set(&sDefault.szLppausecommand,
+ "lp -i %p-%j -H hold");
+ string_set(&sDefault.szLpresumecommand,
+ "lp -i %p-%j -H resume");
+#endif /* SYSV */
+ break;
+
+ case PRINT_QNX:
+ string_set(&sDefault.szLpqcommand, "lpq -P%p");
+ string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
+ string_set(&sDefault.szPrintcommand, "lp -r -P%p %s");
+ break;
+
+ case PRINT_SOFTQ:
+ string_set(&sDefault.szLpqcommand, "qstat -l -d%p");
+ string_set(&sDefault.szLprmcommand,
+ "qstat -s -j%j -c");
+ string_set(&sDefault.szPrintcommand,
+ "lp -d%p -s %s; rm %s");
+ string_set(&sDefault.szLppausecommand,
+ "qstat -s -j%j -h");
+ string_set(&sDefault.szLpresumecommand,
+ "qstat -s -j%j -r");
+ break;
+
+ }
+}
/***************************************************************************
Initialise the global parameter structure.
@@ -1009,9 +1095,10 @@ static void init_globals(void)
string_set(parm_table[i].ptr, "");
string_set(&sDefault.szGuestaccount, GUEST_ACCOUNT);
- string_set(&sDefault.szPrinterDriver, "");
string_set(&sDefault.fstype, FSTYPE_STRING);
+ init_printer_values();
+
done_init = True;
}
@@ -1173,92 +1260,6 @@ static void init_globals(void)
interpret_coding_system(KANJI);
}
-/***************************************************************************
-Initialise the sDefault parameter structure.
-***************************************************************************/
-static void init_locals(void)
-{
- string_set(&sDefault.szDriverFile, DRIVERFILE);
-
- /* choose defaults depending on the type of printing */
- switch (sDefault.iPrinting)
- {
- case PRINT_BSD:
- case PRINT_AIX:
- string_set(&sDefault.szLpqcommand, "lpq -P%p");
- string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
- string_set(&sDefault.szPrintcommand,
- "lpr -r -P%p %s");
- break;
-
- case PRINT_LPRNG:
- case PRINT_PLP:
- string_set(&sDefault.szLpqcommand, "lpq -P%p");
- string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
- string_set(&sDefault.szPrintcommand,
- "lpr -r -P%p %s");
- string_set(&sDefault.szQueuepausecommand,
- "lpc stop %p");
- string_set(&sDefault.szQueueresumecommand,
- "lpc start %p");
- string_set(&sDefault.szLppausecommand,
- "lpc hold %p %j");
- string_set(&sDefault.szLpresumecommand,
- "lpc release %p %j");
- break;
-
- case PRINT_CUPS:
- string_set(&sDefault.szLpqcommand,
- "/usr/bin/lpstat -o%p");
- string_set(&sDefault.szLprmcommand,
- "/usr/bin/cancel %p-%j");
- string_set(&sDefault.szPrintcommand,
- "/usr/bin/lp -d%p -oraw %s; rm %s");
- string_set(&sDefault.szQueuepausecommand,
- "/usr/bin/disable %p");
- string_set(&sDefault.szQueueresumecommand,
- "/usr/bin/enable %p");
- break;
-
- case PRINT_SYSV:
- case PRINT_HPUX:
- string_set(&sDefault.szLpqcommand, "lpstat -o%p");
- string_set(&sDefault.szLprmcommand, "cancel %p-%j");
- string_set(&sDefault.szPrintcommand,
- "lp -c -d%p %s; rm %s");
- string_set(&sDefault.szQueuepausecommand,
- "disable %p");
- string_set(&sDefault.szQueueresumecommand,
- "enable %p");
-#ifndef HPUX
- string_set(&sDefault.szLppausecommand,
- "lp -i %p-%j -H hold");
- string_set(&sDefault.szLpresumecommand,
- "lp -i %p-%j -H resume");
-#endif /* SYSV */
- break;
-
- case PRINT_QNX:
- string_set(&sDefault.szLpqcommand, "lpq -P%p");
- string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
- string_set(&sDefault.szPrintcommand, "lp -r -P%p %s");
- break;
-
- case PRINT_SOFTQ:
- string_set(&sDefault.szLpqcommand, "qstat -l -d%p");
- string_set(&sDefault.szLprmcommand,
- "qstat -s -j%j -c");
- string_set(&sDefault.szPrintcommand,
- "lp -d%p -s %s; rm %s");
- string_set(&sDefault.szLppausecommand,
- "qstat -s -j%j -h");
- string_set(&sDefault.szLpresumecommand,
- "qstat -s -j%j -r");
- break;
-
- }
-}
-
static TALLOC_CTX *lp_talloc;
/******************************************************************* a
@@ -2655,6 +2656,15 @@ static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
}
/***************************************************************************
+ Initialize any local varients in the sDefault table.
+***************************************************************************/
+
+void init_locals(void)
+{
+ /* None as yet. */
+}
+
+/***************************************************************************
Process a new section (service). At this stage all sections are services.
Later we'll have special sections that permit server parameters to be set.
Returns True on success, False on failure.
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index b9c5ea5daa..69d9c5bd83 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -2018,9 +2018,7 @@ BOOL new_smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *i
********************************************************************/
BOOL new_smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
{
- uint32 sec_offset;
prs_struct *ps=&buffer->prs;
- uint32 dummy = 0;
prs_debug(ps, depth, desc, "new_smb_io_printer_info_2");
depth++;
@@ -2055,13 +2053,8 @@ BOOL new_smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *i
if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
return False;
-#if 0 /* JFMTEST */
- if (!prs_uint32_pre("secdesc_ptr ", ps, depth, &dummy, &sec_offset))
- return False;
-#else
if (!new_smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
return False;
-#endif
if (!prs_uint32("attributes", ps, depth, &info->attributes))
return False;
@@ -2845,13 +2838,28 @@ uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
}
/*******************************************************************
+return the size required by a string array.
+********************************************************************/
+uint32 spoolss_size_string_array(uint16 *string)
+{
+ uint32 i = 0;
+
+ if (string) {
+ for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
+ }
+ i=i+2; /* to count all chars including the leading zero */
+ i=2*i; /* because we need the value in bytes */
+ i=i+4; /* the offset pointer size */
+
+ return i;
+}
+
+/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
{
int size=0;
- uint16 *string;
- int i=0;
size+=size_of_uint32( &info->version );
size+=size_of_relative_string( &info->name );
@@ -2863,34 +2871,11 @@ uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
size+=size_of_relative_string( &info->monitorname );
size+=size_of_relative_string( &info->defaultdatatype );
- string=info->dependentfiles;
- if (string) {
- for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
- }
-
- i=i+2; /* to count all chars including the leading zero */
- i=2*i; /* because we need the value in bytes */
- i=i+4; /* the offset pointer size */
-
- size+=i;
+ size+=spoolss_size_string_array(info->dependentfiles);
return size;
}
-uint32 spoolss_size_string_array(uint16 *string)
-{
- uint32 i = 0;
-
- if (string) {
- for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
- }
- i=i+2; /* to count all chars including the leading zero */
- i=2*i; /* because we need the value in bytes */
- i=i+4; /* the offset pointer size */
-
- return i;
-}
-
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
@@ -3140,7 +3125,7 @@ BOOL spoolss_io_q_getprinterdriver2(char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u,
if(!prs_align(ps))
return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
+ if(!prs_uint32("level", ps, depth, &q_u->level))
return False;
if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))