diff options
author | Günther Deschner <gd@samba.org> | 2010-03-04 01:31:30 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-03-04 10:10:02 +0100 |
commit | 74ba0b71891ce180079cc801e9fe11b4ea268e84 (patch) | |
tree | 29bbed87e482391557a1926d9560f790053fd116 /testprogs/win32/spoolss | |
parent | 66b4463fc1a8c9aa0caf12765c4899ee0058a2b3 (diff) | |
download | samba-74ba0b71891ce180079cc801e9fe11b4ea268e84.tar.gz samba-74ba0b71891ce180079cc801e9fe11b4ea268e84.tar.bz2 samba-74ba0b71891ce180079cc801e9fe11b4ea268e84.zip |
testprogs: add print_printer_dataw and dump_data to printlib.
Guenther
Diffstat (limited to 'testprogs/win32/spoolss')
-rw-r--r-- | testprogs/win32/spoolss/printlib.c | 104 | ||||
-rw-r--r-- | testprogs/win32/spoolss/printlib_proto.h | 1 |
2 files changed, 94 insertions, 11 deletions
diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c index f3541c85e1..e0fb6e7a1e 100644 --- a/testprogs/win32/spoolss/printlib.c +++ b/testprogs/win32/spoolss/printlib.c @@ -24,6 +24,10 @@ #include <assert.h> #include <sddl.h> +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + void print_devmode(DEVMODE *pDevModeIn) { if (pDevModeIn == NULL) { @@ -1158,23 +1162,66 @@ LPSTR reg_type_str(DWORD type) } } -void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type) +void print_asc(const BYTE *buf, DWORD len) { - DWORD i = 0; - LPSTR p = NULL; - - if (keyname) { - printf("\tKey Name:\t%s\n", keyname); + int i; + for (i=0; i<len; i++) { + printf("%c", isprint(buf[i])?buf[i]:'.'); } +} - printf("\tValue Name:\t%s\n", valuename); - printf("\tSize:\t\t0x%x (%d)\n", size, size); - printf("\tType:\t\t%s\n", reg_type_str(type)); +static void dump_data(const BYTE *buf, int len) +{ + int i=0; + static const BYTE empty[16] = { 0, }; - if (buffer == NULL || size == 0) { - return; + if (len<=0) return; + + for (i=0; i<len;) { + + if (i%16 == 0) { + if ((i > 0) && + (len > i+16) && + (memcmp(&buf[i], &empty, 16) == 0)) + { + i +=16; + continue; + } + + if (i<len) { + printf("[%04X] ",i); + } + } + + printf("%02x ", buf[i]); + i++; + + if (i%8 == 0) printf(" "); + if (i%16 == 0) { + print_asc(&buf[i-16],8); printf(" "); + print_asc(&buf[i-8],8); printf("\n"); + } } + if (i%16) { + int n; + n = 16 - (i%16); + printf(" "); + if (n>8) printf(" "); + while (n--) printf(" "); + n = MIN(8,i%16); + print_asc(&buf[i-(i%16)],n); printf( " " ); + n = (i%16) - n; + if (n>0) print_asc(&buf[i-n],n); + printf("\n"); + } +} + +static void dump_printer_data(DWORD size, LPBYTE buffer, DWORD type) +{ + DWORD i = 0; + LPSTR p = NULL; + switch (type) { case REG_SZ: printf("\t\t"); @@ -1209,6 +1256,41 @@ void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffe } } +void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type) +{ + if (keyname) { + printf("\tKey Name:\t%s\n", keyname); + } + + printf("\tValue Name:\t%s\n", valuename); + printf("\tSize:\t\t0x%x (%d)\n", size, size); + printf("\tType:\t\t%s\n", reg_type_str(type)); + + if (buffer == NULL || size == 0) { + return; + } + + dump_printer_data(size, buffer, type); +} + +void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type) +{ + if (keyname) { + printf("\tKey Name:\t%ls\n", keyname); + } + + printf("\tValue Name:\t%ls\n", valuename); + printf("\tSize:\t\t0x%x (%d)\n", size, size); + printf("\tType:\t\t%s\n", reg_type_str(type)); + + if (buffer == NULL || size == 0) { + return; + } + + dump_printer_data(size, buffer, type); +} + + void print_printer_enum_values(PRINTER_ENUM_VALUES *info) { print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType); diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h index 5a439995a1..8e44d3be86 100644 --- a/testprogs/win32/spoolss/printlib_proto.h +++ b/testprogs/win32/spoolss/printlib_proto.h @@ -56,6 +56,7 @@ void print_doc_info_1(PDOC_INFO_1 info); void print_printer_keys(LPSTR buffer); LPSTR reg_type_str(DWORD type); void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type); +void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type); void print_printer_enum_values(PRINTER_ENUM_VALUES *info); #undef _PRINTF_ATTRIBUTE #define _PRINTF_ATTRIBUTE(a1, a2) |