add SetPrinterDataExW.exe.
[gd/win32-spoolss/.git] / EnumPrinterKey.c
1 /******************************************************************
2  * SPOOLSS regression testing code for Samba print servers
3  *
4  *****************************************************************/
5
6 #include <windows.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "printlib.h"
10
11 int main (int argc, char* argv[])
12 {
13
14         HANDLE                  printer;
15         DWORD                   returned=0,
16                                         status;
17         LPTSTR                  buffer = NULL;
18
19
20         if (argc < 2)
21         {
22                 fprintf (stderr, "useage: %s <printername>\n", argv[0]);
23                 exit (-1);
24         }
25
26         /* open the server */
27         if (!OpenPrinter (argv[1], &printer, NULL))
28                 PrintLastError();
29         else
30                 printf ("Printer [%s] opened successfully.\n\n", argv[1]);
31
32
33         status = EnumPrinterKey(printer, "", buffer, 0, &returned);
34         if (status == ERROR_MORE_DATA)
35         {
36                 if ((buffer = (LPTSTR)malloc(returned)) == NULL)
37                 {
38                         fprintf (stderr, "Unable to malloc enough space for [%d] bytes\n", returned);
39                         exit (-1);
40                 }
41
42                 status = EnumPrinterKey(printer, "", buffer, returned, &returned);
43                 if (status == ERROR_SUCCESS)
44                 {
45                         LPTSTR  p = NULL;
46
47                         printf ("Enumurated Key Values : [%d]\n", returned);
48
49                         p = buffer;
50                         while (*p)
51                         {
52                                 printf ("\t%s\n", p);
53                                 for (; *p; p=CharNext(p));
54                                 p=CharNext(p);
55                         }
56
57                 }
58                 free (buffer);
59
60         }
61         else if (status != ERROR_SUCCESS)
62                 PrintLastError();
63         else
64                 printf ("No data!\n");
65
66         returned = 0;
67         status = EnumPrinterKey(printer, "PrinterDriverData", buffer, 0, &returned);
68         if (status == ERROR_MORE_DATA)
69         {
70                 if ((buffer = (LPTSTR)malloc(returned)) == NULL)
71                 {
72                         fprintf (stderr, "Unable to malloc enough space for [%d] bytes\n", returned);
73                         exit (-1);
74                 }
75
76                 status = EnumPrinterKey(printer, "PrinterDriverData", buffer, returned, &returned);
77                 if (status == ERROR_SUCCESS)
78                 {
79                         LPTSTR  p = NULL;
80
81                         printf ("Enumurated Key Values : [%d]\n", returned);
82
83                         p = buffer;
84                         while (*p)
85                         {
86                                 printf ("\t%s\n", p);
87                                 for (p = buffer; *p; p=CharNext(p));
88                                 p=CharNext(p);
89                         }
90
91                 }
92                 free (buffer);
93
94         }
95         else if (status != ERROR_SUCCESS)
96                 PrintLastError();
97         else
98                 printf ("No data!\n");
99
100
101
102
103
104
105         /* close the server */
106         if (!ClosePrinter(printer))
107                 PrintLastError();
108         else
109                 printf ("Printer [%s] closed successfully.\n", argv[1]);
110
111         return 0;
112
113 }