diff options
author | Jim McDonough <jmcd@samba.org> | 2002-12-05 19:13:40 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-12-05 19:13:40 +0000 |
commit | 26236b30d09ebf31e43911f2d7cbec80df519b71 (patch) | |
tree | bde4a7882d52f115f0d1c4181df8c8f88312c1b8 /source3/printing | |
parent | 47edb96d9964aeece7ec2975d6781a26be0eb9c5 (diff) | |
download | samba-26236b30d09ebf31e43911f2d7cbec80df519b71.tar.gz samba-26236b30d09ebf31e43911f2d7cbec80df519b71.tar.bz2 samba-26236b30d09ebf31e43911f2d7cbec80df519b71.zip |
More printer data to publish
(This used to be commit 6e2f0c4e304a09313f933a3c9c2a7b3a0219006d)
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/nt_printing.c | 122 |
1 files changed, 89 insertions, 33 deletions
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; } |