Update README to say GPLv2 or later and remove references to bzr.
[jerry/slag.git] / win32 / spoolss / SetPrinterDataEx.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 int main (int argc, char* argv[])\r
12 {\r
13         \r
14         HANDLE                  printer;\r
15         DWORD                   type, pcbData;\r
16         LPBYTE                  pData = NULL;\r
17         DWORD                   i, status;\r
18 \r
19 \r
20         if (argc < 3)\r
21         {\r
22                 fprintf (stderr, "useage: %s <printername> <value name>\n", argv[0]);\r
23                 exit (-1);\r
24         }\r
25 \r
26         /* open the server */\r
27         if (!OpenPrinter (argv[1], &printer, NULL))\r
28                 PrintLastError();\r
29         else\r
30                 printf ("Printer [%s] opened successfully.\n\n", argv[1]);\r
31 \r
32 \r
33         status=GetPrinterDataEx(printer, "PrinterDriverData", argv[2], &type, pData, 0, &pcbData);\r
34         if ((status != ERROR_SUCCESS) && (status != ERROR_MORE_DATA))\r
35         {\r
36                 PrintLastError();\r
37                 ClosePrinter (printer);\r
38                 exit (-1);\r
39         }\r
40 \r
41         if ((pData = (LPBYTE)malloc(pcbData)) == NULL)\r
42         {\r
43                 fprintf (stderr, "Unable to malloc memory for Value Data!\n");\r
44                 exit (-1);\r
45         }\r
46         \r
47         status = GetPrinterDataEx(printer, "PrinterDriverData", argv[2], &type, pData, pcbData, &pcbData);\r
48         if (status == ERROR_SUCCESS)\r
49         {\r
50                 LPBYTE          ptr = pData;\r
51 \r
52                 printf ("\tValue Name = %s\n", argv[2]);\r
53                 printf ("\tType = %d\n", type);\r
54                 printf ("\tData = 0x%x bytes\n", pcbData);\r
55                 i = 0;\r
56                 while (i < pcbData)\r
57                 {\r
58                         printf ("\t0x%x", *(ptr));\r
59                         *ptr = *ptr < 1;\r
60                         ptr++;\r
61                         if (i%4 == 3)\r
62                                 printf ("\n");\r
63                         i++;\r
64                 }\r
65                 printf ("\n");\r
66         }\r
67 \r
68         printf ("Shifting everything to the right one bit...\n\n");\r
69 \r
70         status = SetPrinterDataEx(printer, "PrinterDriverData", argv[2], type, pData, pcbData);\r
71         if (status == ERROR_SUCCESS)\r
72         {\r
73                 printf ("\tValue Name = %s\n", argv[2]);\r
74                 printf ("\tType = %d\n", type);\r
75                 printf ("\tData = 0x%x bytes\n", pcbData);\r
76                 i = 0;\r
77                 while (i < pcbData)\r
78                 {\r
79                         printf ("\t0x%x", *(pData++));\r
80                         if (i%4 == 3)\r
81                                 printf ("\n");\r
82                         i++;\r
83                 }\r
84                 printf ("\n");\r
85         }\r
86         else\r
87                 PrintLastError();\r
88         \r
89         printf ("\n");\r
90 \r
91 \r
92 \r
93         /* close the server */\r
94         if (!ClosePrinter(printer))\r
95                 PrintLastError();\r
96         else\r
97                 printf ("Printer [%s] closed successfully.\n", argv[1]);\r
98 \r
99         return 0;\r
100 \r
101 }\r