testprogs: print form info levels in EnumForms(),GetForm() 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_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_form_info_2(PFORM_INFO_2 info)
280 {
281         printf("\tForm Name\t= %s\n",   info->pName);
282         printf("\tFlags\t\t= 0x%x\n",   info->Flags);
283         printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
284         printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
285                         info->ImageableArea.left, info->ImageableArea.right,
286                         info->ImageableArea.top, info->ImageableArea.bottom);
287         printf("\tKeyword\t= %s\n",     info->pKeyword);
288         printf("\tString Type\t= 0x%08x\n", info->StringType);
289         printf("\tMui DLL\t= %s\n",     info->pMuiDll);
290         printf("\tResource Id\t= 0x%08x\n", info->dwResourceId);
291         printf("\tDisplay Name\t= %s\n",info->pDisplayName);
292         printf("\tLang Id\t= 0x%04x\n", info->wLangId);
293
294         return;
295 }
296
297 void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
298 {
299         DWORD i;
300         PFORM_INFO_1 buffer1 = NULL;
301         PFORM_INFO_2 buffer2 = NULL;
302
303         if (!buffer) {
304                 return;
305         }
306
307         switch (level) {
308         case 1:
309                 buffer1 = (PFORM_INFO_1)buffer;
310                 break;
311         case 2:
312                 buffer2 = (PFORM_INFO_2)buffer;
313                 break;
314         default:
315                 break;
316         }
317
318         printf("Form Info Level %d:\n", level);
319
320         switch (level) {
321         case 1:
322                 for (i=0; i<count; i++) {
323                         print_form_info_1(&buffer1[i]);
324                         printf("\n");
325                 }
326                 break;
327         case 2:
328                 for (i=0; i<count; i++) {
329                         print_form_info_2(&buffer2[i]);
330                         printf("\n");
331                 }
332                 break;
333         default:
334                 break;
335         }
336 }
337
338 void print_printer_info_1(PPRINTER_INFO_1 info)
339 {
340         printf("\tPrinter Name\t= %s\n",        info->pName);
341         printf("\tDescription\t= %s\n",         info->pDescription);
342         printf("\tComment\t\t= %s\n",           info->pComment);
343         printf("\tFlags\t\t= 0x%x\n",           info->Flags);
344
345         return;
346 }
347
348 void print_printer_info_2(PPRINTER_INFO_2 info)
349 {
350         printf("\tServer Name\t\t= %s\n",       info->pServerName);
351         printf("\tPrinter Name\t\t= %s\n",      info->pPrinterName);
352         printf("\tPort Name\t\t= %s\n",         info->pPortName);
353         printf("\tShare Name\t\t= %s\n",        info->pShareName);
354         printf("\tDriver Name\t\t= %s\n",       info->pDriverName);
355         printf("\tComment\t\t\t= %s\n",         info->pComment);
356         printf("\tLocation\t\t= %s\n",          info->pLocation);
357         printf("\tSeparator File\t\t= %s\n",    info->pSepFile);
358         printf("\tDefault Data Type\t= %s\n",   info->pDatatype);
359         printf("\tPrint Processor\t\t= %s\n",   info->pPrintProcessor);
360         printf("\tParameters\t\t= %s\n",        info->pParameters);
361         printf("\tAttributes\t\t= 0x%x\n",      info->Attributes);
362         printf("\tPriority\t\t= 0x%x\n",        info->Priority);
363         printf("\tDefault Priority\t= 0x%x\n",  info->DefaultPriority);
364         printf("\tStart Time\t\t= 0x%x\n",      info->StartTime);
365         printf("\tUntil Time\t\t= 0x%x\n",      info->UntilTime);
366         printf("\tStatus\t\t\t= 0x%x\n",        info->Status);
367         printf("\tcJobs\t\t\t= 0x%x\n",         info->cJobs);
368         printf("\tAverage PPM\t\t= 0x%x\n",     info->AveragePPM);
369
370         printf("\tDevice Mode Information\n");
371         printf("\t-----------------------\n");
372         print_devmode(info->pDevMode);
373 #if 0
374         printf("\tSecurity Descriptor Information\n");
375         printf("\t-------------------------------\n");
376         print_secdesc(info->pSecurityDescriptor);
377 #endif
378         return;
379 }
380
381 void print_printer_info_5(PPRINTER_INFO_5 info)
382 {
383         printf("\tPrinter Name\t\t\t= %s\n",            info->pPrinterName);
384         printf("\tPort Name\t\t\t= %s\n",               info->pPortName);
385         printf("\tAttributes\t\t\t= 0x%x\n",            info->Attributes);
386         printf("\tDev NotSelect Timeout\t= 0x%x\n",     info->DeviceNotSelectedTimeout);
387         printf("\tTX RetryTimeout\t\t= 0x%x\n",         info->TransmissionRetryTimeout);
388         return;
389 }
390
391 void print_printer_info_6(PPRINTER_INFO_6 info)
392 {
393         printf("\tStatus\t\t\t= 0x%x\n",                info->dwStatus);
394         return;
395 }
396
397 void print_printer_info_7(PPRINTER_INFO_7 info)
398 {
399         printf("\tObject GUID\t\t\t= %s\n",             info->pszObjectGUID);
400         printf("\tAction\t\t\t= 0x%x\n",                info->dwAction);
401         return;
402 }
403
404 void print_printer_info_8(PPRINTER_INFO_8 info)
405 {
406         print_devmode(info->pDevMode);
407 }
408
409 void print_printer_info_9(PPRINTER_INFO_9 info)
410 {
411         print_devmode(info->pDevMode);
412 }
413
414 void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
415 {
416         DWORD i;
417         PPRINTER_INFO_1 buffer1 = NULL;
418         PPRINTER_INFO_2 buffer2 = NULL;
419         PPRINTER_INFO_3 buffer3 = NULL;
420         PPRINTER_INFO_4 buffer4 = NULL;
421         PPRINTER_INFO_5 buffer5 = NULL;
422         PPRINTER_INFO_6 buffer6 = NULL;
423         PPRINTER_INFO_7 buffer7 = NULL;
424         PPRINTER_INFO_8 buffer8 = NULL;
425
426         if (!buffer) {
427                 return;
428         }
429
430         switch (level) {
431         case 1:
432                 buffer1 = (PPRINTER_INFO_1)buffer;
433                 break;
434         case 2:
435                 buffer2 = (PPRINTER_INFO_2)buffer;
436                 break;
437         case 3:
438                 buffer3 = (PPRINTER_INFO_3)buffer;
439                 break;
440         case 4:
441                 buffer4 = (PPRINTER_INFO_4)buffer;
442                 break;
443         case 5:
444                 buffer5 = (PPRINTER_INFO_5)buffer;
445                 break;
446         case 6:
447                 buffer6 = (PPRINTER_INFO_6)buffer;
448                 break;
449         case 7:
450                 buffer7 = (PPRINTER_INFO_7)buffer;
451                 break;
452         case 8:
453                 buffer8 = (PPRINTER_INFO_8)buffer;
454                 break;
455         default:
456                 break;
457         }
458
459         printf("Printer Info Level %d:\n", level);
460
461         switch (level) {
462         case 1:
463                 for (i=0; i<count; i++) {
464                         print_printer_info_1(&buffer1[i]);
465                         printf("\n");
466                 }
467                 break;
468         case 2:
469                 for (i=0; i<count; i++) {
470                         print_printer_info_2(&buffer2[i]);
471                         printf("\n");
472                 }
473                 break;
474 #if 0
475         case 3:
476                 for (i=0; i<count; i++) {
477                         print_printer_info_3(&buffer3[i]);
478                         printf("\n");
479                 }
480                 break;
481         case 4:
482                 for (i=0; i<count; i++) {
483                         print_printer_info_4(&buffer4[i]);
484                         printf("\n");
485                 }
486                 break;
487 #endif
488         case 5:
489                 for (i=0; i<count; i++) {
490                         print_printer_info_5(&buffer5[i]);
491                         printf("\n");
492                 }
493                 break;
494         case 6:
495                 for (i=0; i<count; i++) {
496                         print_printer_info_6(&buffer6[i]);
497                         printf("\n");
498                 }
499                 break;
500         case 7:
501                 for (i=0; i<count; i++) {
502                         print_printer_info_7(&buffer7[i]);
503                         printf("\n");
504                 }
505                 break;
506         case 8:
507                 for (i=0; i<count; i++) {
508                         print_printer_info_8(&buffer8[i]);
509                         printf("\n");
510                 }
511                 break;
512         default:
513                 break;
514         }
515 }
516
517 void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
518 {
519         printf("\tPrint Processor Name\t= %s\n", info->pName);
520
521         return;
522 }
523
524 void print_driver_info_1(PDRIVER_INFO_1 info)
525 {
526         printf("\tDriver Name\t= %s\n\n",       info->pName);
527
528         return;
529 }
530
531 void print_driver_info_2(PDRIVER_INFO_2 info)
532 {
533         printf("\tDriver Name\t= %s\n",         info->pName);
534         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
535         printf("\tVersion\t\t= %d\n",           info->cVersion);
536         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
537         printf("\tData File\t= %s\n",           info->pDataFile);
538         printf("\tConfig File\t= %s\n\n",       info->pConfigFile);
539
540         return;
541 }
542
543 void print_driver_info_3(PDRIVER_INFO_3 info)
544 {
545         char *ptr = NULL;
546
547         printf("\tDriver Name\t= %s\n",         info->pName);
548         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
549         printf("\tVersion\t\t= %d\n",           info->cVersion);
550         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
551         printf("\tData File\t= %s\n",           info->pDataFile);
552         printf("\tConfig File\t= %s\n",         info->pConfigFile);
553         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
554         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
555         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
556         ptr = (char*)info->pDependentFiles;
557         while ((ptr != NULL) && (*ptr != '\0')) {
558                 printf("\tDependent Files\t= %s\n", ptr);
559                 for (;*ptr != '\0'; ptr++)
560                         /* printf("%s\n", ptr); */
561                         ;
562                 ptr++;
563         }
564
565         return;
566 }
567
568 void print_driver_info_4(PDRIVER_INFO_4 info)
569 {
570         char *ptr = NULL;
571
572         printf("\tDriver Name\t= %s\n",         info->pName);
573         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
574         printf("\tVersion\t\t= %d\n",           info->cVersion);
575         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
576         printf("\tData File\t= %s\n",           info->pDataFile);
577         printf("\tConfig File\t= %s\n",         info->pConfigFile);
578         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
579         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
580         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
581         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
582         ptr = (char*)info->pDependentFiles;
583         while ((ptr != NULL) && (*ptr != '\0')) {
584                 printf("\tDependent Files\t= %s\n", ptr);
585                 for (;*ptr != '\0'; ptr++)
586                         /* printf("%s\n", ptr); */
587                         ;
588                 ptr++;
589         }
590
591         return;
592 }
593
594 void print_driver_info_5(PDRIVER_INFO_5 info)
595 {
596         printf("\tDriver Name\t= %s\n",         info->pName);
597         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
598         printf("\tVersion\t\t= %d\n",           info->cVersion);
599         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
600         printf("\tData File\t= %s\n",           info->pDataFile);
601         printf("\tConfig File\t= %s\n",         info->pConfigFile);
602         printf("\tDriver Attributes\t= %d\n",   info->dwDriverAttributes);
603         printf("\tConfig Version\t= %d\n",      info->dwConfigVersion);
604         printf("\tDriver Version\t= %d\n",      info->dwDriverVersion);
605
606         return;
607 }
608
609 void print_driver_info_6(PDRIVER_INFO_6 info)
610 {
611         char *ptr = NULL;
612
613         printf("\tDriver Name\t= %s\n",         info->pName);
614         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
615         printf("\tVersion\t\t= %d\n",           info->cVersion);
616         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
617         printf("\tData File\t= %s\n",           info->pDataFile);
618         printf("\tConfig File\t= %s\n",         info->pConfigFile);
619         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
620         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
621         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
622         printf("\tPrevious Names\t= %s\n",      info->pszzPreviousNames);
623         ptr = (char*)info->pDependentFiles;
624         if (ptr != NULL) {
625                 while (*ptr != '\0') {
626                         printf("\tDependent Files\t= %s\n", ptr);
627                         for (;*ptr != '\0'; ptr++)
628                                 /* printf("%s\n", ptr); */
629                                 ;
630                         ptr++;
631                 }
632         } else {
633                 printf("\tPrevious Names\t= (null)\n");
634         }
635
636         ptr = (char*)info->pszzPreviousNames;
637         if (ptr != NULL) {
638                 while (*ptr != '\0') {
639                         printf("\tPrevious Names\t= %s\n", ptr);
640                         for (;*ptr != '\0'; ptr++)
641                                 /* printf("%s\n", ptr); */
642                                 ;
643                         ptr++;
644                 }
645         } else {
646                 printf("\tPrevious Names\t= (null)\n");
647         }
648
649         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
650         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
651         printf("\tManufacture Name = %s\n",     info->pszMfgName);
652         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
653         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
654         printf("\tProvider\t= %s\n",            info->pszProvider);
655         return;
656 }
657
658 static void print_multi_sz(LPSTR multisz)
659 {
660         char *ptr = NULL;
661
662         ptr = (char *)multisz;
663
664         if (!ptr) {
665                 printf("(null)\n");
666                 return;
667         }
668
669         while (*ptr != '\0') {
670                 printf("%s\n", ptr);
671                 for (; *ptr != '\0'; ptr++) {
672                         /* printf("%s\n", ptr); */
673                         ;
674                 }
675                 ptr++;
676         }
677 }
678
679 void print_driver_info_8(PDRIVER_INFO_8 info)
680 {
681         printf("\tDriver Name\t= %s\n",         info->pName);
682         printf("\tEnvironment\t= %s\n",         info->pEnvironment);
683         printf("\tVersion\t\t= %d\n",           info->cVersion);
684         printf("\tDriver Path\t= %s\n",         info->pDriverPath);
685         printf("\tData File\t= %s\n",           info->pDataFile);
686         printf("\tConfig File\t= %s\n",         info->pConfigFile);
687         printf("\tHelp Path\t= %s\n",           info->pHelpFile);
688         printf("\tMonitor Name\t= %s\n",        info->pMonitorName);
689         printf("\tData Type\t= %s\n",           info->pDefaultDataType);
690         printf("\tPrevious Names\t=\n");
691         print_multi_sz(info->pszzPreviousNames);
692         printf("\tDependent Files\t=\n");
693         print_multi_sz(info->pDependentFiles);
694         printf("\tDriver Date\t= %d\n",         info->ftDriverDate);
695         printf("\tDriver Version\t= %d\n",      info->dwlDriverVersion);
696         printf("\tManufacture Name = %s\n",     info->pszMfgName);
697         printf("\tOEM URL\t\t= %s\n",           info->pszOEMUrl);
698         printf("\tHardware ID\t= %s\n",         info->pszHardwareID);
699         printf("\tProvider\t= %s\n",            info->pszProvider);
700         printf("\tPrint Processor\t= %s\n",     info->pszPrintProcessor);
701         printf("\tVendor Setup\t= %s\n",        info->pszVendorSetup);
702         printf("\tColor Profiles\t=\n");
703         print_multi_sz(info->pszzColorProfiles);
704         printf("\tInf Path\t= %s\n",            info->pszInfPath);
705         printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes);
706         printf("\tCore Driver Dependencies\t=\n");
707         print_multi_sz(info->pszzCoreDriverDependencies);
708         printf("\tMin Inbox Driver VerDate\t= %d\n", info->ftMinInboxDriverVerDate);
709         printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion);
710         return;
711 }
712
713 void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
714 {
715         DWORD i;
716         PDRIVER_INFO_1  buffer1 = NULL;
717         PDRIVER_INFO_2  buffer2 = NULL;
718         PDRIVER_INFO_3  buffer3 = NULL;
719         PDRIVER_INFO_4  buffer4 = NULL;
720         PDRIVER_INFO_5  buffer5 = NULL;
721         PDRIVER_INFO_6  buffer6 = NULL;
722         PDRIVER_INFO_8  buffer8 = NULL;
723
724         if (!buffer) {
725                 return;
726         }
727
728         switch (level) {
729         case 1:
730                 buffer1 = (PDRIVER_INFO_1)buffer;
731                 break;
732         case 2:
733                 buffer2 = (PDRIVER_INFO_2)buffer;
734                 break;
735         case 3:
736                 buffer3 = (PDRIVER_INFO_3)buffer;
737                 break;
738         case 4:
739                 buffer4 = (PDRIVER_INFO_4)buffer;
740                 break;
741         case 5:
742                 buffer5 = (PDRIVER_INFO_5)buffer;
743                 break;
744         case 6:
745                 buffer6 = (PDRIVER_INFO_6)buffer;
746                 break;
747         case 8:
748                 buffer8 = (PDRIVER_INFO_8)buffer;
749                 break;
750         default:
751                 break;
752         }
753
754         printf("Driver Info Level %d:\n", level);
755
756         switch (level) {
757         case 1:
758                 for (i=0; i<count; i++) {
759                         print_driver_info_1(&buffer1[i]);
760                         printf("\n");
761                 }
762                 break;
763         case 2:
764                 for (i=0; i<count; i++) {
765                         print_driver_info_2(&buffer2[i]);
766                         printf("\n");
767                 }
768                 break;
769         case 3:
770                 for (i=0; i<count; i++) {
771                         print_driver_info_3(&buffer3[i]);
772                         printf("\n");
773                 }
774                 break;
775         case 4:
776                 for (i=0; i<count; i++) {
777                         print_driver_info_4(&buffer4[i]);
778                         printf("\n");
779                 }
780                 break;
781         case 5:
782                 for (i=0; i<count; i++) {
783                         print_driver_info_5(&buffer5[i]);
784                         printf("\n");
785                 }
786                 break;
787         case 6:
788                 for (i=0; i<count; i++) {
789                         print_driver_info_6(&buffer6[i]);
790                         printf("\n");
791                 }
792                 break;
793         case 8:
794                 for (i=0; i<count; i++) {
795                         print_driver_info_8(&buffer8[i]);
796                         printf("\n");
797                 }
798                 break;
799         default:
800                 break;
801         }
802 }
803
804 void print_doc_info_1(PDOC_INFO_1 info)
805 {
806         printf("\tDocument Name\t= %s\n",       info->pDocName);
807         printf("\tOutput Filename\t= %s\n",     info->pOutputFile);
808         printf("\tDatatype\t= %s\n",            info->pDatatype);
809         return;
810 }
811
812 void print_printer_keys(LPSTR buffer)
813 {
814         LPSTR p = NULL;
815
816         p = buffer;
817
818         while (p && *p) {
819                 printf("%s\n", p);
820                 for (; *p; p = CharNext(p)) {
821                         p = CharNext(p);
822                 }
823         }
824 }
825
826 static LPSTR reg_type_str(DWORD type)
827 {
828         switch (type) {
829         case REG_DWORD:
830                 return "REG_DWORD";
831         case REG_SZ:
832                 return "REG_SZ";
833         case REG_MULTI_SZ:
834                 return "REG_MULTI_SZ";
835         case REG_BINARY:
836                 return "REG_BINARY";
837         default:
838                 return NULL;
839         }
840 }
841
842 void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
843 {
844         DWORD i = 0;
845         LPSTR p = NULL;
846
847         if (keyname) {
848                 printf("\tKey Name:\t%s\n", keyname);
849         }
850
851         printf("\tValue Name:\t%s\n", valuename);
852         printf("\tSize: 0x%x (%d)\n", size, size);
853         printf("\tType:\t\t%s\n", reg_type_str(type));
854
855         switch (type) {
856         case REG_SZ:
857                 printf("\t\t%s\n", (LPSTR)buffer);
858                 break;
859         case REG_MULTI_SZ:
860                 p = (LPSTR)buffer;
861                 while (p && *p) {
862                         printf("%s\n", p);
863                         for (; *p; p = CharNext(p)) {
864                                 p = CharNext(p);
865                         }
866                 }
867                 break;
868         case REG_DWORD:
869                 assert(size == 4);
870                 printf("\t\t0x%08x\n", (DWORD)*buffer);
871                 break;
872         case REG_BINARY:
873                 for (i=0; i < size; i++) {
874                         printf("\t0x%x", buffer[i]);
875                         if (i%4 == 3) {
876                                 printf("\n");
877                         }
878                 }
879                 break;
880         default:
881                 break;
882         }
883 }
884
885 void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
886 {
887         print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType);
888 }
889