testprogs: print job info levels in EnumJobs() spoolss tests.
[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_job_info_4(PJOB_INFO_4 info)
252 {
253         printf("\tJob ID\t\t= %d\n",            info->JobId);
254         printf("\tPrinter Name\t= %s\n",        info->pPrinterName);
255         printf("\tMachine Name\t= %s\n",        info->pMachineName);
256         printf("\tUser Name\t= %s\n",           info->pUserName);
257         printf("\tDocument\t= %s\n",            info->pDocument);
258         printf("\tDatatype\t= %s\n",            info->pDatatype);
259         printf("\tNotify Name\t= %s\n",         info->pNotifyName);
260         printf("\tPrint Processor\t= %s\n",     info->pPrintProcessor);
261         printf("\tDriver Name\t= %s\n",         info->pDriverName);
262         printf("\tStatus\t\t= %s\n",            info->pStatus);
263         printf("\tStatus\t\t= %d\n",            info->Status);
264         printf("\tPriority\t= %d\n",            info->Priority);
265         printf("\tPosition\t= %d\n",            info->Position);
266         printf("\tTotal Pages\t= %d\n",         info->TotalPages);
267         printf("\tPages Printed\t= %d\n",       info->PagesPrinted);
268         printf("\tStart Time\t= %d\n",          info->StartTime);
269         printf("\tUntil Time\t= %d\n",          info->UntilTime);
270         printf("\tTime\t\t= %d\n",              info->Time);
271         printf("\tSize\t\t= %d\n",              info->Size);
272         printf("\tSize High\t\t= 0x%016x\n",    info->SizeHigh);
273         printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
274                 info->Submitted.wDay, info->Submitted.wMonth,
275                 info->Submitted.wYear, info->Submitted.wHour,
276                 info->Submitted.wMinute, info->Submitted.wSecond);
277         printf("\tDevice Mode Information\n");
278         printf("\t-----------------------\n");
279         print_devmode(info->pDevMode);
280         printf("\tSecurity Descriptor Information\n");
281         printf("\t-------------------------------\n");
282         print_secdesc(info->pSecurityDescriptor);
283
284         return;
285 }
286
287 void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
288 {
289         DWORD i;
290         PJOB_INFO_1     buffer1 = NULL;
291         PJOB_INFO_2     buffer2 = NULL;
292         PJOB_INFO_3     buffer3 = NULL;
293         PJOB_INFO_4     buffer4 = NULL;
294
295         if (!buffer) {
296                 return;
297         }
298
299         switch (level) {
300         case 1:
301                 buffer1 = (PJOB_INFO_1)buffer;
302                 break;
303         case 2:
304                 buffer2 = (PJOB_INFO_2)buffer;
305                 break;
306         case 3:
307                 buffer3 = (PJOB_INFO_3)buffer;
308                 break;
309         case 4:
310                 buffer4 = (PJOB_INFO_4)buffer;
311                 break;
312         default:
313                 break;
314         }
315
316         printf("Job Info Level %d:\n", level);
317
318         switch (level) {
319         case 1:
320                 for (i=0; i<count; i++) {
321                         print_job_info_1(&buffer1[i]);
322                         printf("\n");
323                 }
324                 break;
325         case 2:
326                 for (i=0; i<count; i++) {
327                         print_job_info_2(&buffer2[i]);
328                         printf("\n");
329                 }
330                 break;
331         case 3:
332                 for (i=0; i<count; i++) {
333                         print_job_info_3(&buffer3[i]);
334                         printf("\n");
335                 }
336                 break;
337         case 4:
338                 for (i=0; i<count; i++) {
339                         print_job_info_4(&buffer4[i]);
340                         printf("\n");
341                 }
342                 break;
343         default:
344                 break;
345         }
346 }
347
348 void print_monitor_info_1(PMONITOR_INFO_1 info)
349 {
350         printf("\tMonitor Name\t= %s\n",        info->pName);
351
352         return;
353 }
354
355 void print_monitor_info_2(PMONITOR_INFO_2 info)
356 {
357         printf("\tMonitor Name\t= %s\n",        info->pName);
358         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
359         printf("\tDLL Name\t= %s\n",            info->pDLLName);
360
361         return;
362 }
363
364 void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
365 {
366         DWORD i;
367         PMONITOR_INFO_1 buffer1 = NULL;
368         PMONITOR_INFO_2 buffer2 = NULL;
369
370         if (!buffer) {
371                 return;
372         }
373
374         switch (level) {
375         case 1:
376                 buffer1 = (PMONITOR_INFO_1)buffer;
377                 break;
378         case 2:
379                 buffer2 = (PMONITOR_INFO_2)buffer;
380                 break;
381         default:
382                 break;
383         }
384
385         printf("Monitor Info Level %d:\n", level);
386
387         switch (level) {
388         case 1:
389                 for (i=0; i<count; i++) {
390                         print_monitor_info_1(&buffer1[i]);
391                         printf("\n");
392                 }
393                 break;
394         case 2:
395                 for (i=0; i<count; i++) {
396                         print_monitor_info_2(&buffer2[i]);
397                         printf("\n");
398                 }
399                 break;
400         default:
401                 break;
402         }
403 }
404
405 void print_port_info_1(PPORT_INFO_1 info)
406 {
407         printf("\tPort Name\t= %s\n",   info->pName);
408         return;
409 }
410
411 void print_port_info_2(PPORT_INFO_2 info)
412 {
413         printf("\tPort Name\t= %s\n",   info->pPortName);
414         printf("\tMonitor Name\t= %s\n",info->pMonitorName);
415         printf("\tDescription\t= %s\n", info->pDescription);
416         printf("\tPort Type\t= 0x%08x\n", info->fPortType);
417         printf("\tReserved\t= 0x%08x\n", info->Reserved);
418         return;
419 }
420
421 void print_port_info_3(PPORT_INFO_3 info)
422 {
423         printf("\tStatus\t= 0x%08x\n", info->dwStatus);
424         printf("\tStatus String\t= %s\n", info->pszStatus);
425         printf("\tSeverity\t= 0x%08x\n", info->dwSeverity);
426         return;
427 }
428
429 void print_port_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
430 {
431         DWORD i;
432         PPORT_INFO_1 buffer1 = NULL;
433         PPORT_INFO_2 buffer2 = NULL;
434         PPORT_INFO_3 buffer3 = NULL;
435
436         if (!buffer) {
437                 return;
438         }
439
440         switch (level) {
441         case 1:
442                 buffer1 = (PPORT_INFO_1)buffer;
443                 break;
444         case 2:
445                 buffer2 = (PPORT_INFO_2)buffer;
446                 break;
447         case 3:
448                 buffer3 = (PPORT_INFO_3)buffer;
449                 break;
450         default:
451                 break;
452         }
453
454         printf("Port Info Level %d:\n", level);
455
456         switch (level) {
457         case 1:
458                 for (i=0; i<count; i++) {
459                         print_port_info_1(&buffer1[i]);
460                         printf("\n");
461                 }
462                 break;
463         case 2:
464                 for (i=0; i<count; i++) {
465                         print_port_info_2(&buffer2[i]);
466                         printf("\n");
467                 }
468                 break;
469         case 3:
470                 for (i=0; i<count; i++) {
471                         print_port_info_3(&buffer3[i]);
472                         printf("\n");
473                 }
474                 break;
475         default:
476                 break;
477         }
478 }
479
480 void print_form_info_1(PFORM_INFO_1 info)
481 {
482         printf("\tForm Name\t= %s\n",   info->pName);
483         printf("\tFlags\t\t= 0x%x\n",   info->Flags);
484         printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
485         printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
486                         info->ImageableArea.left, info->ImageableArea.right,
487                         info->ImageableArea.top, info->ImageableArea.bottom);
488
489         return;
490 }
491
492 void print_form_info_2(PFORM_INFO_2 info)
493 {
494         printf("\tForm Name\t= %s\n",   info->pName);
495         printf("\tFlags\t\t= 0x%x\n",   info->Flags);
496         printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
497         printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
498                         info->ImageableArea.left, info->ImageableArea.right,
499                         info->ImageableArea.top, info->ImageableArea.bottom);
500         printf("\tKeyword\t= %s\n",     info->pKeyword);
501         printf("\tString Type\t= 0x%08x\n", info->StringType);
502         printf("\tMui DLL\t= %s\n",     info->pMuiDll);
503         printf("\tResource Id\t= 0x%08x\n", info->dwResourceId);
504         printf("\tDisplay Name\t= %s\n",info->pDisplayName);
505         printf("\tLang Id\t= 0x%04x\n", info->wLangId);
506
507         return;
508 }
509
510 void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
511 {
512         DWORD i;
513         PFORM_INFO_1 buffer1 = NULL;
514         PFORM_INFO_2 buffer2 = NULL;
515
516         if (!buffer) {
517                 return;
518         }
519
520         switch (level) {
521         case 1:
522                 buffer1 = (PFORM_INFO_1)buffer;
523                 break;
524         case 2:
525                 buffer2 = (PFORM_INFO_2)buffer;
526                 break;
527         default:
528                 break;
529         }
530
531         printf("Form Info Level %d:\n", level);
532
533         switch (level) {
534         case 1:
535                 for (i=0; i<count; i++) {
536                         print_form_info_1(&buffer1[i]);
537                         printf("\n");
538                 }
539                 break;
540         case 2:
541                 for (i=0; i<count; i++) {
542                         print_form_info_2(&buffer2[i]);
543                         printf("\n");
544                 }
545                 break;
546         default:
547                 break;
548         }
549 }
550
551 void print_printer_info_1(PPRINTER_INFO_1 info)
552 {
553         printf("\tPrinter Name\t= %s\n",        info->pName);
554         printf("\tDescription\t= %s\n",         info->pDescription);
555         printf("\tComment\t\t= %s\n",           info->pComment);
556         printf("\tFlags\t\t= 0x%x\n",           info->Flags);
557
558         return;
559 }
560
561 void print_printer_info_2(PPRINTER_INFO_2 info)
562 {
563         printf("\tServer Name\t\t= %s\n",       info->pServerName);
564         printf("\tPrinter Name\t\t= %s\n",      info->pPrinterName);
565         printf("\tPort Name\t\t= %s\n",         info->pPortName);
566         printf("\tShare Name\t\t= %s\n",        info->pShareName);
567         printf("\tDriver Name\t\t= %s\n",       info->pDriverName);
568         printf("\tComment\t\t\t= %s\n",         info->pComment);
569         printf("\tLocation\t\t= %s\n",          info->pLocation);
570         printf("\tSeparator File\t\t= %s\n",    info->pSepFile);
571         printf("\tDefault Data Type\t= %s\n",   info->pDatatype);
572         printf("\tPrint Processor\t\t= %s\n",   info->pPrintProcessor);
573         printf("\tParameters\t\t= %s\n",        info->pParameters);
574         printf("\tAttributes\t\t= 0x%x\n",      info->Attributes);
575         printf("\tPriority\t\t= 0x%x\n",        info->Priority);
576         printf("\tDefault Priority\t= 0x%x\n",  info->DefaultPriority);
577         printf("\tStart Time\t\t= 0x%x\n",      info->StartTime);
578         printf("\tUntil Time\t\t= 0x%x\n",      info->UntilTime);
579         printf("\tStatus\t\t\t= 0x%x\n",        info->Status);
580         printf("\tcJobs\t\t\t= 0x%x\n",         info->cJobs);
581         printf("\tAverage PPM\t\t= 0x%x\n",     info->AveragePPM);
582
583         printf("\tDevice Mode Information\n");
584         printf("\t-----------------------\n");
585         print_devmode(info->pDevMode);
586 #if 0
587         printf("\tSecurity Descriptor Information\n");
588         printf("\t-------------------------------\n");
589         print_secdesc(info->pSecurityDescriptor);
590 #endif
591         return;
592 }
593
594 void print_printer_info_5(PPRINTER_INFO_5 info)
595 {
596         printf("\tPrinter Name\t\t\t= %s\n",            info->pPrinterName);
597         printf("\tPort Name\t\t\t= %s\n",               info->pPortName);
598         printf("\tAttributes\t\t\t= 0x%x\n",            info->Attributes);
599         printf("\tDev NotSelect Timeout\t= 0x%x\n",     info->DeviceNotSelectedTimeout);
600         printf("\tTX RetryTimeout\t\t= 0x%x\n",         info->TransmissionRetryTimeout);
601         return;
602 }
603
604 void print_printer_info_6(PPRINTER_INFO_6 info)
605 {
606         printf("\tStatus\t\t\t= 0x%x\n",                info->dwStatus);
607         return;
608 }
609
610 void print_printer_info_7(PPRINTER_INFO_7 info)
611 {
612         printf("\tObject GUID\t\t\t= %s\n",             info->pszObjectGUID);
613         printf("\tAction\t\t\t= 0x%x\n",                info->dwAction);
614         return;
615 }
616
617 void print_printer_info_8(PPRINTER_INFO_8 info)
618 {
619         print_devmode(info->pDevMode);
620 }
621
622 void print_printer_info_9(PPRINTER_INFO_9 info)
623 {
624         print_devmode(info->pDevMode);
625 }
626
627 void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
628 {
629         DWORD i;
630         PPRINTER_INFO_1 buffer1 = NULL;
631         PPRINTER_INFO_2 buffer2 = NULL;
632         PPRINTER_INFO_3 buffer3 = NULL;
633         PPRINTER_INFO_4 buffer4 = NULL;
634         PPRINTER_INFO_5 buffer5 = NULL;
635         PPRINTER_INFO_6 buffer6 = NULL;
636         PPRINTER_INFO_7 buffer7 = NULL;
637         PPRINTER_INFO_8 buffer8 = NULL;
638
639         if (!buffer) {
640                 return;
641         }
642
643         switch (level) {
644         case 1:
645                 buffer1 = (PPRINTER_INFO_1)buffer;
646                 break;
647         case 2:
648                 buffer2 = (PPRINTER_INFO_2)buffer;
649                 break;
650         case 3:
651                 buffer3 = (PPRINTER_INFO_3)buffer;
652                 break;
653         case 4:
654                 buffer4 = (PPRINTER_INFO_4)buffer;
655                 break;
656         case 5:
657                 buffer5 = (PPRINTER_INFO_5)buffer;
658                 break;
659         case 6:
660                 buffer6 = (PPRINTER_INFO_6)buffer;
661                 break;
662         case 7:
663                 buffer7 = (PPRINTER_INFO_7)buffer;
664                 break;
665         case 8:
666                 buffer8 = (PPRINTER_INFO_8)buffer;
667                 break;
668         default:
669                 break;
670         }
671
672         printf("Printer Info Level %d:\n", level);
673
674         switch (level) {
675         case 1:
676                 for (i=0; i<count; i++) {
677                         print_printer_info_1(&buffer1[i]);
678                         printf("\n");
679                 }
680                 break;
681         case 2:
682                 for (i=0; i<count; i++) {
683                         print_printer_info_2(&buffer2[i]);
684                         printf("\n");
685                 }
686                 break;
687 #if 0
688         case 3:
689                 for (i=0; i<count; i++) {
690                         print_printer_info_3(&buffer3[i]);
691                         printf("\n");
692                 }
693                 break;
694         case 4:
695                 for (i=0; i<count; i++) {
696                         print_printer_info_4(&buffer4[i]);
697                         printf("\n");
698                 }
699                 break;
700 #endif
701         case 5:
702                 for (i=0; i<count; i++) {
703                         print_printer_info_5(&buffer5[i]);
704                         printf("\n");
705                 }
706                 break;
707         case 6:
708                 for (i=0; i<count; i++) {
709                         print_printer_info_6(&buffer6[i]);
710                         printf("\n");
711                 }
712                 break;
713         case 7:
714                 for (i=0; i<count; i++) {
715                         print_printer_info_7(&buffer7[i]);
716                         printf("\n");
717                 }
718                 break;
719         case 8:
720                 for (i=0; i<count; i++) {
721                         print_printer_info_8(&buffer8[i]);
722                         printf("\n");
723                 }
724                 break;
725         default:
726                 break;
727         }
728 }
729
730 void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
731 {
732         printf("\tPrint Processor Name\t= %s\n", info->pName);
733
734         return;
735 }
736
737 void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
738 {
739         DWORD i;
740         PPRINTPROCESSOR_INFO_1 buffer1 = NULL;
741
742         if (!buffer) {
743                 return;
744         }
745
746         switch (level) {
747         case 1:
748                 buffer1 = (PPRINTPROCESSOR_INFO_1)buffer;
749                 break;
750         default:
751                 break;
752         }
753
754         printf("Print Processor Info Level %d:\n", level);
755
756         switch (level) {
757         case 1:
758                 for (i=0; i<count; i++) {
759                         print_printprocessor_info_1(&buffer1[i]);
760                         printf("\n");
761                 }
762                 break;
763         default:
764                 break;
765         }
766 }
767
768 void print_datatypes_info_1(PDATATYPES_INFO_1 info)
769 {
770         printf("\tDataTypes Name\t= %s\n", info->pName);
771
772         return;
773 }
774
775 void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
776 {
777         DWORD i;
778         PDATATYPES_INFO_1 buffer1 = NULL;
779
780         if (!buffer) {
781                 return;
782         }
783
784         switch (level) {
785         case 1:
786                 buffer1 = (PDATATYPES_INFO_1)buffer;
787                 break;
788         default:
789                 break;
790         }
791
792         printf("DataTypes Info Level %d:\n", level);
793
794         switch (level) {
795         case 1:
796                 for (i=0; i<count; i++) {
797                         print_datatypes_info_1(&buffer1[i]);
798                         printf("\n");
799                 }
800                 break;
801         default:
802                 break;
803         }
804 }
805
806 void print_driver_info_1(PDRIVER_INFO_1 info)
807 {
808         printf("\tDriver Name\t= %s\n\n",       info->pName);
809
810         return;
811 }
812
813 void print_driver_info_2(PDRIVER_INFO_2 info)
814 {
815         printf("\tDriver Name\t= %s\n",         info->pName);
816         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
817         printf("\tVersion\t\t= %d\n",           info->cVersion);
818         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
819         printf("\tData File\t= %s\n",           info->pDataFile);
820         printf("\tConfig File\t= %s\n\n",       info->pConfigFile);
821
822         return;
823 }
824
825 void print_driver_info_3(PDRIVER_INFO_3 info)
826 {
827         char *ptr = NULL;
828
829         printf("\tDriver Name\t= %s\n",         info->pName);
830         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
831         printf("\tVersion\t\t= %d\n",           info->cVersion);
832         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
833         printf("\tData File\t= %s\n",           info->pDataFile);
834         printf("\tConfig File\t= %s\n",         info->pConfigFile);
835         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
836         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
837         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
838         ptr = (char*)info->pDependentFiles;
839         while ((ptr != NULL) && (*ptr != '\0')) {
840                 printf("\tDependent Files\t= %s\n", ptr);
841                 for (;*ptr != '\0'; ptr++)
842                         /* printf("%s\n", ptr); */
843                         ;
844                 ptr++;
845         }
846
847         return;
848 }
849
850 void print_driver_info_4(PDRIVER_INFO_4 info)
851 {
852         char *ptr = NULL;
853
854         printf("\tDriver Name\t= %s\n",         info->pName);
855         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
856         printf("\tVersion\t\t= %d\n",           info->cVersion);
857         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
858         printf("\tData File\t= %s\n",           info->pDataFile);
859         printf("\tConfig File\t= %s\n",         info->pConfigFile);
860         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
861         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
862         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
863         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
864         ptr = (char*)info->pDependentFiles;
865         while ((ptr != NULL) && (*ptr != '\0')) {
866                 printf("\tDependent Files\t= %s\n", ptr);
867                 for (;*ptr != '\0'; ptr++)
868                         /* printf("%s\n", ptr); */
869                         ;
870                 ptr++;
871         }
872
873         return;
874 }
875
876 void print_driver_info_5(PDRIVER_INFO_5 info)
877 {
878         printf("\tDriver Name\t= %s\n",         info->pName);
879         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
880         printf("\tVersion\t\t= %d\n",           info->cVersion);
881         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
882         printf("\tData File\t= %s\n",           info->pDataFile);
883         printf("\tConfig File\t= %s\n",         info->pConfigFile);
884         printf("\tDriver Attributes\t= %d\n",   info->dwDriverAttributes);
885         printf("\tConfig Version\t= %d\n",      info->dwConfigVersion);
886         printf("\tDriver Version\t= %d\n",      info->dwDriverVersion);
887
888         return;
889 }
890
891 void print_driver_info_6(PDRIVER_INFO_6 info)
892 {
893         char *ptr = NULL;
894
895         printf("\tDriver Name\t= %s\n",         info->pName);
896         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
897         printf("\tVersion\t\t= %d\n",           info->cVersion);
898         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
899         printf("\tData File\t= %s\n",           info->pDataFile);
900         printf("\tConfig File\t= %s\n",         info->pConfigFile);
901         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
902         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
903         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
904         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
905         ptr = (char*)info->pDependentFiles;
906         if (ptr != NULL) {
907                 while (*ptr != '\0') {
908                         printf("\tDependent Files\t= %s\n", ptr);
909                         for (;*ptr != '\0'; ptr++)
910                                 /* printf("%s\n", ptr); */
911                                 ;
912                         ptr++;
913                 }
914         } else {
915                 printf("\tPrevious Names\t= (null)\n");
916         }
917
918         ptr = (char*)info->pszzPreviousNames;
919         if (ptr != NULL) {
920                 while (*ptr != '\0') {
921                         printf("\tPrevious Names\t= %s\n", ptr);
922                         for (;*ptr != '\0'; ptr++)
923                                 /* printf("%s\n", ptr); */
924                                 ;
925                         ptr++;
926                 }
927         } else {
928                 printf("\tPrevious Names\t= (null)\n");
929         }
930
931         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
932         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
933         printf("\tManufacture Name = %s\n",     info->pszMfgName);
934         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
935         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
936         printf("\tProvider\t= %s\n",            info->pszProvider);
937         return;
938 }
939
940 static void print_multi_sz(LPSTR multisz)
941 {
942         char *ptr = NULL;
943
944         ptr = (char *)multisz;
945
946         if (!ptr) {
947                 printf("(null)\n");
948                 return;
949         }
950
951         while (*ptr != '\0') {
952                 printf("%s\n", ptr);
953                 for (; *ptr != '\0'; ptr++) {
954                         /* printf("%s\n", ptr); */
955                         ;
956                 }
957                 ptr++;
958         }
959 }
960
961 void print_driver_info_8(PDRIVER_INFO_8 info)
962 {
963         printf("\tDriver Name\t= %s\n",         info->pName);
964         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
965         printf("\tVersion\t\t= %d\n",           info->cVersion);
966         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
967         printf("\tData File\t= %s\n",           info->pDataFile);
968         printf("\tConfig File\t= %s\n",         info->pConfigFile);
969         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
970         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
971         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
972         printf("\tPrevious Names\t=\n");
973         print_multi_sz(info->pszzPreviousNames);
974         printf("\tDependent Files\t=\n");
975         print_multi_sz(info->pDependentFiles);
976         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
977         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
978         printf("\tManufacture Name = %s\n",     info->pszMfgName);
979         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
980         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
981         printf("\tProvider\t= %s\n",            info->pszProvider);
982         printf("\tPrint Processor\t= %s\n",     info->pszPrintProcessor);
983         printf("\tVendor Setup\t= %s\n",        info->pszVendorSetup);
984         printf("\tColor Profiles\t=\n");
985         print_multi_sz(info->pszzColorProfiles);
986         printf("\tInf Path\t= %s\n",            info->pszInfPath);
987         printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes);
988         printf("\tCore Driver Dependencies\t=\n");
989         print_multi_sz(info->pszzCoreDriverDependencies);
990         printf("\tMin Inbox Driver VerDate\t= %d\n", info->ftMinInboxDriverVerDate);
991         printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion);
992         return;
993 }
994
995 void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
996 {
997         DWORD i;
998         PDRIVER_INFO_1  buffer1 = NULL;
999         PDRIVER_INFO_2  buffer2 = NULL;
1000         PDRIVER_INFO_3  buffer3 = NULL;
1001         PDRIVER_INFO_4  buffer4 = NULL;
1002         PDRIVER_INFO_5  buffer5 = NULL;
1003         PDRIVER_INFO_6  buffer6 = NULL;
1004         PDRIVER_INFO_8  buffer8 = NULL;
1005
1006         if (!buffer) {
1007                 return;
1008         }
1009
1010         switch (level) {
1011         case 1:
1012                 buffer1 = (PDRIVER_INFO_1)buffer;
1013                 break;
1014         case 2:
1015                 buffer2 = (PDRIVER_INFO_2)buffer;
1016                 break;
1017         case 3:
1018                 buffer3 = (PDRIVER_INFO_3)buffer;
1019                 break;
1020         case 4:
1021                 buffer4 = (PDRIVER_INFO_4)buffer;
1022                 break;
1023         case 5:
1024                 buffer5 = (PDRIVER_INFO_5)buffer;
1025                 break;
1026         case 6:
1027                 buffer6 = (PDRIVER_INFO_6)buffer;
1028                 break;
1029         case 8:
1030                 buffer8 = (PDRIVER_INFO_8)buffer;
1031                 break;
1032         default:
1033                 break;
1034         }
1035
1036         printf("Driver Info Level %d:\n", level);
1037
1038         switch (level) {
1039         case 1:
1040                 for (i=0; i<count; i++) {
1041                         print_driver_info_1(&buffer1[i]);
1042                         printf("\n");
1043                 }
1044                 break;
1045         case 2:
1046                 for (i=0; i<count; i++) {
1047                         print_driver_info_2(&buffer2[i]);
1048                         printf("\n");
1049                 }
1050                 break;
1051         case 3:
1052                 for (i=0; i<count; i++) {
1053                         print_driver_info_3(&buffer3[i]);
1054                         printf("\n");
1055                 }
1056                 break;
1057         case 4:
1058                 for (i=0; i<count; i++) {
1059                         print_driver_info_4(&buffer4[i]);
1060                         printf("\n");
1061                 }
1062                 break;
1063         case 5:
1064                 for (i=0; i<count; i++) {
1065                         print_driver_info_5(&buffer5[i]);
1066                         printf("\n");
1067                 }
1068                 break;
1069         case 6:
1070                 for (i=0; i<count; i++) {
1071                         print_driver_info_6(&buffer6[i]);
1072                         printf("\n");
1073                 }
1074                 break;
1075         case 8:
1076                 for (i=0; i<count; i++) {
1077                         print_driver_info_8(&buffer8[i]);
1078                         printf("\n");
1079                 }
1080                 break;
1081         default:
1082                 break;
1083         }
1084 }
1085
1086 void print_doc_info_1(PDOC_INFO_1 info)
1087 {
1088         printf("\tDocument Name\t= %s\n",       info->pDocName);
1089         printf("\tOutput Filename\t= %s\n",     info->pOutputFile);
1090         printf("\tDatatype\t= %s\n",            info->pDatatype);
1091         return;
1092 }
1093
1094 void print_printer_keys(LPSTR buffer)
1095 {
1096         LPSTR p = NULL;
1097
1098         p = buffer;
1099
1100         while (p && *p) {
1101                 printf("%s\n", p);
1102                 for (; *p; p = CharNext(p)) {
1103                         p = CharNext(p);
1104                 }
1105         }
1106 }
1107
1108 static LPSTR reg_type_str(DWORD type)
1109 {
1110         switch (type) {
1111         case REG_DWORD:
1112                 return "REG_DWORD";
1113         case REG_SZ:
1114                 return "REG_SZ";
1115         case REG_MULTI_SZ:
1116                 return "REG_MULTI_SZ";
1117         case REG_BINARY:
1118                 return "REG_BINARY";
1119         default:
1120                 return NULL;
1121         }
1122 }
1123
1124 void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
1125 {
1126         DWORD i = 0;
1127         LPSTR p = NULL;
1128
1129         if (keyname) {
1130                 printf("\tKey Name:\t%s\n", keyname);
1131         }
1132
1133         printf("\tValue Name:\t%s\n", valuename);
1134         printf("\tSize: 0x%x (%d)\n", size, size);
1135         printf("\tType:\t\t%s\n", reg_type_str(type));
1136
1137         switch (type) {
1138         case REG_SZ:
1139                 printf("\t\t%s\n", (LPSTR)buffer);
1140                 break;
1141         case REG_MULTI_SZ:
1142                 p = (LPSTR)buffer;
1143                 while (p && *p) {
1144                         printf("%s\n", p);
1145                         for (; *p; p = CharNext(p)) {
1146                                 p = CharNext(p);
1147                         }
1148                 }
1149                 break;
1150         case REG_DWORD:
1151                 assert(size == 4);
1152                 printf("\t\t0x%08x\n", (DWORD)*buffer);
1153                 break;
1154         case REG_BINARY:
1155                 for (i=0; i < size; i++) {
1156                         printf("\t0x%x", buffer[i]);
1157                         if (i%4 == 3) {
1158                                 printf("\n");
1159                         }
1160                 }
1161                 break;
1162         default:
1163                 break;
1164         }
1165 }
1166
1167 void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
1168 {
1169         print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType);
1170 }
1171