summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-08 22:00:41 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-08 22:00:41 +0000
commit702b085293af8ffe7a04865db78a36c85beb22ee (patch)
tree16f0abc1ed8ab201d44d7ceb64ce1281be74e290 /source3/lib/util.c
parentc6e3fc5838aacde454c4b16436532455c4dd8ecf (diff)
downloadsamba-702b085293af8ffe7a04865db78a36c85beb22ee.tar.gz
samba-702b085293af8ffe7a04865db78a36c85beb22ee.tar.bz2
samba-702b085293af8ffe7a04865db78a36c85beb22ee.zip
preparation for doing a spoolss enum jobs command. had to rewrite
spoolss_enumjobs parsing code to do read / writes not just writes. (This used to be commit bc659a09f9103eee9616279e27fafacf89dcd9b9)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 4e18cb93ba..54844fadcc 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2933,7 +2933,7 @@ void out_ascii(FILE *f, const unsigned char *buf,int len)
void out_struct(FILE *f, const char *buf1,int len, int per_line)
{
- const unsigned char *buf = (unsigned char *)buf1;
+ const unsigned char *buf = (const unsigned char *)buf1;
int i;
if (len<=0)
@@ -3309,6 +3309,25 @@ DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid)
(void***)array, (const void*)sid, *fn, False);
}
+void free_devmode(DEVICEMODE *devmode)
+{
+ if (devmode!=NULL)
+ {
+ if (devmode->private!=NULL)
+ free(devmode->private);
+ free(devmode);
+ }
+}
+
+void free_printer_info_2(PRINTER_INFO_2 *printer)
+{
+ if (printer!=NULL)
+ {
+ free_devmode(printer->devmode);
+ free(printer);
+ }
+}
+
static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from)
{
PRINTER_INFO_2 *copy = (PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2));
@@ -3328,7 +3347,7 @@ static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from)
void free_print2_array(uint32 num_entries, PRINTER_INFO_2 **entries)
{
- void(*fn)(void*) = (void(*)(void*))&free;
+ void(*fn)(void*) = (void(*)(void*))&free_printer_info_2;
free_void_array(num_entries, (void**)entries, *fn);
}
@@ -3371,3 +3390,65 @@ PRINTER_INFO_1 *add_print1_to_array(uint32 *len, PRINTER_INFO_1 ***array,
(void***)array, (const void*)prt, *fn, True);
}
+static JOB_INFO_1 *job1_dup(const JOB_INFO_1* from)
+{
+ JOB_INFO_1 *copy = (JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1));
+ if (copy != NULL)
+ {
+ if (from != NULL)
+ {
+ memcpy(copy, from, sizeof(*copy));
+ }
+ else
+ {
+ memset(copy, 0, sizeof(*copy));
+ }
+ }
+ return copy;
+}
+
+void free_job1_array(uint32 num_entries, JOB_INFO_1 **entries)
+{
+ void(*fn)(void*) = (void(*)(void*))&free;
+ free_void_array(num_entries, (void**)entries, *fn);
+}
+
+JOB_INFO_1 *add_job1_to_array(uint32 *len, JOB_INFO_1 ***array,
+ const JOB_INFO_1 *job)
+{
+ void*(*fn)(const void*) = (void*(*)(const void*))&job1_dup;
+ return (JOB_INFO_1*)add_item_to_array(len,
+ (void***)array, (const void*)job, *fn, True);
+}
+
+static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from)
+{
+ JOB_INFO_2 *copy = (JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
+ if (copy != NULL)
+ {
+ if (from != NULL)
+ {
+ memcpy(copy, from, sizeof(*copy));
+ }
+ else
+ {
+ memset(copy, 0, sizeof(*copy));
+ }
+ }
+ return copy;
+}
+
+void free_job2_array(uint32 num_entries, JOB_INFO_2 **entries)
+{
+ void(*fn)(void*) = (void(*)(void*))&free;
+ free_void_array(num_entries, (void**)entries, *fn);
+}
+
+JOB_INFO_2 *add_job2_to_array(uint32 *len, JOB_INFO_2 ***array,
+ const JOB_INFO_2 *job)
+{
+ void*(*fn)(const void*) = (void*(*)(const void*))&job2_dup;
+ return (JOB_INFO_2*)add_item_to_array(len,
+ (void***)array, (const void*)job, *fn, True);
+}
+