Update README to say GPLv2 or later and remove references to bzr.
[jerry/slag.git] / win32 / spoolss / EnumPrinterData.c
1 /******************************************************************\r
2  * SPOOLSS regression testing code for Samba print servers\r
3  * \r
4  *****************************************************************/\r
5 \r
6 #include <windows.h>\r
7 #include <stdio.h>\r
8 #include <stdlib.h>\r
9 #include "printlib.h"\r
10 \r
11 #define START_JOB       0\r
12 #define MAX_JOBS        100\r
13 \r
14 int main (int argc, char* argv[])\r
15 {\r
16         \r
17         HANDLE                  printer;\r
18         DWORD                   dwIndex, pcbValue, type, pcbData;\r
19         DWORD                   pcbMaxValue, pcbMaxData;\r
20         LPTSTR                  pValueName = NULL;\r
21         LPBYTE                  pData = NULL;\r
22         DWORD                   i, status;\r
23 \r
24 \r
25         if (argc < 2)\r
26         {\r
27                 fprintf (stderr, "useage: %s <printername>\n", argv[0]);\r
28                 exit (-1);\r
29         }\r
30 \r
31         /* open the printer */\r
32         if (!OpenPrinter (argv[1], &printer, NULL))\r
33                 PrintLastError();\r
34         else\r
35                 printf ("Printer [%s] opened successfully.\n\n", argv[1]);\r
36 \r
37         dwIndex = 0;\r
38         status = ERROR_SUCCESS;\r
39 \r
40         pcbMaxValue = pcbMaxData = 0;\r
41         status=EnumPrinterData(printer, dwIndex, pValueName, 0, &pcbMaxValue, &type, pData, 0, &pcbMaxData);\r
42         printf ("\tMax Size of Value = %d\n", pcbMaxValue);\r
43         printf ("\tMax Size of Data  = %d\n", pcbMaxData);\r
44         printf("\n");\r
45         if (status != ERROR_SUCCESS)\r
46         {\r
47                 PrintLastError();\r
48                 exit (-1);\r
49         }\r
50 \r
51         if ((pValueName = (LPTSTR)malloc(pcbMaxValue)) == NULL)\r
52         {\r
53                 fprintf (stderr, "Unable to malloc memory for Value Name!\n");\r
54                 exit (-1);\r
55         }\r
56         if ((pData = (LPBYTE)malloc(pcbMaxData)) == NULL)\r
57         {\r
58                 fprintf (stderr, "Unable to malloc memory for Value Data!\n");\r
59                 exit (-1);\r
60         }\r
61 \r
62 \r
63         while (status != ERROR_NO_MORE_ITEMS)\r
64         {\r
65                 pcbValue = pcbData = 0;\r
66                 status = EnumPrinterData(printer, dwIndex, pValueName, pcbMaxValue, &pcbValue, &type, pData, pcbMaxData, &pcbData);\r
67                 PrintLastError();\r
68                 if (status == ERROR_SUCCESS)\r
69                 {\r
70                         printf ("\tValue Name [size] = %s [%d]\n", pValueName, pcbValue);\r
71                         printf ("\tType = %d\n", type);\r
72                         printf ("\tData = 0x%x [%d] bytes\n", pcbData, pcbData);\r
73                         i = 0;\r
74                         while (i < pcbData)\r
75                         {\r
76                                 printf ("\t0x%x", *(pData++));\r
77                                 if (i%4 == 3)\r
78                                         printf ("\n");\r
79                                 i++;\r
80                         }\r
81                         printf ("\n");\r
82                 }\r
83 \r
84                 dwIndex++;\r
85         }\r
86         printf ("\n");\r
87 \r
88 #if 0\r
89         free (pValueName);\r
90         free (pData);\r
91 #endif\r
92 \r
93 \r
94         /* close the printer */\r
95         if (!ClosePrinter(printer))\r
96                 PrintLastError();\r
97         else\r
98                 printf ("Printer [%s] closed successfully.\n", argv[1]);\r
99 \r
100         return 0;\r
101 \r
102 }\r