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