reactos/win32ss/printing/base/winspool/main.c

118 lines
2.8 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Spooler API
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Main functions
* COPYRIGHT: Copyright 2015-2017 Colin Finck (colin@reactos.org)
*/
#include "precomp.h"
// Global Variables
HANDLE hProcessHeap;
HINSTANCE hinstWinSpool = NULL;
CRITICAL_SECTION rtlCritSec;
handle_t __RPC_USER
WINSPOOL_HANDLE_bind(WINSPOOL_HANDLE wszName)
{
handle_t hBinding;
PWSTR wszStringBinding;
RPC_STATUS Status;
// Get us a string binding handle from the supplied connection information
Status = RpcStringBindingComposeW(NULL, L"ncalrpc", NULL, L"spoolss", NULL, &wszStringBinding);
if (Status != RPC_S_OK)
{
Time to commit some Work-In-Progress stuff before my diff gets too large.. [LOCALSPL] - Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor. - Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors. Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List. - Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases. Currently working on LocalStartDocPrinter. - Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files. [WINPRINT] Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW. [WINSPOOL_APITEST] Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW. TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss. [SPOOLSS] Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there. This function should later also initialize further Print Providers. [SPOOLSV] Call InitializeRouter when starting up the service. [WINSPOOL] Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW. [All modules] Fix printf format specifiers for errors (%lu) and statuses (%ld). svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
ERR("RpcStringBindingComposeW failed with status %ld!\n", Status);
return NULL;
}
// Get a handle_t binding handle from the string binding handle
Status = RpcBindingFromStringBindingW(wszStringBinding, &hBinding);
if (Status != RPC_S_OK)
{
Time to commit some Work-In-Progress stuff before my diff gets too large.. [LOCALSPL] - Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor. - Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors. Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List. - Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases. Currently working on LocalStartDocPrinter. - Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files. [WINPRINT] Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW. [WINSPOOL_APITEST] Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW. TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss. [SPOOLSS] Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there. This function should later also initialize further Print Providers. [SPOOLSV] Call InitializeRouter when starting up the service. [WINSPOOL] Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW. [All modules] Fix printf format specifiers for errors (%lu) and statuses (%ld). svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
ERR("RpcBindingFromStringBindingW failed with status %ld!\n", Status);
return NULL;
}
// Free the string binding handle
Status = RpcStringFreeW(&wszStringBinding);
if (Status != RPC_S_OK)
{
Time to commit some Work-In-Progress stuff before my diff gets too large.. [LOCALSPL] - Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor. - Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors. Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List. - Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases. Currently working on LocalStartDocPrinter. - Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files. [WINPRINT] Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW. [WINSPOOL_APITEST] Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW. TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss. [SPOOLSS] Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there. This function should later also initialize further Print Providers. [SPOOLSV] Call InitializeRouter when starting up the service. [WINSPOOL] Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW. [All modules] Fix printf format specifiers for errors (%lu) and statuses (%ld). svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
ERR("RpcStringFreeW failed with status %ld!\n", Status);
return NULL;
}
return hBinding;
}
void __RPC_USER
WINSPOOL_HANDLE_unbind(WINSPOOL_HANDLE wszName, handle_t hBinding)
{
RPC_STATUS Status;
Status = RpcBindingFree(&hBinding);
if (Status != RPC_S_OK)
{
Time to commit some Work-In-Progress stuff before my diff gets too large.. [LOCALSPL] - Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor. - Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors. Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List. - Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases. Currently working on LocalStartDocPrinter. - Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files. [WINPRINT] Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW. [WINSPOOL_APITEST] Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW. TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss. [SPOOLSS] Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there. This function should later also initialize further Print Providers. [SPOOLSV] Call InitializeRouter when starting up the service. [WINSPOOL] Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW. [All modules] Fix printf format specifiers for errors (%lu) and statuses (%ld). svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
ERR("RpcBindingFree failed with status %ld!\n", Status);
}
}
void __RPC_FAR* __RPC_USER
midl_user_allocate(SIZE_T len)
{
return HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, len);
}
void __RPC_USER
midl_user_free(void __RPC_FAR* ptr)
{
HeapFree(hProcessHeap, 0, ptr);
}
BOOL WINAPI
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("DllMain(%p, %lu, %p)\n", hinstDLL, fdwReason, lpvReserved);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
hProcessHeap = GetProcessHeap();
hinstWinSpool = hinstDLL;
InitializeCriticalSection(&rtlCritSec);
break;
case DLL_PROCESS_DETACH:
DeleteCriticalSection(&rtlCritSec);
break;
}
return TRUE;
}
BOOL WINAPI
SpoolerInit(VOID)
{
BOOL bReturnValue = FALSE;
DWORD dwErrorCode;
TRACE("SpoolerInit()\n");
// Nothing to initialize here yet, but pass this call to the Spool Service as well.
RpcTryExcept
{
dwErrorCode = _RpcSpoolerInit();
SetLastError(dwErrorCode);
bReturnValue = (dwErrorCode == ERROR_SUCCESS);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
Time to commit some Work-In-Progress stuff before my diff gets too large.. [LOCALSPL] - Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor. - Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors. Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List. - Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases. Currently working on LocalStartDocPrinter. - Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files. [WINPRINT] Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW. [WINSPOOL_APITEST] Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW. TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss. [SPOOLSS] Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there. This function should later also initialize further Print Providers. [SPOOLSV] Call InitializeRouter when starting up the service. [WINSPOOL] Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW. [All modules] Fix printf format specifiers for errors (%lu) and statuses (%ld). svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
ERR("_RpcSpoolerInit failed with exception code %lu!\n", RpcExceptionCode());
}
RpcEndExcept;
return bReturnValue;
}