[LOCALSPL_APITEST]
[reactos.git] / reactos / win32ss / printing / base / spoolss / main.c
index b37bd30..2a83055 100644 (file)
@@ -7,12 +7,30 @@
 
 #include "precomp.h"
 
+HANDLE hProcessHeap;
+PRINTPROVIDOR LocalSplFuncs;
+
+
 BOOL WINAPI
 ClosePrinter(HANDLE hPrinter)
 {
     return FALSE;
 }
 
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    switch (fdwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hinstDLL);
+            hProcessHeap = GetProcessHeap();
+            break;
+    }
+
+    return TRUE;
+}
+
 BOOL WINAPI
 EndDocPrinter(HANDLE hPrinter)
 {
@@ -52,7 +70,32 @@ GetPrintProcessorDirectoryW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBY
 BOOL WINAPI
 InitializeRouter(HANDLE SpoolerStatusHandle)
 {
-    return FALSE;
+    HINSTANCE hinstLocalSpl;
+    PInitializePrintProvidor pfnInitializePrintProvidor;
+
+    // Only initialize localspl.dll for now.
+    // This function should later look for all available print providers in the registry and initialize all of them.
+    hinstLocalSpl = LoadLibraryW(L"localspl");
+    if (!hinstLocalSpl)
+    {
+        ERR("LoadLibraryW for localspl failed with error %lu!\n", GetLastError());
+        return FALSE;
+    }
+
+    pfnInitializePrintProvidor = (PInitializePrintProvidor)GetProcAddress(hinstLocalSpl, "InitializePrintProvidor");
+    if (!pfnInitializePrintProvidor)
+    {
+        ERR("GetProcAddress failed with error %lu!\n", GetLastError());
+        return FALSE;
+    }
+
+    if (!pfnInitializePrintProvidor(&LocalSplFuncs, sizeof(PRINTPROVIDOR), NULL))
+    {
+        ERR("InitializePrintProvidor failed for localspl with error %lu!\n", GetLastError());
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 BOOL WINAPI
@@ -67,6 +110,44 @@ StartDocPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo)
     return 0;
 }
 
+BOOL WINAPI
+SplInitializeWinSpoolDrv(PVOID* pTable)
+{
+    HINSTANCE hWinspool;
+    int i;
+
+    hWinspool = LoadLibraryW(L"winspool.drv");
+    if (!hWinspool)
+    {
+        ERR("Could not load winspool.drv, last error is %lu!\n", GetLastError());
+        return FALSE;
+    }
+
+    // Get the function pointers which are meant to be returned by this function.
+    pTable[0] = GetProcAddress(hWinspool, "OpenPrinterW");
+    pTable[1] = GetProcAddress(hWinspool, "ClosePrinter");
+    pTable[2] = GetProcAddress(hWinspool, "SpoolerDevQueryPrintW");
+    pTable[3] = GetProcAddress(hWinspool, "SpoolerPrinterEvent");
+    pTable[4] = GetProcAddress(hWinspool, "DocumentPropertiesW");
+    pTable[5] = GetProcAddress(hWinspool, (LPSTR)212);
+    pTable[6] = GetProcAddress(hWinspool, (LPSTR)213);
+    pTable[7] = GetProcAddress(hWinspool, (LPSTR)214);
+    pTable[8] = GetProcAddress(hWinspool, (LPSTR)215);
+
+    // Verify that all calls succeeded.
+    for (i = 0; i < 9; i++)
+        if (!pTable[i])
+            return FALSE;
+
+    return TRUE;
+}
+
+BOOL WINAPI
+SplIsUpgrade()
+{
+       return FALSE;
+}
+
 DWORD WINAPI
 SpoolerInit()
 {