Update README to say GPLv2 or later and remove references to bzr.
[jerry/slag.git] / win32 / spoolss / GetPrinterDataEx.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                  server;\r
18         DWORD                   type, pcbData;\r
19         LPBYTE                  pData = NULL;\r
20         DWORD                   i, status;\r
21 \r
22 \r
23         if (argc < 3)\r
24         {\r
25                 fprintf (stderr, "useage: %s <servername> <value name>\n", argv[0]);\r
26                 exit (-1);\r
27         }\r
28 \r
29         /* open the server */\r
30         if (!OpenPrinter (argv[1], &server, NULL))\r
31                 PrintLastError();\r
32         else\r
33                 printf ("Server [%s] opened successfully.\n\n", argv[1]);\r
34 \r
35         status=GetPrinterDataEx(server, "PrinterDriverData", argv[2], &type, pData, 0, &pcbData);\r
36         if ((status != ERROR_SUCCESS) && (status != ERROR_MORE_DATA))\r
37         {\r
38                 PrintLastError();\r
39         }\r
40         else\r
41         {\r
42                 if ((pData = (LPBYTE)malloc(pcbData)) == NULL)\r
43                 {\r
44                         fprintf (stderr, "Unable to malloc memory for Value Data!\n");\r
45                         exit (-1);\r
46                 }\r
47         \r
48                 status = GetPrinterDataEx(server, "PrinterDriverData", argv[2], &type, pData, pcbData, &pcbData);\r
49                 if (status == ERROR_SUCCESS)\r
50                 {\r
51                         printf ("\tValue Name = %s\n", argv[2]);\r
52                         printf ("\tType = %d\n", type);\r
53                         printf ("\tData = 0x%x bytes\n", pcbData);\r
54                         i = 0;\r
55                         while (i < pcbData)\r
56                         {\r
57                                 printf ("\t0x%x", *(pData++));\r
58                                 if (i%4 == 3)\r
59                                         printf ("\n");\r
60                                 i++;\r
61                         }\r
62                         printf ("\n");\r
63                 }\r
64         \r
65                 printf ("\n");\r
66         }\r
67 \r
68 \r
69         /* close the server */\r
70         if (!ClosePrinter(server))\r
71                 PrintLastError();\r
72         else\r
73                 printf ("Server [%s] closed successfully.\n", argv[1]);\r
74 \r
75         return 0;\r
76 \r
77 }\r