summaryrefslogtreecommitdiffstats
path: root/testprogs/win32/spoolss
diff options
context:
space:
mode:
Diffstat (limited to 'testprogs/win32/spoolss')
-rw-r--r--testprogs/win32/spoolss/GNUmakefile23
-rw-r--r--testprogs/win32/spoolss/NMakefile43
-rw-r--r--testprogs/win32/spoolss/README.win3265
-rw-r--r--testprogs/win32/spoolss/error.c137
-rw-r--r--testprogs/win32/spoolss/error.h36
-rw-r--r--testprogs/win32/spoolss/printlib.c1386
-rw-r--r--testprogs/win32/spoolss/printlib_proto.h67
-rw-r--r--testprogs/win32/spoolss/string.h15
-rw-r--r--testprogs/win32/spoolss/testspoolss.c1842
-rw-r--r--testprogs/win32/spoolss/testspoolss.h51
-rw-r--r--testprogs/win32/spoolss/testspoolss.sln20
-rw-r--r--testprogs/win32/spoolss/testspoolss.vcproj224
-rw-r--r--testprogs/win32/spoolss/torture.c106
-rw-r--r--testprogs/win32/spoolss/torture.h92
-rw-r--r--testprogs/win32/spoolss/torture_proto.h32
15 files changed, 4139 insertions, 0 deletions
diff --git a/testprogs/win32/spoolss/GNUmakefile b/testprogs/win32/spoolss/GNUmakefile
new file mode 100644
index 0000000..0321a65
--- /dev/null
+++ b/testprogs/win32/spoolss/GNUmakefile
@@ -0,0 +1,23 @@
+CFLAGS=-I../../../
+MINGW_CC = i586-mingw32msvc-cc
+CC = $(MINGW_CC)
+
+LIBS=-lwinspool
+
+all: testspoolss.exe
+
+clean:
+ rm -vf *.exe tags
+
+ctags:
+ ctags `find . -name "*.[ch]" | grep -v include/proto.h`
+ ctags --c-kinds=-p -a `find /usr/i686-pc-mingw32/sys-root/mingw/include -name "*.[ch]" | grep -v /CVS/`
+
+proto:
+ mkproto.pl printlib.c --private=printlib_proto.h --public=printlib_proto_pub.h --srcdir=. --builddir=.
+ mkproto.pl torture.c --private=torture_proto.h --public=torture_proto_pub.h --srcdir=. --builddir=.
+
+testspoolss.exe: testspoolss.c printlib.c torture.c error.c
+ @echo Compiling testspoolss.exe
+ @$(CC) $(CFLAGS) $(LDFLAGS) testspoolss.c printlib.c torture.c error.c $(LIBS) -o testspoolss.exe
+
diff --git a/testprogs/win32/spoolss/NMakefile b/testprogs/win32/spoolss/NMakefile
new file mode 100644
index 0000000..949104e
--- /dev/null
+++ b/testprogs/win32/spoolss/NMakefile
@@ -0,0 +1,43 @@
+#
+# use nmake /f NMakefile [<target>]
+#
+CFLAGS = /nologo /Zi /MT /Gm- /W4 /FR /D_CRT_SECURE_NO_WARNINGS
+LIBS = kernel32.lib gdi32.lib user32.lib shell32.lib \
+ advapi32.lib ole32.lib ws2_32.lib rpcrt4.lib
+WINSPOOL_LIBS = winspool.lib
+
+all: testspoolss.exe
+
+.cpp.obj:
+ cl /c $(CFLAGS) $*.cpp
+
+.c.obj:
+ cl /c $(CFLAGS) $*.c
+
+clean: cleantmp
+ -del *.dll 2>nul
+
+cleantmp:
+ -del *~ *.o *.obj *.sbr *.bsc *.pdb *.lib *.ilk *.exp 2>nul
+ -del test_s.c test_c.c test.h 2>nul
+
+###############################
+# helpers
+###############################
+
+printlib.obj: printlib.c
+
+error.obj: error.c
+
+torture.obj: torture.c
+
+###############################
+# binaries
+###############################
+
+testspoolss.obj: testspoolss.c
+
+testspoolss.exe: testspoolss.obj printlib.obj error.obj torture.obj
+ cl $(CFLAGS) /Fe$@ testspoolss.obj printlib.obj error.obj torture.obj \
+ /link /incremental:no /subsystem:console $(LIBS) $(WINSPOOL_LIBS)
+
diff --git a/testprogs/win32/spoolss/README.win32 b/testprogs/win32/spoolss/README.win32
new file mode 100644
index 0000000..f43a9c7
--- /dev/null
+++ b/testprogs/win32/spoolss/README.win32
@@ -0,0 +1,65 @@
+
+This directory holds sources for a Win32 test utility to test the "spoolss"
+(print spool subsystem) functions of either a Windows or a Samba server. The
+sources are known to build with (free as in beer) Microsoft Visual C++ 2008
+Express Edition's "nmake.exe" on Windows XP Professional.
+
+
+How to build
+------------
+
+Use the Microsoft "nmake" command to build the *.exe. This command is in your
+%path% if you start the "Visual Studio 2008 Command Prompt" from your Start
+menu.
+
+Currently the real build target is named "testspoolss.exe". Run
+
+ nmake /f Makefile
+
+to build the testspoolss.exe. After a successful build you may want to clean up
+temporary files:
+
+ nmake /f Makefile cleantmp
+
+
+How to use
+----------
+
+Running testspoolss.exe with no additional params displays a short usage info.
+
+..............................................................................
+usage: testspoolss.exe <name> [print] [samba3] [architecture=ARCHITECTURE]
+
+ <name> can be a server or printer name URI
+ [print] will print all data that has been retrieved
+ from the printserver
+ [samba3] will skip some tests samba servers are known
+ not to have implemented
+ [architecture=X] allows one to define a specific
+ architecture to test with. choose between:
+ "Windows NT x86" or "Windows x64"
+..............................................................................
+
+The utility may be most useful if you use the "print" parameter to output all
+data received from the print server. You may re-direct the data into log files
+for later evaluation like this:
+
+ testspoolss.exe \\smbserver print samba3 1>smbserver.log 2>smbserver.err
+ testspoolss.exe \\smbserver print 1>smbserver.log 2>smbserver.err
+ testspoolss.exe \\winserver print 1>winserver.log 2>winserver.err
+
+One interesting source of learning could be to compare the output for (maybe
+"the same") printers/drivers as installed on a Windows and on a Samba print
+server:
+
+ testspoolss.exe \\winserver\printername print 1>winprinter.log 2>winprinter.err
+ testspoolss.exe \\smbserver\printername print 1>smbprinter.log 2>smbprinter.err
+
+and then compare the respective log files with a diff utility of your choice.
+To install "the same" printer/driver on a Samba server as on a Windows server,
+you can use the Samba "net" utility, which has the following syntax:
+
+ net rpc printer MIGRATE PRINTERS printername \
+ --server=winserver \
+ --destination=smbserver \
+ -UAdministrator%secretpassword
diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c
new file mode 100644
index 0000000..3f96594
--- /dev/null
+++ b/testprogs/win32/spoolss/error.c
@@ -0,0 +1,137 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "testspoolss.h"
+
+const char *errstr(DWORD error)
+{
+ static char tmp[20];
+
+ switch (error) {
+ case ERROR_FILE_NOT_FOUND:
+ return "ERROR_FILE_NOT_FOUND";
+ case ERROR_ACCESS_DENIED:
+ return "ERROR_ACCESS_DENIED";
+ case ERROR_INVALID_PARAMETER:
+ return "ERROR_INVALID_PARAMETER";
+ case ERROR_INVALID_HANDLE:
+ return "ERROR_INVALID_HANDLE";
+ case ERROR_CALL_NOT_IMPLEMENTED:
+ return "ERROR_CALL_NOT_IMPLEMENTED";
+ case ERROR_INSUFFICIENT_BUFFER:
+ return "ERROR_INSUFFICIENT_BUFFER";
+ case ERROR_INVALID_NAME:
+ return "ERROR_INVALID_NAME";
+ case ERROR_INVALID_LEVEL:
+ return "ERROR_INVALID_LEVEL";
+ case ERROR_INVALID_DATA:
+ return "ERROR_INVALID_DATA";
+ case ERROR_MORE_DATA:
+ return "ERROR_MORE_DATA";
+ case ERROR_NO_MORE_ITEMS:
+ return "ERROR_NO_MORE_ITEMS";
+#ifdef ERROR_INVALID_DATATYPE
+ case ERROR_INVALID_DATATYPE:
+ return "ERROR_INVALID_DATATYPE";
+#endif
+ case ERROR_INVALID_ENVIRONMENT:
+ return "ERROR_INVALID_ENVIRONMENT";
+ case ERROR_INVALID_PRINTER_COMMAND:
+ return "ERROR_INVALID_PRINTER_COMMAND";
+ case ERROR_PRINTER_ALREADY_EXISTS:
+ return "ERROR_PRINTER_ALREADY_EXISTS";
+ case ERROR_INVALID_PRINTER_NAME:
+ return "ERROR_INVALID_PRINTER_NAME";
+ case ERROR_INVALID_PRIORITY:
+ return "ERROR_INVALID_PRIORITY";
+ case ERROR_INVALID_SEPARATOR_FILE:
+ return "ERROR_INVALID_SEPARATOR_FILE";
+ case ERROR_UNKNOWN_PRINTPROCESSOR:
+ return "ERROR_UNKNOWN_PRINTPROCESSOR";
+ case ERROR_UNKNOWN_PRINTER_DRIVER:
+ return "ERROR_UNKNOWN_PRINTER_DRIVER";
+ case ERROR_UNKNOWN_PORT:
+ return "ERROR_UNKNOWN_PORT";
+ case ERROR_PRINTER_DRIVER_ALREADY_INSTALLED:
+ return "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED";
+ case ERROR_UNKNOWN_PRINT_MONITOR:
+ return "ERROR_UNKNOWN_PRINT_MONITOR";
+ case ERROR_PRINTER_DRIVER_IN_USE:
+ return "ERROR_PRINTER_DRIVER_IN_USE";
+ case ERROR_SPOOL_FILE_NOT_FOUND:
+ return "ERROR_SPOOL_FILE_NOT_FOUND";
+ case ERROR_SPL_NO_STARTDOC:
+ return "ERROR_SPL_NO_STARTDOC";
+ case ERROR_SPL_NO_ADDJOB:
+ return "ERROR_SPL_NO_ADDJOB";
+ case ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED:
+ return "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED";
+ case ERROR_PRINT_MONITOR_ALREADY_INSTALLED:
+ return "ERROR_PRINT_MONITOR_ALREADY_INSTALLED";
+ case ERROR_INVALID_PRINT_MONITOR:
+ return "ERROR_INVALID_PRINT_MONITOR";
+ case ERROR_PRINT_MONITOR_IN_USE:
+ return "ERROR_PRINT_MONITOR_IN_USE";
+ case ERROR_PRINTER_HAS_JOBS_QUEUED:
+ return "ERROR_PRINTER_HAS_JOBS_QUEUED";
+ case ERROR_PRINTER_NOT_FOUND:
+ return "ERROR_PRINTER_NOT_FOUND";
+ case ERROR_PRINTER_DRIVER_WARNED:
+ return "ERROR_PRINTER_DRIVER_WARNED";
+ case ERROR_PRINTER_DRIVER_BLOCKED:
+ return "ERROR_PRINTER_DRIVER_BLOCKED";
+#ifdef ERROR_PRINTER_DRIVER_PACKAGE_IN_USE
+ case ERROR_PRINTER_DRIVER_PACKAGE_IN_USE:
+ return "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE";
+#endif
+#ifdef ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND
+ case ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND:
+ return "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND";
+#endif
+#ifdef ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED
+ case ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED:
+ return "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED";
+#endif
+#ifdef ERROR_PRINT_JOB_RESTART_REQUIRED
+ case ERROR_PRINT_JOB_RESTART_REQUIRED:
+ return "ERROR_PRINT_JOB_RESTART_REQUIRED";
+#endif
+ case ERROR_CANCELLED:
+ return "ERROR_CANCELLED";
+ case ERROR_NOACCESS:
+ return "ERROR_NOACCESS";
+ case RPC_X_NULL_REF_POINTER:
+ return "RPC_X_NULL_REF_POINTER";
+ case RPC_S_PROCNUM_OUT_OF_RANGE:
+ return "RPC_S_PROCNUM_OUT_OF_RANGE";
+ case RPC_S_SERVER_UNAVAILABLE:
+ return "RPC_S_SERVER_UNAVAILABLE";
+ case RPC_S_INVALID_NET_ADDR:
+ return "RPC_S_INVALID_NET_ADDR";
+ case RPC_S_CALL_FAILED:
+ return "RPC_S_CALL_FAILED";
+ default:
+ break;
+ }
+
+ sprintf(tmp, "0x%08x", error);
+
+ return tmp;
+}
diff --git a/testprogs/win32/spoolss/error.h b/testprogs/win32/spoolss/error.h
new file mode 100644
index 0000000..581c109
--- /dev/null
+++ b/testprogs/win32/spoolss/error.h
@@ -0,0 +1,36 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ERROR_INVALID_PARAMETER
+#define ERROR_INVALID_PARAMETER 87
+#endif
+
+#ifndef ERROR_INSUFFICIENT_BUFFER
+#define ERROR_INSUFFICIENT_BUFFER 0x007a
+#endif
+
+#if 0
+#ifdef STATUS_PENDING
+#undef STATUS_PENDING
+#define STATUS_PENDING 0x0103
+#endif
+#endif
+
+const char *errstr(DWORD error);
diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c
new file mode 100644
index 0000000..1dd1277
--- /dev/null
+++ b/testprogs/win32/spoolss/printlib.c
@@ -0,0 +1,1386 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Gerald (Jerry) Carter 2007
+ Copyright (C) Guenther Deschner 2009-2010
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <windows.h>
+#include <stdio.h>
+#include <assert.h>
+#include <sddl.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+void print_devmode(DEVMODE *pDevModeIn)
+{
+ if (pDevModeIn == NULL) {
+ printf("\tDevice Mode\t= (null)\n");
+ return;
+ }
+
+ printf("\tDEVMODE:----------\n");
+ printf("\tDeviceName: [%s]\n", pDevModeIn->dmDeviceName);
+ printf("\tSpecVersion: %d\n", pDevModeIn->dmSpecVersion);
+ printf("\tDriverVersion: %d\n", pDevModeIn->dmDriverVersion);
+ printf("\tSize: %d\n", pDevModeIn->dmSize);
+ printf("\tDriverExtra: %d\n", pDevModeIn->dmDriverExtra);
+ printf("\tFields: 0x%x\n", pDevModeIn->dmFields);
+
+ if (pDevModeIn->dmFields & DM_ORIENTATION)
+ printf("\tOrientation: %d\n", pDevModeIn->dmOrientation);
+ if (pDevModeIn->dmFields & DM_PAPERSIZE)
+ printf("\tPaperSize: %d\n", pDevModeIn->dmPaperSize);
+ if (pDevModeIn->dmFields & DM_PAPERLENGTH)
+ printf("\tPaperLength: %d\n", pDevModeIn->dmPaperLength);
+ if (pDevModeIn->dmFields & DM_PAPERWIDTH)
+ printf("\tPaperWidth: %d\n", pDevModeIn->dmPaperWidth);
+// if (pDevModeIn->dmFields & DM_POSITION)
+// printf("\tPosition: %d\n", pDevModeIn->dmPosition);
+ if (pDevModeIn->dmFields & DM_SCALE)
+ printf("\tScale: %d\n", pDevModeIn->dmScale);
+ if (pDevModeIn->dmFields & DM_COPIES)
+ printf("\tCopies: %d\n", pDevModeIn->dmCopies );
+ if (pDevModeIn->dmFields & DM_DEFAULTSOURCE)
+ printf("\tDefaultSource: %d\n", pDevModeIn->dmDefaultSource);
+ if (pDevModeIn->dmFields & DM_PRINTQUALITY)
+ printf("\tPrintQuality: %d\n", pDevModeIn->dmPrintQuality);
+ if (pDevModeIn->dmFields & DM_COLOR)
+ printf("\tColor: %d\n", pDevModeIn->dmColor);
+ if (pDevModeIn->dmFields & DM_DUPLEX)
+ printf("\tDuplex: %d\n", pDevModeIn->dmDuplex);
+ if (pDevModeIn->dmFields & DM_YRESOLUTION)
+ printf("\tYResolution: %d\n", pDevModeIn->dmYResolution);
+ if (pDevModeIn->dmFields & DM_TTOPTION)
+ printf("\tTTOption: %d\n", pDevModeIn->dmTTOption);
+ if (pDevModeIn->dmFields & DM_COLLATE)
+ printf("\tCollate: %d\n", pDevModeIn->dmCollate);
+ if (pDevModeIn->dmFields & DM_FORMNAME)
+ printf("\tForm: [%s]\n", pDevModeIn->dmFormName);
+ if (pDevModeIn->dmFields & DM_LOGPIXELS)
+ printf("\tLogPixels: %d\n", pDevModeIn->dmLogPixels);
+ if (pDevModeIn->dmFields & DM_BITSPERPEL)
+ printf("\tBitsPerPel: %d\n", pDevModeIn->dmBitsPerPel);
+ if (pDevModeIn->dmFields & DM_PELSWIDTH)
+ printf("\tPelsWidth: %d\n", pDevModeIn->dmPelsWidth);
+ if (pDevModeIn->dmFields & DM_PELSHEIGHT)
+ printf("\tPelsHeight: %d\n", pDevModeIn->dmPelsHeight);
+ if (pDevModeIn->dmFields & DM_DISPLAYFLAGS)
+ printf("\tDisplayFlags: %d\n", pDevModeIn->dmDisplayFlags);
+// if (pDevModeIn->dmFields & DM_NUP)
+// printf("\tNup: %d\n", pDevModeIn->dmNup);
+ if (pDevModeIn->dmFields & DM_DISPLAYFREQUENCY)
+ printf("\tDisplayFrequency:%d\n", pDevModeIn->dmDisplayFrequency);
+ if (pDevModeIn->dmFields & DM_ICMMETHOD)
+ printf("\tICMMethod: %d\n", pDevModeIn->dmICMMethod);
+ if (pDevModeIn->dmFields & DM_ICMINTENT)
+ printf("\tICMIntent: %d\n", pDevModeIn->dmICMIntent);
+ if (pDevModeIn->dmFields & DM_MEDIATYPE)
+ printf("\tMediaType: %d\n", pDevModeIn->dmMediaType);
+ if (pDevModeIn->dmFields & DM_DITHERTYPE)
+ printf("\tDitherType: %d\n", pDevModeIn->dmDitherType);
+// if (pDevModeIn->dmFields & DM_PANNINGWIDTH)
+// printf("\tPanningWidth: %d\n", pDevModeIn->dmPanningWidth);
+// if (pDevModeIn->dmFields & DM_PANNINGHEIGHT)
+// printf("\tPanningHeight: %d\n", pDevModeIn->dmPanningHeight);
+
+#if 0
+ if (bForceIn) {
+ printf("DEVMODE\n");
+ Dump((BYTE*)pDevModeIn, sizeof(DEVMODE), LEADER);
+
+ if (pDevModeIn->dmDriverExtra) {
+ printf("DriverExtra\n");
+ Dump((BYTE*)pDevModeIn + sizeof(DEVMODE), pDevModeIn->dmDriverExtra, LEADER);
+ }
+ }
+#endif
+
+ return;
+}
+
+void print_acl(const char* str, ACL *acl)
+{
+ printf("%s\n", str);
+ if (acl == NULL)
+ return;
+
+ printf("\t\tACL Revision \t\t 0x%x\n", acl->AclRevision);
+ printf("\t\tSbz1\t\t 0x%x\n", acl->Sbz1);
+ printf("\t\tSbz2\t\t 0x%x\n", acl->Sbz2);
+ printf("\t\tACL Size\t\t 0x%x\n", acl->AclSize);
+ printf("\t\tACL Count\t\t 0x%x\n", acl->AceCount);
+
+ return;
+}
+
+void PrintLastError();
+
+void print_sid(LPSTR str, PSID sid)
+{
+ LPSTR sid_string;
+
+ printf("%s\n", str);
+
+ if (sid == NULL) {
+ printf("(null sid)\n");
+ return;
+ }
+
+ if (!ConvertSidToStringSid(sid, &sid_string)) {
+ PrintLastError();
+ return;
+ }
+
+ printf("%s\n", sid_string);
+ LocalFree(sid_string);
+
+ return;
+}
+
+void print_secdesc(SECURITY_DESCRIPTOR *secdesc)
+{
+ LPSTR sd_string;
+
+ if (secdesc == NULL) {
+ printf("\tSecurity Descriptor\t= (null)\n");
+ return;
+ }
+
+ if (!ConvertSecurityDescriptorToStringSecurityDescriptor(secdesc, 1, 7, &sd_string, NULL)) {
+ PrintLastError();
+ return;
+ }
+
+ printf("%s\n", sd_string);
+ LocalFree(sd_string);
+
+#if 0
+ printf("\tRevision\t= 0x%x\n", secdesc->Revision);
+ printf("\tSbz1\t\t= 0x%x\n", secdesc->Sbz1);
+ printf("\tControl\t\t= 0x%x\n", secdesc->Control);
+ print_sid("\tOwner\t\t= ", secdesc->Owner);
+ print_sid("\tGroup\t\t= ",secdesc->Group);
+ print_acl("\tSacl\t\t= ", secdesc->Sacl);
+ print_acl("\tDacl\t\t= ", secdesc->Dacl);
+#endif
+ return;
+}
+
+void PrintLastError()
+{
+ LPVOID lpMsgBuf;
+ DWORD status;
+
+ status = GetLastError();
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf, 0, NULL);
+ printf("ERROR [0x%x] : %s\n", status, (char*)lpMsgBuf);
+ LocalFree(lpMsgBuf);
+
+ return;
+}
+
+
+void print_job_info_1(PJOB_INFO_1 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+
+ return;
+}
+
+void print_job_info_2(PJOB_INFO_2 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tNotify Name\t= %s\n", info->pNotifyName);
+ printf("\tPrint Processor\t= %s\n", info->pPrintProcessor);
+ printf("\tParameters\t= %s\n", info->pParameters);
+ printf("\tDriver Name\t= %s\n", info->pDriverName);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tStart Time\t= %d\n", info->StartTime);
+ printf("\tUntil Time\t= %d\n", info->UntilTime);
+ printf("\tTime\t\t= %d\n", info->Time);
+ printf("\tSize\t\t= %d\n", info->Size);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+
+ return;
+}
+
+void print_job_info_3(PJOB_INFO_3 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tJob ID Next Job\t= %d\n", info->NextJobId);
+ printf("\tReserved (must be 0)\t= %d\n",info->Reserved);
+
+ return;
+}
+
+void print_job_info_4(PJOB_INFO_4 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tNotify Name\t= %s\n", info->pNotifyName);
+ printf("\tPrint Processor\t= %s\n", info->pPrintProcessor);
+ printf("\tDriver Name\t= %s\n", info->pDriverName);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tStart Time\t= %d\n", info->StartTime);
+ printf("\tUntil Time\t= %d\n", info->UntilTime);
+ printf("\tTime\t\t= %d\n", info->Time);
+ printf("\tSize\t\t= %d\n", info->Size);
+ printf("\tSize High\t\t= 0x%016x\n", info->SizeHigh);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+
+ return;
+}
+
+void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PJOB_INFO_1 buffer1 = NULL;
+ PJOB_INFO_2 buffer2 = NULL;
+ PJOB_INFO_3 buffer3 = NULL;
+ PJOB_INFO_4 buffer4 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PJOB_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PJOB_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PJOB_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PJOB_INFO_4)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Job Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_job_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_job_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_job_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_job_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_monitor_info_1(PMONITOR_INFO_1 info)
+{
+ printf("\tMonitor Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_monitor_info_2(PMONITOR_INFO_2 info)
+{
+ printf("\tMonitor Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tDLL Name\t= %s\n", info->pDLLName);
+
+ return;
+}
+
+void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PMONITOR_INFO_1 buffer1 = NULL;
+ PMONITOR_INFO_2 buffer2 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PMONITOR_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PMONITOR_INFO_2)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Monitor Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_monitor_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_monitor_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_port_info_1(PPORT_INFO_1 info)
+{
+ printf("\tPort Name\t= %s\n", info->pName);
+ return;
+}
+
+void print_port_info_2(PPORT_INFO_2 info)
+{
+ printf("\tPort Name\t= %s\n", info->pPortName);
+ printf("\tMonitor Name\t= %s\n",info->pMonitorName);
+ printf("\tDescription\t= %s\n", info->pDescription);
+ printf("\tPort Type\t= 0x%08x\n", info->fPortType);
+ printf("\tReserved\t= 0x%08x\n", info->Reserved);
+ return;
+}
+
+void print_port_info_3(PPORT_INFO_3 info)
+{
+ printf("\tStatus\t= 0x%08x\n", info->dwStatus);
+ printf("\tStatus String\t= %s\n", info->pszStatus);
+ printf("\tSeverity\t= 0x%08x\n", info->dwSeverity);
+ return;
+}
+
+void print_port_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPORT_INFO_1 buffer1 = NULL;
+ PPORT_INFO_2 buffer2 = NULL;
+ PPORT_INFO_3 buffer3 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPORT_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PPORT_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PPORT_INFO_3)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Port Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_port_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_port_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_port_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_form_info_1(PFORM_INFO_1 info)
+{
+ printf("\tForm Name\t= %s\n", info->pName);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+ printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
+ printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
+ info->ImageableArea.left, info->ImageableArea.right,
+ info->ImageableArea.top, info->ImageableArea.bottom);
+
+ return;
+}
+
+void print_form_info_2(PFORM_INFO_2 info)
+{
+ printf("\tForm Name\t= %s\n", info->pName);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+ printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
+ printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
+ info->ImageableArea.left, info->ImageableArea.right,
+ info->ImageableArea.top, info->ImageableArea.bottom);
+ printf("\tKeyword\t= %s\n", info->pKeyword);
+ printf("\tString Type\t= 0x%08x\n", info->StringType);
+ printf("\tMui DLL\t= %s\n", info->pMuiDll);
+ printf("\tResource Id\t= 0x%08x\n", info->dwResourceId);
+ printf("\tDisplay Name\t= %s\n",info->pDisplayName);
+ printf("\tLang Id\t= 0x%04x\n", info->wLangId);
+
+ return;
+}
+
+void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PFORM_INFO_1 buffer1 = NULL;
+ PFORM_INFO_2 buffer2 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PFORM_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PFORM_INFO_2)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Form Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_form_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_form_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printer_info_1(PPRINTER_INFO_1 info)
+{
+ printf("\tPrinter Name\t= %s\n", info->pName);
+ printf("\tDescription\t= %s\n", info->pDescription);
+ printf("\tComment\t\t= %s\n", info->pComment);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+
+ return;
+}
+
+void print_printer_info_2(PPRINTER_INFO_2 info)
+{
+ printf("\tServer Name\t\t= %s\n", info->pServerName);
+ printf("\tPrinter Name\t\t= %s\n", info->pPrinterName);
+ printf("\tPort Name\t\t= %s\n", info->pPortName);
+ printf("\tShare Name\t\t= %s\n", info->pShareName);
+ printf("\tDriver Name\t\t= %s\n", info->pDriverName);
+ printf("\tComment\t\t\t= %s\n", info->pComment);
+ printf("\tLocation\t\t= %s\n", info->pLocation);
+ printf("\tSeparator File\t\t= %s\n", info->pSepFile);
+ printf("\tDefault Data Type\t= %s\n", info->pDatatype);
+ printf("\tPrint Processor\t\t= %s\n", info->pPrintProcessor);
+ printf("\tParameters\t\t= %s\n", info->pParameters);
+ printf("\tAttributes\t\t= 0x%x\n", info->Attributes);
+ printf("\tPriority\t\t= 0x%x\n", info->Priority);
+ printf("\tDefault Priority\t= 0x%x\n", info->DefaultPriority);
+ printf("\tStart Time\t\t= 0x%x\n", info->StartTime);
+ printf("\tUntil Time\t\t= 0x%x\n", info->UntilTime);
+ printf("\tStatus\t\t\t= 0x%x\n", info->Status);
+ printf("\tcJobs\t\t\t= 0x%x\n", info->cJobs);
+ printf("\tAverage PPM\t\t= 0x%x\n", info->AveragePPM);
+
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+ return;
+}
+
+void print_printer_info_3(PPRINTER_INFO_3 info)
+{
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+ return;
+}
+
+void print_printer_info_4(PPRINTER_INFO_4 info)
+{
+ printf("\tServer Name\t\t= %s\n", info->pServerName);
+ printf("\tPrinter Name\t\t= %s\n", info->pPrinterName);
+ printf("\tAttributes\t\t= 0x%x\n", info->Attributes);
+ return;
+}
+
+void print_printer_info_5(PPRINTER_INFO_5 info)
+{
+ printf("\tPrinter Name\t\t\t= %s\n", info->pPrinterName);
+ printf("\tPort Name\t\t\t= %s\n", info->pPortName);
+ printf("\tAttributes\t\t\t= 0x%x\n", info->Attributes);
+ printf("\tDev NotSelect Timeout\t= 0x%x\n", info->DeviceNotSelectedTimeout);
+ printf("\tTX RetryTimeout\t\t= 0x%x\n", info->TransmissionRetryTimeout);
+ return;
+}
+
+void print_printer_info_6(PPRINTER_INFO_6 info)
+{
+ printf("\tStatus\t\t\t= 0x%x\n", info->dwStatus);
+ return;
+}
+
+void print_printer_info_7(PPRINTER_INFO_7 info)
+{
+ printf("\tObject GUID\t\t\t= %s\n", info->pszObjectGUID);
+ printf("\tAction\t\t\t= 0x%x\n", info->dwAction);
+ return;
+}
+
+void print_printer_info_8(PPRINTER_INFO_8 info)
+{
+ print_devmode(info->pDevMode);
+}
+
+void print_printer_info_9(PPRINTER_INFO_9 info)
+{
+ print_devmode(info->pDevMode);
+}
+
+void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPRINTER_INFO_1 buffer1 = NULL;
+ PPRINTER_INFO_2 buffer2 = NULL;
+ PPRINTER_INFO_3 buffer3 = NULL;
+ PPRINTER_INFO_4 buffer4 = NULL;
+ PPRINTER_INFO_5 buffer5 = NULL;
+ PPRINTER_INFO_6 buffer6 = NULL;
+ PPRINTER_INFO_7 buffer7 = NULL;
+ PPRINTER_INFO_8 buffer8 = NULL;
+ PPRINTER_INFO_9 buffer9 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPRINTER_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PPRINTER_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PPRINTER_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PPRINTER_INFO_4)buffer;
+ break;
+ case 5:
+ buffer5 = (PPRINTER_INFO_5)buffer;
+ break;
+ case 6:
+ buffer6 = (PPRINTER_INFO_6)buffer;
+ break;
+ case 7:
+ buffer7 = (PPRINTER_INFO_7)buffer;
+ break;
+ case 8:
+ buffer8 = (PPRINTER_INFO_8)buffer;
+ break;
+ case 9:
+ buffer9 = (PPRINTER_INFO_9)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Printer Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_printer_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_printer_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_printer_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_printer_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ case 5:
+ for (i=0; i<count; i++) {
+ print_printer_info_5(&buffer5[i]);
+ printf("\n");
+ }
+ break;
+ case 6:
+ for (i=0; i<count; i++) {
+ print_printer_info_6(&buffer6[i]);
+ printf("\n");
+ }
+ break;
+ case 7:
+ for (i=0; i<count; i++) {
+ print_printer_info_7(&buffer7[i]);
+ printf("\n");
+ }
+ break;
+ case 8:
+ for (i=0; i<count; i++) {
+ print_printer_info_8(&buffer8[i]);
+ printf("\n");
+ }
+ break;
+ case 9:
+ for (i=0; i<count; i++) {
+ print_printer_info_9(&buffer9[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
+{
+ printf("\tPrint Processor Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPRINTPROCESSOR_INFO_1 buffer1 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPRINTPROCESSOR_INFO_1)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Print Processor Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_printprocessor_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_datatypes_info_1(PDATATYPES_INFO_1 info)
+{
+ printf("\tDataTypes Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PDATATYPES_INFO_1 buffer1 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PDATATYPES_INFO_1)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("DataTypes Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_datatypes_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_driver_info_1(PDRIVER_INFO_1 info)
+{
+ printf("\tDriver Name\t= %s\n\n", info->pName);
+
+ return;
+}
+
+void print_driver_info_2(PDRIVER_INFO_2 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n\n", info->pConfigFile);
+
+ return;
+}
+
+void print_driver_info_3(PDRIVER_INFO_3 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ ptr = (char*)info->pDependentFiles;
+ while ((ptr != NULL) && (*ptr != '\0')) {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+
+ return;
+}
+
+void print_driver_info_4(PDRIVER_INFO_4 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames);
+ ptr = (char*)info->pDependentFiles;
+ while ((ptr != NULL) && (*ptr != '\0')) {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+
+ return;
+}
+
+void print_driver_info_5(PDRIVER_INFO_5 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tDriver Attributes\t= %d\n", info->dwDriverAttributes);
+ printf("\tConfig Version\t= %d\n", info->dwConfigVersion);
+ printf("\tDriver Version\t= %d\n", info->dwDriverVersion);
+
+ return;
+}
+
+void print_driver_info_6(PDRIVER_INFO_6 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames);
+ ptr = (char*)info->pDependentFiles;
+ if (ptr != NULL) {
+ while (*ptr != '\0') {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+ } else {
+ printf("\tPrevious Names\t= (null)\n");
+ }
+
+ ptr = (char*)info->pszzPreviousNames;
+ if (ptr != NULL) {
+ while (*ptr != '\0') {
+ printf("\tPrevious Names\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+ } else {
+ printf("\tPrevious Names\t= (null)\n");
+ }
+
+ printf("\tDriver Date\t= %d (%08x:%08x)\n",
+ info->ftDriverDate,
+ info->ftDriverDate.dwLowDateTime,
+ info->ftDriverDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftDriverDate);
+ printf("\tDriver Version\t= %d\n", info->dwlDriverVersion);
+ printf("\tManufacture Name = %s\n", info->pszMfgName);
+ printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl);
+ printf("\tHardware ID\t= %s\n", info->pszHardwareID);
+ printf("\tProvider\t= %s\n", info->pszProvider);
+ return;
+}
+
+static void print_multi_sz(LPSTR multisz)
+{
+ char *ptr = NULL;
+
+ ptr = (char *)multisz;
+
+ if (!ptr) {
+ printf("(null)\n");
+ return;
+ }
+
+ while (*ptr != '\0') {
+ printf("%s\n", ptr);
+ for (; *ptr != '\0'; ptr++) {
+ /* printf("%s\n", ptr); */
+ ;
+ }
+ ptr++;
+ }
+}
+
+void print_driver_info_8(PDRIVER_INFO_8 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t=\n");
+ print_multi_sz(info->pszzPreviousNames);
+ printf("\tDependent Files\t=\n");
+ print_multi_sz(info->pDependentFiles);
+ printf("\tDriver Date\t= %d (%08x:%08x)\n",
+ info->ftDriverDate,
+ info->ftDriverDate.dwLowDateTime,
+ info->ftDriverDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftDriverDate);
+ printf("\tDriver Version\t= %d\n", info->dwlDriverVersion);
+ printf("\tManufacture Name = %s\n", info->pszMfgName);
+ printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl);
+ printf("\tHardware ID\t= %s\n", info->pszHardwareID);
+ printf("\tProvider\t= %s\n", info->pszProvider);
+ printf("\tPrint Processor\t= %s\n", info->pszPrintProcessor);
+ printf("\tVendor Setup\t= %s\n", info->pszVendorSetup);
+ printf("\tColor Profiles\t=\n");
+ print_multi_sz(info->pszzColorProfiles);
+ printf("\tInf Path\t= %s\n", info->pszInfPath);
+ printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes);
+ printf("\tCore Driver Dependencies\t=\n");
+ print_multi_sz(info->pszzCoreDriverDependencies);
+ printf("\tMin Inbox Driver VerDate\t= %d (%08x:%08x)\n",
+ info->ftMinInboxDriverVerDate,
+ info->ftMinInboxDriverVerDate.dwLowDateTime,
+ info->ftMinInboxDriverVerDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftMinInboxDriverVerDate);
+ printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion);
+ return;
+}
+
+void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PDRIVER_INFO_1 buffer1 = NULL;
+ PDRIVER_INFO_2 buffer2 = NULL;
+ PDRIVER_INFO_3 buffer3 = NULL;
+ PDRIVER_INFO_4 buffer4 = NULL;
+ PDRIVER_INFO_5 buffer5 = NULL;
+ PDRIVER_INFO_6 buffer6 = NULL;
+ PDRIVER_INFO_8 buffer8 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PDRIVER_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PDRIVER_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PDRIVER_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PDRIVER_INFO_4)buffer;
+ break;
+ case 5:
+ buffer5 = (PDRIVER_INFO_5)buffer;
+ break;
+ case 6:
+ buffer6 = (PDRIVER_INFO_6)buffer;
+ break;
+ case 8:
+ buffer8 = (PDRIVER_INFO_8)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Driver Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_driver_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_driver_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_driver_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_driver_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ case 5:
+ for (i=0; i<count; i++) {
+ print_driver_info_5(&buffer5[i]);
+ printf("\n");
+ }
+ break;
+ case 6:
+ for (i=0; i<count; i++) {
+ print_driver_info_6(&buffer6[i]);
+ printf("\n");
+ }
+ break;
+ case 8:
+ for (i=0; i<count; i++) {
+ print_driver_info_8(&buffer8[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_doc_info_1(PDOC_INFO_1 info)
+{
+ printf("\tDocument Name\t= %s\n", info->pDocName);
+ printf("\tOutput Filename\t= %s\n", info->pOutputFile);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ return;
+}
+
+void print_printer_keys(LPSTR buffer)
+{
+ LPSTR p = NULL;
+
+ p = buffer;
+
+ while (p && *p) {
+ printf("%s\n", p);
+ for (; *p; p = CharNext(p)) {
+ p = CharNext(p);
+ }
+ }
+}
+
+LPSTR reg_type_str(DWORD type)
+{
+ switch (type) {
+ case REG_DWORD:
+ return "REG_DWORD";
+ case REG_SZ:
+ return "REG_SZ";
+ case REG_MULTI_SZ:
+ return "REG_MULTI_SZ";
+ case REG_BINARY:
+ return "REG_BINARY";
+ default:
+ return NULL;
+ }
+}
+
+void print_asc(const BYTE *buf, DWORD len)
+{
+ int i;
+ for (i=0; i<len; i++) {
+ printf("%c", isprint(buf[i])?buf[i]:'.');
+ }
+}
+
+static void dump_data(const BYTE *buf, int len)
+{
+ int i=0;
+ static const BYTE empty[16] = { 0, };
+
+ if (len<=0) return;
+
+ for (i=0; i<len;) {
+
+ if (i%16 == 0) {
+ if ((i > 0) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0))
+ {
+ i +=16;
+ continue;
+ }
+
+ if (i<len) {
+ printf("[%04X] ",i);
+ }
+ }
+
+ printf("%02x ", buf[i]);
+ i++;
+
+ if (i%8 == 0) printf(" ");
+ if (i%16 == 0) {
+ print_asc(&buf[i-16],8); printf(" ");
+ print_asc(&buf[i-8],8); printf("\n");
+ }
+ }
+
+ if (i%16) {
+ int n;
+ n = 16 - (i%16);
+ printf(" ");
+ if (n>8) printf(" ");
+ while (n--) printf(" ");
+ n = MIN(8,i%16);
+ print_asc(&buf[i-(i%16)],n); printf( " " );
+ n = (i%16) - n;
+ if (n>0) print_asc(&buf[i-n],n);
+ printf("\n");
+ }
+}
+
+static void dump_printer_data(DWORD size, LPBYTE buffer, DWORD type)
+{
+ DWORD i = 0;
+ LPSTR p = NULL;
+
+ switch (type) {
+ case REG_SZ:
+ dump_data(buffer, size);
+ break;
+ case REG_MULTI_SZ:
+ dump_data(buffer, size);
+ p = (LPSTR)buffer;
+ while (p && *p) {
+ printf("\t\t%s\n", p);
+ for (; *p; p = CharNext(p)) {
+ p = CharNext(p);
+ }
+ }
+ break;
+ case REG_DWORD:
+ assert(size == 4);
+ printf("\t\t0x%08x\n", (DWORD)*buffer);
+ break;
+ case REG_BINARY:
+ dump_data(buffer, size);
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
+{
+ if (keyname) {
+ printf("\tKey Name:\t%s\n", keyname);
+ }
+
+ printf("\tValue Name:\t%s\n", valuename);
+ printf("\tSize:\t\t0x%x (%d)\n", size, size);
+ printf("\tType:\t\t%s\n", reg_type_str(type));
+
+ if (buffer == NULL || size == 0) {
+ return;
+ }
+
+ dump_printer_data(size, buffer, type);
+}
+
+void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
+{
+ if (keyname) {
+ printf("\tKey Name:\t%ls\n", keyname);
+ }
+
+ printf("\tValue Name:\t%ls\n", valuename);
+ printf("\tSize:\t\t0x%x (%d)\n", size, size);
+ printf("\tType:\t\t%s\n", reg_type_str(type));
+
+ if (buffer == NULL || size == 0) {
+ return;
+ }
+
+ dump_printer_data(size, buffer, type);
+}
+
+
+void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
+{
+ print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType);
+}
+
+void print_file_time(const FILETIME *t)
+{
+ SYSTEMTIME s;
+ LPSTR dayofweek = NULL;
+ LPSTR month = NULL;
+
+ if (!FileTimeToSystemTime(t, &s)) {
+ printf("Failed to convert FILETIME to SYSTEMTIME\n");
+ return;
+ }
+ switch (s.wDayOfWeek) {
+ case 0:
+ dayofweek = "Sun";
+ break;
+ case 1:
+ dayofweek = "Mon";
+ break;
+ case 2:
+ dayofweek = "Tue";
+ break;
+ case 3:
+ dayofweek = "Wed";
+ break;
+ case 4:
+ dayofweek = "Thu";
+ break;
+ case 5:
+ dayofweek = "Fri";
+ break;
+ case 6:
+ dayofweek = "Sat";
+ break;
+ default:
+ break;
+ }
+
+ switch (s.wMonth) {
+ case 1:
+ month = "Jan";
+ break;
+ case 2:
+ month = "Feb";
+ break;
+ case 3:
+ month = "Mar";
+ break;
+ case 4:
+ month = "Apr";
+ break;
+ case 5:
+ month = "May";
+ break;
+ case 6:
+ month = "Jun";
+ break;
+ case 7:
+ month = "Jul";
+ break;
+ case 8:
+ month = "Aug";
+ break;
+ case 9:
+ month = "Sep";
+ break;
+ case 10:
+ month = "Oct";
+ break;
+ case 11:
+ month = "Nov";
+ break;
+ case 12:
+ month = "Dec";
+ break;
+ default:
+ break;
+ }
+
+ printf("%s %s %02d %02d:%02d:%02d %04d\n",
+ dayofweek, month, s.wDay,
+ s.wHour, s.wMinute, s.wSecond, s.wYear);
+}
diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h
new file mode 100644
index 0000000..704cdbf
--- /dev/null
+++ b/testprogs/win32/spoolss/printlib_proto.h
@@ -0,0 +1,67 @@
+#ifndef __PRINTLIB_PROTO_H__
+#define __PRINTLIB_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private
+ * to this subsystem or library. These functions should not be
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from printlib.c */
+
+void print_devmode(DEVMODE *pDevModeIn);
+void print_acl(const char* str, ACL *acl);
+void print_sid(const char* str, SID *sid);
+void print_secdesc(SECURITY_DESCRIPTOR *secdesc);
+void PrintLastError();
+void print_job_info_1(PJOB_INFO_1 info);
+void print_job_info_2(PJOB_INFO_2 info);
+void print_job_info_3(PJOB_INFO_3 info);
+void print_job_info_4(PJOB_INFO_4 info);
+void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_monitor_info_1(PMONITOR_INFO_1 info);
+void print_monitor_info_2(PMONITOR_INFO_2 info);
+void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_port_info_1(PPORT_INFO_1 info);
+void print_port_info_2(PPORT_INFO_2 info);
+void print_port_info_3(PPORT_INFO_3 info);
+void print_port_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_form_info_1(PFORM_INFO_1 info);
+void print_form_info_2(PFORM_INFO_2 info);
+void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_printer_info_1(PPRINTER_INFO_1 info);
+void print_printer_info_2(PPRINTER_INFO_2 info);
+void print_printer_info_5(PPRINTER_INFO_5 info);
+void print_printer_info_6(PPRINTER_INFO_6 info);
+void print_printer_info_7(PPRINTER_INFO_7 info);
+void print_printer_info_8(PPRINTER_INFO_8 info);
+void print_printer_info_9(PPRINTER_INFO_9 info);
+void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info);
+void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_datatypes_info_1(PDATATYPES_INFO_1 info);
+void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_driver_info_1(PDRIVER_INFO_1 info);
+void print_driver_info_2(PDRIVER_INFO_2 info);
+void print_driver_info_3(PDRIVER_INFO_3 info);
+void print_driver_info_4(PDRIVER_INFO_4 info);
+void print_driver_info_5(PDRIVER_INFO_5 info);
+void print_driver_info_6(PDRIVER_INFO_6 info);
+void print_driver_info_8(PDRIVER_INFO_8 info);
+void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_doc_info_1(PDOC_INFO_1 info);
+void print_printer_keys(LPSTR buffer);
+LPSTR reg_type_str(DWORD type);
+void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
+void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
+void print_printer_enum_values(PRINTER_ENUM_VALUES *info);
+void print_file_time(const FILETIME *t);
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __PRINTLIB_PROTO_H__ */
+
diff --git a/testprogs/win32/spoolss/string.h b/testprogs/win32/spoolss/string.h
new file mode 100644
index 0000000..17561eb
--- /dev/null
+++ b/testprogs/win32/spoolss/string.h
@@ -0,0 +1,15 @@
+/* __location__ macro replacement taken from talloc.h */
+
+/*
+ this uses a little trick to allow __LINE__ to be stringified
+*/
+#ifndef __location__
+#define __STRING_LINE1__(s) #s
+#define __STRING_LINE2__(s) __STRING_LINE1__(s)
+#define __STRING_LINE3__ __STRING_LINE2__(__LINE__)
+#define __location__ __FILE__ ":" __STRING_LINE3__
+#endif
+
+#ifndef __STRING
+#define __STRING(s) #s
+#endif
diff --git a/testprogs/win32/spoolss/testspoolss.c b/testprogs/win32/spoolss/testspoolss.c
new file mode 100644
index 0000000..794e545
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.c
@@ -0,0 +1,1842 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009-2010
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/****************************************************************************
+****************************************************************************/
+
+#include "testspoolss.h"
+#include "string.h"
+#include "torture.h"
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_OpenPrinter(struct torture_context *tctx,
+ LPSTR printername,
+ LPPRINTER_DEFAULTS defaults,
+ LPHANDLE handle)
+{
+ torture_comment(tctx, "Testing OpenPrinter(%s)", printername);
+
+ if (!OpenPrinter(printername, handle, defaults)) {
+ char tmp[1024];
+ sprintf(tmp, "failed to open printer %s, error was: 0x%08x\n",
+ printername, GetLastError());
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_ClosePrinter(struct torture_context *tctx,
+ HANDLE handle)
+{
+ torture_comment(tctx, "Testing ClosePrinter");
+
+ if (!ClosePrinter(handle)) {
+ char tmp[1024];
+ sprintf(tmp, "failed to close printer, error was: %s\n",
+ errstr(GetLastError()));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinters(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2, 5 };
+ DWORD success[] = { 1, 1, 1 };
+ DWORD i;
+ DWORD flags = PRINTER_ENUM_NAME;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinters level %d", levels[i]);
+
+ EnumPrinters(flags, servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinters(flags, servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printer_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumDrivers(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterDrivers(%s) level %d",
+ architecture, levels[i]);
+
+ EnumPrinterDrivers(servername, architecture, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinterDrivers(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterDrivers failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_driver_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetForm(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle,
+ LPSTR formname)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 0 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetForm(%s) level %d", formname, levels[i]);
+
+ GetForm(handle, formname, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetForm(handle, formname, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetForm failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_form_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumForms(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumForms level %d", levels[i]);
+
+ if (tctx->samba3 && levels[i] == 2) {
+ torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+ continue;
+ }
+
+ EnumForms(handle, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumForms(handle, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumForms failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_form_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPorts(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPorts level %d", levels[i]);
+
+ EnumPorts(servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPorts(servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPorts failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_port_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumMonitors(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]);
+
+ EnumMonitors(servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_monitor_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrintProcessors(%s) level %d", architecture, levels[i]);
+
+ EnumPrintProcessors(servername, architecture, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrintProcessors(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrintProcessors failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printprocessor_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]);
+
+ EnumPrintProcessorDatatypes(servername, "winprint", levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrintProcessorDatatypes(servername, "winprint", levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrintProcessorDatatypes failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_datatypes_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterKey(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle,
+ LPCSTR key)
+{
+ LPSTR buffer = NULL;
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterKey(%s)", key);
+
+ err = EnumPrinterKey(handle, key, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPTSTR)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = EnumPrinterKey(handle, key, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterKey(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ key, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_keys(buffer);
+ }
+
+ free(buffer);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinter(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinter level %d", levels[i]);
+
+ GetPrinter(handle, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinter(handle, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printer_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDriver(struct torture_context *tctx,
+ LPSTR printername,
+ LPSTR architecture,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDriver(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrinterDriver(handle, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinterDriver(handle, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDriver failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_driver_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumJobs(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4 };
+ DWORD success[] = { 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumJobs level %d", levels[i]);
+
+ if (tctx->samba3 && levels[i] == 4) {
+ torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+ continue;
+ }
+
+ EnumJobs(handle, 0, 100, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumJobs(handle, 0, 100, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterData(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ LPTSTR value_name;
+ LPBYTE data;
+ DWORD index = 0;
+ DWORD type;
+ DWORD value_offered = 0, value_needed;
+ DWORD data_offered = 0, data_needed;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n",
+ index, value_offered, data_offered);
+
+ err = EnumPrinterData(handle, 0, NULL, 0, &value_needed, NULL, NULL, 0, &data_needed);
+ if (err) {
+ sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n",
+ index, servername, value_offered, data_offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ value_name = malloc(value_needed);
+ torture_assert(tctx, value_name, "malloc failed");
+ data = malloc(data_needed);
+ torture_assert(tctx, data, "malloc failed");
+
+ value_offered = value_needed;
+ data_offered = data_needed;
+
+ do {
+
+ value_needed = 0;
+ data_needed = 0;
+
+ torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n",
+ index, value_offered, data_offered);
+
+ err = EnumPrinterData(handle, index++, value_name, value_offered, &value_needed, &type, data, data_offered, &data_needed);
+ if (err == ERROR_NO_MORE_ITEMS) {
+ break;
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n",
+ index, servername, value_offered, data_offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data(NULL, value_name, data_needed, data, type);
+ }
+
+ } while (err != ERROR_NO_MORE_ITEMS);
+
+ free(value_name);
+ free(data);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ HANDLE handle,
+ LPBYTE *buffer_p,
+ DWORD *returned_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterDataEx(%s)", keyname);
+
+ err = EnumPrinterDataEx(handle, keyname, NULL, 0, &needed, &returned);
+ if (err == ERROR_MORE_DATA) {
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = EnumPrinterDataEx(handle, keyname, buffer, needed, &needed, &returned);
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ keyname, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ DWORD i;
+ LPPRINTER_ENUM_VALUES v = (LPPRINTER_ENUM_VALUES)buffer;
+ for (i=0; i < returned; i++) {
+ print_printer_enum_values(&v[i]);
+ }
+ }
+
+ if (returned_p) {
+ *returned_p = returned;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_devicemode_equal(struct torture_context *tctx,
+ const DEVMODE *d1,
+ const DEVMODE *d2)
+{
+ if (d1 == d2) {
+ return TRUE;
+ }
+
+ if (!d1 || !d2) {
+ torture_comment(tctx, "%s\n", __location__);
+ return FALSE;
+ }
+
+ torture_assert_str_equal(tctx, (const char *)d1->dmDeviceName, (const char *)d2->dmDeviceName, "dmDeviceName mismatch");
+ torture_assert_int_equal(tctx, d1->dmSpecVersion, d2->dmSpecVersion, "dmSpecVersion mismatch");
+ torture_assert_int_equal(tctx, d1->dmDriverVersion, d2->dmDriverVersion, "dmDriverVersion mismatch");
+ torture_assert_int_equal(tctx, d1->dmSize, d2->dmSize, "size mismatch");
+ torture_assert_int_equal(tctx, d1->dmDriverExtra, d2->dmDriverExtra, "dmDriverExtra mismatch");
+ torture_assert_int_equal(tctx, d1->dmFields, d2->dmFields, "dmFields mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmOrientation, d2->dmOrientation, "dmOrientation mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperSize, d2->dmPaperSize, "dmPaperSize mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperLength, d2->dmPaperLength, "dmPaperLength mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperWidth, d2->dmPaperWidth, "dmPaperWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmScale, d2->dmScale, "dmScale mismatch");
+ torture_assert_int_equal(tctx, d1->dmCopies, d2->dmCopies, "dmCopies mismatch");
+ torture_assert_int_equal(tctx, d1->dmDefaultSource, d2->dmDefaultSource, "dmDefaultSource mismatch");
+ torture_assert_int_equal(tctx, d1->dmPrintQuality, d2->dmPrintQuality, "dmPrintQuality mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmColor, d2->dmColor, "dmColor mismatch");
+ torture_assert_int_equal(tctx, d1->dmDuplex, d2->dmDuplex, "dmDuplex mismatch");
+ torture_assert_int_equal(tctx, d1->dmYResolution, d2->dmYResolution, "dmYResolution mismatch");
+ torture_assert_int_equal(tctx, d1->dmTTOption, d2->dmTTOption, "dmTTOption mismatch");
+ torture_assert_int_equal(tctx, d1->dmCollate, d2->dmCollate, "dmCollate mismatch");
+ torture_assert_str_equal(tctx, (const char *)d1->dmFormName, (const char *)d2->dmFormName, "dmFormName mismatch");
+ torture_assert_int_equal(tctx, d1->dmLogPixels, d2->dmLogPixels, "dmLogPixels mismatch");
+ torture_assert_int_equal(tctx, d1->dmBitsPerPel, d2->dmBitsPerPel, "dmBitsPerPel mismatch");
+ torture_assert_int_equal(tctx, d1->dmPelsWidth, d2->dmPelsWidth, "dmPelsWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmPelsHeight, d2->dmPelsHeight, "dmPelsHeight mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmDisplayFlags, d2->dmDisplayFlags, "dmDisplayFlags mismatch");
+ /* or dmNup ? */
+ torture_assert_int_equal(tctx, d1->dmDisplayFrequency, d2->dmDisplayFrequency, "dmDisplayFrequency mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmICMMethod, d2->dmICMMethod, "dmICMMethod mismatch");
+ torture_assert_int_equal(tctx, d1->dmICMIntent, d2->dmICMIntent, "dmICMIntent mismatch");
+ torture_assert_int_equal(tctx, d1->dmMediaType, d2->dmMediaType, "dmMediaType mismatch");
+ torture_assert_int_equal(tctx, d1->dmDitherType, d2->dmDitherType, "dmDitherType mismatch");
+ torture_assert_int_equal(tctx, d1->dmReserved1, d2->dmReserved1, "dmReserved1 mismatch");
+ torture_assert_int_equal(tctx, d1->dmReserved2, d2->dmReserved2, "reserved2 mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmPanningWidth, d2->dmPanningWidth, "dmPanningWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmPanningHeight, d2->dmPanningHeight, "dmPanningHeight mismatch");
+
+ /* torture_assert_mem_equal(tctx, d1 + d1->dmSize, d2 + d2->dmSize, d1->dmDriverExtra, "private extra data mismatch"); */
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeviceModes(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ PPRINTER_INFO_2 info2 = NULL;
+ PPRINTER_INFO_8 info8 = NULL;
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeviceModes");
+
+ torture_comment(tctx, "Testing GetPrinter level %d", 2);
+
+ GetPrinter(handle, 2, NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ info2 = (PPRINTER_INFO_2)malloc(needed);
+ torture_assert(tctx, (LPBYTE)info2, "malloc failed");
+ if (!GetPrinter(handle, 2, (LPBYTE)info2, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 2, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_info_2(info2);
+ }
+
+ torture_comment(tctx, "Testing GetPrinter level %d", 8);
+
+ GetPrinter(handle, 8, NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ info8 = (PPRINTER_INFO_8)malloc(needed);
+ torture_assert(tctx, (LPBYTE)info8, "malloc failed");
+ if (!GetPrinter(handle, 8, (LPBYTE)info8, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 8, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_info_8(info8);
+ }
+
+ torture_assert(tctx, test_devicemode_equal(tctx, info2->pDevMode, info8->pDevMode), "");
+
+ free(info2);
+ free(info8);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetJob(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle,
+ DWORD job_id)
+{
+ DWORD levels[] = { 1, 2, 3, 4 };
+ DWORD success[] = { 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetJob(%d) level %d", job_id, levels[i]);
+
+ if (tctx->samba3 && (levels[i] == 4) || (levels[i] == 3)) {
+ torture_comment(tctx, "skipping level %d getjob against samba\n", levels[i]);
+ continue;
+ }
+
+ GetJob(handle, job_id, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetJob(handle, job_id, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetJob failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EachJob(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD i;
+ PJOB_INFO_1 buffer = NULL;
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ DWORD level = 1;
+ char tmp[1024];
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing Each PrintJob %d");
+
+ EnumJobs(handle, 0, 100, level, NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = (PJOB_INFO_1)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumJobs(handle, 0, 100, level, (LPBYTE)buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
+ level, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(level, (LPBYTE)buffer, returned);
+ }
+
+ for (i=0; i < returned; i++) {
+ ret = test_GetJob(tctx, printername, handle, buffer[i].JobId);
+ }
+
+ free(buffer);
+
+ return ret;
+
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_OnePrinter(struct torture_context *tctx,
+ LPSTR printername,
+ LPSTR architecture,
+ LPPRINTER_DEFAULTS defaults)
+{
+ HANDLE handle;
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing Printer %s", printername);
+
+ ret &= test_OpenPrinter(tctx, printername, defaults, &handle);
+ ret &= test_GetPrinter(tctx, printername, handle);
+ ret &= test_GetPrinterDriver(tctx, printername, architecture, handle);
+ ret &= test_EnumForms(tctx, printername, handle);
+ ret &= test_EnumJobs(tctx, printername, handle);
+ ret &= test_EachJob(tctx, printername, handle);
+ ret &= test_EnumPrinterKey(tctx, printername, handle, "");
+ ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData");
+ ret &= test_EnumPrinterData(tctx, printername, handle);
+ ret &= test_EnumPrinterDataEx(tctx, printername, "PrinterDriverData", handle, NULL, NULL);
+ ret &= test_DeviceModes(tctx, printername, handle);
+#if 0
+ /* don't run these at the moment, behaviour is PrinterData API calls (not
+ * dcerpc calls) is almost unpredictable - gd */
+ ret &= test_PrinterData(tctx, printername, handle);
+ ret &= test_PrinterDataW(tctx, printername, handle);
+#endif
+ ret &= test_ClosePrinter(tctx, handle);
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EachPrinter(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture,
+ LPPRINTER_DEFAULTS defaults)
+{
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+ DWORD i;
+ DWORD flags = PRINTER_ENUM_NAME;
+ PPRINTER_INFO_1 buffer = NULL;
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing EnumPrinters level %d", 1);
+
+ EnumPrinters(flags, servername, 1, NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = (PPRINTER_INFO_1)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinters(flags, servername, 1, (LPBYTE)buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 1, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ for (i=0; i < returned; i++) {
+ ret &= test_OnePrinter(tctx, buffer[i].pName, architecture, defaults);
+ }
+
+ free(buffer);
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrintProcessorDirectory(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrintProcessorDirectory(servername, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrintProcessorDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrintProcessorDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ printf("\tPrint Processor Directory\t= %s\n\n", (LPSTR)buffer);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDriverDirectory(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrinterDriverDirectory(servername, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinterDriverDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDriverDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ printf("\tPrinter Driver Directory\t= %s\n\n", (LPSTR)buffer);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterData(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterData(%s)", valuename);
+
+ err = GetPrinterData(handle, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterData(handle, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterData(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data("PrinterDriverData", valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = GetPrinterDataEx(handle, keyname, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterDataEx(handle, keyname, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data(keyname, valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDataExW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = GetPrinterDataExW(handle, keyname, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterDataExW(handle, keyname, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDataExW(%ls) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_dataw(keyname, valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = DeletePrinterDataEx(handle, keyname, valuename);
+ if (err) {
+ sprintf(tmp, "DeletePrinterDataEx(%s - %s) failed on [%s], error: %s\n",
+ keyname, valuename, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterDataExW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = DeletePrinterDataExW(handle, keyname, valuename);
+ if (err) {
+ sprintf(tmp, "DeletePrinterDataExW(%ls - %ls) failed on [%s], error: %s\n",
+ keyname, valuename, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterKey(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterKey(%s)", keyname);
+
+ err = DeletePrinterKey(handle, keyname);
+ if (err) {
+ sprintf(tmp, "DeletePrinterKey(%s) failed on [%s], error: %s\n",
+ keyname, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterKeyW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterKeyW(%ls)", keyname);
+
+ err = DeletePrinterKeyW(handle, keyname);
+ if (err) {
+ sprintf(tmp, "DeletePrinterKeyW(%ls) failed on [%s], error: %s\n",
+ keyname, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_SetPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD type,
+ LPBYTE buffer,
+ DWORD offered)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = SetPrinterDataEx(handle, keyname, valuename, type, buffer, offered);
+ if (err) {
+ sprintf(tmp, "SetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_SetPrinterDataExW(struct torture_context *tctx,
+ LPCSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle,
+ DWORD type,
+ LPBYTE buffer,
+ DWORD offered)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing SetPrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = SetPrinterDataExW(handle, keyname, valuename, type, buffer, offered);
+ if (err) {
+ sprintf(tmp, "SetPrinterDataExW(%ls) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterData_Server(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ BOOL ret = TRUE;
+ DWORD i;
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+ LPSTR valuenames[] = {
+ SPLREG_DEFAULT_SPOOL_DIRECTORY,
+ SPLREG_MAJOR_VERSION,
+ SPLREG_MINOR_VERSION,
+ SPLREG_DS_PRESENT,
+ SPLREG_DNS_MACHINE_NAME,
+ SPLREG_ARCHITECTURE,
+ SPLREG_OS_VERSION
+ };
+
+ for (i=0; i < ARRAY_SIZE(valuenames); i++) {
+ ret &= test_GetPrinterData(tctx, servername, valuenames[i], handle, &type, &buffer, &size);
+ ret &= test_GetPrinterDataEx(tctx, servername, "random", valuenames[i], handle, &type_ex, &buffer_ex, &size_ex);
+ torture_assert_int_equal(tctx, type, type_ex, "type mismatch");
+ torture_assert_int_equal(tctx, size, size_ex, "size mismatch");
+ torture_assert_mem_equal(tctx, buffer, buffer_ex, size, "buffer mismatch");
+ free(buffer);
+ free(buffer_ex);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL PrinterDataEqual(struct torture_context *tctx,
+ DWORD type1, DWORD type2,
+ DWORD size1, DWORD size2,
+ LPBYTE buffer1, LPBYTE buffer2)
+{
+ torture_assert_int_equal(tctx, type1, type2, "type mismatch");
+ torture_assert_int_equal(tctx, size1, size2, "size mismatch");
+ torture_assert_mem_equal(tctx, buffer1, buffer2, size1, "buffer mismatch");
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterData(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ char tmp[1024];
+ LPSTR keyname = "torture_key";
+ LPSTR valuename = "torture_value";
+ BOOL ret = TRUE;
+ DWORD types[] = {
+ REG_SZ,
+ REG_DWORD,
+ REG_BINARY
+ };
+ DWORD value = 12345678;
+ LPSTR str = "abcdefghijklmnopqrstuvwxzy";
+ DWORD t, s;
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+ for (s=0; s < strlen(str); s++) {
+
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+
+ if (types[t] == REG_DWORD) {
+ s = 0xffff;
+ }
+
+ switch (types[t]) {
+ case REG_BINARY:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ case REG_DWORD:
+ buffer = malloc(4);
+ memcpy(buffer, &value, 4);
+ size = 4;
+ break;
+ case REG_SZ:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ default:
+ sprintf(tmp, "type %d untested\n", types[t]);
+ torture_fail(tctx, tmp);
+ break;
+ }
+
+ type = types[t];
+
+ torture_comment(tctx, "Testing PrinterData (type: %s, size: 0x%08x)", reg_type_str(type), size);
+
+ torture_assert(tctx,
+ test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size),
+ "failed to call SetPrinterDataEx");
+ torture_assert(tctx,
+ test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex),
+ "failed to call GetPrinterDataEx");
+
+ if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
+ torture_warning(tctx, "GetPrinterDataEx does not return the same info as we set with SetPrinterDataEx");
+ ret = FALSE;
+ }
+ ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
+ ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
+
+ free(buffer);
+ free(buffer_ex);
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterDataW(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ char tmp[1024];
+ LPCWSTR keyname = L"torture_key";
+ LPCWSTR valuename = L"torture_value";
+ BOOL ret = TRUE;
+ DWORD types[] = {
+ REG_SZ,
+ REG_DWORD,
+ REG_BINARY
+ };
+ DWORD value = 12345678;
+ LPSTR str = "abcdefghijklmnopqrstuvwxzy";
+ DWORD t, s;
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+ for (s=0; s < strlen(str); s++) {
+
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+
+ if (types[t] == REG_DWORD) {
+ s = 0xffff;
+ }
+
+ switch (types[t]) {
+ case REG_BINARY:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ case REG_DWORD:
+ buffer = malloc(4);
+ memcpy(buffer, &value, 4);
+ size = 4;
+ break;
+ case REG_SZ:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ default:
+ sprintf(tmp, "type %d untested\n", types[t]);
+ torture_fail(tctx, tmp);
+ break;
+ }
+
+ type = types[t];
+
+ torture_comment(tctx, "Testing PrinterDataW (type: %s, size: 0x%08x)", reg_type_str(type), size);
+
+ torture_assert(tctx,
+ test_SetPrinterDataExW(tctx, printername, keyname, valuename, handle, type, buffer, size),
+ "failed to call SetPrinterDataExW");
+ torture_assert(tctx,
+ test_GetPrinterDataExW(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex),
+ "failed to call GetPrinterDataExW");
+
+ if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
+ torture_warning(tctx, "GetPrinterDataExW does not return the same info as we set with SetPrinterDataExW");
+ ret = FALSE;
+ }
+ ret &= test_DeletePrinterDataExW(tctx, printername, keyname, valuename, handle);
+ ret &= test_DeletePrinterKeyW(tctx, printername, keyname, handle);
+
+ free(buffer);
+ free(buffer_ex);
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+const char *get_string_param(const char *str)
+{
+ const char *p;
+
+ p = strchr(str, '=');
+ if (!p) {
+ return NULL;
+ }
+
+ return (p+1);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ BOOL ret = FALSE;
+ LPSTR servername;
+ LPSTR architecture = "Windows NT x86";
+ HANDLE server_handle;
+ PRINTER_DEFAULTS defaults_admin, defaults_use;
+ struct torture_context *tctx;
+ int i;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <name> [print] [samba3] [architecture=ARCHITECTURE]\n\n", argv[0]);
+ fprintf(stderr, "\t<name> can be a server or printer name URI\n");
+ fprintf(stderr, "\t[print] will print all data that has been retrieved\n");
+ fprintf(stderr, "\t from the printserver\n");
+ fprintf(stderr, "\t[samba3] will skip some tests samba servers are known\n");
+ fprintf(stderr, "\t not to have implemented\n");
+ fprintf(stderr, "\t[architecture=X] allows one to define a specific\n");
+ fprintf(stderr, "\t architecture to test with. choose between:\n");
+ fprintf(stderr, "\t \"Windows NT x86\" or \"Windows x64\"\n");
+ exit(-1);
+ }
+
+ tctx = malloc(sizeof(struct torture_context));
+ if (!tctx) {
+ fprintf(stderr, "out of memory\n");
+ exit(-1);
+ }
+ memset(tctx, '\0', sizeof(*tctx));
+
+ servername = argv[1];
+
+ for (i=1; i < argc; i++) {
+ if (strcmp(argv[i], "print") == 0) {
+ tctx->print = TRUE;
+ }
+ if (strcmp(argv[i], "samba3") == 0) {
+ tctx->samba3 = TRUE;
+ }
+ if (strncmp(argv[i], "architecture", strlen("architecture")) == 0) {
+ architecture = get_string_param(argv[i]);
+ }
+ }
+
+ printf("Running testsuite with architecture: %s\n", architecture);
+
+ defaults_admin.pDatatype = NULL;
+ defaults_admin.pDevMode = NULL;
+ defaults_admin.DesiredAccess = PRINTER_ACCESS_ADMINISTER;
+
+ defaults_use.pDatatype = NULL;
+ defaults_use.pDevMode = NULL;
+ defaults_use.DesiredAccess = PRINTER_ACCESS_USE;
+
+ if ((servername[0] == '\\') && (servername[1] == '\\')) {
+ LPSTR p = servername+2;
+ LPSTR p2;
+ if ((p2 = strchr(p, '\\')) != NULL) {
+ ret = test_OnePrinter(tctx, servername, architecture, &defaults_admin);
+ goto done;
+ }
+ }
+
+ ret &= test_EnumPrinters(tctx, servername);
+ ret &= test_EnumDrivers(tctx, servername, architecture);
+ ret &= test_OpenPrinter(tctx, servername, NULL, &server_handle);
+/* ret &= test_EnumPrinterKey(tctx, servername, server_handle, ""); */
+ ret &= test_PrinterData_Server(tctx, servername, server_handle);
+ ret &= test_EnumForms(tctx, servername, server_handle);
+ ret &= test_ClosePrinter(tctx, server_handle);
+ ret &= test_EnumPorts(tctx, servername);
+ ret &= test_EnumMonitors(tctx, servername);
+ ret &= test_EnumPrintProcessors(tctx, servername, architecture);
+ ret &= test_EnumPrintProcessorDatatypes(tctx, servername);
+ ret &= test_GetPrintProcessorDirectory(tctx, servername, architecture);
+ ret &= test_GetPrinterDriverDirectory(tctx, servername, architecture);
+ ret &= test_EachPrinter(tctx, servername, architecture, &defaults_admin);
+
+ done:
+ if (!ret) {
+ if (tctx->last_reason) {
+ fprintf(stderr, "failed: %s\n", tctx->last_reason);
+ }
+ free(tctx);
+ return -1;
+ }
+
+ printf("%s run successfully\n", argv[0]);
+
+ free(tctx);
+ return 0;
+}
diff --git a/testprogs/win32/spoolss/testspoolss.h b/testprogs/win32/spoolss/testspoolss.h
new file mode 100644
index 0000000..eb19c64
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.h
@@ -0,0 +1,51 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if 0
+#include "lib/replace/replace.h"
+#endif
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "error.h"
+#include "printlib_proto.h"
+
+#if 0
+#include <talloc.h>
+#include "libcli/util/ntstatus.h"
+#include "lib/torture/torture.h"
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#endif
+
+#ifndef true
+#define true TRUE
+#endif
+
+#ifndef false
+#define false FALSE
+#endif
+
+#ifndef PRINTER_ENUM_NAME
+#define PRINTER_ENUM_NAME 8
+#endif
diff --git a/testprogs/win32/spoolss/testspoolss.sln b/testprogs/win32/spoolss/testspoolss.sln
new file mode 100644
index 0000000..2082f5a
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testspoolss", "testspoolss.vcproj", "{60508731-0901-4B1D-9B11-DE070147DEF7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Debug|Win32.Build.0 = Debug|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Release|Win32.ActiveCfg = Release|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/testprogs/win32/spoolss/testspoolss.vcproj b/testprogs/win32/spoolss/testspoolss.vcproj
new file mode 100644
index 0000000..45544bc
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.vcproj
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="testspoolss"
+ ProjectGUID="{60508731-0901-4B1D-9B11-DE070147DEF7}"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\error.h"
+ >
+ </File>
+ <File
+ RelativePath=".\printlib_proto.h"
+ >
+ </File>
+ <File
+ RelativePath=".\string.h"
+ >
+ </File>
+ <File
+ RelativePath=".\testspoolss.h"
+ >
+ </File>
+ <File
+ RelativePath=".\torture.h"
+ >
+ </File>
+ <File
+ RelativePath=".\torture_proto.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\error.c"
+ >
+ </File>
+ <File
+ RelativePath=".\printlib.c"
+ >
+ </File>
+ <File
+ RelativePath=".\testspoolss.c"
+ >
+ </File>
+ <File
+ RelativePath=".\torture.c"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/testprogs/win32/spoolss/torture.c b/testprogs/win32/spoolss/torture.c
new file mode 100644
index 0000000..ff2824a
--- /dev/null
+++ b/testprogs/win32/spoolss/torture.c
@@ -0,0 +1,106 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture UI functions
+
+ Copyright (C) Jelmer Vernooij 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "testspoolss.h"
+#include "torture.h"
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_warning(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char tmp[1024];
+
+#if 0
+ if (!context->results->ui_ops->warning)
+ return;
+#endif
+
+ va_start(ap, comment);
+ if (vsprintf(tmp, comment, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+ fprintf(stderr, "WARNING: %s\n", tmp);
+#if 0
+ context->results->ui_ops->warning(context, tmp);
+
+ free(tmp);
+#endif
+}
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_result(struct torture_context *context,
+ enum torture_result result, const char *fmt, ...)
+{
+ va_list ap;
+ char tmp[1024];
+
+ va_start(ap, fmt);
+
+ if (context->last_reason) {
+ torture_warning(context, "%s", context->last_reason);
+ free(context->last_reason);
+ context->last_reason = NULL;
+ }
+
+ context->last_result = result;
+ if (vsprintf(tmp, fmt, ap) == -1) {
+ return;
+ }
+ context->last_reason = malloc(sizeof(tmp));
+ if (!context->last_reason) {
+ return;
+ }
+ memcpy(context->last_reason, tmp, sizeof(tmp));
+
+ va_end(ap);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_comment(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char tmp[1024];
+#if 0
+ if (!context->results->ui_ops->comment)
+ return;
+#endif
+ va_start(ap, comment);
+ if (vsprintf(tmp, comment, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+#if 0
+ context->results->ui_ops->comment(context, tmp);
+#endif
+ fprintf(stdout, "%s\n", tmp);
+
+#if 0
+ free(tmp);
+#endif
+}
diff --git a/testprogs/win32/spoolss/torture.h b/testprogs/win32/spoolss/torture.h
new file mode 100644
index 0000000..7c9c443
--- /dev/null
+++ b/testprogs/win32/spoolss/torture.h
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture UI functions
+
+ Copyright (C) Jelmer Vernooij 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TORTURE_UI_H__
+#define __TORTURE_UI_H__
+
+/****************************************************************************
+****************************************************************************/
+
+enum torture_result {
+ TORTURE_OK=0,
+ TORTURE_FAIL=1,
+ TORTURE_ERROR=2,
+ TORTURE_SKIP=3
+};
+
+struct torture_context {
+ enum torture_result last_result;
+ char *last_reason;
+ BOOL print;
+ BOOL samba3;
+};
+
+/****************************************************************************
+****************************************************************************/
+
+#define torture_assert(torture_ctx,expr,cmt) do {\
+ if (!(expr)) {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
+ return false;\
+ }\
+} while(0)
+
+#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strcmp(__got, __expected) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
+ do { int __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d, expected %d: %s", \
+ __got, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
+ do { const void *__got = (got), *__expected = (expected); \
+ if (memcmp(__got, __expected, len) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_skip(torture_ctx,cmt) do {\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
+ return true; \
+ } while(0)
+
+#define torture_fail(torture_ctx,cmt) do {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
+ return false; \
+ } while (0)
+
+#include "torture_proto.h"
+
+#endif
diff --git a/testprogs/win32/spoolss/torture_proto.h b/testprogs/win32/spoolss/torture_proto.h
new file mode 100644
index 0000000..5d1dd88
--- /dev/null
+++ b/testprogs/win32/spoolss/torture_proto.h
@@ -0,0 +1,32 @@
+#ifndef __TORTURE_PROTO_H__
+#define __TORTURE_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private
+ * to this subsystem or library. These functions should not be
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from torture.c */
+
+
+/****************************************************************************
+****************************************************************************/
+void torture_warning(struct torture_context *context, const char *comment, ...);
+
+/****************************************************************************
+****************************************************************************/
+void torture_result(struct torture_context *context,
+ enum torture_result result, const char *fmt, ...);
+
+/****************************************************************************
+****************************************************************************/
+void torture_comment(struct torture_context *context, const char *comment, ...);
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __TORTURE_PROTO_H__ */
+