testprogs: print all driver info levels in spoolss testsuite.
[ira/wip.git] / testprogs / win32 / spoolss / printlib.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for spoolss rpc operations
4
5    Copyright (C) Gerald (Jerry) Carter 2007
6    Copyright (C) Guenther Deschner 2009-2010
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include <windows.h>
23 #include <stdio.h>
24 #include <assert.h>
25
26 void print_devmode(DEVMODE *pDevModeIn)
27 {
28         if (pDevModeIn == NULL) {
29                 printf("\tDevice Mode\t= (null)\n");
30                 return;
31         }
32
33         printf("\tDEVMODE:----------\n");
34         printf("\tDeviceName:      [%s]\n", pDevModeIn->dmDeviceName);
35         printf("\tSpecVersion:     %d\n",   pDevModeIn->dmSpecVersion);
36         printf("\tDriverVersion:   %d\n",   pDevModeIn->dmDriverVersion);
37         printf("\tSize:            %d\n",   pDevModeIn->dmSize);
38         printf("\tDriverExtra:     %d\n",   pDevModeIn->dmDriverExtra);
39         printf("\tFields:          0x%x\n", pDevModeIn->dmFields);
40
41         if (pDevModeIn->dmFields & DM_ORIENTATION)
42                 printf("\tOrientation:     %d\n", pDevModeIn->dmOrientation);
43         if (pDevModeIn->dmFields & DM_PAPERSIZE)
44                 printf("\tPaperSize:       %d\n", pDevModeIn->dmPaperSize);
45         if (pDevModeIn->dmFields & DM_PAPERLENGTH)
46                 printf("\tPaperLength:     %d\n", pDevModeIn->dmPaperLength);
47         if (pDevModeIn->dmFields & DM_PAPERWIDTH)
48                 printf("\tPaperWidth:      %d\n", pDevModeIn->dmPaperWidth);
49 //      if (pDevModeIn->dmFields & DM_POSITION)
50 //              printf("\tPosition:        %d\n", pDevModeIn->dmPosition);
51         if (pDevModeIn->dmFields & DM_SCALE)
52                 printf("\tScale:           %d\n", pDevModeIn->dmScale);
53         if (pDevModeIn->dmFields & DM_COPIES)
54                 printf("\tCopies:          %d\n", pDevModeIn->dmCopies );
55         if (pDevModeIn->dmFields & DM_DEFAULTSOURCE)
56                 printf("\tDefaultSource:   %d\n", pDevModeIn->dmDefaultSource);
57         if (pDevModeIn->dmFields & DM_PRINTQUALITY)
58                 printf("\tPrintQuality:    %d\n", pDevModeIn->dmPrintQuality);
59         if (pDevModeIn->dmFields & DM_COLOR)
60                 printf("\tColor:           %d\n", pDevModeIn->dmColor);
61         if (pDevModeIn->dmFields & DM_DUPLEX)
62                 printf("\tDuplex:          %d\n", pDevModeIn->dmDuplex);
63         if (pDevModeIn->dmFields & DM_YRESOLUTION)
64                 printf("\tYResolution:     %d\n", pDevModeIn->dmYResolution);
65         if (pDevModeIn->dmFields & DM_TTOPTION)
66                 printf("\tTTOption:        %d\n", pDevModeIn->dmTTOption);
67         if (pDevModeIn->dmFields & DM_COLLATE)
68                 printf("\tCollate:         %d\n", pDevModeIn->dmCollate);
69         if (pDevModeIn->dmFields & DM_FORMNAME)
70                 printf("\tForm:            [%s]\n", pDevModeIn->dmFormName);
71         if (pDevModeIn->dmFields & DM_LOGPIXELS)
72                 printf("\tLogPixels:       %d\n", pDevModeIn->dmLogPixels);
73         if (pDevModeIn->dmFields & DM_BITSPERPEL)
74                 printf("\tBitsPerPel:      %d\n", pDevModeIn->dmBitsPerPel);
75         if (pDevModeIn->dmFields & DM_PELSWIDTH)
76                 printf("\tPelsWidth:       %d\n", pDevModeIn->dmPelsWidth);
77         if (pDevModeIn->dmFields & DM_PELSHEIGHT)
78                 printf("\tPelsHeight:      %d\n", pDevModeIn->dmPelsHeight);
79         if (pDevModeIn->dmFields & DM_DISPLAYFLAGS)
80                 printf("\tDisplayFlags:    %d\n", pDevModeIn->dmDisplayFlags);
81 //      if (pDevModeIn->dmFields & DM_NUP)
82 //              printf("\tNup:             %d\n", pDevModeIn->dmNup);
83         if (pDevModeIn->dmFields & DM_DISPLAYFREQUENCY)
84                 printf("\tDisplayFrequency:%d\n", pDevModeIn->dmDisplayFrequency);
85         if (pDevModeIn->dmFields & DM_ICMMETHOD)
86                 printf("\tICMMethod:       %d\n", pDevModeIn->dmICMMethod);
87         if (pDevModeIn->dmFields & DM_ICMINTENT)
88                 printf("\tICMIntent:       %d\n", pDevModeIn->dmICMIntent);
89         if (pDevModeIn->dmFields & DM_MEDIATYPE)
90                 printf("\tMediaType:       %d\n", pDevModeIn->dmMediaType);
91         if (pDevModeIn->dmFields & DM_DITHERTYPE)
92                 printf("\tDitherType:      %d\n", pDevModeIn->dmDitherType);
93 //      if (pDevModeIn->dmFields & DM_PANNINGWIDTH)
94 //              printf("\tPanningWidth:    %d\n", pDevModeIn->dmPanningWidth);
95 //      if (pDevModeIn->dmFields & DM_PANNINGHEIGHT)
96 //              printf("\tPanningHeight:   %d\n", pDevModeIn->dmPanningHeight);
97
98 #if 0
99         if (bForceIn) {
100                 printf("DEVMODE\n");
101                 Dump((BYTE*)pDevModeIn, sizeof(DEVMODE), LEADER);
102
103                 if (pDevModeIn->dmDriverExtra) {
104                         printf("DriverExtra\n");
105                         Dump((BYTE*)pDevModeIn + sizeof(DEVMODE), pDevModeIn->dmDriverExtra, LEADER);
106                 }
107         }
108 #endif
109
110         return;
111 }
112
113 void print_acl(const char* str, ACL *acl)
114 {
115         printf("%s\n", str);
116         if (acl == NULL)
117                 return;
118
119         printf("\t\tACL Revision \t\t 0x%x\n", acl->AclRevision);
120         printf("\t\tSbz1\t\t 0x%x\n", acl->Sbz1);
121         printf("\t\tSbz2\t\t 0x%x\n", acl->Sbz2);
122         printf("\t\tACL Size\t\t 0x%x\n", acl->AclSize);
123         printf("\t\tACL Count\t\t 0x%x\n", acl->AceCount);
124
125         return;
126 }
127
128 void print_sid(const char* str, SID *sid)
129 {
130         DWORD   i = 0;
131
132         printf("%s\n", str);
133         printf("0x%x\n", sid);
134         if (sid == NULL)
135                 return;
136         printf("\t\tRevision\t\t0x%x\n", sid->Revision);
137         printf("\t\tSubAuthorityCount\t0x%x\n", sid->SubAuthorityCount);
138         printf("\t\tSubAuthority\n\t");
139         while (i < sid->SubAuthorityCount) {
140                 printf("\t0x%x", sid->SubAuthority[i]);
141                 if (i%4 == 3)
142                         printf("\n\t");
143                 i++;
144         }
145
146         return;
147 }
148
149 void print_secdesc(SECURITY_DESCRIPTOR *secdesc)
150 {
151         if (secdesc == NULL) {
152                 printf("\tSecurity Descriptor\t= (null)\n");
153                 return;
154         }
155
156         printf("\tRevision\t= 0x%x\n", secdesc->Revision);
157         printf("\tSbz1\t\t= 0x%x\n", secdesc->Sbz1);
158 #if 0
159         print_sid("\tOwner\t\t= ", secdesc->Owner);
160         print_sid("\tGroup\t\t= ",secdesc->Group);
161         print_acl("\tSacl\t\t= ", secdesc->Sacl);
162         print_acl("\tDacl\t\t= ", secdesc->Dacl);
163 #endif
164         return;
165 }
166
167 void PrintLastError()
168 {
169         LPVOID lpMsgBuf;
170         DWORD status;
171
172         status = GetLastError();
173
174         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
175                       NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
176                       (LPTSTR)&lpMsgBuf, 0, NULL);
177         printf("ERROR  [0x%x] : %s\n", status, (char*)lpMsgBuf);
178         LocalFree(lpMsgBuf);
179
180         return;
181 }
182
183
184 void print_job_info_1(PJOB_INFO_1 info)
185 {
186         printf("\tJob ID\t\t= %d\n",            info->JobId);
187         printf("\tPrinter Name\t= %s\n",        info->pPrinterName);
188         printf("\tMachine Name\t= %s\n",        info->pMachineName);
189         printf("\tUser Name\t= %s\n",           info->pUserName);
190         printf("\tDocument\t= %s\n",            info->pDocument);
191         printf("\tDatatype\t= %s\n",            info->pDatatype);
192         printf("\tStatus\t\t= %s\n",            info->pStatus);
193         printf("\tStatus\t= %d\n",              info->Status);
194         printf("\tPriority\t= %d\n",            info->Priority);
195         printf("\tPosition\t= %d\n",            info->Position);
196         printf("\tTotal Pages\t= %d\n", info->TotalPages);
197         printf("\tPages Printed\t= %d\n",       info->PagesPrinted);
198         printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
199                 info->Submitted.wDay, info->Submitted.wMonth,
200                 info->Submitted.wYear, info->Submitted.wHour,
201                 info->Submitted.wMinute, info->Submitted.wSecond);
202
203         return;
204 }
205
206 void print_job_info_2(PJOB_INFO_2 info)
207 {
208         printf("\tJob ID\t\t= %d\n",            info->JobId);
209         printf("\tPrinter Name\t= %s\n",        info->pPrinterName);
210         printf("\tMachine Name\t= %s\n",        info->pMachineName);
211         printf("\tUser Name\t= %s\n",           info->pUserName);
212         printf("\tDocument\t= %s\n",            info->pDocument);
213         printf("\tDatatype\t= %s\n",            info->pDatatype);
214         printf("\tNotify Name\t= %s\n",         info->pNotifyName);
215         printf("\tPrint Processor\t= %s\n",     info->pPrintProcessor);
216         printf("\tParameters\t= %s\n",          info->pParameters);
217         printf("\tDriver Name\t= %s\n",         info->pDriverName);
218         printf("\tStatus\t\t= %s\n",            info->pStatus);
219         printf("\tStatus\t\t= %d\n",            info->Status);
220         printf("\tPriority\t= %d\n",            info->Priority);
221         printf("\tPosition\t= %d\n",            info->Position);
222         printf("\tTotal Pages\t= %d\n",         info->TotalPages);
223         printf("\tPages Printed\t= %d\n",       info->PagesPrinted);
224         printf("\tStart Time\t= %d\n",          info->StartTime);
225         printf("\tUntil Time\t= %d\n",          info->UntilTime);
226         printf("\tTime\t\t= %d\n",              info->Time);
227         printf("\tSize\t\t= %d\n",              info->Size);
228         printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
229                 info->Submitted.wDay, info->Submitted.wMonth,
230                 info->Submitted.wYear, info->Submitted.wHour,
231                 info->Submitted.wMinute, info->Submitted.wSecond);
232         printf("\tDevice Mode Information\n");
233         printf("\t-----------------------\n");
234         print_devmode(info->pDevMode);
235         printf("\tSecurity Descriptor Information\n");
236         printf("\t-------------------------------\n");
237         print_secdesc(info->pSecurityDescriptor);
238
239         return;
240 }
241
242 void print_job_info_3(PJOB_INFO_3 info)
243 {
244         printf("\tJob ID\t\t= %d\n",            info->JobId);
245         printf("\tJob ID Next Job\t= %d\n",     info->NextJobId);
246         printf("\tReserved (must be 0)\t= %d\n",info->Reserved);
247
248         return;
249 }
250
251 void print_monitor_info_1(PMONITOR_INFO_1 info)
252 {
253         printf("\tMonitor Name\t= %s\n",        info->pName);
254
255         return;
256 }
257
258 void print_monitor_info_2(PMONITOR_INFO_2 info)
259 {
260         printf("\tMonitor Name\t= %s\n",        info->pName);
261         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
262         printf("\tDLL Name\t= %s\n",            info->pDLLName);
263
264         return;
265 }
266
267 void print_form_info_1(PFORM_INFO_1 info)
268 {
269         printf("\tForm Name\t= %s\n",   info->pName);
270         printf("\tFlags\t\t= 0x%x\n",   info->Flags);
271         printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
272         printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
273                         info->ImageableArea.left, info->ImageableArea.right,
274                         info->ImageableArea.top, info->ImageableArea.bottom);
275
276         return;
277 }
278
279 void print_printer_info_1(PPRINTER_INFO_1 info)
280 {
281         printf("\tPrinter Name\t= %s\n",        info->pName);
282         printf("\tDescription\t= %s\n",         info->pDescription);
283         printf("\tComment\t\t= %s\n",           info->pComment);
284         printf("\tFlags\t\t= 0x%x\n",           info->Flags);
285
286         return;
287 }
288
289 void print_printer_info_2(PPRINTER_INFO_2 info)
290 {
291         printf("\tServer Name\t\t= %s\n",       info->pServerName);
292         printf("\tPrinter Name\t\t= %s\n",      info->pPrinterName);
293         printf("\tPort Name\t\t= %s\n",         info->pPortName);
294         printf("\tShare Name\t\t= %s\n",        info->pShareName);
295         printf("\tDriver Name\t\t= %s\n",       info->pDriverName);
296         printf("\tComment\t\t\t= %s\n",         info->pComment);
297         printf("\tLocation\t\t= %s\n",          info->pLocation);
298         printf("\tSeparator File\t\t= %s\n",    info->pSepFile);
299         printf("\tDefault Data Type\t= %s\n",   info->pDatatype);
300         printf("\tPrint Processor\t\t= %s\n",   info->pPrintProcessor);
301         printf("\tParameters\t\t= %s\n",        info->pParameters);
302         printf("\tAttributes\t\t= 0x%x\n",      info->Attributes);
303         printf("\tPriority\t\t= 0x%x\n",        info->Priority);
304         printf("\tDefault Priority\t= 0x%x\n",  info->DefaultPriority);
305         printf("\tStart Time\t\t= 0x%x\n",      info->StartTime);
306         printf("\tUntil Time\t\t= 0x%x\n",      info->UntilTime);
307         printf("\tStatus\t\t\t= 0x%x\n",        info->Status);
308         printf("\tcJobs\t\t\t= 0x%x\n",         info->cJobs);
309         printf("\tAverage PPM\t\t= 0x%x\n",     info->AveragePPM);
310
311         printf("\tDevice Mode Information\n");
312         printf("\t-----------------------\n");
313         print_devmode(info->pDevMode);
314 #if 0
315         printf("\tSecurity Descriptor Information\n");
316         printf("\t-------------------------------\n");
317         print_secdesc(info->pSecurityDescriptor);
318 #endif
319         return;
320 }
321
322 void print_printer_info_5(PPRINTER_INFO_5 info)
323 {
324         printf("\tPrinter Name\t\t\t= %s\n",            info->pPrinterName);
325         printf("\tPort Name\t\t\t= %s\n",               info->pPortName);
326         printf("\tAttributes\t\t\t= 0x%x\n",            info->Attributes);
327         printf("\tDev NotSelect Timeout\t= 0x%x\n",     info->DeviceNotSelectedTimeout);
328         printf("\tTX RetryTimeout\t\t= 0x%x\n",         info->TransmissionRetryTimeout);
329         return;
330 }
331
332 void print_printer_info_6(PPRINTER_INFO_6 info)
333 {
334         printf("\tStatus\t\t\t= 0x%x\n",                info->dwStatus);
335         return;
336 }
337
338 void print_printer_info_7(PPRINTER_INFO_7 info)
339 {
340         printf("\tObject GUID\t\t\t= %s\n",             info->pszObjectGUID);
341         printf("\tAction\t\t\t= 0x%x\n",                info->dwAction);
342         return;
343 }
344
345 void print_printer_info_8(PPRINTER_INFO_8 info)
346 {
347         print_devmode(info->pDevMode);
348 }
349
350 void print_printer_info_9(PPRINTER_INFO_9 info)
351 {
352         print_devmode(info->pDevMode);
353 }
354
355 void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
356 {
357         DWORD i;
358         PPRINTER_INFO_1 buffer1 = NULL;
359         PPRINTER_INFO_2 buffer2 = NULL;
360         PPRINTER_INFO_3 buffer3 = NULL;
361         PPRINTER_INFO_4 buffer4 = NULL;
362         PPRINTER_INFO_5 buffer5 = NULL;
363         PPRINTER_INFO_6 buffer6 = NULL;
364         PPRINTER_INFO_7 buffer7 = NULL;
365         PPRINTER_INFO_8 buffer8 = NULL;
366
367         if (!buffer) {
368                 return;
369         }
370
371         switch (level) {
372         case 1:
373                 buffer1 = (PPRINTER_INFO_1)buffer;
374                 break;
375         case 2:
376                 buffer2 = (PPRINTER_INFO_2)buffer;
377                 break;
378         case 3:
379                 buffer3 = (PPRINTER_INFO_3)buffer;
380                 break;
381         case 4:
382                 buffer4 = (PPRINTER_INFO_4)buffer;
383                 break;
384         case 5:
385                 buffer5 = (PPRINTER_INFO_5)buffer;
386                 break;
387         case 6:
388                 buffer6 = (PPRINTER_INFO_6)buffer;
389                 break;
390         case 7:
391                 buffer7 = (PPRINTER_INFO_7)buffer;
392                 break;
393         case 8:
394                 buffer8 = (PPRINTER_INFO_8)buffer;
395                 break;
396         default:
397                 break;
398         }
399
400         printf("Printer Info Level %d:\n", level);
401
402         switch (level) {
403         case 1:
404                 for (i=0; i<count; i++) {
405                         print_printer_info_1(&buffer1[i]);
406                         printf("\n");
407                 }
408                 break;
409         case 2:
410                 for (i=0; i<count; i++) {
411                         print_printer_info_2(&buffer2[i]);
412                         printf("\n");
413                 }
414                 break;
415 #if 0
416         case 3:
417                 for (i=0; i<count; i++) {
418                         print_printer_info_3(&buffer3[i]);
419                         printf("\n");
420                 }
421                 break;
422         case 4:
423                 for (i=0; i<count; i++) {
424                         print_printer_info_4(&buffer4[i]);
425                         printf("\n");
426                 }
427                 break;
428 #endif
429         case 5:
430                 for (i=0; i<count; i++) {
431                         print_printer_info_5(&buffer5[i]);
432                         printf("\n");
433                 }
434                 break;
435         case 6:
436                 for (i=0; i<count; i++) {
437                         print_printer_info_6(&buffer6[i]);
438                         printf("\n");
439                 }
440                 break;
441         case 7:
442                 for (i=0; i<count; i++) {
443                         print_printer_info_7(&buffer7[i]);
444                         printf("\n");
445                 }
446                 break;
447         case 8:
448                 for (i=0; i<count; i++) {
449                         print_printer_info_8(&buffer8[i]);
450                         printf("\n");
451                 }
452                 break;
453         default:
454                 break;
455         }
456 }
457
458 void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
459 {
460         printf("\tPrint Processor Name\t= %s\n", info->pName);
461
462         return;
463 }
464
465 void print_driver_info_1(PDRIVER_INFO_1 info)
466 {
467         printf("\tDriver Name\t= %s\n\n",       info->pName);
468
469         return;
470 }
471
472 void print_driver_info_2(PDRIVER_INFO_2 info)
473 {
474         printf("\tDriver Name\t= %s\n",         info->pName);
475         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
476         printf("\tVersion\t\t= %d\n",           info->cVersion);
477         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
478         printf("\tData File\t= %s\n",           info->pDataFile);
479         printf("\tConfig File\t= %s\n\n",       info->pConfigFile);
480
481         return;
482 }
483
484 void print_driver_info_3(PDRIVER_INFO_3 info)
485 {
486         char *ptr = NULL;
487
488         printf("\tDriver Name\t= %s\n",         info->pName);
489         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
490         printf("\tVersion\t\t= %d\n",           info->cVersion);
491         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
492         printf("\tData File\t= %s\n",           info->pDataFile);
493         printf("\tConfig File\t= %s\n",         info->pConfigFile);
494         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
495         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
496         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
497         ptr = (char*)info->pDependentFiles;
498         while ((ptr != NULL) && (*ptr != '\0')) {
499                 printf("\tDependent Files\t= %s\n", ptr);
500                 for (;*ptr != '\0'; ptr++)
501                         /* printf("%s\n", ptr); */
502                         ;
503                 ptr++;
504         }
505
506         return;
507 }
508
509 void print_driver_info_4(PDRIVER_INFO_4 info)
510 {
511         char *ptr = NULL;
512
513         printf("\tDriver Name\t= %s\n",         info->pName);
514         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
515         printf("\tVersion\t\t= %d\n",           info->cVersion);
516         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
517         printf("\tData File\t= %s\n",           info->pDataFile);
518         printf("\tConfig File\t= %s\n",         info->pConfigFile);
519         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
520         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
521         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
522         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
523         ptr = (char*)info->pDependentFiles;
524         while ((ptr != NULL) && (*ptr != '\0')) {
525                 printf("\tDependent Files\t= %s\n", ptr);
526                 for (;*ptr != '\0'; ptr++)
527                         /* printf("%s\n", ptr); */
528                         ;
529                 ptr++;
530         }
531
532         return;
533 }
534
535 void print_driver_info_5(PDRIVER_INFO_5 info)
536 {
537         printf("\tDriver Name\t= %s\n",         info->pName);
538         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
539         printf("\tVersion\t\t= %d\n",           info->cVersion);
540         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
541         printf("\tData File\t= %s\n",           info->pDataFile);
542         printf("\tConfig File\t= %s\n",         info->pConfigFile);
543         printf("\tDriver Attributes\t= %d\n",   info->dwDriverAttributes);
544         printf("\tConfig Version\t= %d\n",      info->dwConfigVersion);
545         printf("\tDriver Version\t= %d\n",      info->dwDriverVersion);
546
547         return;
548 }
549
550 void print_driver_info_6(PDRIVER_INFO_6 info)
551 {
552         char *ptr = NULL;
553
554         printf("\tDriver Name\t= %s\n",         info->pName);
555         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
556         printf("\tVersion\t\t= %d\n",           info->cVersion);
557         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
558         printf("\tData File\t= %s\n",           info->pDataFile);
559         printf("\tConfig File\t= %s\n",         info->pConfigFile);
560         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
561         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
562         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
563         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
564         ptr = (char*)info->pDependentFiles;
565         if (ptr != NULL) {
566                 while (*ptr != '\0') {
567                         printf("\tDependent Files\t= %s\n", ptr);
568                         for (;*ptr != '\0'; ptr++)
569                                 /* printf("%s\n", ptr); */
570                                 ;
571                         ptr++;
572                 }
573         } else {
574                 printf("\tPrevious Names\t= (null)\n");
575         }
576
577         ptr = (char*)info->pszzPreviousNames;
578         if (ptr != NULL) {
579                 while (*ptr != '\0') {
580                         printf("\tPrevious Names\t= %s\n", ptr);
581                         for (;*ptr != '\0'; ptr++)
582                                 /* printf("%s\n", ptr); */
583                                 ;
584                         ptr++;
585                 }
586         } else {
587                 printf("\tPrevious Names\t= (null)\n");
588         }
589
590         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
591         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
592         printf("\tManufacture Name = %s\n",     info->pszMfgName);
593         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
594         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
595         printf("\tProvider\t= %s\n",            info->pszProvider);
596         return;
597 }
598
599 static void print_multi_sz(LPSTR multisz)
600 {
601         char *ptr = NULL;
602
603         ptr = (char *)multisz;
604
605         if (!ptr) {
606                 printf("(null)\n");
607                 return;
608         }
609
610         while (*ptr != '\0') {
611                 printf("%s\n", ptr);
612                 for (; *ptr != '\0'; ptr++) {
613                         /* printf("%s\n", ptr); */
614                         ;
615                 }
616                 ptr++;
617         }
618 }
619
620 void print_driver_info_8(PDRIVER_INFO_8 info)
621 {
622         printf("\tDriver Name\t= %s\n",         info->pName);
623         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
624         printf("\tVersion\t\t= %d\n",           info->cVersion);
625         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
626         printf("\tData File\t= %s\n",           info->pDataFile);
627         printf("\tConfig File\t= %s\n",         info->pConfigFile);
628         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
629         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
630         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
631         printf("\tPrevious Names\t=\n");
632         print_multi_sz(info->pszzPreviousNames);
633         printf("\tDependent Files\t=\n");
634         print_multi_sz(info->pDependentFiles);
635         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
636         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
637         printf("\tManufacture Name = %s\n",     info->pszMfgName);
638         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
639         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
640         printf("\tProvider\t= %s\n",            info->pszProvider);
641         printf("\tPrint Processor\t= %s\n",     info->pszPrintProcessor);
642         printf("\tVendor Setup\t= %s\n",        info->pszVendorSetup);
643         printf("\tColor Profiles\t=\n");
644         print_multi_sz(info->pszzColorProfiles);
645         printf("\tInf Path\t= %s\n",            info->pszInfPath);
646         printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes);
647         printf("\tCore Driver Dependencies\t=\n");
648         print_multi_sz(info->pszzCoreDriverDependencies);
649         printf("\tMin Inbox Driver VerDate\t= %d\n", info->ftMinInboxDriverVerDate);
650         printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion);
651         return;
652 }
653
654 void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
655 {
656         DWORD i;
657         PDRIVER_INFO_1  buffer1 = NULL;
658         PDRIVER_INFO_2  buffer2 = NULL;
659         PDRIVER_INFO_3  buffer3 = NULL;
660         PDRIVER_INFO_4  buffer4 = NULL;
661         PDRIVER_INFO_5  buffer5 = NULL;
662         PDRIVER_INFO_6  buffer6 = NULL;
663         PDRIVER_INFO_8  buffer8 = NULL;
664
665         if (!buffer) {
666                 return;
667         }
668
669         switch (level) {
670         case 1:
671                 buffer1 = (PDRIVER_INFO_1)buffer;
672                 break;
673         case 2:
674                 buffer2 = (PDRIVER_INFO_2)buffer;
675                 break;
676         case 3:
677                 buffer3 = (PDRIVER_INFO_3)buffer;
678                 break;
679         case 4:
680                 buffer4 = (PDRIVER_INFO_4)buffer;
681                 break;
682         case 5:
683                 buffer5 = (PDRIVER_INFO_5)buffer;
684                 break;
685         case 6:
686                 buffer6 = (PDRIVER_INFO_6)buffer;
687                 break;
688         case 8:
689                 buffer8 = (PDRIVER_INFO_8)buffer;
690                 break;
691         default:
692                 break;
693         }
694
695         printf("Driver Info Level %d:\n", level);
696
697         switch (level) {
698         case 1:
699                 for (i=0; i<count; i++) {
700                         print_driver_info_1(&buffer1[i]);
701                         printf("\n");
702                 }
703                 break;
704         case 2:
705                 for (i=0; i<count; i++) {
706                         print_driver_info_2(&buffer2[i]);
707                         printf("\n");
708                 }
709                 break;
710         case 3:
711                 for (i=0; i<count; i++) {
712                         print_driver_info_3(&buffer3[i]);
713                         printf("\n");
714                 }
715                 break;
716         case 4:
717                 for (i=0; i<count; i++) {
718                         print_driver_info_4(&buffer4[i]);
719                         printf("\n");
720                 }
721                 break;
722         case 5:
723                 for (i=0; i<count; i++) {
724                         print_driver_info_5(&buffer5[i]);
725                         printf("\n");
726                 }
727                 break;
728         case 6:
729                 for (i=0; i<count; i++) {
730                         print_driver_info_6(&buffer6[i]);
731                         printf("\n");
732                 }
733                 break;
734         case 8:
735                 for (i=0; i<count; i++) {
736                         print_driver_info_8(&buffer8[i]);
737                         printf("\n");
738                 }
739                 break;
740         default:
741                 break;
742         }
743 }
744
745 void print_doc_info_1(PDOC_INFO_1 info)
746 {
747         printf("\tDocument Name\t= %s\n",       info->pDocName);
748         printf("\tOutput Filename\t= %s\n",     info->pOutputFile);
749         printf("\tDatatype\t= %s\n",            info->pDatatype);
750         return;
751 }
752
753 void print_printer_keys(LPSTR buffer)
754 {
755         LPSTR p = NULL;
756
757         p = buffer;
758
759         while (p && *p) {
760                 printf("%s\n", p);
761                 for (; *p; p = CharNext(p)) {
762                         p = CharNext(p);
763                 }
764         }
765 }
766
767 static LPSTR reg_type_str(DWORD type)
768 {
769         switch (type) {
770         case REG_DWORD:
771                 return "REG_DWORD";
772         case REG_SZ:
773                 return "REG_SZ";
774         case REG_MULTI_SZ:
775                 return "REG_MULTI_SZ";
776         case REG_BINARY:
777                 return "REG_BINARY";
778         default:
779                 return NULL;
780         }
781 }
782
783 void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
784 {
785         DWORD i = 0;
786         LPSTR p = NULL;
787
788         if (keyname) {
789                 printf("\tKey Name:\t%s\n", keyname);
790         }
791
792         printf("\tValue Name:\t%s\n", valuename);
793         printf("\tSize: 0x%x (%d)\n", size, size);
794         printf("\tType:\t\t%s\n", reg_type_str(type));
795
796         switch (type) {
797         case REG_SZ:
798                 printf("\t\t%s\n", (LPSTR)buffer);
799                 break;
800         case REG_MULTI_SZ:
801                 p = (LPSTR)buffer;
802                 while (p && *p) {
803                         printf("%s\n", p);
804                         for (; *p; p = CharNext(p)) {
805                                 p = CharNext(p);
806                         }
807                 }
808                 break;
809         case REG_DWORD:
810                 assert(size == 4);
811                 printf("\t\t0x%08x\n", (DWORD)*buffer);
812                 break;
813         case REG_BINARY:
814                 for (i=0; i < size; i++) {
815                         printf("\t0x%x", buffer[i]);
816                         if (i%4 == 3) {
817                                 printf("\n");
818                         }
819                 }
820                 break;
821         default:
822                 break;
823         }
824 }
825
826 void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
827 {
828         print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType);
829 }
830