summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/nt_printing.h4
-rw-r--r--source3/libads/ldap_printer.c1
-rw-r--r--source3/printing/nt_printing.c122
3 files changed, 94 insertions, 33 deletions
diff --git a/source3/include/nt_printing.h b/source3/include/nt_printing.h
index 23d474c957..6d952a89a5 100644
--- a/source3/include/nt_printing.h
+++ b/source3/include/nt_printing.h
@@ -187,6 +187,7 @@ typedef struct nt_printer_driver_info_level
#define SPOOL_REG_ASSETNUMBER "assetNumber"
#define SPOOL_REG_BYTESPERMINUTE "bytesPerMinute"
#define SPOOL_REG_DEFAULTPRIORITY "defaultPriority"
+#define SPOOL_REG_DESCRIPTION "description"
#define SPOOL_REG_DRIVERNAME "driverName"
#define SPOOL_REG_DRIVERVERSION "driverVersion"
#define SPOOL_REG_FLAGS "flags"
@@ -227,6 +228,9 @@ typedef struct nt_printer_driver_info_level
#define SPOOL_REG_PRINTSEPARATORFILE "printSeparatorFile"
#define SPOOL_REG_PRINTSHARENAME "printShareName"
#define SPOOL_REG_PRINTSPOOLING "printSpooling"
+#define SPOOL_REGVAL_PRINTWHILESPOOLING "PrintWhileSpooling"
+#define SPOOL_REGVAL_PRINTAFTERSPOOLED "PrintAfterSpooled"
+#define SPOOL_REGVAL_PRINTDIRECT "PrintDirect"
#define SPOOL_REG_PRINTSTAPLINGSUPPORTED "printStaplingSupported"
#define SPOOL_REG_PRINTSTARTTIME "printStartTime"
#define SPOOL_REG_PRINTSTATUS "printStatus"
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index a8c1148093..b2ee5f2265 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -181,6 +181,7 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods,
{SPOOL_REG_ASSETNUMBER, map_sz},
{SPOOL_REG_BYTESPERMINUTE, map_dword},
{SPOOL_REG_DEFAULTPRIORITY, map_dword},
+ {SPOOL_REG_DESCRIPTION, map_sz},
{SPOOL_REG_DRIVERNAME, map_sz},
{SPOOL_REG_DRIVERVERSION, map_dword},
{SPOOL_REG_FLAGS, map_dword},
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 00d1eaacd3..cdcca6bbfe 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2443,6 +2443,57 @@ uint32 get_printer_subkeys( NT_PRINTER_DATA *data, char* key, fstring **subkeys
return num_subkeys;
}
+static void map_sz_into_ctr(REGVAL_CTR *ctr, const char *val_name,
+ const char *sz)
+{
+ smb_ucs2_t conv_str[1024];
+ size_t str_size;
+
+ regval_ctr_delvalue(ctr, val_name);
+ str_size = push_ucs2(NULL, conv_str, sz, sizeof(conv_str),
+ STR_TERMINATE | STR_NOALIGN);
+ regval_ctr_addvalue(ctr, val_name, REG_SZ,
+ (char *) conv_str, str_size);
+}
+
+static void map_dword_into_ctr(REGVAL_CTR *ctr, const char *val_name,
+ uint32 dword)
+{
+ regval_ctr_delvalue(ctr, val_name);
+ regval_ctr_addvalue(ctr, val_name, REG_DWORD,
+ (char *) &dword, sizeof(dword));
+}
+
+static void map_bool_into_ctr(REGVAL_CTR *ctr, const char *val_name,
+ BOOL bool)
+{
+ uint8 bin_bool = (bool ? 1 : 0);
+ regval_ctr_delvalue(ctr, val_name);
+ regval_ctr_addvalue(ctr, val_name, REG_BINARY,
+ (char *) &bin_bool, sizeof(bin_bool));
+}
+
+static void map_single_multi_sz_into_ctr(REGVAL_CTR *ctr, const char *val_name,
+ const char *multi_sz)
+{
+ smb_ucs2_t *conv_strs = NULL;
+ size_t str_size;
+
+ /* a multi-sz has to have a null string terminator, i.e., the last
+ string must be followed by two nulls */
+ str_size = (strlen(multi_sz) + 2) * sizeof(smb_ucs2_t);
+ conv_strs = calloc(str_size, 1);
+
+ push_ucs2(NULL, conv_strs, multi_sz, str_size,
+ STR_TERMINATE | STR_NOALIGN);
+
+ regval_ctr_delvalue(ctr, val_name);
+ regval_ctr_addvalue(ctr, val_name, REG_MULTI_SZ,
+ (char *) conv_strs, str_size);
+ safe_free(conv_strs);
+
+}
+
/****************************************************************************
* Map the NT_PRINTER_INFO_LEVEL_2 data into DsSpooler keys for publishing.
*
@@ -2453,11 +2504,8 @@ uint32 get_printer_subkeys( NT_PRINTER_DATA *data, char* key, fstring **subkeys
static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2)
{
REGVAL_CTR *ctr = NULL;
- smb_ucs2_t conv_str[1024];
- size_t str_size;
fstring longname;
- char *uncname;
- uint32 dword;
+ char *ascii_str;
int i;
for (i=0; i < info2->data.num_keys; i++)
@@ -2469,37 +2517,45 @@ static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2)
add_new_printer_key(&info2->data, SPOOL_DSSPOOLER_KEY);
ctr = &info2->data.keys[info2->data.num_keys - 1].values;
}
+
+ map_sz_into_ctr(ctr, SPOOL_REG_PRINTERNAME, info2->sharename);
+ map_sz_into_ctr(ctr, SPOOL_REG_SHORTSERVERNAME, global_myname());
- regval_ctr_delvalue(ctr, SPOOL_REG_PRINTERNAME);
- str_size = push_ucs2(NULL, conv_str, info2->sharename,
- sizeof(conv_str), STR_TERMINATE | STR_NOALIGN);
- regval_ctr_addvalue(ctr, SPOOL_REG_PRINTERNAME, REG_SZ,
- (char *) conv_str, str_size);
-
- regval_ctr_delvalue(ctr, SPOOL_REG_SHORTSERVERNAME);
- str_size = push_ucs2(NULL, conv_str, global_myname(), sizeof(conv_str),
- STR_TERMINATE | STR_NOALIGN);
- regval_ctr_addvalue(ctr, SPOOL_REG_SHORTSERVERNAME, REG_SZ,
- (char *) conv_str, str_size);
-
- regval_ctr_delvalue(ctr, SPOOL_REG_SERVERNAME);
get_myfullname(longname);
- str_size = push_ucs2(NULL, conv_str, longname, sizeof(conv_str),
- STR_TERMINATE | STR_NOALIGN);
- regval_ctr_addvalue(ctr, SPOOL_REG_SERVERNAME, REG_SZ,
- (char *) conv_str, str_size);
-
- regval_ctr_delvalue(ctr, SPOOL_REG_VERSIONNUMBER);
- dword = 4;
- regval_ctr_addvalue(ctr, SPOOL_REG_VERSIONNUMBER, REG_DWORD,
- (char *) &dword, sizeof(dword));
-
- regval_ctr_delvalue(ctr, SPOOL_REG_UNCNAME);
- asprintf(&uncname, "\\\\%s\\%s", longname, info2->sharename);
- str_size = push_ucs2(NULL, conv_str, uncname, sizeof(conv_str),
- STR_TERMINATE | STR_NOALIGN);
- regval_ctr_addvalue(ctr, SPOOL_REG_UNCNAME, REG_SZ, (char *) conv_str,
- str_size);
+ map_sz_into_ctr(ctr, SPOOL_REG_SERVERNAME, longname);
+
+ asprintf(&ascii_str, "\\\\%s\\%s", longname, info2->sharename);
+ map_sz_into_ctr(ctr, SPOOL_REG_UNCNAME, ascii_str);
+ safe_free(ascii_str);
+
+
+ map_dword_into_ctr(ctr, SPOOL_REG_VERSIONNUMBER, 4);
+ map_sz_into_ctr(ctr, SPOOL_REG_DRIVERNAME, info2->drivername);
+ map_sz_into_ctr(ctr, SPOOL_REG_LOCATION, info2->location);
+ map_sz_into_ctr(ctr, SPOOL_REG_DESCRIPTION, info2->comment);
+ map_single_multi_sz_into_ctr(ctr, SPOOL_REG_PORTNAME, info2->portname);
+ map_sz_into_ctr(ctr, SPOOL_REG_PRINTSEPARATORFILE, info2->sepfile);
+ map_dword_into_ctr(ctr, SPOOL_REG_PRINTSTARTTIME, info2->starttime);
+ map_dword_into_ctr(ctr, SPOOL_REG_PRINTENDTIME, info2->untiltime);
+ map_dword_into_ctr(ctr, SPOOL_REG_PRIORITY, info2->priority);
+
+ map_bool_into_ctr(ctr, SPOOL_REG_PRINTKEEPPRINTEDJOBS,
+ (info2->attributes & 0x100));
+
+ switch (info2->attributes & 0x3) {
+ case 0:
+ ascii_str = SPOOL_REGVAL_PRINTWHILESPOOLING;
+ break;
+ case 1:
+ ascii_str = SPOOL_REGVAL_PRINTAFTERSPOOLED;
+ break;
+ case 2:
+ ascii_str = SPOOL_REGVAL_PRINTDIRECT;
+ break;
+ default:
+ ascii_str = "unknown";
+ }
+ map_sz_into_ctr(ctr, SPOOL_REG_PRINTSPOOLING, ascii_str);
return True;
}