dos2unix everything
[gd/win32-spoolss/.git] / AddPrinterDriver.c
1 /******************************************************************
2  * SPOOLSS regression testing code for Samba print servers
3  *
4  *****************************************************************/
5
6 #include <windows.h>
7 #include <stdio.h>
8 #include "printlib.h"
9
10 /* we assume the necessary driver files are already uploaded
11    on the server.  We also only exercise The info level 3
12    since that is the one used by the NT Add Printer Wizard */
13 int main (int argc, char* argv[])
14 {
15         DRIVER_INFO_3   buffer3;
16         BYTE                    pDependentFiles[] = { "PSCRIPT.HLP\0PSCRPTUI.DLL\0PSCRIPT.DLL\0LWNTX518.PPD\0\0" };
17         LPVOID                  lpMsgBuf;
18
19         if (argc < 2)
20         {
21                 fprintf (stderr, "useage: %s <servername>\n", argv[0]);
22                 exit (-1);
23         }
24
25         /* we'll use the Apple LaserWriter II NTX v51.8 driver
26            for simplcity */
27         buffer3.cVersion                = 2;
28         buffer3.pEnvironment    = strdup("Windows NT x86");
29         buffer3.pName                   = strdup("Apple LaserWriter II NTX v51.8");
30         buffer3.pDriverPath             = strdup("pscript.dll");
31         buffer3.pDataFile               = strdup("lwntx518.ppd");
32         buffer3.pConfigFile             = strdup("pscriptui.dll");
33         buffer3.pDependentFiles = pDependentFiles;
34         buffer3.pHelpFile               = strdup("pscript.hlp");
35         buffer3.pMonitorName    = NULL;
36         buffer3.pDefaultDataType = strdup("RAW");
37
38         printf ("Attempting to add Driver Info Level 3 :\n");
39         print_driver_info_3 (&buffer3);
40         printf ("\n");
41
42
43         if (!AddPrinterDriver(argv[1], 3, (LPBYTE)&buffer3))
44         {
45                 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
46                         FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
47                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
48                         (LPTSTR) &lpMsgBuf, 0, NULL);
49                 printf ("ERROR : %s\n", (char*)lpMsgBuf);
50                 LocalFree (lpMsgBuf);
51         }
52         else
53         {
54                 printf ("Printer Driver installed successfully\n");
55         }
56
57
58         return 0;
59
60 }