Add a semi-working stub of GetDefaultPrinter[A/W] ported from WINE.
authorSteven Edwards <winehacker@gmail.com>
Mon, 12 Jan 2004 23:42:23 +0000 (23:42 +0000)
committerSteven Edwards <winehacker@gmail.com>
Mon, 12 Jan 2004 23:42:23 +0000 (23:42 +0000)
This isnt right but its needed to get comdlg32.dll working.

svn path=/trunk/; revision=7592

reactos/lib/winspool/Makefile
reactos/lib/winspool/info.c [new file with mode: 0644]
reactos/lib/winspool/stubs.c
reactos/lib/winspool/winspool.def
reactos/lib/winspool/winspool.edf

index dcee536..e4e24ce 100644 (file)
@@ -1,4 +1,6 @@
-# $Id: Makefile,v 1.2 2003/08/07 04:03:24 royce Exp $
+#
+# Fix this
+#
 
 PATH_TO_TOP = ../..
 
@@ -15,6 +17,8 @@ TARGET_CFLAGS = \
  -Wall \
  -Werror \
  -fno-builtin \
+ -D__REACTOS__ \
+ -D__USE_W32API \
  -DUNICODE \
  -DLE \
  -DDBG
@@ -24,9 +28,9 @@ TARGET_CFLAGS += -D_DISABLE_TIDENTS
 
 TARGET_LFLAGS = -nostartfiles -nostdlib
 
-TARGET_SDKLIBS = kernel32.a
+TARGET_SDKLIBS = libwine.a libwine_unicode.a ntdll.a kernel32.a
 
-TARGET_OBJECTS = stubs.o
+TARGET_OBJECTS = info.o stubs.o
 
 TARGET_CLEAN = $(DEP_FILES)
 
diff --git a/reactos/lib/winspool/info.c b/reactos/lib/winspool/info.c
new file mode 100644 (file)
index 0000000..0bd58f3
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * WINSPOOL functions
+ *
+ * Copyright 1996 John Harvey
+ * Copyright 1998 Andreas Mohr
+ * Copyright 1999 Klaas van Gend
+ * Copyright 1999, 2000 Huw D M Davies
+ * Copyright 2001 Marcus Meissner
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "wine/config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stddef.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wingdi.h"
+#include "winspool.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
+#include "winnls.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(winspool);
+
+/******************************************************************************
+ *             GetDefaultPrinterA   (WINSPOOL.@)
+ */
+BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize)
+{
+   char *ptr;
+
+   if (*namesize < 1)
+   {
+      SetLastError (ERROR_INSUFFICIENT_BUFFER);
+      return FALSE;
+   }
+
+   if (!GetProfileStringA ("windows", "device", "", name, *namesize))
+   {
+      SetLastError (ERROR_FILE_NOT_FOUND);
+      return FALSE;
+   }
+
+   if ((ptr = strchr (name, ',')) == NULL)
+   {
+      SetLastError (ERROR_FILE_NOT_FOUND);
+      return FALSE;
+   }
+
+   *ptr = '\0';
+   *namesize = strlen (name) + 1;
+   return TRUE;
+}
+
+
+/******************************************************************************
+ *             GetDefaultPrinterW   (WINSPOOL.@)
+ */
+BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
+{
+   char *buf;
+   BOOL  ret;
+
+   if (*namesize < 1)
+   {
+      SetLastError (ERROR_INSUFFICIENT_BUFFER);
+      return FALSE;
+   }
+
+   buf = HeapAlloc (GetProcessHeap (), 0, *namesize);
+   ret = GetDefaultPrinterA (buf, namesize);
+   if (ret)
+   {
+       DWORD len = MultiByteToWideChar (CP_ACP, 0, buf, -1, name, *namesize);
+       if (!len)
+       {
+           SetLastError (ERROR_INSUFFICIENT_BUFFER);
+           ret = FALSE;
+       }
+       else *namesize = len;
+   }
+
+   HeapFree (GetProcessHeap (), 0, buf);
+   return ret;
+}
index 63cc0ed..858f3c3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.2 2003/07/10 21:48:16 chorns Exp $
+/* $Id: stubs.c,v 1.3 2004/01/12 23:42:23 sedwards Exp $
  *
  * COPYRIGHT:   See COPYING in the top level directory
  * PROJECT:     ReactOS winspool DRV
@@ -8,6 +8,7 @@
  * REVISIONS:
  */
 
+#undef __USE_W32API
 #include <windows.h>
 
 /*
index 5395203..64cb258 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: winspool.def,v 1.1 2003/04/30 20:44:06 gvg Exp $
+; $Id: winspool.def,v 1.2 2004/01/12 23:42:23 sedwards Exp $
 ;
 ; winspool.drv - Printer spooler
 
@@ -76,6 +76,8 @@ FindClosePrinterChangeNotification@4
 FindFirstPrinterChangeNotification@16
 FindNextPrinterChangeNotification@16
 FreePrinterNotifyInfo@4
+GetDefaultPrinterA@8
+GetDefaultPrinterW@8
 GetFormA@24
 GetFormW@24
 GetJobA@24
index 1d8ccc0..0665d16 100644 (file)
-; $Id: winspool.edf,v 1.1 2003/04/30 20:44:06 gvg Exp $
+; $Id: winspool.edf,v 1.2 2004/01/12 23:42:23 sedwards Exp $
 ;
 ; winspool.drv - Printer spooler
 
 LIBRARY winspool.drv
 
 EXPORTS
-AbortPrinter=AbortPrinter@4\r
-AddFormA=AddFormA@12\r
-AddFormW=AddFormW@12\r
-AddJobA=AddJobA@20\r
-AddJobW=AddJobW@20\r
-AddMonitorA=AddMonitorA@12\r
-AddMonitorW=AddMonitorW@12\r
-AddPortA=AddPortA@12\r
-AddPortW=AddPortW@12\r
-AddPrinterA=AddPrinterA@12\r
-AddPrinterConnectionA=AddPrinterConnectionA@4\r
-AddPrinterConnectionW=AddPrinterConnectionW@4\r
-AddPrinterDriverA=AddPrinterDriverA@12\r
-AddPrinterDriverW=AddPrinterDriverW@12\r
-AddPrinterW=AddPrinterW@12\r
-AddPrintProcessorA=AddPrintProcessorA@16\r
-AddPrintProcessorW=AddPrintProcessorW@16\r
-AddPrintProvidorA=AddPrintProvidorA@12\r
-AddPrintProvidorW=AddPrintProvidorW@12\r
-AdvancedDocumentPropertiesA=AdvancedDocumentPropertiesA@20\r
-AdvancedDocumentPropertiesW=AdvancedDocumentPropertiesW@20\r
-ClosePrinter=ClosePrinter@4\r
-ConfigurePortA=ConfigurePortA@12\r
-ConfigurePortW=ConfigurePortW@12\r
-ConnectToPrinterDlg=ConnectToPrinterDlg@8\r
-DeleteFormA=DeleteFormA@8\r
-DeleteFormW=DeleteFormW@8\r
-DeleteMonitorA=DeleteMonitorA@12\r
-DeleteMonitorW=DeleteMonitorW@12\r
-DeletePortA=DeletePortA@12\r
-DeletePortW=DeletePortW@12\r
-DeletePrinter=DeletePrinter@4\r
-DeletePrinterConnectionA=DeletePrinterConnectionA@4\r
-DeletePrinterConnectionW=DeletePrinterConnectionW@4\r
-DeletePrinterDataA=DeletePrinterDataA@8\r
-DeletePrinterDataW=DeletePrinterDataW@8\r
-DeletePrinterDriverA=DeletePrinterDriverA@12\r
-DeletePrinterDriverW=DeletePrinterDriverW@12\r
-DeletePrintProcessorA=DeletePrintProcessorA@12\r
-DeletePrintProcessorW=DeletePrintProcessorW@12\r
-DeletePrintProvidorA=DeletePrintProvidorA@12\r
+AbortPrinter=AbortPrinter@4
+AddFormA=AddFormA@12
+AddFormW=AddFormW@12
+AddJobA=AddJobA@20
+AddJobW=AddJobW@20
+AddMonitorA=AddMonitorA@12
+AddMonitorW=AddMonitorW@12
+AddPortA=AddPortA@12
+AddPortW=AddPortW@12
+AddPrinterA=AddPrinterA@12
+AddPrinterConnectionA=AddPrinterConnectionA@4
+AddPrinterConnectionW=AddPrinterConnectionW@4
+AddPrinterDriverA=AddPrinterDriverA@12
+AddPrinterDriverW=AddPrinterDriverW@12
+AddPrinterW=AddPrinterW@12
+AddPrintProcessorA=AddPrintProcessorA@16
+AddPrintProcessorW=AddPrintProcessorW@16
+AddPrintProvidorA=AddPrintProvidorA@12
+AddPrintProvidorW=AddPrintProvidorW@12
+AdvancedDocumentPropertiesA=AdvancedDocumentPropertiesA@20
+AdvancedDocumentPropertiesW=AdvancedDocumentPropertiesW@20
+ClosePrinter=ClosePrinter@4
+ConfigurePortA=ConfigurePortA@12
+ConfigurePortW=ConfigurePortW@12
+ConnectToPrinterDlg=ConnectToPrinterDlg@8
+DeleteFormA=DeleteFormA@8
+DeleteFormW=DeleteFormW@8
+DeleteMonitorA=DeleteMonitorA@12
+DeleteMonitorW=DeleteMonitorW@12
+DeletePortA=DeletePortA@12
+DeletePortW=DeletePortW@12
+DeletePrinter=DeletePrinter@4
+DeletePrinterConnectionA=DeletePrinterConnectionA@4
+DeletePrinterConnectionW=DeletePrinterConnectionW@4
+DeletePrinterDataA=DeletePrinterDataA@8
+DeletePrinterDataW=DeletePrinterDataW@8
+DeletePrinterDriverA=DeletePrinterDriverA@12
+DeletePrinterDriverW=DeletePrinterDriverW@12
+DeletePrintProcessorA=DeletePrintProcessorA@12
+DeletePrintProcessorW=DeletePrintProcessorW@12
+DeletePrintProvidorA=DeletePrintProvidorA@12
 DeletePrintProvidorW=DeletePrintProvidorW@12
-DeviceCapabilitiesA=DeviceCapabilitiesA@20\r
-DeviceCapabilitiesW=DeviceCapabilitiesW@20\r
-DllMain=DllMain@12\r
-DocumentPropertiesA=DocumentPropertiesA@24\r
-DocumentPropertiesW=DocumentPropertiesW@24\r
-EndDocPrinter=EndDocPrinter@4\r
-EndPagePrinter=EndPagePrinter@4\r
-EnumFormsA=EnumFormsA@24\r
-EnumFormsW=EnumFormsW@24\r
-EnumJobsA=EnumJobsA@32\r
-EnumJobsW=EnumJobsW@32\r
-EnumMonitorsA=EnumMonitorsA@24\r
-EnumMonitorsW=EnumMonitorsW@24\r
-EnumPortsA=EnumPortsA@24\r
-EnumPortsW=EnumPortsW@24\r
-EnumPrinterDataA=EnumPrinterDataA@36\r
-EnumPrinterDataW=EnumPrinterDataW@36\r
-EnumPrinterDriversA=EnumPrinterDriversA@28\r
-EnumPrinterDriversW=EnumPrinterDriversW@28\r
-EnumPrintersA=EnumPrintersA@28\r
-EnumPrintersW=EnumPrintersW@28\r
-EnumPrintProcessorDatatypesA=EnumPrintProcessorDatatypesA@28\r
-EnumPrintProcessorDatatypesW=EnumPrintProcessorDatatypesW@28\r
-EnumPrintProcessorsA=EnumPrintProcessorsA@28\r
-EnumPrintProcessorsW=EnumPrintProcessorsW@28\r
-FindClosePrinterChangeNotification=FindClosePrinterChangeNotification@4\r
-FindFirstPrinterChangeNotification=FindFirstPrinterChangeNotification@16\r
-FindNextPrinterChangeNotification=FindNextPrinterChangeNotification@16\r
-FreePrinterNotifyInfo=FreePrinterNotifyInfo@4\r
-GetFormA=GetFormA@24\r
-GetFormW=GetFormW@24\r
-GetJobA=GetJobA@24\r
-GetJobW=GetJobW@24\r
-GetPrinterA=GetPrinterA@20\r
-GetPrinterDataA=GetPrinterDataA@24\r
-GetPrinterDataW=GetPrinterDataW@24\r
-GetPrinterDriverA=GetPrinterDriverA@24\r
-GetPrinterDriverDirectoryA=GetPrinterDriverDirectoryA@24\r
-GetPrinterDriverDirectoryW=GetPrinterDriverDirectoryW@24\r
-GetPrinterDriverW=GetPrinterDriverW@24\r
-GetPrinterW=GetPrinterW@20\r
-GetPrintProcessorDirectoryA=GetPrintProcessorDirectoryA@24\r
-GetPrintProcessorDirectoryW=GetPrintProcessorDirectoryW@24\r
-OpenPrinterA=OpenPrinterA@12\r
-OpenPrinterW=OpenPrinterW@12\r
-PrinterMessageBoxA=PrinterMessageBoxA@24\r
-PrinterMessageBoxW=PrinterMessageBoxW@24\r
-PrinterProperties=PrinterProperties@8\r
-ReadPrinter=ReadPrinter@16\r
-ResetPrinterA=ResetPrinterA@8\r
-ResetPrinterW=ResetPrinterW@8\r
-ScheduleJob=ScheduleJob@8\r
-SetFormA=SetFormA@16\r
-SetFormW=SetFormW@16\r
-SetJobA=SetJobA@20\r
-SetJobW=SetJobW@20\r
-SetPrinterA=SetPrinterA@16\r
-SetPrinterDataA=SetPrinterDataA@20\r
-SetPrinterDataW=SetPrinterDataW@20\r
-SetPrinterW=SetPrinterW@16\r
-StartDocPrinterA=StartDocPrinterA@12\r
-StartDocPrinterW=StartDocPrinterW@12\r
-StartPagePrinter=StartPagePrinter@4\r
-WaitForPrinterChange=WaitForPrinterChange@8\r
-WritePrinter=WritePrinter@16\r
+DeviceCapabilitiesA=DeviceCapabilitiesA@20
+DeviceCapabilitiesW=DeviceCapabilitiesW@20
+DllMain=DllMain@12
+DocumentPropertiesA=DocumentPropertiesA@24
+DocumentPropertiesW=DocumentPropertiesW@24
+EndDocPrinter=EndDocPrinter@4
+EndPagePrinter=EndPagePrinter@4
+EnumFormsA=EnumFormsA@24
+EnumFormsW=EnumFormsW@24
+EnumJobsA=EnumJobsA@32
+EnumJobsW=EnumJobsW@32
+EnumMonitorsA=EnumMonitorsA@24
+EnumMonitorsW=EnumMonitorsW@24
+EnumPortsA=EnumPortsA@24
+EnumPortsW=EnumPortsW@24
+EnumPrinterDataA=EnumPrinterDataA@36
+EnumPrinterDataW=EnumPrinterDataW@36
+EnumPrinterDriversA=EnumPrinterDriversA@28
+EnumPrinterDriversW=EnumPrinterDriversW@28
+EnumPrintersA=EnumPrintersA@28
+EnumPrintersW=EnumPrintersW@28
+EnumPrintProcessorDatatypesA=EnumPrintProcessorDatatypesA@28
+EnumPrintProcessorDatatypesW=EnumPrintProcessorDatatypesW@28
+EnumPrintProcessorsA=EnumPrintProcessorsA@28
+EnumPrintProcessorsW=EnumPrintProcessorsW@28
+FindClosePrinterChangeNotification=FindClosePrinterChangeNotification@4
+FindFirstPrinterChangeNotification=FindFirstPrinterChangeNotification@16
+FindNextPrinterChangeNotification=FindNextPrinterChangeNotification@16
+FreePrinterNotifyInfo=FreePrinterNotifyInfo@4
+GetDefaultPrinterA=GetDefaultPrinterA@8
+GetDefaultPrinterW=GetDefaultPrinterW@8
+GetFormA=GetFormA@24
+GetFormW=GetFormW@24
+GetJobA=GetJobA@24
+GetJobW=GetJobW@24
+GetPrinterA=GetPrinterA@20
+GetPrinterDataA=GetPrinterDataA@24
+GetPrinterDataW=GetPrinterDataW@24
+GetPrinterDriverA=GetPrinterDriverA@24
+GetPrinterDriverDirectoryA=GetPrinterDriverDirectoryA@24
+GetPrinterDriverDirectoryW=GetPrinterDriverDirectoryW@24
+GetPrinterDriverW=GetPrinterDriverW@24
+GetPrinterW=GetPrinterW@20
+GetPrintProcessorDirectoryA=GetPrintProcessorDirectoryA@24
+GetPrintProcessorDirectoryW=GetPrintProcessorDirectoryW@24
+OpenPrinterA=OpenPrinterA@12
+OpenPrinterW=OpenPrinterW@12
+PrinterMessageBoxA=PrinterMessageBoxA@24
+PrinterMessageBoxW=PrinterMessageBoxW@24
+PrinterProperties=PrinterProperties@8
+ReadPrinter=ReadPrinter@16
+ResetPrinterA=ResetPrinterA@8
+ResetPrinterW=ResetPrinterW@8
+ScheduleJob=ScheduleJob@8
+SetFormA=SetFormA@16
+SetFormW=SetFormW@16
+SetJobA=SetJobA@20
+SetJobW=SetJobW@20
+SetPrinterA=SetPrinterA@16
+SetPrinterDataA=SetPrinterDataA@20
+SetPrinterDataW=SetPrinterDataW@20
+SetPrinterW=SetPrinterW@16
+StartDocPrinterA=StartDocPrinterA@12
+StartDocPrinterW=StartDocPrinterW@12
+StartPagePrinter=StartPagePrinter@4
+WaitForPrinterChange=WaitForPrinterChange@8
+WritePrinter=WritePrinter@16