- Timestamp:
- Nov 15, 2000, 11:54:24 AM (25 years ago)
- Location:
- trunk/src/winspool
- Files:
-
- 2 added
- 3 edited
-
makefile (modified) (2 diffs)
-
oslibspl.cpp (added)
-
oslibspl.h (added)
-
winspool.DEF (modified) (2 diffs)
-
winspool.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winspool/makefile
r4527 r4594 1 # $Id: makefile,v 1.1 6 2000-10-25 19:47:43 sandervl Exp $1 # $Id: makefile,v 1.17 2000-11-15 10:54:23 sandervl Exp $ 2 2 3 3 # … … 25 25 OBJS = \ 26 26 $(OBJDIR)\winspool.obj \ 27 $(OBJDIR)\oslibspl.obj \ 27 28 $(OBJDIR)\winspoolrsrc.obj \ 28 29 $(PDWIN32_LIB)\dllentry.obj -
trunk/src/winspool/winspool.DEF
r2217 r4594 1 ; $Id: winspool.DEF,v 1. 3 1999-12-27 18:45:27sandervl Exp $1 ; $Id: winspool.DEF,v 1.4 2000-11-15 10:54:24 sandervl Exp $ 2 2 3 3 ; … … 63 63 ; DevQueryPrint @157 64 64 ; DevQueryPrintEx @158 65 ; DeviceCapabilities@15965 DeviceCapabilities = _DeviceCapabilitiesA@20 @159 66 66 DeviceCapabilitiesA = _DeviceCapabilitiesA@20 @160 67 67 DeviceCapabilitiesW = _DeviceCapabilitiesW@20 @161 -
trunk/src/winspool/winspool.cpp
r2217 r4594 1 /* $Id: winspool.cpp,v 1. 4 1999-12-27 18:45:27sandervl Exp $ */1 /* $Id: winspool.cpp,v 1.5 2000-11-15 10:54:24 sandervl Exp $ */ 2 2 3 3 /* … … 8 8 * 9 9 * Copyright 1998 Patrick Haller 10 * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl) 11 * 12 * 13 * Partially based on Wine code (dlls\winspool\info.c (EnumPrinters, DeviceCapabilitiesA/W) 14 * 15 * Copyright 1996 John Harvey 16 * Copyright 1998 Andreas Mohr 17 * Copyright 1999 Klaas van Gend 18 * Copyright 1999, 2000 Huw D M Davies 19 * 20 * TODO: far from complete (although the Spl API seems to provide everything we need!) 10 21 * 11 22 */ … … 18 29 #include <winspool.h> 19 30 #include <odinwrap.h> 31 #include <heapstring.h> 32 #include <win\winnls.h> 20 33 21 34 #include <stdio.h> 22 35 #include <stdlib.h> 23 36 #include <string.h> 24 #include "misc.h"25 37 #include <misc.h> 38 #include "oslibspl.h" 26 39 27 40 ODINDEBUGCHANNEL(WINSPOOL) … … 35 48 * Result : 36 49 * Remark : 37 * Status : UNTESTED STUB38 * 39 * Author : Markus Montkowski [09.07.98 13:39:08]50 * Status : 51 * 52 * Author : SvL 40 53 *****************************************************************************/ 41 54 … … 49 62 LPDWORD, lpdwReturned) 50 63 { 51 return(O32_EnumPrinters(dwType, 52 lpszName, 53 dwLevel, 54 lpbPrinters, 55 cbBuf, 56 lpdwNeeded, 57 lpdwReturned)); 64 ULONG cReturned, cTotal, cbNeeded, flType; 65 int used, nameoff; 66 OSLIB_PRINTERINFO *printerInfo; 67 PRINTER_INFO_1A *pi1; 68 PRINTER_INFO_2A *pi2; 69 PRINTER_INFO_4A *pi4; 70 PRINTER_INFO_5A *pi5; 71 LPSTR lpszPrinterStrings; 72 73 if(lpbPrinters) 74 memset(lpbPrinters, 0, cbBuf); 75 76 if(lpdwReturned) 77 *lpdwReturned = 0; 78 79 if (!((dwType & PRINTER_ENUM_LOCAL) || (dwType & PRINTER_ENUM_NAME))) 80 { 81 dprintf(("Invalid parameters !(PRINTER_ENUM_LOCAL & PRINTER_ENUM_NAME)!!")); 82 SetLastError(ERROR_INVALID_FLAGS); 83 return FALSE; 84 } 85 86 if(lpszName) {//TODO: 87 dprintf(("remote printer enumeration not (yet) supported!!")); 88 flType = OSLIB_SPL_PR_ALL; 89 } 90 else flType = OSLIB_SPL_PR_LOCAL_ONLY | OSLIB_SPL_PR_ALL; 91 92 if(OSLibSplEnumPrinters(flType, NULL, 0, &cReturned, &cTotal, &cbNeeded) == FALSE) { 93 SetLastError(ERROR_FILE_NOT_FOUND); //todo wrong error 94 return FALSE; 95 } 96 if(cTotal == 0) {//no printers installed 97 SetLastError(ERROR_SUCCESS); 98 return TRUE; 99 } 100 101 switch(dwLevel) { 102 case 1: 103 used = cTotal * sizeof(PRINTER_INFO_1A); 104 break; 105 106 case 2: 107 used = cTotal * sizeof(PRINTER_INFO_2A); 108 break; 109 110 case 4: 111 used = cTotal * sizeof(PRINTER_INFO_4A); 112 break; 113 114 case 5: 115 used = cTotal * sizeof(PRINTER_INFO_5A); 116 break; 117 118 default: 119 dprintf(("ERROR: EnumPrintersA: Unknown level %d!", dwLevel)); 120 SetLastError(ERROR_INVALID_LEVEL); 121 return FALSE; 122 } 123 nameoff = used; 124 used += cbNeeded; //add size of printer names 125 126 if(used > cbBuf) { 127 if(lpdwNeeded) 128 *lpdwNeeded = used; 129 SetLastError(ERROR_INSUFFICIENT_BUFFER); 130 return FALSE; 131 } 132 133 printerInfo = (OSLIB_PRINTERINFO *)malloc(cbNeeded); 134 if(OSLibSplEnumPrinters(flType, printerInfo, cbNeeded, &cReturned, &cTotal, &cbNeeded) == FALSE) { 135 free(printerInfo); 136 SetLastError(ERROR_FILE_NOT_FOUND); 137 return FALSE; 138 } 139 lpszPrinterStrings = (char *)lpbPrinters + nameoff; 140 141 for(int i=0;i<cReturned;i++) { 142 switch(dwLevel) { 143 case 1: 144 pi1 = (PRINTER_INFO_1A *)lpbPrinters; 145 lpbPrinters += sizeof(PRINTER_INFO_1A); 146 147 pi1->Flags = PRINTER_ENUM_ICON8; 148 pi1->pName = lpszPrinterStrings; 149 strcpy(lpszPrinterStrings, printerInfo[i].pszPrintDestinationName); 150 lpszPrinterStrings += strlen(printerInfo[i].pszPrintDestinationName)+1; 151 152 if(printerInfo[i].pszDescription) { 153 pi1->pDescription = lpszPrinterStrings; 154 strcpy(lpszPrinterStrings, printerInfo[i].pszDescription); 155 lpszPrinterStrings += strlen(printerInfo[i].pszDescription)+1; 156 } 157 //pComment empty 158 break; 159 160 case 2: 161 pi2 = (PRINTER_INFO_2A *)lpbPrinters; 162 lpbPrinters += sizeof(PRINTER_INFO_2A); 163 164 pi2->pPrinterName = lpszPrinterStrings; 165 strcpy(lpszPrinterStrings, printerInfo[i].pszPrintDestinationName); 166 lpszPrinterStrings += strlen(printerInfo[i].pszPrintDestinationName)+1; 167 pi2->pDriverName = pi2->pPrinterName; //TODO:might not be correct! 168 169 if(printerInfo[i].pszLocalName) { 170 pi2->pPortName = lpszPrinterStrings; 171 strcpy(lpszPrinterStrings, printerInfo[i].pszLocalName); 172 lpszPrinterStrings += strlen(printerInfo[i].pszLocalName)+1; 173 } 174 175 if(printerInfo[i].pszComputerName) { 176 pi2->pServerName = lpszPrinterStrings; 177 strcpy(lpszPrinterStrings, printerInfo[i].pszComputerName); 178 lpszPrinterStrings += strlen(printerInfo[i].pszComputerName)+1; 179 } 180 181 pi2->Attributes = PRINTER_ATTRIBUTE_QUEUED; //todo 182 183 dprintf(("EnumPrinters level 2 NOT COMPLETE!!")); 184 //todo not complete 185 break; 186 187 case 4: 188 pi4 = (PRINTER_INFO_4A *)lpbPrinters; 189 lpbPrinters += sizeof(PRINTER_INFO_4A); 190 191 pi4->Attributes = PRINTER_ATTRIBUTE_QUEUED; //todo 192 pi4->pPrinterName = lpszPrinterStrings; 193 strcpy(lpszPrinterStrings, printerInfo[i].pszPrintDestinationName); 194 lpszPrinterStrings += strlen(printerInfo[i].pszPrintDestinationName)+1; 195 196 if(printerInfo[i].pszComputerName) { 197 pi4->pServerName = lpszPrinterStrings; 198 strcpy(lpszPrinterStrings, printerInfo[i].pszComputerName); 199 lpszPrinterStrings += strlen(printerInfo[i].pszComputerName)+1; 200 } 201 dprintf(("EnumPrinters level 4 NOT COMPLETE!!")); 202 break; 203 204 case 5: 205 pi5 = (PRINTER_INFO_5A *)lpbPrinters; 206 lpbPrinters += sizeof(PRINTER_INFO_5A); 207 208 pi5->Attributes = PRINTER_ATTRIBUTE_QUEUED; //todo 209 pi5->pPrinterName = lpszPrinterStrings; 210 strcpy(lpszPrinterStrings, printerInfo[i].pszPrintDestinationName); 211 lpszPrinterStrings += strlen(printerInfo[i].pszPrintDestinationName)+1; 212 213 if(printerInfo[i].pszLocalName) { 214 pi5->pPortName = lpszPrinterStrings; 215 strcpy(lpszPrinterStrings, printerInfo[i].pszLocalName); 216 lpszPrinterStrings += strlen(printerInfo[i].pszLocalName)+1; 217 } 218 dprintf(("EnumPrinters level 5 NOT COMPLETE!!")); 219 break; 220 } 221 } 222 free(printerInfo); 223 224 if(lpdwNeeded) 225 *lpdwNeeded = used; 226 227 if(lpdwReturned) 228 *lpdwReturned = cReturned; 229 SetLastError(ERROR_SUCCESS); 230 return TRUE; 58 231 } 59 232 … … 759 932 760 933 934 /*********************************************************** 935 * DEVMODEdupWtoA 936 * Creates an ascii copy of supplied devmode on heap 937 */ 938 static LPDEVMODEA DEVMODEdupWtoA(HANDLE heap, const DEVMODEW *dmW) 939 { 940 LPDEVMODEA dmA; 941 DWORD size; 942 BOOL Formname; 943 ptrdiff_t off_formname = (char *)dmW->dmFormName - (char *)dmW; 944 945 if(!dmW) return NULL; 946 Formname = (dmW->dmSize > off_formname); 947 size = dmW->dmSize - CCHDEVICENAME - (Formname ? CCHFORMNAME : 0); 948 dmA = (LPDEVMODEA)HeapAlloc(heap, HEAP_ZERO_MEMORY, size + dmW->dmDriverExtra); 949 WideCharToMultiByte(CP_ACP, 0, dmW->dmDeviceName, -1, (LPSTR)dmA->dmDeviceName, 950 CCHDEVICENAME, NULL, NULL); 951 if(!Formname) { 952 memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion, 953 dmW->dmSize - CCHDEVICENAME * sizeof(WCHAR)); 954 } else { 955 memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion, 956 off_formname - CCHDEVICENAME * sizeof(WCHAR)); 957 WideCharToMultiByte(CP_ACP, 0, dmW->dmFormName, -1, (LPSTR)dmA->dmFormName, 958 CCHFORMNAME, NULL, NULL); 959 memcpy(&dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize - 960 (off_formname + CCHFORMNAME * sizeof(WCHAR))); 961 } 962 dmA->dmSize = size; 963 memcpy((char *)dmA + dmA->dmSize, (char *)dmW + dmW->dmSize, 964 dmW->dmDriverExtra); 965 return dmA; 966 } 967 761 968 /***************************************************************************** 762 969 * Name : DWORD DeviceCapabilitiesA … … 784 991 DEVMODEA *, pDevMode) 785 992 { 786 dprintf(("WINSPOOL: DeviceCapabilitiesA not implemented\n")); 787 return (0); 788 } 789 790 791 /***************************************************************************** 792 * Name : DWORD DeviceCapabilitiesW 793 * Purpose : 794 * Parameters: LPCWSTR pDevice pointer to a printer-name string 795 * LPCWSTR pPort pointer to a port-name string 796 * WORD fwCapability device capability to query 797 * LPWSTR pOutput pointer to the output 798 * CONST DEVMODEW *pDevMode pointer to structure with device data 799 * Variables : 800 * Result : 801 * Remark : 802 * Status : UNTESTED STUB 803 * 804 * Stub Generated through PE2LX Stubwizard 0.02 from Markus Montkowski 805 * 806 * Author : Markus Montkowski [09.07.98 14:27:08] 807 *****************************************************************************/ 808 809 ODINFUNCTION5(INT, DeviceCapabilitiesW, 810 LPCWSTR, pDevice, 811 LPCWSTR, pPort, 812 WORD, fwCapability, 813 LPWSTR, pOutput, 814 CONST DEVMODEW *, pDevMode) 815 { 816 dprintf(("WINSPOOL: DeviceCapabilitiesW not implemented\n")); 817 return (0); 993 dprintf(("WINSPOOL: DeviceCapabilitiesA %s %s %x %x %x", pDevice, pPort, fwCapability, pOutput, pDevMode)); 994 return O32_DeviceCapabilities(pDevice, pPort, fwCapability, pOutput, pDevMode); 995 } 996 997 998 /***************************************************************************** 999 * DeviceCapabilitiesW [WINSPOOL.152] 1000 * 1001 * Call DeviceCapabilitiesA since we later call 16bit stuff anyway 1002 * 1003 */ 1004 ODINFUNCTION5(INT, DeviceCapabilitiesW, LPCWSTR, pDevice, LPCWSTR, pPort, 1005 WORD, fwCapability, LPWSTR, pOutput, 1006 CONST DEVMODEW *, pDevMode) 1007 { 1008 LPDEVMODEA dmA = DEVMODEdupWtoA(GetProcessHeap(), pDevMode); 1009 LPSTR pDeviceA = HEAP_strdupWtoA(GetProcessHeap(),0,pDevice); 1010 LPSTR pPortA = HEAP_strdupWtoA(GetProcessHeap(),0,pPort); 1011 INT ret; 1012 1013 if(pOutput && (fwCapability == DC_BINNAMES || 1014 fwCapability == DC_FILEDEPENDENCIES || 1015 fwCapability == DC_PAPERNAMES)) { 1016 /* These need A -> W translation */ 1017 INT size = 0, i; 1018 LPSTR pOutputA; 1019 ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability, NULL, 1020 dmA); 1021 if(ret == -1) 1022 return ret; 1023 switch(fwCapability) { 1024 case DC_BINNAMES: 1025 size = 24; 1026 break; 1027 case DC_PAPERNAMES: 1028 case DC_FILEDEPENDENCIES: 1029 size = 64; 1030 break; 1031 } 1032 pOutputA = (LPSTR)HeapAlloc(GetProcessHeap(), 0, size * ret); 1033 ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability, pOutputA, 1034 dmA); 1035 for(i = 0; i < ret; i++) 1036 MultiByteToWideChar(CP_ACP, 0, pOutputA + (i * size), -1, 1037 pOutput + (i * size), size); 1038 HeapFree(GetProcessHeap(), 0, pOutputA); 1039 } else { 1040 ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability, 1041 (LPSTR)pOutput, dmA); 1042 } 1043 HeapFree(GetProcessHeap(),0,pPortA); 1044 HeapFree(GetProcessHeap(),0,pDeviceA); 1045 HeapFree(GetProcessHeap(),0,dmA); 1046 return ret; 818 1047 } 819 1048 … … 2833 3062 */ 2834 3063 ODINFUNCTION2(DWORD, DeletePrinterDataA, 2835 HANDLE, hPrinter,2836 LPSTR, pValueName)3064 HANDLE, hPrinter, 3065 LPSTR, pValueName) 2837 3066 { 2838 3067 dprintf(("WINSPOOL: DeletePrinterDataA not implemented\n")); … … 2845 3074 */ 2846 3075 ODINFUNCTION2(DWORD, DeletePrinterDataW, 2847 HANDLE, hPrinter,2848 LPWSTR, pValueName)3076 HANDLE, hPrinter, 3077 LPWSTR, pValueName) 2849 3078 { 2850 3079 dprintf(("WINSPOOL: DeletePrinterDataW not implemented\n")); … … 2857 3086 */ 2858 3087 ODINFUNCTION6(LONG, DocumentPropertiesW, 2859 HWND, hWnd,2860 HANDLE, hPrinter,2861 LPWSTR, pDeviceName,2862 PDEVMODEW, pDevModeOutput,2863 PDEVMODEW, pDevModeInput,2864 DWORD, fMode)3088 HWND, hWnd, 3089 HANDLE, hPrinter, 3090 LPWSTR, pDeviceName, 3091 PDEVMODEW, pDevModeOutput, 3092 PDEVMODEW, pDevModeInput, 3093 DWORD, fMode) 2865 3094 { 2866 3095 dprintf(("WINSPOOL: DocumentPropertiesW not implemented\n"));
Note:
See TracChangeset
for help on using the changeset viewer.
