ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

router.c
Go to the documentation of this file.
00001 /*
00002  * Routing for Spooler-Service helper DLL
00003  *
00004  * Copyright 2006-2009 Detlef Riekenberg
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdarg.h>
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "winerror.h"
00026 #include "winreg.h"
00027 
00028 #include "wingdi.h"
00029 #include "winspool.h"
00030 #include "ddk/winsplp.h"
00031 #include "spoolss.h"
00032 
00033 #include "wine/debug.h"
00034 
00035 WINE_DEFAULT_DEBUG_CHANNEL(spoolss);
00036 
00037 /* ################################ */
00038 
00039 #define MAX_BACKEND 3
00040 
00041 typedef struct {
00042     /* PRINTPROVIDOR functions */
00043     DWORD  (WINAPI *fpOpenPrinter)(LPWSTR, HANDLE *, LPPRINTER_DEFAULTSW);
00044     DWORD  (WINAPI *fpSetJob)(HANDLE, DWORD, DWORD, LPBYTE, DWORD);
00045     DWORD  (WINAPI *fpGetJob)(HANDLE, DWORD, DWORD, LPBYTE, DWORD, LPDWORD);
00046     DWORD  (WINAPI *fpEnumJobs)(HANDLE, DWORD, DWORD, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00047     HANDLE (WINAPI *fpAddPrinter)(LPWSTR, DWORD, LPBYTE);
00048     DWORD  (WINAPI *fpDeletePrinter)(HANDLE);
00049     DWORD  (WINAPI *fpSetPrinter)(HANDLE, DWORD, LPBYTE, DWORD);
00050     DWORD  (WINAPI *fpGetPrinter)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
00051     DWORD  (WINAPI *fpEnumPrinters)(DWORD, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00052     DWORD  (WINAPI *fpAddPrinterDriver)(LPWSTR, DWORD, LPBYTE);
00053     DWORD  (WINAPI *fpEnumPrinterDrivers)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00054     DWORD  (WINAPI *fpGetPrinterDriver)(HANDLE, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
00055     DWORD  (WINAPI *fpGetPrinterDriverDirectory)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
00056     DWORD  (WINAPI *fpDeletePrinterDriver)(LPWSTR, LPWSTR, LPWSTR);
00057     DWORD  (WINAPI *fpAddPrintProcessor)(LPWSTR, LPWSTR, LPWSTR, LPWSTR);
00058     DWORD  (WINAPI *fpEnumPrintProcessors)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00059     DWORD  (WINAPI *fpGetPrintProcessorDirectory)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
00060     DWORD  (WINAPI *fpDeletePrintProcessor)(LPWSTR, LPWSTR, LPWSTR);
00061     DWORD  (WINAPI *fpEnumPrintProcessorDatatypes)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00062     DWORD  (WINAPI *fpStartDocPrinter)(HANDLE, DWORD, LPBYTE);
00063     DWORD  (WINAPI *fpStartPagePrinter)(HANDLE);
00064     DWORD  (WINAPI *fpWritePrinter)(HANDLE, LPVOID, DWORD, LPDWORD);
00065     DWORD  (WINAPI *fpEndPagePrinter)(HANDLE);
00066     DWORD  (WINAPI *fpAbortPrinter)(HANDLE);
00067     DWORD  (WINAPI *fpReadPrinter)(HANDLE, LPVOID, DWORD, LPDWORD);
00068     DWORD  (WINAPI *fpEndDocPrinter)(HANDLE);
00069     DWORD  (WINAPI *fpAddJob)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
00070     DWORD  (WINAPI *fpScheduleJob)(HANDLE, DWORD);
00071     DWORD  (WINAPI *fpGetPrinterData)(HANDLE, LPWSTR, LPDWORD, LPBYTE, DWORD, LPDWORD);
00072     DWORD  (WINAPI *fpSetPrinterData)(HANDLE, LPWSTR, DWORD, LPBYTE, DWORD);
00073     DWORD  (WINAPI *fpWaitForPrinterChange)(HANDLE, DWORD);
00074     DWORD  (WINAPI *fpClosePrinter)(HANDLE);
00075     DWORD  (WINAPI *fpAddForm)(HANDLE, DWORD, LPBYTE);
00076     DWORD  (WINAPI *fpDeleteForm)(HANDLE, LPWSTR);
00077     DWORD  (WINAPI *fpGetForm)(HANDLE, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
00078     DWORD  (WINAPI *fpSetForm)(HANDLE, LPWSTR, DWORD, LPBYTE);
00079     DWORD  (WINAPI *fpEnumForms)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00080     DWORD  (WINAPI *fpEnumMonitors)(LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00081     DWORD  (WINAPI *fpEnumPorts)(LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
00082     DWORD  (WINAPI *fpAddPort)(LPWSTR, HWND, LPWSTR);
00083     DWORD  (WINAPI *fpConfigurePort)(LPWSTR, HWND, LPWSTR);
00084     DWORD  (WINAPI *fpDeletePort)(LPWSTR, HWND, LPWSTR);
00085     HANDLE (WINAPI *fpCreatePrinterIC)(HANDLE, LPDEVMODEW);
00086     DWORD  (WINAPI *fpPlayGdiScriptOnPrinterIC)(HANDLE, LPBYTE, DWORD, LPBYTE, DWORD, DWORD);
00087     DWORD  (WINAPI *fpDeletePrinterIC)(HANDLE);
00088     DWORD  (WINAPI *fpAddPrinterConnection)(LPWSTR);
00089     DWORD  (WINAPI *fpDeletePrinterConnection)(LPWSTR);
00090     DWORD  (WINAPI *fpPrinterMessageBox)(HANDLE, DWORD, HWND, LPWSTR, LPWSTR, DWORD);
00091     DWORD  (WINAPI *fpAddMonitor)(LPWSTR, DWORD, LPBYTE);
00092     DWORD  (WINAPI *fpDeleteMonitor)(LPWSTR, LPWSTR, LPWSTR);
00093     DWORD  (WINAPI *fpResetPrinter)(HANDLE, LPPRINTER_DEFAULTSW);
00094     DWORD  (WINAPI *fpGetPrinterDriverEx)(HANDLE, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, DWORD, DWORD, PDWORD, PDWORD);
00095     HANDLE (WINAPI *fpFindFirstPrinterChangeNotification)(HANDLE, DWORD, DWORD, LPVOID);
00096     DWORD  (WINAPI *fpFindClosePrinterChangeNotification)(HANDLE);
00097     DWORD  (WINAPI *fpAddPortEx)(HANDLE, LPWSTR, DWORD, LPBYTE, LPWSTR);
00098     DWORD  (WINAPI *fpShutDown)(LPVOID);
00099     DWORD  (WINAPI *fpRefreshPrinterChangeNotification)(HANDLE, DWORD, PVOID, PVOID);
00100     DWORD  (WINAPI *fpOpenPrinterEx)(LPWSTR, LPHANDLE, LPPRINTER_DEFAULTSW, LPBYTE, DWORD);
00101     HANDLE (WINAPI *fpAddPrinterEx)(LPWSTR, DWORD, LPBYTE, LPBYTE, DWORD);
00102     DWORD  (WINAPI *fpSetPort)(LPWSTR, LPWSTR, DWORD, LPBYTE);
00103     DWORD  (WINAPI *fpEnumPrinterData)(HANDLE, DWORD, LPWSTR, DWORD, LPDWORD, LPDWORD, LPBYTE, DWORD, LPDWORD);
00104     DWORD  (WINAPI *fpDeletePrinterData)(HANDLE, LPWSTR);
00105     DWORD  (WINAPI *fpClusterSplOpen)(LPCWSTR, LPCWSTR, PHANDLE, LPCWSTR, LPCWSTR);
00106     DWORD  (WINAPI *fpClusterSplClose)(HANDLE);
00107     DWORD  (WINAPI *fpClusterSplIsAlive)(HANDLE);
00108     DWORD  (WINAPI *fpSetPrinterDataEx)(HANDLE, LPCWSTR, LPCWSTR, DWORD, LPBYTE, DWORD);
00109     DWORD  (WINAPI *fpGetPrinterDataEx)(HANDLE, LPCWSTR, LPCWSTR, LPDWORD, LPBYTE, DWORD, LPDWORD);
00110     DWORD  (WINAPI *fpEnumPrinterDataEx)(HANDLE, LPCWSTR, LPBYTE, DWORD, LPDWORD, LPDWORD);
00111     DWORD  (WINAPI *fpEnumPrinterKey)(HANDLE, LPCWSTR, LPWSTR, DWORD, LPDWORD);
00112     DWORD  (WINAPI *fpDeletePrinterDataEx)(HANDLE, LPCWSTR, LPCWSTR);
00113     DWORD  (WINAPI *fpDeletePrinterKey)(HANDLE hPrinter, LPCWSTR pKeyName);
00114     DWORD  (WINAPI *fpSeekPrinter)(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD, BOOL);
00115     DWORD  (WINAPI *fpDeletePrinterDriverEx)(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD);
00116     DWORD  (WINAPI *fpAddPerMachineConnection)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
00117     DWORD  (WINAPI *fpDeletePerMachineConnection)(LPCWSTR, LPCWSTR);
00118     DWORD  (WINAPI *fpEnumPerMachineConnections)(LPCWSTR, LPBYTE, DWORD, LPDWORD, LPDWORD);
00119     DWORD  (WINAPI *fpXcvData)(HANDLE, LPCWSTR, PBYTE, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
00120     DWORD  (WINAPI *fpAddPrinterDriverEx)(LPWSTR, DWORD, LPBYTE, DWORD);
00121     DWORD  (WINAPI *fpSplReadPrinter)(HANDLE, LPBYTE *, DWORD);
00122     DWORD  (WINAPI *fpDriverUnloadComplete)(LPWSTR);
00123     DWORD  (WINAPI *fpGetSpoolFileInfo)(HANDLE, LPWSTR *, LPHANDLE, HANDLE, HANDLE);
00124     DWORD  (WINAPI *fpCommitSpoolData)(HANDLE, DWORD);
00125     DWORD  (WINAPI *fpCloseSpoolFileHandle)(HANDLE);
00126     DWORD  (WINAPI *fpFlushPrinter)(HANDLE, LPBYTE, DWORD, LPDWORD, DWORD);
00127     DWORD  (WINAPI *fpSendRecvBidiData)(HANDLE, LPCWSTR, LPBIDI_REQUEST_CONTAINER, LPBIDI_RESPONSE_CONTAINER *);
00128     DWORD  (WINAPI *fpAddDriverCatalog)(HANDLE, DWORD, VOID *, DWORD);
00129     /* Private Data */
00130     HMODULE dll;
00131     LPWSTR  dllname;
00132     LPWSTR  name;
00133     LPWSTR  regroot;
00134     DWORD   index;
00135 } backend_t;
00136 
00137 /* ################################ */
00138 
00139 static backend_t *backend[MAX_BACKEND];
00140 static DWORD used_backends = 0;
00141 
00142 static CRITICAL_SECTION backend_cs;
00143 static CRITICAL_SECTION_DEBUG backend_cs_debug =
00144 {
00145     0, 0, &backend_cs,
00146     { &backend_cs_debug.ProcessLocksList, &backend_cs_debug.ProcessLocksList },
00147       0, 0, { (DWORD_PTR)(__FILE__ ": backend_cs") }
00148 };
00149 static CRITICAL_SECTION backend_cs = { &backend_cs_debug, -1, 0, 0, 0, 0 };
00150 
00151 /* ################################ */
00152 
00153 static WCHAR localsplW[] = {'l','o','c','a','l','s','p','l','.','d','l','l',0};
00154 
00155 /******************************************************************
00156  * strdupW [internal]
00157  *
00158  * create a copy of a unicode-string
00159  *
00160  */
00161 
00162 static LPWSTR strdupW(LPCWSTR p)
00163 {
00164     LPWSTR ret;
00165     DWORD len;
00166 
00167     if(!p) return NULL;
00168     len = (lstrlenW(p) + 1) * sizeof(WCHAR);
00169     ret = heap_alloc(len);
00170     memcpy(ret, p, len);
00171     return ret;
00172 }
00173 
00174 /******************************************************************
00175  * backend_unload_all [internal]
00176  *
00177  * unload all backends
00178  */
00179 void backend_unload_all(void)
00180 {
00181     EnterCriticalSection(&backend_cs);
00182     while (used_backends > 0) {
00183         used_backends--;
00184         FreeLibrary(backend[used_backends]->dll);
00185         heap_free(backend[used_backends]->dllname);
00186         heap_free(backend[used_backends]->name);
00187         heap_free(backend[used_backends]->regroot);
00188         heap_free(backend[used_backends]);
00189         backend[used_backends] = NULL;
00190     }
00191     LeaveCriticalSection(&backend_cs);
00192 }
00193 
00194 /******************************************************************************
00195  * backend_load [internal]
00196  *
00197  * load and init a backend
00198  *
00199  * PARAMS
00200  *  name   [I] Printprovider to use for the backend. NULL for the local print provider
00201  *
00202  * RETURNS
00203  *  Success: PTR to the backend
00204  *  Failure: NULL
00205  *
00206  */
00207 static backend_t * backend_load(LPWSTR dllname, LPWSTR name, LPWSTR regroot)
00208 {
00209 
00210     BOOL (WINAPI *pInitializePrintProvidor)(LPPRINTPROVIDOR, DWORD, LPWSTR);
00211     DWORD id;
00212     DWORD res;
00213 
00214     TRACE("(%s, %s, %s)\n", debugstr_w(dllname), debugstr_w(name), debugstr_w(regroot));
00215 
00216     EnterCriticalSection(&backend_cs);
00217     id = used_backends;
00218 
00219     backend[id] = heap_alloc_zero(sizeof(backend_t));
00220     if (!backend[id]) {
00221         LeaveCriticalSection(&backend_cs);
00222         return NULL;
00223     }
00224 
00225     backend[id]->dllname = strdupW(dllname);
00226     backend[id]->name = strdupW(name);
00227     backend[id]->regroot = strdupW(regroot);
00228 
00229     backend[id]->dll = LoadLibraryW(dllname);
00230     if (backend[id]->dll) {
00231         pInitializePrintProvidor = (void *) GetProcAddress(backend[id]->dll, "InitializePrintProvidor");
00232         if (pInitializePrintProvidor) {
00233 
00234             /* native localspl does not clear unused entries */
00235             res = pInitializePrintProvidor((PRINTPROVIDOR *) backend[id], sizeof(PRINTPROVIDOR), regroot);
00236             if (res) {
00237                 used_backends++;
00238                 backend[id]->index = used_backends;
00239                 LeaveCriticalSection(&backend_cs);
00240                 TRACE("--> backend #%d: %p (%s)\n", id, backend[id], debugstr_w(dllname));
00241                 return backend[id];
00242             }
00243         }
00244         FreeLibrary(backend[id]->dll);
00245     }
00246     heap_free(backend[id]->dllname);
00247     heap_free(backend[id]->name);
00248     heap_free(backend[id]->regroot);
00249     heap_free(backend[id]);
00250     backend[id] = NULL;
00251     LeaveCriticalSection(&backend_cs);
00252     WARN("failed to init %s: %u\n", debugstr_w(dllname), GetLastError());
00253     return NULL;
00254 }
00255 
00256 /******************************************************************************
00257  * backend_load_all [internal]
00258  *
00259  * load and init all backends
00260  *
00261  * RETURNS
00262  *  Success: TRUE
00263  *  Failure: FALSE
00264  *
00265  */
00266 BOOL backend_load_all(void)
00267 {
00268     static BOOL failed = FALSE;
00269 
00270     EnterCriticalSection(&backend_cs);
00271 
00272     /* if we failed before, don't try again */
00273     if (!failed && (used_backends == 0)) {
00274         backend_load(localsplW, NULL, NULL);
00275 
00276         /* ToDo: parse the registry and load all other backends */
00277 
00278         failed = (used_backends == 0);
00279     }
00280     LeaveCriticalSection(&backend_cs);
00281     TRACE("-> %d\n", !failed);
00282     return (!failed);
00283 }
00284 
00285 /******************************************************************************
00286  * backend_first [internal]
00287  *
00288  * find the first usable backend
00289  *
00290  * RETURNS
00291  *  Success: PTR to the backend
00292  *  Failure: NULL
00293  *
00294  */
00295 static backend_t * backend_first(LPWSTR name)
00296 {
00297 
00298     EnterCriticalSection(&backend_cs);
00299     /* Load all backends, when not done yet */
00300     if (used_backends || backend_load_all()) {
00301 
00302         /* test for the local system first */
00303         if (!name || !name[0]) {
00304             LeaveCriticalSection(&backend_cs);
00305             return backend[0];
00306         }
00307     }
00308 
00309     FIXME("server %s not supported in %d backends\n", debugstr_w(name), used_backends);
00310     LeaveCriticalSection(&backend_cs);
00311     return NULL;
00312 }
00313 
00314 /******************************************************************
00315  * AddMonitorW (spoolss.@)
00316  *
00317  * Install a Printmonitor
00318  *
00319  * PARAMS
00320  *  pName       [I] Servername or NULL (local Computer)
00321  *  Level       [I] Structure-Level (Must be 2)
00322  *  pMonitors   [I] PTR to MONITOR_INFO_2
00323  *
00324  * RETURNS
00325  *  Success: TRUE
00326  *  Failure: FALSE
00327  *
00328  * NOTES
00329  *  All Files for the Monitor must already be copied to %winsysdir% ("%SystemRoot%\system32")
00330  *
00331  */
00332 BOOL WINAPI AddMonitorW(LPWSTR pName, DWORD Level, LPBYTE pMonitors)
00333 {
00334     backend_t * pb;
00335     DWORD res = ROUTER_UNKNOWN;
00336 
00337     TRACE("(%s, %d, %p)\n", debugstr_w(pName), Level, pMonitors);
00338 
00339     if (Level != 2) {
00340         SetLastError(ERROR_INVALID_LEVEL);
00341         return FALSE;
00342     }
00343 
00344     pb = backend_first(pName);
00345     if (pb && pb->fpAddMonitor)
00346         res = pb->fpAddMonitor(pName, Level, pMonitors);
00347     else
00348     {
00349         SetLastError(ERROR_PROC_NOT_FOUND);
00350     }
00351 
00352     TRACE("got %u with %u\n", res, GetLastError());
00353     return (res == ROUTER_SUCCESS);
00354 }
00355 
00356 /******************************************************************
00357  * AddPrinterDriverExW (spoolss.@)
00358  *
00359  * Install a Printer Driver with the Option to upgrade / downgrade the Files
00360  *
00361  * PARAMS
00362  *  pName           [I] Servername or NULL (local Computer)
00363  *  level           [I] Level for the supplied DRIVER_INFO_*W struct
00364  *  pDriverInfo     [I] PTR to DRIVER_INFO_*W struct with the Driver Parameter
00365  *  dwFileCopyFlags [I] How to Copy / Upgrade / Downgrade the needed Files
00366  *
00367  * RESULTS
00368  *  Success: TRUE
00369  *  Failure: FALSE
00370  *
00371  */
00372 BOOL WINAPI AddPrinterDriverExW(LPWSTR pName, DWORD level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags)
00373 {
00374     backend_t * pb;
00375     DWORD res = ROUTER_UNKNOWN;
00376 
00377     TRACE("(%s, %d, %p, 0x%x)\n", debugstr_w(pName), level, pDriverInfo, dwFileCopyFlags);
00378 
00379     if (!pDriverInfo) {
00380         SetLastError(ERROR_INVALID_PARAMETER);
00381         return FALSE;
00382     }
00383 
00384     pb = backend_first(pName);
00385     if (pb && pb->fpAddPrinterDriverEx)
00386         res = pb->fpAddPrinterDriverEx(pName, level, pDriverInfo, dwFileCopyFlags);
00387     else
00388     {
00389         SetLastError(ERROR_PROC_NOT_FOUND);
00390     }
00391 
00392     TRACE("got %u with %u\n", res, GetLastError());
00393     return (res == ROUTER_SUCCESS);
00394 }
00395 
00396 /******************************************************************
00397  * DeleteMonitorW (spoolss.@)
00398  *
00399  * Delete a specific Printmonitor from a Printing-Environment
00400  *
00401  * PARAMS
00402  *  pName        [I] Servername or NULL (local Computer)
00403  *  pEnvironment [I] Printing-Environment of the Monitor or NULL (Default)
00404  *  pMonitorName [I] Name of the Monitor, that should be deleted
00405  *
00406  * RETURNS
00407  *  Success: TRUE
00408  *  Failure: FALSE
00409  *
00410  */
00411 BOOL WINAPI DeleteMonitorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMonitorName)
00412 {
00413     backend_t * pb;
00414     DWORD res = ROUTER_UNKNOWN;
00415 
00416     TRACE("(%s, %s, %s)\n", debugstr_w(pName), debugstr_w(pEnvironment), debugstr_w(pMonitorName));
00417 
00418     pb = backend_first(pName);
00419     if (pb && pb->fpDeleteMonitor)
00420         res = pb->fpDeleteMonitor(pName, pEnvironment, pMonitorName);
00421     else
00422     {
00423         SetLastError(ERROR_PROC_NOT_FOUND);
00424     }
00425 
00426     TRACE("got %u with %u\n", res, GetLastError());
00427     return (res == ROUTER_SUCCESS);
00428 }
00429 
00430 /******************************************************************
00431  * EnumMonitorsW (spoolss.@)
00432  *
00433  * Enumerate available Port-Monitors
00434  *
00435  * PARAMS
00436  *  pName      [I] Servername or NULL (local Computer)
00437  *  Level      [I] Structure-Level
00438  *  pMonitors  [O] PTR to Buffer that receives the Result
00439  *  cbBuf      [I] Size of Buffer at pMonitors
00440  *  pcbNeeded  [O] PTR to DWORD that receives the size in Bytes used / required for pMonitors
00441  *  pcReturned [O] PTR to DWORD that receives the number of Monitors in pMonitors
00442  *
00443  * RETURNS
00444  *  Success: TRUE
00445  *  Failure: FALSE and in pcbNeeded the Bytes required for pMonitors, if cbBuf is too small
00446  *
00447  */
00448 BOOL WINAPI EnumMonitorsW(LPWSTR pName, DWORD Level, LPBYTE pMonitors, DWORD cbBuf,
00449                           LPDWORD pcbNeeded, LPDWORD pcReturned)
00450 {
00451     backend_t * pb;
00452     DWORD res = ROUTER_UNKNOWN;
00453 
00454     TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_w(pName), Level, pMonitors,
00455           cbBuf, pcbNeeded, pcReturned);
00456 
00457     if (pcbNeeded) *pcbNeeded = 0;
00458     if (pcReturned) *pcReturned = 0;
00459 
00460     pb = backend_first(pName);
00461     if (pb && pb->fpEnumMonitors)
00462         res = pb->fpEnumMonitors(pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned);
00463     else
00464     {
00465         SetLastError(ERROR_PROC_NOT_FOUND);
00466     }
00467 
00468     TRACE("got %u with %u (%u byte for %u entries)\n\n", res, GetLastError(),
00469             pcbNeeded ? *pcbNeeded : 0, pcReturned ? *pcReturned : 0);
00470 
00471     return (res == ROUTER_SUCCESS);
00472 }
00473 
00474 /******************************************************************
00475  * EnumPortsW (spoolss.@)
00476  *
00477  * Enumerate available Ports
00478  *
00479  * PARAMS
00480  *  pName      [I] Servername or NULL (local Computer)
00481  *  Level      [I] Structure-Level (1 or 2)
00482  *  pPorts     [O] PTR to Buffer that receives the Result
00483  *  cbBuf      [I] Size of Buffer at pPorts
00484  *  pcbNeeded  [O] PTR to DWORD that receives the size in Bytes used / required for pPorts
00485  *  pcReturned [O] PTR to DWORD that receives the number of Ports in pPorts
00486  *
00487  * RETURNS
00488  *  Success: TRUE
00489  *  Failure: FALSE and in pcbNeeded the Bytes required for pPorts, if cbBuf is too small
00490  *
00491  */
00492 BOOL WINAPI EnumPortsW(LPWSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf,
00493                        LPDWORD pcbNeeded, LPDWORD pcReturned)
00494 {
00495     backend_t * pb;
00496     DWORD res = ROUTER_UNKNOWN;
00497 
00498     TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_w(pName), Level, pPorts, cbBuf,
00499             pcbNeeded, pcReturned);
00500 
00501     if (pcbNeeded) *pcbNeeded = 0;
00502     if (pcReturned) *pcReturned = 0;
00503 
00504     pb = backend_first(pName);
00505     if (pb && pb->fpEnumPorts)
00506         res = pb->fpEnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
00507     else
00508     {
00509         SetLastError(ERROR_PROC_NOT_FOUND);
00510     }
00511 
00512     TRACE("got %u with %u (%u byte for %u entries)\n", res, GetLastError(),
00513             pcbNeeded ? *pcbNeeded : 0, pcReturned ? *pcReturned : 0);
00514 
00515     return (res == ROUTER_SUCCESS);
00516 }
00517 
00518 /******************************************************************
00519  * GetPrinterDriverDirectoryW (spoolss.@)
00520  *
00521  * Return the PATH for the Printer-Drivers
00522  *
00523  * PARAMS
00524  *   pName            [I] Servername or NULL (local Computer)
00525  *   pEnvironment     [I] Printing-Environment or NULL (Default)
00526  *   Level            [I] Structure-Level (must be 1)
00527  *   pDriverDirectory [O] PTR to Buffer that receives the Result
00528  *   cbBuf            [I] Size of Buffer at pDriverDirectory
00529  *   pcbNeeded        [O] PTR to DWORD that receives the size in Bytes used /
00530  *                        required for pDriverDirectory
00531  *
00532  * RETURNS
00533  *   Success: TRUE  and in pcbNeeded the Bytes used in pDriverDirectory
00534  *   Failure: FALSE and in pcbNeeded the Bytes required for pDriverDirectory,
00535  *   if cbBuf is too small
00536  *
00537  *   Native Values returned in pDriverDirectory on Success:
00538  *|  NT(Windows NT x86): "%winsysdir%\\spool\\DRIVERS\\w32x86"
00539  *|  NT(Windows x64):    "%winsysdir%\\spool\\DRIVERS\\x64"
00540  *|  NT(Windows 4.0):    "%winsysdir%\\spool\\DRIVERS\\win40"
00541  *|  win9x(Windows 4.0): "%winsysdir%"
00542  *
00543  *   "%winsysdir%" is the Value from GetSystemDirectoryW()
00544  *
00545  */
00546 BOOL WINAPI GetPrinterDriverDirectoryW(LPWSTR pName, LPWSTR pEnvironment,
00547             DWORD Level, LPBYTE pDriverDirectory, DWORD cbBuf, LPDWORD pcbNeeded)
00548 {
00549     backend_t * pb;
00550     DWORD res = ROUTER_UNKNOWN;
00551 
00552     TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(pName),
00553           debugstr_w(pEnvironment), Level, pDriverDirectory, cbBuf, pcbNeeded);
00554 
00555     if (pcbNeeded) *pcbNeeded = 0;
00556 
00557     pb = backend_first(pName);
00558     if (pb && pb->fpGetPrinterDriverDirectory)
00559         res = pb->fpGetPrinterDriverDirectory(pName, pEnvironment, Level,
00560                                               pDriverDirectory, cbBuf, pcbNeeded);
00561     else
00562     {
00563         SetLastError(ERROR_PROC_NOT_FOUND);
00564     }
00565 
00566     TRACE("got %u with %u (%u byte)\n",
00567             res, GetLastError(), pcbNeeded ? *pcbNeeded : 0);
00568 
00569     return (res == ROUTER_SUCCESS);
00570 
00571 }

Generated on Sat May 26 2012 04:25:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.