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

ntprint.c
Go to the documentation of this file.
00001 /*
00002  * Implementation of the Spooler Setup API (Printing)
00003  *
00004  * Copyright 2007 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 #define COBJMACROS
00024 #define NONAMELESSUNION
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "winerror.h"
00029 #include "wingdi.h"
00030 #include "winnls.h"
00031 #include "winver.h"
00032 #include "winspool.h"
00033 
00034 #include "wine/unicode.h"
00035 #include "wine/debug.h"
00036 
00037 WINE_DEFAULT_DEBUG_CHANNEL(ntprint);
00038 
00039 static HINSTANCE NTPRINT_hInstance = NULL;
00040 
00041 typedef struct {
00042   LPMONITOR_INFO_2W mi2;    /* Buffer for installed Monitors */
00043   DWORD installed;          /* Number of installed Monitors */
00044 } monitorinfo_t;
00045 
00046 /*****************************************************
00047  *      DllMain
00048  */
00049 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
00050 {
00051     TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
00052 
00053     switch(fdwReason)
00054     {
00055         case DLL_WINE_PREATTACH:
00056             return FALSE;           /* prefer native version */
00057 
00058         case DLL_PROCESS_ATTACH:
00059             NTPRINT_hInstance = hinstDLL;
00060             DisableThreadLibraryCalls( hinstDLL );
00061             break;
00062     }
00063     return TRUE;
00064 }
00065 
00066 /*****************************************************
00067  *  PSetupCreateMonitorInfo  [NTPRINT.@]
00068  *
00069  *
00070  */
00071 
00072 HANDLE WINAPI PSetupCreateMonitorInfo(LPVOID unknown1, LPVOID  unknown2,LPVOID unknown3)
00073 {
00074     monitorinfo_t * mi=NULL;
00075     DWORD needed;
00076     DWORD res;
00077 
00078     TRACE("(%p, %p, %p)\n", unknown1, unknown2, unknown3);
00079 
00080     if ((unknown2 != NULL) || (unknown3 != NULL)) {
00081         FIXME("got unknown parameter: (%p, %p, %p)\n", unknown1, unknown2, unknown3);
00082         return NULL;
00083     }
00084 
00085     mi = HeapAlloc(GetProcessHeap(), 0, sizeof(monitorinfo_t));
00086     if (!mi) {
00087         /* FIXME: SetLastError() needed? */
00088         return NULL;
00089     }
00090 
00091     /* Get the needed size for all Monitors */
00092     res = EnumMonitorsW(NULL, 2, NULL, 0, &needed, &mi->installed);
00093     if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
00094         mi->mi2 = HeapAlloc(GetProcessHeap(), 0, needed);
00095         res = EnumMonitorsW(NULL, 2, (LPBYTE) mi->mi2, needed, &needed, &mi->installed);
00096     }
00097 
00098     if (!res) {
00099         HeapFree(GetProcessHeap(), 0, mi);
00100         /* FIXME: SetLastError() needed? */
00101         return NULL;
00102     }
00103 
00104     TRACE("=> %p (%u monitors installed)\n", mi, mi->installed);
00105     return mi;
00106 }
00107 
00108 /*****************************************************
00109  *  PSetupDestroyMonitorInfo  [NTPRINT.@]
00110  *
00111  */
00112 
00113 VOID WINAPI PSetupDestroyMonitorInfo(HANDLE monitorinfo)
00114 {
00115     monitorinfo_t * mi = monitorinfo;
00116 
00117     TRACE("(%p)\n", mi);
00118     if (mi) {
00119         if (mi->installed) HeapFree(GetProcessHeap(), 0, mi->mi2);
00120         HeapFree(GetProcessHeap(), 0, mi);
00121     }
00122 }
00123 
00124 /*****************************************************
00125  *  PSetupEnumMonitor  [NTPRINT.@]
00126  *
00127  * Copy the selected Monitorname to a buffer
00128  *
00129  * PARAMS
00130  *  monitorinfo [I]  HANDLE from PSetupCreateMonitorInfo
00131  *  index       [I]  Nr. of the Monitorname to copy
00132  *  buffer      [I]  Target, that receive the Monitorname
00133  *  psize       [IO] PTR to a DWORD that hold the size of the buffer and receive
00134  *                   the needed size, when the buffer is too small
00135  *
00136  * RETURNS
00137  *  Success:  TRUE
00138  *  Failure:  FALSE
00139  *
00140  * NOTES
00141  *   size is in Bytes on w2k and WCHAR on XP
00142  *
00143  */
00144 
00145 BOOL WINAPI PSetupEnumMonitor(HANDLE monitorinfo, DWORD index, LPWSTR buffer, LPDWORD psize)
00146 {
00147     monitorinfo_t * mi = monitorinfo;
00148     LPWSTR  nameW;
00149     DWORD   len;
00150 
00151     TRACE("(%p, %u, %p, %p) => %d\n", mi, index, buffer, psize, psize ? *psize : 0);
00152 
00153     if (index < mi->installed) {
00154         nameW = mi->mi2[index].pName;
00155         len = lstrlenW(nameW) + 1;
00156         if (len <= *psize) {
00157             memcpy(buffer, nameW, len * sizeof(WCHAR));
00158             TRACE("#%u: %s\n", index, debugstr_w(buffer));
00159             return TRUE;
00160         }
00161         *psize = len;
00162         SetLastError(ERROR_INSUFFICIENT_BUFFER);
00163         return FALSE;
00164     }
00165     SetLastError(ERROR_NO_MORE_ITEMS);
00166     return FALSE;
00167 }

Generated on Sun May 27 2012 04:25:31 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.