Compare commits

..

1 Commits

Author SHA1 Message Date
The ReactOS Team
ac585f2a8e This commit was manufactured by cvs2svn to create branch
'win32k_message_rewrite'.

svn path=/branches/win32k_message_rewrite/; revision=6767
2003-11-23 15:44:14 +00:00
4377 changed files with 190863 additions and 1064397 deletions

View File

@@ -19,4 +19,3 @@ reactos
*.zip
*.iso
*.cab
doxy-doc

4
reactos/.gdbinit Normal file
View File

@@ -0,0 +1,4 @@
directory /mnt/windows/CvsHome/reactos/ntoskrnl
symbol-file ntoskrnl/ntoskrnl.nostrip.exe -mapped
set remotebaud 115200
target remote com2

View File

@@ -1,55 +1,19 @@
ReactOS is available thanks to the work of
In no particular order
Emanuele Aliberti <ea@iol.it>
Robert Bergkvist <fragdance@hotmail.com>
Hartmut Birr <hartmut.birr@gmx.de>
Aleksey Bragin <aleksey@studiocerebral.com>
Richard Campbell <eek2121@comcast.net>
Gunnar Andre' Dalsnes <hardon@online.no>
Arindam Das
Boudewijn Dekker <ariadne@xs4all.nl>
Robert Dickenson <robd@reactos.org>
Marty Dill <mdill@uvic.ca>
Jason Eager
Steven Edwards <steven_ed4153@yahoo.com>
Iwan Fatahi <i_fatahi@hotmail.com>
Jason Filby <jasonfilby@yahoo.com>
Martin Fuchs <martin-fuchs@gmx.net>
Jurgen van Gael <jurgen.vangael@student.kuleuven.ac.be>
Ge van Geldorp <ge@gse.nl>
Andrew Greenwood <lists@silverblade.co.uk>
Casper S. Hornstrup <chorns@users.sourceforge.net>
KJK::Hyperion <noog@libero.it>
Eugene Ingerman <geneing@myrealbox.com>
Rex Jolliff <rex@lvcablemodem.com>
Guido de Jong
Victor Kirhenshtein <sauros@iname.com>
Eric Kohl <ekohl@rz-online.de>
Hans Kremer
Frederik Leemans
Jean Michault
Royce Mitchell III <royce3@ev1.net>
Filip Navara <xnavara@volny.cz>
Jim Noeth
Mike Nordell ("tamlin")
Hernan Ochoa
Brian Palmer <brianp@sginet.com>
Paolo Pantaleo <paolopan@freemail.it>
Matt Pyne
Phillip Susi <phreak@iag.net>
James B. Tabor <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
Mark Tempel <mtempel@visi.com>
Vizzini <vizzini@plasmic.com>
Mark Weaver <mark@npsl.co.uk>
Thomas Weidenmueller <w3seek@users.sourceforge.net>
Jason Weiler
David Welch <welch@cwcom.net>
Jonathan Wilson <jonwil@tpgi.com.au>
Art Yerkes <ayerkes@speakeasy.net>
Graphic Design from
Everaldo (http://everaldo.com) for Explorer icons
Rex Jolliff (rex@lvcablemodem.com)
Boudewijn Dekker (ariadne@xs4all.nl)
Eric Kohl (ekohl@rz-online.de)
Emanuele Aliberti (ea@iol.it)
David Welch (welch@cwcom.net)
Iwan Fatahi (i_fatahi@hotmail.com)
Robert Bergkvist (fragdance@hotmail.com)
Victor Kirhenshtein (sauros@iname.com)
Jason Filby (jasonfilby@yahoo.com)
Brian Palmer (brianp@sginet.com)
Phillip Susi (phreak@iag.net)
Paolo Pantaleo (paolopan@freemail.it)
Casper S. Hornstrup (chorns@users.sourceforge.net)
James B. Tabor (jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net)
Source and inspiration from
@@ -76,3 +40,4 @@ Richter, Jeffery. Advanced Windows, 3rd ed. Microsoft, 1997.
Simon, Richard J. Windows NT Win32 API Superbible. Waite Group, 1996.
Solomon, David A. Inside Windows NT, 2nd Ed. Microsoft, 1998.
"The NT Insider." Open Systems Resources, 1999-2000.

View File

@@ -1,361 +1,3 @@
2004-06-05 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/helper.mk: Skip automatic dependency tracking if
DEPENDENCIES=no.
2004-05-31 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/reactos/version.h (KERNEL_VERSION_BUILD_TYPE): Replace possible
value FINAL with RELEASE.
2004-03-27 Art Yerkes <arty@users.sourceforge.net>
* Fixed make bootcd on windows + cross. Define TOPDIR as PATH_TO_TOP
2004-03-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
* subsys/system/usetup/bootsup.c (UpdateFreeLoaderIni): Use existing
ReactOS entry if available.
2004-03-09 Casper S. Hornstrup <chorns@users.sourceforge.net>
* regtests/Makefile: Make REGTEST_TARGETS depend on *.c.
* regtests/kmregtests/driver.c: Update call to PerformTests().
* regtests/kmrtint/kmrtint.c (RegTestMain): Update to match prototype.
* regtests/kmrtint/kmrtint.def (RegTestMain): Ditto.
* regtests/kmrtint/kmrtint.edf (RegTestMain): Ditto.
* regtests/win32base/tests/ws2event.c: New file.
* regtests/regtests/regtests.c (OUPUT_MODE_DbgPrint,
OUPUT_MODE_OutputDebugString, OUPUT_MODE_printf): Define.
(OutputMode): New variable.
(OutputRoutine): New function.
(RunTestDriver): Add TestName parameter.
(main): Parse command line to find output routine and test name.
* regtests/shared/regtests.c (PerformTest): Use specified output routine
if specified. Run only specified test if specified.
(PerformTests): Update call to PerformTest().
* regtests/shared/regtests.h (TestOutputRoutine): Add prototype.
(TestDriverMain): Add OutputRoutine and TestName parameter.
(PerformTests): Ditto.
* regtests/win32base/Makefile (TARGET_SDKLIBS): Add ws2_32.a.
* regtests/win32base/driver.c (RegTestMain): Update to match prototype.
* regtests/win32base/win32base.def (RegTestMain): Ditto.
* regtests/win32base/win32base.edf (RegTestMain): Ditto.
* tools/regtests.c (UMSTUB): Update call to PerformTests().
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
2004-02-25 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/datalink/loopback.c: Reformat.
* drivers/net/tcpip/network/neighbor.c: Ditto.
* drivers/net/tcpip/tcpip/info.c: Ditto.
* drivers/net/tcpip/transport/datagram/datagram.c: Cleanup.
If there is an out-of-resources situation, don't transmit the
datagram out of order.
2004-02-23 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/regtests.c (KMSTUB): Correct device name.
2004-02-22 Ge van Geldorp <ge@gse.nl>
* Implement keyboard navigation for menus
* Implement system menus
2004-02-22 Casper S. Hornstrup <chorns@users.sourceforge.net>
* Makefile (all): Put REGTESTS dependency earlier in the list.
* lib/kernel32/makefile: Support regression tests.
* lib/kernel32/misc/dllmain.c: Prepare regression tests.
* regtests/win32base/driver.c: (DummyThreadMain,
RunPrivateTests): Add.
(RegTestMain): Run private module regression tests.
* tools/helper.mk: Add rtshared.a to MK_LIBS if building
user-mode regression tests.
* tools/regtests.c (UMSTUB): Add.
(main): Output user-mode stub.
* lib/kernel32/tests: New directory.
* lib/kernel32/tests/.cvsignore: New file.
* lib/kernel32/tests/Makefile: New file.
* lib/kernel32/tests/tests: New directory.
* lib/kernel32/tests/tests/.cvsignore: New file.
* regtests/win32base/tests/file-1.c: move...
* lib/kernel32/tests/tests/file-1.c: ...here.
2004-02-22 Casper S. Hornstrup <chorns@users.sourceforge.net>
* config (REGRESSIONTESTS): Add.
* rules.mak (REGTESTS_PATH_INC): Add.
* drivers/net/tcpip/makefile: Support regression tests.
* drivers/net/tcpip/tcpip/main.c: Prepare regression tests.
* hal/halx86/Makefile: Rename TARGET_LIBPATH to TARGET_IMPLIBPATH.
* regtests/kmregtests/driver.c (KMRegTestsRegister): Add.
(KMRegTestsRun): Move call to InitializeTests() and RegisterTests() to
DriverEntry().
(KMRegTestsDispatch): Support IOCTL_KMREGTESTS_REGISTER.
* regtests/kmregtests/kmregtests.h (IOCTL_KMREGTESTS_REGISTER): Define.
* tools/config.mk: Define REGTESTS if REGRESSIONTESTS = 1.
* tools/helper.mk: Support module private regression tests.
(TARGET_LIBPATH): Rename to TARGET_IMPLIBPATH.
(TARGET_LIBPATH, TARGET_REGTESTS): Add.
* tools/mkconfig.c: Support REGTESTS.
* tools/regtests.c (umstubfile, kmstubfile): Add.
(is_file_changed, write_file_if_changed): Add.
(KMSTUB): Add.
(HELP): Mention -u and -k switches.
(main): Parse -u and -k switches.
* drivers/net/tcpip/tests: New directory.
* drivers/net/tcpip/tests/.cvsignore: New file.
* drivers/net/tcpip/tests/Makefile: Makefile.
* drivers/net/tcpip/tests/tests: New directory.
* drivers/net/tcpip/tests/tests/.cvsignore: New file.
2004-02-18 Casper S. Hornstrup <chorns@users.sourceforge.net>
* apistatus.lst: Correct path of videoprt.dll.
2004-02-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
* bootdata/packages/reactos.dff: Add oleaut32.dll.
2004-01-21 Casper S. Hornstrup <chorns@users.sourceforge.net>
* apistatus.lst: Rename tdi.dll to tdi.sys.
2004-01-18 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/winebuild/spec32.c (BuildDef32File): Don't support private flag
when cross-compiling.
2004-01-02 Steven Edwards <Steven_Ed4153@yahoo.com>
* ntoskrnl/kd/dlog.c: Make /DEBUGPORT=FILE work. With the help
of Filip Navara
* ntoskrnl/ke/main.c: Ditto
2003-12-29 Steven Edwards <Steven_Ed4153@yahoo.com>
* lib/version: Sync with Winehq 12-29-03
2003-12-25 Casper S. Hornstrup <chorns@users.sourceforge.net>
* apps/utils/net/roshttpd/error.cpp (ReportErrorStr): Cast to wchar_t*,
not __wchar_t*.
* apps/utils/net/roshttpd/makefile (TARGET_CPPFLAGS): Add -Wno-deprecated.
(TARGET_GCCLIBS): Add stdc++.
* apps/utils/net/roshttpd/common/socket.cpp: Include <string.h>.
* apps/utils/net/roshttpd/common/thread.cpp (CThread::CThread): Fix
warning.
* drivers/net/afd/afd/afd.c (ListenRequestLookasideList): New variable.
(DriverEntry): Initialize ListenRequestLookasideList.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): New function.
(AfdDispListen): Partial implement.
* drivers/net/afd/afd/opnclose.c (AfdInitializeFCB): Initialize
NewFCB->ListenRequestQueue.
(AfdKillListenRequests): New function.
(AfdClose): Call AfdKillListenRequests.
* drivers/net/afd/afd/routines.c (DumpName): New function.
* drivers/net/afd/afd/tdi.c (TdiAddressSizeFromType): New function.
(TdiBuildConnectionInfo): Initialize ConnInfo->OptionsLength.
(TdiBuildNullConnectionInfo): New function.
(TdiOpenAddressFileIPv4, TdiOpenConnectionEndpointFile): EaName is
0-terminated.
(TdiListen): New function.
* drivers/net/afd/include/afd.h (AFDFCB): Add ListenRequestQueue.
(AFD_LISTEN_REQUEST): New structure.
(ListenRequestLookasideList): Declare.
(DumpName, TdiListen): Add prototypes.
* drivers/net/tcpip/datalink/lan.c (BindAdapter): Initialize
AnsiAddress.Length and AnsiAddress.MaximumLength.
* drivers/net/tcpip/include/debug.h: Define DEBUG_TCP.
* drivers/net/tcpip/include/routines.h (DisplayTCPPacket): Add
prototype.
(DISPLAY_TCP_PACKET): Define.
* drivers/net/tcpip/include/tcp.h (TCPListen): Add prototype.
* drivers/net/tcpip/include/titypes.h (ADDRESS_FILE): Add Connection.
* drivers/net/tcpip/network/ip.c (IPLocateNTEOnInterface): Cleanup.
* drivers/net/tcpip/tcpip/address.c (AddrSearchNext): Port is in
network byte order.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiAssociateAddress):
Initialize AddrFile->Connection.
(DispTdiListen): Implement.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't
initialize AddrFile->Connections.
* drivers/net/tcpip/tcpip/routines.c: Include <tcp.h>.
(DisplayIPPacket): Enable.
(DisplayTCPHeader, DisplayTCPPacket): New functions.
* drivers/net/tcpip/transport/tcp/tcp.c: Include <routines.h>.
(TCPListen, TCPiReceive): New functions.
(TCPReceive): Partial implement.
* lib/msafd/misc/helpers.c (CreateHelperDLLDatabase): Add
{SOCK_STREAM,IPPROTO_TCP,0} and {SOCK_DGRAM,IPPROTO_UDP,0} mappings.
* lib/ntdll/ldr/utils.c (LdrLoadDll): Print name of DLL if not found.
* lib/ws2_32/include/ws2_32.h (Initialized): Declare.
(WINSOCK_THREAD_BLOCK): Remove Initialized member.
* (WSAINITIALIZED, WSASETINITIALIZED): Update.
* lib/ws2_32/misc/catalog.c (CreateCatalog): Add
{SOCK_STREAM,IPPROTO_TCP,0} and {SOCK_DGRAM,IPPROTO_UDP,0} mappings.
(Initialized): New variable.
(DllMain): Don't initialize p->Initialized.
* ntoskrnl/dbg/kdb.c: Include <ctype.h>.
* subsys/win32k/ntuser/message.c (NtUserDispatchMessage): Kill noisy
message.
2003-12-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/wine2ros: New directory.
* tools/wine2ros/Makefile: New file.
* tools/wine2ros/wine2ros.c: Ditto.
* tools/Makefile (wine2ros_target): Add.
* rules.mak (WINE2ROS): Define.
2003-12-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
Changes for compiling with w32api/Wine
* include/basetsd.h: #include_next <basetsd.h>. Add definitions missing
in w32api.
* include/mmddk.h: #include_next <mmddk.h>. Add definitions missing in
w32api.
* include/wine/winternl.h (DbgPrint): Use ReactOS prototype to avoid
conflicts.
2003-12-09 Casper S. Hornstrup <chorns@users.sourceforge.net>
* rules.mak (WINEBUILD): Define.
* tools/winebuild/Makefile: New file.
* tools/winebuild/import.c (ldcombine_files): Replace mkstemps with Win32
APIs.
* tools/winebuild/main.c (main): Win16 specs and relays are not supported.
* tools/winebuild/spec32.c (EXCEPTION_WINE_STUB, EH_NONCONTINUABLE):
Define.
(BuildDef32File): Don't emit PRIVATE.
2003-12-09 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/winebuild: Import winebuild from Wine (D20031208).
2003-12-08 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/win32k/text.h (NtGdiExtTextOut): Follow ExtTextOut prototype.
* lib/gdi32/objects/text.c (ExtTextOutW): Call NtGdiExtTextOut().
* lib/user32/controls/edit.c (EDIT_BuildLineDefs_ML): Order parameters to
CreateRectRgn().
* lib/user32/windows/draw.c (TabbedTextOutA): Implement.
(TEXT_TabbedTextOut): New function.
(TabbedTextOutW): Implement.
* subsys/win32k/objects/text.c (NtGdiExtTextOut): Call NtGdiTextOut() for
now.
2003-12-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
* lib/user32/windows/accel.c (U32IsValidAccelMessage): Translate WM_KEYUP
and WM_SYSKEYUP messages.
(TranslateAcceleratorA): Returntype of RtlMultiByteToUnicodeN is NTSTATUS,
so interpret it as such.
* subsys/win32k/ntuser/accelerator.c (NtUserDestroyAcceleratorTable):
Call ObmCloseHandle() before destroying the object.
(IntTranslateAccelerator): New function.
(NtUserTranslateAccelerator): Partial implementation.
2003-12-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
* subsys/win32k/include/accelerator.h: New file.
* subsys/win32k/ntuser/accelerator.c: Ditto.
* include/win32k/ntuser.h (NtUserDestroyAcceleratorTable): Make returntype
BOOLEAN.
* subsys/win32k/makefile (NTUSER_OBJECTS): Add ntuser/accelerator.o.
* subsys/win32k/include/object.h (USER_OBJECT_TYPE): Add otAcceleratorTable.
* subsys/win32k/main/dllmain.c (DllMain): Call InitAcceleratorImpl().
* subsys/win32k/ntuser/stubs.c (NtUserCopyAcceleratorTable,
NtUserCreateAcceleratorTable, NtUserDestroyAcceleratorTable,
NtUserTranslateAccelerator): Move to accelerator.c.
2003-12-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
* apps/tests/accelerator: New directory.
* apps/tests/accelerator/accelerator.c: New file.
* apps/tests/accelerator/.cvsignore: Ditto.
* apps/tests/accelerator/Makefile: Ditto.
* apps/tests/Makefile (TEST_APPS): Add accelerator.
2003-12-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
* regtests/Makefile: Generate regression test registrations.
* regtests/kmregtests/.cvsignore: Ignore Makefile.tests.
* regtests/win32base/.cvsignore: Ditto.
* regtests/kmregtests/Makefile: Include Makefile.tests.
* regtests/win32base/Makefile: Ditto.
* regtests/kmregtests/tests: New directory.
* regtests/win32base/tests: Ditto.
* regtests/kmregtests/tests/.cvsignore: New file.
* regtests/win32base/tests/.cvsignore: Ditto.
* tools/helper.mk: Remove TARGET_GENREGTESTS.
* tools/regtests.c: Generate makefile for regression tests.
(change_extension): New function.
* regtests/win32base/file-1.c: Move ...
* regtests/win32base/tests/file-1.c: ... here.
2003-12-06 Martin Fuchs <martin-fuchs@gmx.net>
* Doxyfile, Makefile: initial doxygen configuration
* drivers/Doxyfile, drivers/Makefile: Ditto.
* ntoskrnl/Doxyfile, ntoskrnl/Makefile: Ditto.
* subsys/win32k/Doxyfile, subsys/win32k/Makefile: Ditto.
* apps/Doxyfile, apps/Makefile: Ditto.
2003-11-29 Casper S. Hornstrup <chorns@users.sourceforge.net>
* tools/cabman/dfp.cxx (CDFParser::Parse): Allow TokenString.
(CDFParser::PerformFileCopy): Use CurrentChar instead of length of
CurrentString to find the start of the next token.
2003-11-08 Martin Fuchs <martin-fuchs@gmx.net>
* controls/button.c partial fix for for Bug #42:
@@ -3195,3 +2837,12 @@
* Disabled broken code in kernel32.

View File

@@ -1,211 +0,0 @@
# Doxyfile 1.3.5
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = ReactOS
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doxy-doc
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = .
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = NO
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = hal \
subsys \
services \
regtests \
iface
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE = subsys/win32k \
subsys/system/explorer
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = YES
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = YES
RTF_HYPERLINKS = YES
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = NO
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = include
INCLUDE_FILE_PATTERNS = *.h
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = YES

View File

@@ -1,4 +1,4 @@
# $Id: Makefile,v 1.231 2004/06/15 22:33:45 gvg Exp $
# $Id: Makefile,v 1.179 2003/11/19 03:20:25 rcampbell Exp $
#
# Global makefile
#
@@ -32,23 +32,19 @@ BUS = acpi isapnp pci
LIB_FSLIB = vfatlib
# Static libraries
LIB_STATIC = string rosrtl epsapi uuid libwine zlib rtl tgetopt
LIB_STATIC = string rosrtl epsapi zlib
# Keyboard layout libraries
DLLS_KBD = kbddv kbdfr kbdgr kbdse kbduk kbdus
# Control Panels
DLLS_CPL = cpl
DLLS_KBD = kbdus kbdgr kbdfr
# User mode libraries
# advapi32 cards crtdll comdlg32 fmifs gdi32 imagehlp kernel32 libpcap packet msafd msvcrt ntdll
# advapi32 cards crtdll fmifs gdi32 imagehlp kernel32 libpcap packet msafd msvcrt ntdll
# epsapi psapi richedit rpcrt4 secur32 user32 version ws2help ws2_32 wsock32 wshirda mswsock
# imagehlp imm32
DLLS = advapi32 cabinet cards comctl32 crtdll comdlg32 d3d8thk expat fmifs freetype gdi32 \
imm32 iphlpapi kernel32 lzexpand mpr msafd msgina msimg32 msvcrt msvcrt20 mswsock \
netapi32 ntdll ole32 oleaut32 oledlg packet psapi richedit rpcrt4 samlib secur32 \
setupapi shell32 shlwapi snmpapi syssetup twain unicode user32 userenv version wininet \
winmm winspool ws2help ws2_32 wsock32 wshirda imagehlp $(DLLS_KBD) $(DLLS_CPL)
# imagehlp
DLLS = advapi32 cards crtdll fmifs freetype gdi32 kernel32 packet lzexpand msafd \
msvcrt ntdll psapi richedit rpcrt4 secur32 syssetup twain user32 version winedbgc \
winspool ws2help ws2_32 wsock32 wshirda iphlpapi mswsock msimg32 d3d8thk \
$(DLLS_KBD)
SUBSYS = smss win32k csrss ntvdm
@@ -63,13 +59,13 @@ SERVERS = win32
LOADERS = dos
# Driver support libraries
#bzip2 zlib oskittcp
DRIVERS_LIB = bzip2 oskittcp csq
#bzip2 zlib
DRIVERS_LIB = bzip2
# Kernel mode device drivers
# Obsolete: ide
# beep blue floppy null parallel ramdrv serenum serial
DEVICE_DRIVERS = beep blue debugout null serial bootvid
# beep blue floppy null parallel ramdrv serenum serial vga videoprt
DEVICE_DRIVERS = beep blue debugout floppy null serial vga videoprt bootvid
# Kernel mode input drivers
INPUT_DRIVERS = keyboard mouclass psaux sermouse
@@ -88,11 +84,11 @@ NET_DEVICE_DRIVERS = ne2000 pcnet
# Kernel mode storage drivers
# atapi cdrom class2 disk scsiport
STORAGE_DRIVERS = atapi cdrom class2 disk floppy scsiport diskdump
STORAGE_DRIVERS = atapi cdrom class2 disk scsiport diskdump
# System applications
# autochk cmd format services setup usetup welcome winlogon
SYS_APPS = autochk cmd explorer format services setup taskmgr userinit usetup welcome vmwinst winlogon regedit
# autochk cmd format gstart services setup usetup welcome winlogon
SYS_APPS = autochk cmd format gstart services setup usetup welcome winlogon
# System services
# rpcss eventlog
@@ -101,9 +97,9 @@ SYS_SVC = rpcss eventlog
APPS = tests testsets utils
# External modules and (sub)systems for ReactOS
# rosapps posix os2 (requires c++) java (non-existant)
EXTERNALS = rosapps
# External (sub)systems for ReactOS
# rosapps wine posix os2 (requires c++) java (non-existant)
EXTERNALS = rosapps wine posix os2
ifeq ($(ROS_BUILD_EXT),yes)
EXT_MODULES = $(EXTERNALS)
@@ -112,14 +108,14 @@ EXT_MODULES =
endif
KERNEL_DRIVERS = $(DRIVERS_LIB) $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) \
$(NET_DRIVERS) $(NET_DEVICE_DRIVERS) $(STORAGE_DRIVERS) VIDEO_DRIVERS
$(NET_DRIVERS) $(NET_DEVICE_DRIVERS) $(STORAGE_DRIVERS)
# Regression tests
REGTESTS = regtests
all: tools dk implib $(LIB_STATIC) $(COMPONENTS) $(REGTESTS) $(HALS) $(BUS) $(LIB_FSLIB) $(DLLS) $(SUBSYS) \
all: tools dk implib $(LIB_STATIC) $(COMPONENTS) $(HALS) $(BUS) $(LIB_FSLIB) $(DLLS) $(SUBSYS) \
$(LOADERS) $(KERNEL_DRIVERS) $(SYS_APPS) $(SYS_SVC) \
$(APPS) $(EXT_MODULES)
$(APPS) $(EXT_MODULES) $(REGTESTS)
#config: $(TOOLS:%=%_config)
@@ -127,9 +123,10 @@ depends: $(LIB_STATIC:%=%_depends) $(LIB_FSLIB:%=%_depends) $(DLLS:%=%_depends)
$(EXT_MODULES:%=%_depends) $(POSIX_LIBS:%=%_depends)
implib: $(COMPONENTS:%=%_implib) $(HALS:%=%_implib) $(BUS:%=%_implib) \
$(LIB_STATIC:%=%_implib) $(LIB_FSLIB:%=%_implib) $(DLLS:%=%_implib) $(LOADERS:%=%_implib) \
$(KERNEL_DRIVERS:%=%_implib) $(SUBSYS:%=%_implib) \
$(SYS_SVC:%=%_implib) $(EXT_MODULES:%=%_implib)
$(LIB_STATIC:%=%_implib) $(LIB_FSLIB:%=%_implib) $(DLLS:%=%_implib) $(LOADERS:%=%_implib) \
$(KERNEL_DRIVERS:%=%_implib) $(SUBSYS:%=%_implib) \
$(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) \
$(APPS:%=%_implib) $(EXT_MODULES:%=%_implib)
clean: tools dk_clean $(HALS:%=%_clean) \
$(COMPONENTS:%=%_clean) $(BUS:%=%_clean) $(LIB_STATIC:%=%_clean) $(LIB_FSLIB:%=%_clean) $(DLLS:%=%_clean) \
@@ -142,20 +139,26 @@ clean: tools dk_clean $(HALS:%=%_clean) \
clean_after:
$(RM) $(PATH_TO_TOP)/include/roscfg.h
fastinstall: tools install_dirs install_before \
install: tools install_dirs install_before \
$(COMPONENTS:%=%_install) $(HALS:%=%_install) $(BUS:%=%_install) \
$(LIB_STATIC:%=%_install) $(LIB_FSLIB:%=%_install) $(DLLS:%=%_install) $(LOADERS:%=%_install) \
$(KERNEL_DRIVERS:%=%_install) $(SUBSYS:%=%_install) \
$(SYS_APPS:%=%_install) $(SYS_SVC:%=%_install) \
$(APPS:%=%_install) $(EXT_MODULES:%=%_install) $(REGTESTS:%=%_install)
install: fastinstall registry
dist: $(TOOLS_PATH)/rcopy$(EXE_POSTFIX) dist_clean dist_dirs \
$(HALS:%=%_dist) $(COMPONENTS:%=%_dist) $(BUS:%=%_dist) $(LIB_STATIC:%=%_dist) $(LIB_FSLIB:%=%_dist) \
$(DLLS:%=%_dist) $(LOADERS:%=%_dist) $(KERNEL_DRIVERS:%=%_dist) $(SUBSYS:%=%_dist) \
$(SYS_APPS:%=%_dist) $(SYS_SVC:%=%_dist) \
$(NET_APPS:%=%_dist) \
$(APPS:%=%_dist) $(EXT_MODULES:%=%_dist)
FREELDR_DIR = ../freeldr
freeldr:
$(MAKE) -C $(FREELDR_DIR)
bootcd_directory_layout:
bootcd_directory_layout: freeldr
$(RMKDIR) $(BOOTCD_DIR)
$(RMKDIR) $(BOOTCD_DIR)/bootdisk
$(RMKDIR) $(BOOTCD_DIR)/loader
@@ -183,12 +186,11 @@ bootcd_install_before:
$(RLINE) bootdata/hivesys.inf $(BOOTCD_DIR)/reactos/hivesys.inf
$(RLINE) bootdata/txtsetup.sif $(BOOTCD_DIR)/reactos/txtsetup.sif
$(CP) bootdata/icon.ico $(BOOTCD_DIR)/icon.ico
$(CP) subsys/system/welcome/welcome.exe $(BOOTCD_DIR)/reactos/welcome.exe
$(CP) media/nls/c_1252.nls $(BOOTCD_DIR)/reactos/c_1252.nls
$(CP) media/nls/c_437.nls $(BOOTCD_DIR)/reactos/c_437.nls
$(CP) media/nls/l_intl.nls $(BOOTCD_DIR)/reactos/l_intl.nls
bootcd_basic: bootcd_directory_layout bootcd_bootstrap_files bootcd_install_before
bootcd_basic: all bootcd_directory_layout bootcd_bootstrap_files bootcd_install_before
bootcd_makecd:
$(CABMAN) /C bootdata/packages/reactos.dff /L $(BOOTCD_DIR)/reactos /I
@@ -199,38 +201,14 @@ bootcd_makecd:
ubootcd_unattend:
$(CP) bootdata/unattend.inf $(BOOTCD_DIR)/reactos/unattend.inf
livecd_directory_layout:
$(RMKDIR) $(LIVECD_DIR)
$(RMKDIR) $(LIVECD_DIR)/loader
$(RMKDIR) $(LIVECD_DIR)/reactos
$(RMKDIR) $(LIVECD_DIR)/Profiles/All\ Users/Desktop
$(RMKDIR) $(LIVECD_DIR)/Profiles/Default\ User/Desktop
$(RMKDIR) $(LIVECD_DIR)/Profiles/Default\ User/My\ Documents
$(CP) ${FREELDR_DIR}/bootsect/isoboot.bin ${LIVECD_DIR}/../isoboot.bin
$(CP) ${FREELDR_DIR}/freeldr/obj/i386/freeldr.sys ${LIVECD_DIR}/loader/setupldr.sys
$(RLINE) bootdata/livecd.ini $(LIVECD_DIR)/freeldr.ini
livecd_bootstrap_files:
$(MAKE) LIVECD_INSTALL=yes fastinstall
livecd_install_before:
$(TOOLS_PATH)/mkhive/mkhive$(EXE_POSTFIX) bootdata $(LIVECD_DIR)/reactos/system32/config bootdata/livecd.inf bootdata/hiveinst.inf
livecd_basic: livecd_directory_layout livecd_bootstrap_files livecd_install_before
livecd_makecd:
$(TOOLS_PATH)/cdmake/cdmake -m -j -b $(LIVECD_DIR)/../isoboot.bin $(LIVECD_DIR) REACTOS roslive.iso
bootcd: bootcd_basic bootcd_makecd
ubootcd: bootcd_basic ubootcd_unattend bootcd_makecd
livecd: livecd_basic livecd_makecd
registry: tools
$(TOOLS_PATH)/mkhive/mkhive$(EXE_POSTFIX) bootdata $(INSTALL_DIR)/system32/config bootdata/hiveinst.inf
$(TOOLS_PATH)/mkhive/mkhive$(EXE_POSTFIX) bootdata $(INSTALL_DIR)/system32/config
.PHONY: all depends implib clean clean_before install freeldr bootcd_directory_layout \
.PHONY: all depends implib clean clean_before install dist freeldr bootcd_directory_layout \
bootcd_bootstrap_files bootcd_install_before bootcd_basic bootcd_makecd ubootcd_unattend bootcd
@@ -246,13 +224,16 @@ $(SYS_APPS:%=%_implib): %_implib:
$(SYS_APPS:%=%_clean): %_clean:
$(MAKE) -C subsys/system/$* clean
$(SYS_APPS:%=%_dist): %_dist:
$(MAKE) -C subsys/system/$* dist
$(SYS_APPS:%=%_install): %_install:
$(MAKE) -C subsys/system/$* install
$(SYS_APPS:%=%_bootcd): %_bootcd:
$(MAKE) -C subsys/system/$* bootcd
.PHONY: $(SYS_APPS) $(SYS_APPS:%=%_implib) $(SYS_APPS:%=%_clean) $(SYS_APPS:%=%_install) $(SYS_APPS:%=%_bootcd)
.PHONY: $(SYS_APPS) $(SYS_APPS:%=%_implib) $(SYS_APPS:%=%_clean) $(SYS_APPS:%=%_install) $(SYS_APPS:%=%_dist) $(SYS_APPS:%=%_bootcd)
#
# System Services
@@ -269,10 +250,13 @@ $(SYS_SVC:%=%_implib): %_implib:
$(SYS_SVC:%=%_clean): %_clean:
$(MAKE) -C services/$* clean
$(SYS_SVC:%=%_dist): %_dist:
$(MAKE) -C services/$* dist
$(SYS_SVC:%=%_install): %_install:
$(MAKE) -C services/$* install
.PHONY: $(SYS_SVC) $(SYS_SVC:%=%_depends) $(SYS_SVC:%=%_implib) $(SYS_SVC:%=%_clean) $(SYS_SVC:%=%_install)
.PHONY: $(SYS_SVC) $(SYS_SVC:%=%_depends) $(SYS_SVC:%=%_implib) $(SYS_SVC:%=%_clean) $(SYS_SVC:%=%_install) $(SYS_SVC:%=%_dist)
#
@@ -284,17 +268,19 @@ $(SYS_SVC:%=%_install): %_install:
$(APPS): %:
$(MAKE) -C apps/$*
# Not needed
# $(APPS:%=%_implib): %_implib:
# $(MAKE) -C apps/$* implib
$(APPS:%=%_implib): %_implib:
$(MAKE) -C apps/$* implib
$(APPS:%=%_clean): %_clean:
$(MAKE) -C apps/$* clean
$(APPS:%=%_dist): %_dist:
$(MAKE) -C apps/$* dist
$(APPS:%=%_install): %_install:
$(MAKE) -C apps/$* install
.PHONY: $(APPS) $(APPS:%=%_implib) $(APPS:%=%_clean) $(APPS:%=%_install)
.PHONY: $(APPS) $(APPS:%=%_implib) $(APPS:%=%_clean) $(APPS:%=%_install) $(APPS:%=%_dist)
#
@@ -312,10 +298,13 @@ $(EXTERNALS:%=%_implib): %_implib:
$(EXTERNALS:%=%_clean): %_clean:
$(MAKE) -C $(ROOT_PATH)/$* clean
$(EXTERNALS:%=%_dist): %_dist:
$(MAKE) -C $(ROOT_PATH)/$* dist
$(EXTERNALS:%=%_install): %_install:
$(MAKE) -C $(ROOT_PATH)/$* install
.PHONY: $(EXTERNALS) $(EXTERNALS:%=%_depends) $(EXTERNALS:%=%_implib) $(EXTERNALS:%=%_clean) $(EXTERNALS:%=%_install)
.PHONY: $(EXTERNALS) $(EXTERNALS:%=%_depends) $(EXTERNALS:%=%_implib) $(EXTERNALS:%=%_clean) $(EXTERNALS:%=%_install) $(EXTERNALS:%=%_dist)
#
@@ -331,7 +320,9 @@ tools_clean:
tools_install:
.PHONY: tools tools_implib tools_clean tools_install
tools_dist:
.PHONY: tools tools_implib tools_clean tools_install tools_dist
#
@@ -369,7 +360,9 @@ dk_clean:
dk_install:
.PHONY: dk dk_implib dk_clean dk_install
dk_dist:
.PHONY: dk dk_implib dk_clean dk_install dk_dist
#
@@ -385,6 +378,8 @@ iface_native_clean:
iface_native_install:
iface_native_dist:
iface_native_bootcd:
iface_additional:
@@ -397,13 +392,14 @@ iface_additional_clean:
iface_additional_install:
iface_additional_dist:
iface_additional_bootcd:
.PHONY: iface_native iface_native_implib iface_native_clean iface_native_install \
iface_native_bootcd \
iface_native_dist iface_native_bootcd \
iface_additional iface_additional_implib iface_additional_clean \
iface_additional_install iface_additional_bootcd
iface_additional_install iface_additional_dist iface_additional_bootcd
#
# Bus driver rules
@@ -420,12 +416,14 @@ $(BUS:%=%_clean): %_clean:
$(BUS:%=%_install): %_install:
$(MAKE) -C drivers/bus/$* install
$(BUS:%=%_dist): %_dist:
$(MAKE) -C drivers/bus/$* dist
$(BUS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/bus/$* bootcd
.PHONY: $(BUS) $(BUS:%=%_implib) $(BUS:%=%_clean) \
$(BUS:%=%_install) $(BUS:%=%_bootcd)
$(BUS:%=%_install) $(BUS:%=%_dist) $(BUS:%=%_bootcd)
#
# Driver support libraries rules
@@ -442,12 +440,14 @@ $(DRIVERS_LIB:%=%_clean): %_clean:
$(DRIVERS_LIB:%=%_install): %_install:
$(MAKE) -C drivers/lib/$* install
$(DRIVERS_LIB:%=%_dist): %_dist:
$(MAKE) -C drivers/lib/$* dist
$(DRIVERS_LIB:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/lib/$* bootcd
.PHONY: $(DRIVERS_LIB) $(DRIVERS_LIB:%=%_implib) $(DRIVERS_LIB:%=%_clean) \
$(DRIVERS_LIB:%=%_install) $(DRIVERS_LIB:%=%_bootcd)
$(DRIVERS_LIB:%=%_install) $(DRIVERS_LIB:%=%_dist) $(DRIVERS_LIB:%=%_bootcd)
#
# Device driver rules
@@ -464,34 +464,14 @@ $(DEVICE_DRIVERS:%=%_clean): %_clean:
$(DEVICE_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/dd/$* install
$(DEVICE_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/dd/$* dist
$(DEVICE_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/dd/$* bootcd
.PHONY: $(DEVICE_DRIVERS) $(DEVICE_DRIVERS:%=%_implib) $(DEVICE_DRIVERS:%=%_clean) \
$(DEVICE_DRIVERS:%=%_install) $(DEVICE_DRIVERS:%=%_bootcd)
#
# Video device driver rules
#
VIDEO_DRIVERS:
$(MAKE) -C drivers/video
VIDEO_DRIVERS_implib:
$(MAKE) -C drivers/video implib
VIDEO_DRIVERS_clean:
$(MAKE) -C drivers/video clean
VIDEO_DRIVERS_install:
$(MAKE) -C drivers/video install
VIDEO_DRIVERS_bootcd:
$(MAKE) -C drivers/video bootcd
.PHONY: VIDEO_DRIVERS VIDEO_DRIVERS_implib VIDEO_DRIVERS_clean \
VIDEO_DRIVERS_install VIDEO_DRIVERS_bootcd
$(DEVICE_DRIVERS:%=%_install) $(DEVICE_DRIVERS:%=%_dist) $(DEVICE_DRIVERS:%=%_bootcd)
#
# Input driver rules
@@ -508,15 +488,15 @@ $(INPUT_DRIVERS:%=%_clean): %_clean:
$(INPUT_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/input/$* install
$(INPUT_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/input/$* dist
$(INPUT_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/input/$* bootcd
.PHONY: $(INPUT_DRIVERS) $(INPUT_DRIVERS:%=%_implib) $(INPUT_DRIVERS:%=%_clean)\
$(INPUT_DRIVERS:%=%_install) $(INPUT_DRIVERS:%=%_bootcd)
$(INPUT_DRIVERS:%=%_install) $(INPUT_DRIVERS:%=%_dist) $(INPUT_DRIVERS:%=%_bootcd)
#
# Filesystem driver rules
#
$(FS_DRIVERS): %:
$(MAKE) -C drivers/fs/$*
@@ -529,12 +509,14 @@ $(FS_DRIVERS:%=%_clean): %_clean:
$(FS_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/fs/$* install
$(FS_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/fs/$* dist
$(FS_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/fs/$* bootcd
.PHONY: $(FS_DRIVERS) $(FS_DRIVERS:%=%_implib) $(FS_DRIVERS:%=%_clean) \
$(FS_DRIVERS:%=%_install) $(FS_DRIVERS:%=%_bootcd)
$(FS_DRIVERS:%=%_install) $(FS_DRIVERS:%=%_dist) $(FS_DRIVERS:%=%_bootcd)
#
# Network driver rules
@@ -551,16 +533,15 @@ $(NET_DRIVERS:%=%_clean): %_clean:
$(NET_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/net/$* install
$(NET_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/net/$* dist
$(NET_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/net/$* bootcd
.PHONY: $(NET_DRIVERS) $(NET_DRIVERS:%=%_implib) $(NET_DRIVERS:%=%_clean) \
$(NET_DRIVERS:%=%_install) $(NET_DRIVERS:%=%_bootcd)
$(NET_DRIVERS:%=%_install) $(NET_DRIVERS:%=%_dist) $(NET_DRIVERS:%=%_bootcd)
#
# Network device driver rules
#
$(NET_DEVICE_DRIVERS): %:
$(MAKE) -C drivers/net/dd/$*
@@ -573,12 +554,14 @@ $(NET_DEVICE_DRIVERS:%=%_clean): %_clean:
$(NET_DEVICE_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/net/dd/$* install
$(NET_DEVICE_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/net/dd/$* dist
$(NET_DEVICE_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/net/dd/$* bootcd
.PHONY: $(NET_DEVICE_DRIVERS) $(NET_DEVICE_DRIVERS:%=%_clean) $(NET_DEVICE_DRIVERS:%=%_implib) \
$(NET_DEVICE_DRIVERS:%=%_install) $(NET_DEVICE_DRIVERS:%=%_bootcd)
$(NET_DEVICE_DRIVERS:%=%_install) $(NET_DEVICE_DRIVERS:%=%_dist) $(NET_DEVICE_DRIVERS:%=%_bootcd)
#
# storage driver rules
@@ -595,16 +578,19 @@ $(STORAGE_DRIVERS:%=%_clean): %_clean:
$(STORAGE_DRIVERS:%=%_install): %_install:
$(MAKE) -C drivers/storage/$* install
$(STORAGE_DRIVERS:%=%_dist): %_dist:
$(MAKE) -C drivers/storage/$* dist
$(STORAGE_DRIVERS:%=%_bootcd): %_bootcd:
$(MAKE) -C drivers/storage/$* bootcd
.PHONY: $(STORAGE_DRIVERS) $(STORAGE_DRIVERS:%=%_clean) $(STORAGE_DRIVERS:%=%_implib) \
$(STORAGE_DRIVERS:%=%_install) $(STORAGE_DRIVERS:%=%_bootcd)
$(STORAGE_DRIVERS:%=%_install) $(STORAGE_DRIVERS:%=%_dist) $(STORAGE_DRIVERS:%=%_bootcd)
#
# Kernel loaders
#
$(LOADERS): %:
$(MAKE) -C loaders/$*
@@ -616,12 +602,16 @@ $(LOADERS:%=%_clean): %_clean:
$(LOADERS:%=%_install): %_install:
$(MAKE) -C loaders/$* install
.PHONY: $(LOADERS) $(LOADERS:%=%_implib) $(LOADERS:%=%_clean) $(LOADERS:%=%_install)
$(LOADERS:%=%_dist): %_dist:
$(MAKE) -C loaders/$* dist
.PHONY: $(LOADERS) $(LOADERS:%=%_implib) $(LOADERS:%=%_clean) $(LOADERS:%=%_install) \
$(LOADERS:%=%_dist)
#
# Required system components
#
ntoskrnl:
$(MAKE) -C ntoskrnl
@@ -634,15 +624,18 @@ ntoskrnl_clean:
ntoskrnl_install:
$(MAKE) -C ntoskrnl install
ntoskrnl_dist:
$(MAKE) -C ntoskrnl dist
ntoskrnl_bootcd:
$(MAKE) -C ntoskrnl bootcd
.PHONY: ntoskrnl ntoskrnl_implib ntoskrnl_clean ntoskrnl_install ntoskrnl_bootcd
.PHONY: ntoskrnl ntoskrnl_implib ntoskrnl_clean ntoskrnl_install ntoskrnl_dist ntoskrnl_bootcd
#
# Hardware Abstraction Layer import library
#
hallib:
$(MAKE) -C hal/hal
@@ -655,15 +648,18 @@ hallib_clean:
hallib_install:
$(MAKE) -C hal/hal install
hallib_dist:
$(MAKE) -C hal/hal dist
hallib_bootcd:
$(MAKE) -C hal/hal bootcd
.PHONY: hallib hallib_implib hallib_clean hallib_install hallib_bootcd
.PHONY: hallib hallib_implib hallib_clean hallib_install hallib_dist hallib_bootcd
#
# Hardware Abstraction Layers
#
$(HALS): %:
$(MAKE) -C hal/$*
@@ -676,15 +672,18 @@ $(HALS:%=%_clean): %_clean:
$(HALS:%=%_install): %_install:
$(MAKE) -C hal/$* install
$(HALS:%=%_dist): %_dist:
$(MAKE) -C hal/$* dist
$(HALS:%=%_bootcd): %_bootcd:
$(MAKE) -C hal/$* bootcd
.PHONY: $(HALS) $(HALS:%=%_implib) $(HALS:%=%_clean) $(HALS:%=%_install) $(HALS:%=%_bootcd)
.PHONY: $(HALS) $(HALS:%=%_implib) $(HALS:%=%_clean) $(HALS:%=%_install) $(HALS:%=%_dist) $(HALS:%=%_bootcd)
#
# File system libraries
#
$(LIB_FSLIB): %:
$(MAKE) -C lib/fslib/$*
@@ -700,16 +699,19 @@ $(LIB_FSLIB:%=%_clean): %_clean:
$(LIB_FSLIB:%=%_install): %_install:
$(MAKE) -C lib/fslib/$* install
$(LIB_FSLIB:%=%_dist): %_dist:
$(MAKE) -C lib/fslib/$* dist
$(LIB_FSLIB:%=%_bootcd): %_bootcd:
$(MAKE) -C lib/fslib/$* bootcd
.PHONY: $(LIB_FSLIB) $(LIB_FSLIB:%=%_depends) $(LIB_FSLIB:%=%_implib) $(LIB_FSLIB:%=%_clean) \
$(LIB_FSLIB:%=%_install) $(LIB_FSLIB:%=%_bootcd)
$(LIB_FSLIB:%=%_install) $(LIB_FSLIB:%=%_dist) $(LIB_FSLIB:%=%_bootcd)
#
# Static libraries
#
$(LIB_STATIC): %:
$(MAKE) -C lib/$*
@@ -725,16 +727,19 @@ $(LIB_STATIC:%=%_clean): %_clean:
$(LIB_STATIC:%=%_install): %_install:
$(MAKE) -C lib/$* install
$(LIB_STATIC:%=%_dist): %_dist:
$(MAKE) -C lib/$* dist
$(LIB_STATIC:%=%_bootcd): %_bootcd:
$(MAKE) -C lib/$* bootcd
.PHONY: $(LIB_STATIC) $(LIB_STATIC:%=%_depends) $(LIB_STATIC:%=%_implib) $(LIB_STATIC:%=%_clean) \
$(LIB_STATIC:%=%_install) $(LIB_STATIC:%=%_bootcd)
$(LIB_STATIC:%=%_install) $(LIB_STATIC:%=%_dist) $(LIB_STATIC:%=%_bootcd)
#
# DLLs
# Required DLLs
#
$(DLLS): %:
$(MAKE) -C lib/$*
@@ -750,16 +755,18 @@ $(DLLS:%=%_clean): %_clean:
$(DLLS:%=%_install): %_install:
$(MAKE) -C lib/$* install
$(DLLS:%=%_dist): %_dist:
$(MAKE) -C lib/$* dist
$(DLLS:%=%_bootcd): %_bootcd:
$(MAKE) -C lib/$* bootcd
.PHONY: $(DLLS) $(DLLS:%=%_depends) $(DLLS:%=%_implib) $(DLLS:%=%_clean) $(DLLS:%=%_install) \
$(DLLS:%=%_bootcd)
.PHONY: $(DLLS) $(DLLS:%=%_depends) $(DLLS:%=%_implib) $(DLLS:%=%_clean) $(DLLS:%=%_install) $(DLLS:%=%_dist) $(DLLS:%=%_bootcd)
#
# Subsystem support modules
#
$(SUBSYS): %:
$(MAKE) -C subsys/$*
@@ -775,11 +782,14 @@ $(SUBSYS:%=%_clean): %_clean:
$(SUBSYS:%=%_install): %_install:
$(MAKE) -C subsys/$* install
$(SUBSYS:%=%_dist): %_dist:
$(MAKE) -C subsys/$* dist
$(SUBSYS:%=%_bootcd): %_bootcd:
$(MAKE) -C subsys/$* bootcd
.PHONY: $(SUBSYS) $(SUBSYS:%=%_depends) $(SUBSYS:%=%_implib) $(SUBSYS:%=%_clean) $(SUBSYS:%=%_install) \
$(SUBSYS:%=%_bootcd)
$(SUBSYS:%=%_dist) $(SUBSYS:%=%_bootcd)
#
# Regression testsuite
@@ -820,6 +830,25 @@ install_clean:
$(RMDIR) $(INSTALL_DIR)/bin
$(RMDIR) $(INSTALL_DIR)
ifneq ($(BOOTCD_INSTALL),)
install_dirs:
$(RMKDIR) $(INSTALL_DIR)
install_before:
$(RLINE) bootdata/autorun.inf $(INSTALL_DIR)/../autorun.inf
$(RLINE) bootdata/readme.txt $(INSTALL_DIR)/../readme.txt
$(RLINE) bootdata/hivecls.inf $(INSTALL_DIR)/hivecls.inf
$(RLINE) bootdata/hivedef.inf $(INSTALL_DIR)/hivedef.inf
$(RLINE) bootdata/hivesft.inf $(INSTALL_DIR)/hivesft.inf
$(RLINE) bootdata/hivesys.inf $(INSTALL_DIR)/hivesys.inf
$(RLINE) bootdata/txtsetup.sif $(INSTALL_DIR)/txtsetup.sif
$(CP) bootdata/icon.ico $(INSTALL_DIR)/../icon.ico
$(CP) media/fonts $(INSTALL_DIR)
$(CP) media/nls $(INSTALL_DIR)
else # !BOOTCD_INSTALL
install_dirs:
$(RMKDIR) $(INSTALL_DIR)
$(RMKDIR) $(INSTALL_DIR)/bin
@@ -840,43 +869,41 @@ install_before:
$(CP) media/nls/c_437.nls $(INSTALL_DIR)/system32/oem.nls
$(CP) media/nls/l_intl.nls $(INSTALL_DIR)/system32/casemap.nls
endif # BOOTCD_INSTALL
.PHONY: install_clean install_dirs install_before
#
# Make a distribution saveset
#
dist_clean:
$(RM) $(DIST_DIR)/symbols/*.sym
$(RM) $(DIST_DIR)/drivers/*.sys
$(RM) $(DIST_DIR)/subsys/*.exe
$(RM) $(DIST_DIR)/dlls/*.dll
$(RM) $(DIST_DIR)/apps/*.exe
$(RM) $(DIST_DIR)/*.exe
$(RMDIR) $(DIST_DIR)/symbols
$(RMDIR) $(DIST_DIR)/subsys
$(RMDIR) $(DIST_DIR)/drivers
$(RMDIR) $(DIST_DIR)/dlls
$(RMDIR) $(DIST_DIR)/apps
$(RMDIR) $(DIST_DIR)
dist_dirs:
$(RMKDIR) $(DIST_DIR)
$(RMKDIR) $(DIST_DIR)/apps
$(RMKDIR) $(DIST_DIR)/dlls
$(RMKDIR) $(DIST_DIR)/drivers
$(RMKDIR) $(DIST_DIR)/subsys
$(RMKDIR) $(DIST_DIR)/symbols
.PHONY: dist_clean dist_dirs
etags:
find . -name "*.[ch]" -print | etags --language=c -
docu:
echo generating ReactOS NTOSKRNL documentation ...
$(MAKE) -C ntoskrnl docu
echo generating ReactOS drivers documentation ...
$(MAKE) -C drivers docu
echo generating ReactOS NTDLL documentation ...
$(MAKE) -C lib/ntdll docu
echo generating ReactOS Freetype documentation ...
$(MAKE) -C lib/freetype docu
echo generating ReactOS libs documentation ...
$(MAKE) -C lib docu
echo generating ReactOS WIN32K documentation ...
$(MAKE) -C subsys/win32k docu
echo generating ReactOS apps+tools documentation ...
$(MAKE) -C apps docu
echo generating ReactOS explorer documentation ...
$(MAKE) -C subsys/system/explorer full-docu
echo generating remaining ReactOS documentation ...
doxygen Doxyfile
.PHONY: docu
# EOF

View File

@@ -1,6 +1,6 @@
========================
ReactOS Version 0.2.x
Updated June 23rd, 2004
ReactOS Version 0.1.x
Updated March 19th, 2003
========================
1. What is ReactOS?

View File

@@ -22,9 +22,9 @@ winmm.dll reactos/lib/winmm
winspool.dll reactos/lib/winspool
ws2_32.dll reactos/lib/ws2_32
wsock32.dll reactos/lib/wsock32
videoprt.dll reactos/drivers/video/videoprt
ndis.sys reactos/drivers/net/ndis
tdi.sys reactos/drivers/net/tdi
videoprt.dll reactos/drivers/dd/videoprt
ndis.dll reactos/drivers/net/ndis
tdi.dll reactos/drivers/net/tdi
class2.sys reactos/drivers/storage/class2
scsiport.sys reactos/drivers/storage/scsiport
ntoskrnl.exe reactos/ntoskrnl

View File

@@ -1 +0,0 @@
doxy-doc

View File

@@ -1,207 +0,0 @@
# Doxyfile 1.3.5
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "ReactOS Apps & Tools"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doxy-doc
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = ..
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = NO
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = . \
../tools
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = YES
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 200
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = YES
RTF_HYPERLINKS = YES
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = NO
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../include
INCLUDE_FILE_PATTERNS = *.h
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = YES

View File

@@ -1,13 +0,0 @@
# $Id: Makefile,v 1.1 2003/12/06 23:10:50 mf Exp $
#
# ReactOS apps and tools makefile to generate Doxygen documentation
#
docu:
doxygen Doxyfile
.PHONY: docu
# EOF

View File

@@ -7,17 +7,15 @@ PATH_TO_TOP = ../..
include $(PATH_TO_TOP)/rules.mak
# test_old tests
TEST_APPS = accelerator alive alphablend apc args atomtest bench bitblt button \
button2 capclock carets combo consume copymove count dibtest dump_shared_data \
edit enumwnd enumws event global_mem gradient hello mdi \
hivetest icontest isotest lineclip linetest lpc \
mktime mstest multithrdwin multiwin mutex nptest patblt primitives pteb \
regtest sectest sertest shaptest shm statst statst2 stretchblt suspend \
tcpsvr terminate txtscale thread thread_msg tokentest user32 vmtest \
winhello wm_erasebkgnd wm_paint eventpair threadwait popupmenu \
map_dup_inherit p_dup_handle apc2 enhmetafile dirdlg guithreadinfo fiber
# Build failure:
# kernel32
TEST_APPS = SampleWindow alive apc args atomtest bench bitblt button \
button2 capclock carets cliarea combo consume copymove count dibtest \
dump_shared_data edit enumwnd event file gditest global_mem hello \
hivetest hotkey icontest isotest lineclip linetest lock lpc messagebox \
mktime mstest multiwin mutex nptest patblt pipe primitives pteb regtest \
sectest sertest shaptest shm statst statst2 stretchblt suspend \
tcpsvr terminate txtscale thread thread_msg tokentest vmtest \
winhello winhello2 wm_erasebkgnd wm_paint eventpair threadwait \
map_dup_inherit p_dup_handle apc2 enhmetafile dirdlg guithreadinfo
TEST_MISC =
@@ -34,7 +32,10 @@ clean: $(TEST_APPS:%=%_clean) \
install: $(TEST_APPS:%=%_install) \
$(TEST_MISC:%=%_install)
.PHONY: all depends implib clean install
dist: $(TEST_APPS:%=%_dist) \
$(TEST_MISC:%=%_dist)
.PHONY: all depends implib clean install dist
#
@@ -49,10 +50,13 @@ $(TEST_APPS:%=%_implib): %_implib:
$(TEST_APPS:%=%_clean): %_clean:
$(MAKE) -C $* clean
$(TEST_APPS:%=%_dist): %_dist:
$(MAKE) -C $* dist
$(TEST_APPS:%=%_install): %_install:
$(MAKE) -C $* install
.PHONY: $(TEST_APPS) $(TEST_APPS:%=%_implib) $(TEST_APPS:%=%_clean) $(TEST_APPS:%=%_install)
.PHONY: $(TEST_APPS) $(TEST_APPS:%=%_implib) $(TEST_APPS:%=%_clean) $(TEST_APPS:%=%_install) $(TEST_APPS:%=%_dist)
#
@@ -67,13 +71,17 @@ $(TEST_MISC:%=%_implib): %_implib:
$(TEST_MISC:%=%_clean): %_clean:
$(MAKE) -C tests/$* clean
$(TEST_MISC:%=%_dist): %_dist:
$(MAKE) -C tests/$* dist
$(TEST_MISC:%=%_install): %_install:
$(MAKE) -C tests/$* install
.PHONY: $(TEST_MISC) $(TEST_MISC:%=%_implib) $(TEST_MISC:%=%_clean) $(TEST_MISC:%=%_install)
.PHONY: $(TEST_MISC) $(TEST_MISC:%=%_implib) $(TEST_MISC:%=%_clean) $(TEST_MISC:%=%_install) $(TEST_MISC:%=%_dist)
etags:
find . -name "*.[ch]" -print | etags --language=c -
# EOF

View File

@@ -1,4 +1,4 @@
# $Id: makefile,v 1.1 2004/02/08 21:57:35 weiden Exp $
# $Id: makefile,v 1.2 2003/11/14 17:13:14 weiden Exp $
PATH_TO_TOP = ../../..
@@ -8,9 +8,9 @@ TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = gradient
TARGET_NAME = window
TARGET_SDKLIBS = gdi32.a
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -0,0 +1,212 @@
/*
* A basic example of Win32 programming in C.
*
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
*
* Colin Peters <colinp at ma.kcom.ne.jp>
*/
#include <windows.h>
#include <string.h>
/*
* This is the window function for the main window. Whenever a message is
* dispatched using DispatchMessage (or sent with SendMessage) this function
* gets called with the contents of the message.
*/
LRESULT CALLBACK
MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
/* The window handle for the "Click Me" button. */
static HWND hwndButton = 0;
static int cx, cy; /* Height and width of our button. */
HDC hdc; /* A device context used for drawing */
PAINTSTRUCT ps; /* Also used during window drawing */
RECT rc; /* A rectangle used during drawing */
/*
* Perform processing based on what kind of message we got.
*/
switch (nMsg)
{
case WM_CREATE:
{
/* The window is being created. Create our button
* window now. */
TEXTMETRIC tm;
/* First we use the system fixed font size to choose
* a nice button size. */
hdc = GetDC (hwnd);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
GetTextMetrics (hdc, &tm);
cx = tm.tmAveCharWidth * 30;
cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
ReleaseDC (hwnd, hdc);
/* Now create the button */
hwndButton = CreateWindow (
"button", /* Builtin button class */
"Click Here",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, cx, cy,
hwnd, /* Parent is this window. */
(HMENU) 1, /* Control ID: 1 */
((LPCREATESTRUCT) lParam)->hInstance,
NULL
);
return 0;
break;
}
case WM_DESTROY:
/* The window is being destroyed, close the application
* (the child button gets destroyed automatically). */
PostQuitMessage (0);
return 0;
break;
case WM_PAINT:
/* The window needs to be painted (redrawn). */
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rc);
/* Draw "Hello, World" in the middle of the upper
* half of the window. */
rc.bottom = rc.bottom / 2;
DrawText (hdc, "Hello, World", -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint (hwnd, &ps);
return 0;
break;
case WM_SIZE:
/* The window size is changing. If the button exists
* then place it in the center of the bottom half of
* the window. */
if (hwndButton &&
(wParam == SIZEFULLSCREEN ||
wParam == SIZENORMAL)
)
{
rc.left = (LOWORD(lParam) - cx) / 2;
rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;
MoveWindow (
hwndButton,
rc.left, rc.top, cx, cy, TRUE);
}
break;
case WM_COMMAND:
/* Check the control ID, notification code and
* control handle to see if this is a button click
* message from our child button. */
if (LOWORD(wParam) == 1 &&
HIWORD(wParam) == BN_CLICKED &&
(HWND) lParam == hwndButton)
{
/* Our button was clicked. Close the window. */
DestroyWindow (hwnd);
}
return 0;
break;
}
/* If we don't handle a message completely we hand it to the system
* provided default window function. */
return DefWindowProc (hwnd, nMsg, wParam, lParam);
}
int STDCALL
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
HWND hwndMain; /* Handle for the main window. */
MSG msg; /* A Win32 message structure. */
WNDCLASSEX wndclass; /* A window class structure. */
char* szMainWndClass = "WinTestWin";
/* The name of the main window class */
/*
* First we create a window class for our main window.
*/
/* Initialize the entire structure to zero. */
memset (&wndclass, 0, sizeof(WNDCLASSEX));
/* This class is called WinTestWin */
wndclass.lpszClassName = szMainWndClass;
/* cbSize gives the size of the structure for extensibility. */
wndclass.cbSize = sizeof(WNDCLASSEX);
/* All windows of this class redraw when resized. */
wndclass.style = CS_HREDRAW | CS_VREDRAW;
/* All windows of this class use the MainWndProc window function. */
wndclass.lpfnWndProc = MainWndProc;
/* This class is used with the current program instance. */
wndclass.hInstance = hInst;
/* Use standard application icon and arrow cursor provided by the OS */
wndclass.hIcon = LoadIcon (NULL, (LPCTSTR)IDI_APPLICATION);
wndclass.hIconSm = LoadIcon (NULL, (LPCTSTR)IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, (LPCTSTR)IDC_ARROW);
/* Color the background white */
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
/*
* Now register the window class for use.
*/
RegisterClassEx (&wndclass);
/*
* Create our main window using that window class.
*/
hwndMain = CreateWindow (
szMainWndClass, /* Class name */
"Hello", /* Caption */
WS_OVERLAPPEDWINDOW, /* Style */
CW_USEDEFAULT, /* Initial x (use default) */
CW_USEDEFAULT, /* Initial y (use default) */
CW_USEDEFAULT, /* Initial x size (use default) */
CW_USEDEFAULT, /* Initial y size (use default) */
NULL, /* No parent window */
NULL, /* No menu */
hInst, /* This program instance */
NULL /* Creation parameters */
);
/*
* Display the window which we just created (using the nShow
* passed by the OS, which allows for start minimized and that
* sort of thing).
*/
ShowWindow (hwndMain, nShow);
UpdateWindow (hwndMain);
/*
* The main message loop. All messages being sent to the windows
* of the application (or at least the primary thread) are retrieved
* by the GetMessage call, then translated (mainly for keyboard
* messages) and dispatched to the appropriate window procedure.
* This is the simplest kind of message loop. More complex loops
* are required for idle processing or handling modeless dialog
* boxes. When one of the windows calls PostQuitMessage GetMessage
* will return zero and the wParam of the message will be filled
* with the argument to PostQuitMessage. The loop will end and
* the application will close.
*/
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
/* EOF */

View File

@@ -1,6 +0,0 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View File

@@ -1,19 +0,0 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = accelerator
#TARGET_SDKLIBS = kernel32.a user32.a
TARGET_OBJECTS = accelerator.o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk

View File

@@ -1,161 +0,0 @@
#include <windows.h>
#include <stdio.h>
#include <string.h>
#define ID_ACCEL1 0x100
#define ID_ACCEL2 0x101
#define ID_ACCEL3 0x102
#define ID_ACCEL4 0x103
/*
* {fVirt, key, cmd}
* fVirt |= FVIRTKEY | FCONTROL | FALT | FSHIFT
*/
//static HFONT tf;
static ACCEL Accelerators[4] = {
{ FVIRTKEY, VK_A, ID_ACCEL1},
{ FVIRTKEY | FSHIFT, VK_A, ID_ACCEL2},
{ FVIRTKEY | FCONTROL, VK_A, ID_ACCEL3},
{ FVIRTKEY | FALT, VK_A, ID_ACCEL4}};
static HACCEL hAcceleratorTable;
static char Event[200];
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = "AcceleratorTest";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow("AcceleratorTest",
"Accelerator Test",
WS_OVERLAPPEDWINDOW,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
/*tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");*/
Event[0] = 0;
ShowWindow(hWnd, nCmdShow);
hAcceleratorTable = CreateAcceleratorTable(Accelerators,
sizeof(Accelerators)/sizeof(Accelerators[1]));
if (hAcceleratorTable == NULL)
{
fprintf(stderr, "CreateAcceleratorTable failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
while(GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(hWnd, hAcceleratorTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (!DestroyAcceleratorTable(hAcceleratorTable))
{
fprintf(stderr, "DestroyAcceleratorTable failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
//DeleteObject(tf);
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
char buf[200];
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
//SelectObject(hDC, tf);
sprintf(buf, "Event: '%s'", Event);
TextOut(hDC, 10, 10, buf, strlen(buf));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_ACCEL1:
strcpy(Event, "A");
break;
case ID_ACCEL2:
strcpy(Event, "SHIFT+A");
break;
case ID_ACCEL3:
strcpy(Event, "CTRL+A");
break;
case ID_ACCEL4:
strcpy(Event, "ALT+A");
break;
default:
sprintf(Event, "%d", LOWORD(wParam));
break;
}
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View File

@@ -1,213 +0,0 @@
#include <windows.h>
#include <string.h>
#ifndef AC_SRC_ALPHA
#define AC_SRC_ALPHA (0x1)
#endif
HINSTANCE HInst;
const char* WndClassName = "GMainWnd";
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam);
WINBOOL
STDCALL
GdiAlphaBlend(HDC hdcDst,LONG DstX,LONG DstY,LONG DstCx,LONG DstCy,HDC hdcSrc,LONG SrcX,LONG SrcY,LONG SrcCx,LONG SrcCy,BLENDFUNCTION BlendFunction);
int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HInst = HInstance;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = HInstance;
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
/* wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1); */
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = WndClassName;
if (RegisterClass(&wc))
{
HWND HWnd =
CreateWindow(
WndClassName, TEXT("AlphaBlend Rendering Demo"),
WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
WS_VISIBLE | WS_CLIPSIBLINGS,
0, 0, 320, 430,
NULL, NULL, HInst, NULL
);
if (HWnd)
{
ShowWindow(HWnd, nCmdShow);
UpdateWindow(HWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return 0;
}
/* image related */
BITMAP bmp;
LPCSTR filename = TEXT("lena.bmp");
HDC HMemDC = NULL, HMemDC2 = NULL;
HBITMAP HOldBmp = NULL;
PVOID pBmpBits = NULL;
HBITMAP H32BppBitmap = NULL;
BITMAPINFO bmpi;
BOOL ConvertBitmapTo32Bpp(HDC hDC, BITMAP *bmp)
{
ZeroMemory(&bmpi, sizeof(BITMAPINFO));
bmpi.bmiHeader.biSize = sizeof(BITMAPINFO);
bmpi.bmiHeader.biWidth = bmp->bmWidth;
bmpi.bmiHeader.biHeight = bmp->bmHeight;
bmpi.bmiHeader.biPlanes = 1;
bmpi.bmiHeader.biBitCount = 32;
bmpi.bmiHeader.biCompression = BI_RGB;
bmpi.bmiHeader.biSizeImage = 4 * bmpi.bmiHeader.biWidth * bmpi.bmiHeader.biHeight;
H32BppBitmap = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, &pBmpBits, 0, 0);
if(H32BppBitmap)
{
HBITMAP bmpalpha;
SelectObject(hDC, H32BppBitmap);
BitBlt(hDC, 0, 0, bmp->bmWidth, bmp->bmHeight, HMemDC, 0, 0, SRCCOPY);
/* load and apply alpha channel */
bmpalpha = LoadImage(HInst, TEXT("lenaalpha.bmp"), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
if(bmpalpha)
{
COLORREF *col = pBmpBits;
int x, y;
HDC hdcTemp = CreateCompatibleDC(NULL);
if(!hdcTemp)
{
DeleteObject(bmpalpha);
return FALSE;
}
SelectObject(hdcTemp, bmpalpha);
for(y = 0; y < bmp->bmHeight; y++)
{
for(x = 0; x < bmp->bmWidth; x++)
{
COLORREF Color = (COLORREF)GetRValue(GetPixel(hdcTemp, x, y)) << 24;
*col++ |= Color;
}
}
DeleteObject(bmpalpha);
DeleteDC(hdcTemp);
return TRUE;
}
return FALSE;
}
return FALSE;
}
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam)
{
switch (Msg)
{
case WM_CREATE:
{
/* create a memory DC */
HMemDC = CreateCompatibleDC(NULL);
if (HMemDC)
{
/* load a bitmap from file */
HBITMAP HBmp =
/* static_cast<HBITMAP> */(
LoadImage(HInst, filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE)
);
if (HBmp)
{
/* extract dimensions of the bitmap */
GetObject(HBmp, sizeof(BITMAP), &bmp);
/* associate the bitmap with the memory DC */
/* HOldBmp = static_cast<HBITMAP> */
(SelectObject(HMemDC, HBmp)
);
HMemDC2 = CreateCompatibleDC(NULL);
if(!ConvertBitmapTo32Bpp(HMemDC2, &bmp))
{
PostQuitMessage(0);
return 0;
}
}
}
}
case WM_PAINT:
{
PAINTSTRUCT ps;
BLENDFUNCTION BlendFunc;
HDC Hdc = BeginPaint(HWnd, &ps);
#if 0
try
#endif
{
BlendFunc.BlendOp = AC_SRC_OVER;
BlendFunc.BlendFlags = 0;
BlendFunc.SourceConstantAlpha = 128;
BlendFunc.AlphaFormat = 0;
BitBlt(Hdc, 100, 90,
bmp.bmWidth, bmp.bmHeight,
HMemDC2, 0, 0,
SRCCOPY);
GdiAlphaBlend(Hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
GdiAlphaBlend(Hdc, bmp.bmWidth - 15, 10, bmp.bmWidth / 2, bmp.bmHeight / 2,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
BlendFunc.SourceConstantAlpha = 255;
BlendFunc.AlphaFormat = AC_SRC_ALPHA;
GdiAlphaBlend(Hdc, 140, 200, bmp.bmWidth, bmp.bmHeight,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
GdiAlphaBlend(Hdc, 20, 210, (bmp.bmWidth / 3) * 2, (bmp.bmHeight / 3) * 2,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
}
#if 0
catch (...)
{
EndPaint(HWnd, &ps);
}
#endif
EndPaint(HWnd, &ps);
break;
}
case WM_DESTROY:
{
/* clean up */
DeleteObject(SelectObject(HMemDC, HOldBmp));
DeleteDC(HMemDC);
DeleteDC(HMemDC2);
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(HWnd, Msg, WParam, LParam);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

View File

@@ -16,7 +16,6 @@ ApcRoutine(PVOID Context,
printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
}
int main(int argc, char* argv[])
{
NTSTATUS Status;
@@ -26,8 +25,7 @@ int main(int argc, char* argv[])
IO_STATUS_BLOCK IoStatus;
CHAR Buffer[256];
HANDLE EventHandle;
LARGE_INTEGER off;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -59,30 +57,24 @@ int main(int argc, char* argv[])
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (FileHandle == INVALID_HANDLE_VALUE)
{
printf("Open failed last err 0x%lu\n",GetLastError());
printf("Open failed\n");
return 0;
}
off.QuadPart = 0;
printf("Reading file\n");
Status = ZwReadFile(FileHandle,
NULL,
(PIO_APC_ROUTINE)ApcRoutine,
(PVOID) 0xdeadbeef,
(PVOID)0xdeadbeef,
&IoStatus,
Buffer,
256,//len
&off ,//offset must exist if file was opened for asynch. i/o aka. OVERLAPPED
NULL);
256,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{
printf("Read failed status 0x%lu\n",Status);
printf("Read failed\n");
}
printf("Waiting\n");
WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);

View File

@@ -31,7 +31,7 @@ int main()
bSuccess = SetWaitableTimer(
hTimer,
&DueTime,
2001 /*interval (using an odd number to be able to find it easy in kmode) */,
2000 /*interval*/,
TimerApcProc,
&value /*callback argument*/,
FALSE );

View File

@@ -1,8 +1,7 @@
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "resource.h"
//HFONT tf;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
@@ -15,14 +14,14 @@ WinMain(HINSTANCE hInstance,
MSG msg;
HWND hWnd;
wc.lpszClassName = "MenuTestClass";
wc.lpszClassName = "CliAreaClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = (LPCTSTR)IDM_MAINMENU;
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
@@ -32,9 +31,9 @@ WinMain(HINSTANCE hInstance,
return(1);
}
hWnd = CreateWindow("MenuTestClass",
"PopupMenu Test",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
hWnd = CreateWindow("CliAreaClass",
"ClientArea Test",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0,
0,
CW_USEDEFAULT,
@@ -50,53 +49,49 @@ WinMain(HINSTANCE hInstance,
return(1);
}
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//DeleteObject(tf);
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDM_EXIT:
PostQuitMessage(0);
break;
}
break;
}
case WM_RBUTTONUP:
{
POINT pos;
HMENU Menu;
pos.x = LOWORD(lParam);
pos.y = HIWORD(lParam);
ClientToScreen(hWnd, &pos);
if((Menu = GetMenu(hWnd)) && (Menu = GetSubMenu(Menu, 1)))
{
TrackPopupMenu(Menu, 0, pos.x, pos.y, 0, hWnd, NULL);
}
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default:
{
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}
return 0;
HDC hDC;
char txt[100];
switch(msg)
{
case WM_LBUTTONUP:
{
RECT Rect;
GetWindowRect(hWnd, &Rect);
SendMessage(hWnd, WM_NCCALCSIZE, 0, (LPARAM)(&Rect));
hDC = GetWindowDC(0);
Rectangle(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom);
sprintf(txt, "Client coordinates: %lu, %lu, %lu, %lu", Rect.left, Rect.top, Rect.right, Rect.bottom);
TextOut(hDC, Rect.left + 1, Rect.top + 1, (LPCTSTR)txt, strlen(txt));
ReleaseDC(0, hDC);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View File

@@ -1,16 +1,16 @@
# $Id: makefile,v 1.1 2003/12/27 23:45:48 weiden Exp $
# $Id: makefile,v 1.2 2003/11/14 17:13:16 weiden Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = no
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = popupmenu
TARGET_NAME = cliarea
TARGET_SDKLIBS = kernel32.a gdi32.a user32.a
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -1,25 +0,0 @@
# $Id: Makefile,v 1.1 2003/12/28 21:36:53 gvg Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = create-links
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_GCCLIBS = ole32 uuid shell32 shlwapi
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API -D_WIN32_IE=0x0400
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,97 +0,0 @@
/*
compile via:
gcc -o create-links -D_WIN32_IE=0x400 create-links.c -lole32 -luuid -lshell32 -lshlwapi
Martin Fuchs, 27.12.2003
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shlobj.h>
#include <objidl.h>
#include <shlwapi.h>
#include <stdio.h>
HRESULT CreateShellLink(LPCSTR linkPath, LPCSTR cmd, LPCSTR arg, LPCSTR dir, LPCSTR iconPath, int icon_nr, LPCSTR comment)
{
IShellLinkA* psl;
IPersistFile* ppf;
WCHAR buffer[MAX_PATH];
HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl);
printf("creating shortcut file '%s' to %s...\n", linkPath, cmd);
if (SUCCEEDED(hr)) {
hr = psl->lpVtbl->SetPath(psl, cmd);
if (arg)
hr = psl->lpVtbl->SetArguments(psl, arg);
if (dir)
hr = psl->lpVtbl->SetWorkingDirectory(psl, dir);
if (iconPath)
hr = psl->lpVtbl->SetIconLocation(psl, iconPath, icon_nr);
if (comment)
hr = psl->lpVtbl->SetDescription(psl, comment);
hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hr)) {
MultiByteToWideChar(CP_ACP, 0, linkPath, -1, buffer, MAX_PATH);
hr = ppf->lpVtbl->Save(ppf, buffer, TRUE);
ppf->lpVtbl->Release(ppf);
}
psl->lpVtbl->Release(psl);
}
if (SUCCEEDED(hr))
printf("OK\n\n");
else
printf("error %08x\n\n", (int) hr);
return hr;
}
int main()
{
char path[MAX_PATH];
LPSTR p;
CoInitialize(NULL);
/* create some shortcuts in the start menu "programs" folder */
SHGetSpecialFolderPathA(0, path, CSIDL_PROGRAMS, TRUE);
p = PathAddBackslash(path);
strcpy(p, "start-cmd.lnk");
CreateShellLink(path, "cmd.exe", "", NULL, NULL, 0, "open console window");
strcpy(p, "start-winhello.lnk");
CreateShellLink(path, "winhello.exe", "", NULL, NULL, 0, "launch winhello");
/* create some shortcuts on the desktop */
SHGetSpecialFolderPathA(0, path, CSIDL_DESKTOP, TRUE);
p = PathAddBackslash(path);
strcpy(p, "start-wcmd.lnk");
CreateShellLink(path, "cmd.exe", "", NULL, NULL, 0, "open console window");
strcpy(p, "start-winemine.lnk");
CreateShellLink(path, "winemine.exe", "", NULL, NULL, 0, "launch winemine");
CoUninitialize();
return 0;
}

View File

@@ -1,165 +0,0 @@
/*
* Copyright (C) 2004 ReactOS Team
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS diskspeed.exe
* FILE: apps/tests/diskspeed/diskspeed.c
* PURPOSE: Determines disk transfer rates
* PROGRAMMER: Hartmut Birr
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ddk/ntddk.h>
#include <ddk/ntddscsi.h>
#include <ddk/scsi.h>
BOOL GetInquiryData(HANDLE hDevice, PINQUIRYDATA InquiryData)
{
BOOL Result;
DWORD dwReturned;
SCSI_ADDRESS ScsiAddress;
PSCSI_ADAPTER_BUS_INFO AdapterInfo;
PSCSI_INQUIRY_DATA InquiryBuffer;
BYTE Buffer[4096];
int i;
Result = DeviceIoControl(hDevice,
IOCTL_SCSI_GET_ADDRESS,
NULL,
0,
&ScsiAddress,
sizeof(ScsiAddress),
&dwReturned,
FALSE);
if (Result == FALSE)
{
return FALSE;
}
Result = DeviceIoControl(hDevice,
IOCTL_SCSI_GET_INQUIRY_DATA,
NULL,
0,
Buffer,
sizeof(Buffer),
&dwReturned,
FALSE);
if (Result)
{
AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)Buffer;
for (i = 0; i < AdapterInfo->NumberOfBuses; i++)
{
InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + AdapterInfo->BusData[i].InquiryDataOffset);
if (AdapterInfo->BusData[i].InquiryDataOffset)
{
while (1)
{
if (InquiryBuffer->PathId == ScsiAddress.PathId &&
InquiryBuffer->TargetId == ScsiAddress.TargetId &&
InquiryBuffer->Lun == ScsiAddress.Lun)
{
memcpy(InquiryData, InquiryBuffer->InquiryData, sizeof(INQUIRYDATA));
return TRUE;
}
if (InquiryBuffer->NextInquiryDataOffset == 0)
{
break;
}
InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + InquiryBuffer->NextInquiryDataOffset);
}
}
}
}
return FALSE;
}
int main(void)
{
HANDLE hDevice;
OVERLAPPED ov;
PBYTE Buffer;
DWORD Start;
DWORD dwReturned;
DWORD dwReadTotal;
DWORD Size;
BOOL Result;
ULONG Drive;
CHAR Name[20];
INQUIRYDATA InquiryData;
Drive = 0;
while (1)
{
sprintf(Name, "\\\\.\\PHYSICALDRIVE%ld", Drive);
hDevice = CreateFile(Name,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
if (Drive > 0)
{
VirtualFree(Buffer, 512 * 1024, MEM_RELEASE);
}
else
{
printf("Cannot open '%s'\n", Name);
}
break;
}
if (Drive == 0)
{
printf("Transfer Size (kB) 1 2 4 8 16 32 64 128 256\n");
printf("Transfer Rate (MB/s)\n");
printf("-------------------------------------------------------------------------------\n");
Buffer = VirtualAlloc(NULL, 512 * 1024, MEM_COMMIT, PAGE_READWRITE);
}
Result = GetInquiryData(hDevice, &InquiryData);
if (Result)
{
printf("%.24s ", InquiryData.VendorId);
}
else
{
printf("Disk %ld ", Drive + 1);
}
Size = 1024;
memset(&ov, 0, sizeof(OVERLAPPED));
while (Size <= 256 * 1024)
{
memset(Buffer, 0, Size);
dwReadTotal = 0;
Start = GetTickCount() + 2000;
while (Start > GetTickCount())
{
Result = ReadFile(hDevice, Buffer, Size, &dwReturned, &ov);
if (Result)
{
dwReadTotal += dwReturned;
ov.Offset += dwReturned;
}
}
dwReadTotal /= 2048;
printf("%3ld.%ld ", dwReadTotal / 1024, (dwReadTotal % 1024) * 10 / 1024);
Size *= 2;
}
printf("\n");
CloseHandle(hDevice);
Drive++;
}
printf("\n");
return 0;
}

View File

@@ -1,33 +0,0 @@
#include <windows.h>
#include <stdio.h>
#include <WinError.h>
#include <WinDNS.h>
#include <winsock2.h>
#include <assert.h>
int main( int argc, char **argv ) {
PDNS_RECORD QueryReply, AddrResponse;
DWORD Addr;
assert (DnsValidateName( "||||", DnsNameDomain ) == DNS_ERROR_INVALID_NAME_CHAR);
assert (DnsValidateName( "a.b.c", DnsNameDomainLabel ) == DNS_ERROR_INVALID_NAME);
assert (DnsValidateName( "1234", DnsNameDomainLabel ) == ERROR_SUCCESS);
assert (DnsValidateName( "fubar", DnsNameDomain ) == ERROR_SUCCESS);
assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
NULL, &QueryReply, NULL) == ERROR_SUCCESS);
AddrResponse = QueryReply;
while( AddrResponse ) {
if( AddrResponse->wType == DNS_TYPE_A ) {
Addr = ntohl( AddrResponse->Data.A.IpAddress );
printf( "www.reactos.com == %d.%d.%d.%d\n",
(int)(Addr >> 24) & 0xff,
(int)(Addr >> 16) & 0xff,
(int)(Addr >> 8) & 0xff,
(int)Addr & 0xff );
}
AddrResponse = AddrResponse->pNext;
}
DnsRecordListFree( QueryReply, DnsFreeRecordList );
return 0;
}

View File

@@ -1,22 +0,0 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = dnsapi
TARGET_SDKLIBS = dnsapi.a ws2_32.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,29 +0,0 @@
#include <windows.h>
#include <stdio.h>
#include <WinError.h>
#include <WinDNS.h>
#include <winsock2.h>
#include <assert.h>
int main( int argc, char **argv ) {
PDNS_RECORD QueryReply, AddrResponse;
DWORD Addr;
assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
NULL, &QueryReply, NULL) == ERROR_SUCCESS);
AddrResponse = QueryReply;
while( AddrResponse ) {
if( AddrResponse->wType == DNS_TYPE_A ) {
Addr = ntohl( AddrResponse->Data.A.IpAddress );
printf( "www.reactos.com == %d.%d.%d.%d\n",
(int)(Addr >> 24) & 0xff,
(int)(Addr >> 16) & 0xff,
(int)(Addr >> 8) & 0xff,
(int)Addr & 0xff );
}
AddrResponse = AddrResponse->pNext;
}
DnsRecordListFree( QueryReply, DnsFreeRecordList );
return 0;
}

View File

@@ -1,22 +0,0 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = dnsquery
TARGET_SDKLIBS = dnsapi.a ws2_32.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,21 +0,0 @@
# $Id: Makefile,v 1.2 2004/03/07 20:07:04 hyperion Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = fiber
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,446 +0,0 @@
/* $Id: fiber.c,v 1.2 2004/03/07 20:07:04 hyperion Exp $
*/
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <tchar.h>
#include <windows.h>
#ifndef InitializeListHead
#define InitializeListHead(PLH__) ((PLH__)->Flink = (PLH__)->Blink = (PLH__))
#endif
#ifndef IsListEmpty
#define IsListEmpty(PLH__) ((PLH__)->Flink == (PVOID)(PLH__))
#endif
#ifndef RemoveEntryList
#define RemoveEntryList(PLE__) \
{ \
PLIST_ENTRY pleBack__ = (PLIST_ENTRY)((PLE__)->Blink); \
PLIST_ENTRY pleForward__ = (PLIST_ENTRY)((PLE__)->Flink); \
\
pleBack__->Flink = pleForward__; \
pleForward__->Blink = pleBack__; \
}
#endif
#ifndef InsertTailList
#define InsertTailList(PLH__, PLE__) \
{ \
PLIST_ENTRY pleListHead__ = (PLH__); \
PLIST_ENTRY pleBlink__ = (PLIST_ENTRY)((PLH__)->Blink); \
\
(PLE__)->Flink = pleListHead__; \
(PLE__)->Blink = pleBlink__; \
pleBlink__->Flink = (PLE__); \
pleListHead__->Blink = (PLE__); \
}
#endif
#ifndef RemoveHeadList
#define RemoveHeadList(PLH__) \
(PLIST_ENTRY)((PLH__)->Flink); \
RemoveEntryList((PLIST_ENTRY)((PLH__)->Flink));
#endif
#define FIBERTEST_COUNT 500
struct FiberData
{
unsigned nMagic;
unsigned nId;
unsigned nPrio;
unsigned nRealPrio;
PVOID pFiber;
LIST_ENTRY leQueue;
int nQuantumQueued;
int nBoost;
struct FiberData * pfdPrev;
int bExitPrev;
};
static LIST_ENTRY a_leQueues[32];
static unsigned nQuantum = 0;
static struct FiberData * pfdLastStarveScan = NULL;
void Fbt_Create(int);
void Fbt_Exit(void);
void Fbt_Yield(void);
struct FiberData * Fbt_GetCurrent(void);
unsigned Fbt_GetCurrentId(void);
VOID CALLBACK Fbt_Startup(PVOID);
void Fbt_Dispatch(struct FiberData *, int);
void Fbt_AfterSwitch(struct FiberData *);
void DoStuff(void);
struct FiberData * Fbt_GetCurrent(VOID)
{
return GetFiberData();
}
unsigned Fbt_GetCurrentId(VOID)
{
return Fbt_GetCurrent()->nId;
}
void Fbt_Yield(VOID)
{
struct FiberData * pfdCur;
pfdCur = Fbt_GetCurrent();
if(pfdCur->nBoost)
{
-- pfdCur->nBoost;
if(!pfdCur->nBoost)
pfdCur->nPrio = pfdCur->nRealPrio;
}
else if((rand() % 100) > 50 - (45 * pfdCur->nPrio) / 32)
Fbt_Dispatch(pfdCur, 0);
}
void Fbt_AfterSwitch(struct FiberData * pfdCur)
{
struct FiberData * pfdPrev;
pfdPrev = pfdCur->pfdPrev;
/* The previous fiber left some homework for us */
if(pfdPrev)
{
/* Kill the predecessor */
if(pfdCur->bExitPrev)
{
if(pfdLastStarveScan == pfdPrev)
pfdLastStarveScan = 0;
DeleteFiber(pfdPrev->pFiber);
free(pfdPrev);
}
/* Enqueue the previous fiber in the correct ready queue */
else
{
/* Remember the quantum in which the previous fiber was queued */
pfdPrev->nQuantumQueued = nQuantum;
/* Disable the anti-starvation boost */
if(pfdPrev->nBoost)
{
pfdPrev->nBoost = 0;
pfdPrev->nPrio = pfdPrev->nRealPrio;
}
/* Enqueue the previous fiber */
InsertTailList
(
&a_leQueues[pfdPrev->nPrio],
&pfdPrev->leQueue
);
}
}
}
VOID CALLBACK Fbt_Startup(PVOID pParam)
{
assert(pParam == GetFiberData());
Fbt_AfterSwitch(pParam);
DoStuff();
Fbt_Exit();
}
void Fbt_Dispatch(struct FiberData * pfdCur, int bExit)
{
UCHAR i;
UCHAR n;
struct FiberData * pfdNext;
assert(pfdCur == GetFiberData());
++ nQuantum;
/* Every ten quantums check for starving threads */
/* FIXME: this implementation of starvation prevention isn't that great */
if(nQuantum % 10 == 0)
{
int j;
int k;
int b;
int bResume;
PLIST_ENTRY ple;
bResume = 0;
i = 0;
/* Pick up from where we left last time */
if(pfdLastStarveScan)
{
unsigned nPrio;
nPrio = pfdLastStarveScan->nPrio;
/* The last fiber we scanned for starvation isn't queued anymore */
if(IsListEmpty(&pfdLastStarveScan->leQueue))
/* Scan the ready queue for its priority */
i = nPrio;
/* Last fiber for its priority level */
else if(pfdLastStarveScan->leQueue.Flink == &a_leQueues[nPrio])
/* Scan the ready queue for the next priority level */
i = nPrio + 1;
/* Scan the next fiber in the ready queue */
else
{
i = nPrio;
ple = pfdLastStarveScan->leQueue.Flink;
bResume = 1;
}
/* Priority levels 15-31 are never checked for starvation */
if(i >= 15)
{
if(bResume)
bResume = 0;
i = 0;
}
}
/*
Scan at most 16 threads, in the priority range 0-14, applying in total at
most 10 boosts. This loop scales O(1)
*/
for(j = 0, k = 0, b = 0; j < 16 && k < 15 && b < 10; ++ j)
{
unsigned nDiff;
/* No previous state to resume from */
if(!bResume)
{
int nQueue;
/* Get the first element in the current queue */
nQueue = (k + i) % 15;
if(IsListEmpty(&a_leQueues[nQueue]))
{
++ k;
continue;
}
ple = (PLIST_ENTRY)a_leQueues[nQueue].Flink;
}
else
bResume = 0;
/* Get the current fiber */
pfdLastStarveScan = CONTAINING_RECORD(ple, struct FiberData, leQueue);
assert(pfdLastStarveScan->nMagic == 0x12345678);
assert(pfdLastStarveScan != pfdCur);
/* Calculate the number of quantums the fiber has been in the queue */
if(nQuantum > pfdLastStarveScan->nQuantumQueued)
nDiff = nQuantum - pfdLastStarveScan->nQuantumQueued;
else
nDiff = UINT_MAX - pfdLastStarveScan->nQuantumQueued + nQuantum;
/* The fiber has been ready for more than 30 quantums: it's starving */
if(nDiff > 30)
{
/* Plus one boost applied */
++ b;
/* Apply the boost */
pfdLastStarveScan->nBoost = 1;
pfdLastStarveScan->nRealPrio = pfdLastStarveScan->nPrio;
pfdLastStarveScan->nPrio = 15;
/* Re-enqueue the fiber in the correct priority queue */
RemoveEntryList(&pfdLastStarveScan->leQueue);
InsertTailList(&a_leQueues[15], &pfdLastStarveScan->leQueue);
}
}
}
pfdNext = NULL;
/* This fiber is going to die: scan all ready queues */
if(bExit)
n = 1;
/*
Scan only ready queues for priorities greater than or equal to the priority of
the current thread (round-robin)
*/
else
n = pfdCur->nPrio + 1;
/* This loop scales O(1) */
for(i = 32; i >= n; -- i)
{
PLIST_ENTRY pleNext;
/* No fiber ready for this priority level */
if(IsListEmpty(&a_leQueues[i - 1]))
continue;
/* Get the next ready fiber */
pleNext = RemoveHeadList(&a_leQueues[i - 1]);
InitializeListHead(pleNext);
pfdNext = CONTAINING_RECORD(pleNext, struct FiberData, leQueue);
assert(pfdNext->pFiber != GetCurrentFiber());
assert(pfdNext->nMagic == 0x12345678);
break;
}
/* Next fiber chosen */
if(pfdNext)
{
/* Give some homework to the next fiber */
pfdNext->pfdPrev = pfdCur;
pfdNext->bExitPrev = bExit;
/* Switch to the next fiber */
SwitchToFiber(pfdNext->pFiber);
/* Complete the switch back to this fiber */
Fbt_AfterSwitch(pfdCur);
}
/* No next fiber, and current fiber exiting */
else if(bExit)
{
PVOID pCurFiber;
/* Delete the current fiber. This kills the thread and stops the simulation */
if(pfdLastStarveScan == pfdCur)
pfdLastStarveScan = NULL;
pCurFiber = pfdCur->pFiber;
free(pfdCur);
DeleteFiber(pCurFiber);
}
/* No next fiber: continue running the current one */
}
void Fbt_Exit(VOID)
{
Fbt_Dispatch(GetFiberData(), 1);
}
void Fbt_CreateFiber(int bInitial)
{
PVOID pFiber;
struct FiberData * pData;
static int s_bFiberPrioSeeded = 0;
static LONG s_nFiberIdSeed = 0;
pData = malloc(sizeof(struct FiberData));
assert(pData);
if(bInitial)
pFiber = ConvertThreadToFiber(pData);
else
pFiber = CreateFiber(0, Fbt_Startup, pData);
if(!s_bFiberPrioSeeded)
{
unsigned nFiberPrioSeed;
time_t tCurTime;
tCurTime = time(NULL);
memcpy(&nFiberPrioSeed, &tCurTime, sizeof(nFiberPrioSeed));
srand(nFiberPrioSeed);
s_bFiberPrioSeeded = 1;
}
assert(pFiber);
pData->nMagic = 0x12345678;
pData->nId = InterlockedIncrement(&s_nFiberIdSeed);
pData->nPrio = rand() % 32;
pData->pFiber = pFiber;
pData->nQuantumQueued = 0;
pData->nBoost = 0;
pData->nRealPrio = pData->nPrio;
pData->pfdPrev = NULL;
pData->bExitPrev = 0;
if(bInitial)
{
InitializeListHead(&pData->leQueue);
}
else
{
InsertTailList
(
&a_leQueues[pData->nPrio],
&pData->leQueue
);
}
}
void DoStuff(void)
{
unsigned i;
unsigned n;
unsigned nId;
n = rand() % 1000;
nId = Fbt_GetCurrentId();
_ftprintf(stderr, _T("[%u] BEGIN\n"), nId);
for(i = 0; i < n; ++ i)
{
unsigned j;
unsigned m;
_ftprintf(stderr, _T("[%u] [%u/%u]\n"), nId, i + 1, n);
m = rand() % 1000;
for(j = 0; j < m; ++ j)
Sleep(0);
Fbt_Yield();
}
_ftprintf(stderr, _T("[%u] END\n"), nId);
}
int _tmain(int argc, _TCHAR const * const * argv)
{
unsigned i;
unsigned nFibers;
if(argc > 1)
nFibers = _tcstoul(argv[1], 0, NULL);
else
nFibers = FIBERTEST_COUNT;
for(i = 0; i < 32; ++ i)
{
InitializeListHead(&a_leQueues[i]);
}
for(i = 0; i < nFibers; ++ i)
Fbt_CreateFiber(i == 0);
Fbt_Startup(GetFiberData());
return 0;
}
/* EOF */

View File

@@ -1,3 +1,5 @@
# $Id: Makefile,v 1.9 2003/11/14 17:13:17 weiden Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
@@ -6,11 +8,7 @@ TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = miditest
TARGET_SDKLIBS = winmm.a
TARGET_GCCLIBS =
TARGET_NAME = file
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -0,0 +1,54 @@
/***********************************************************
* File read/write test utility *
**********************************************************/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
HANDLE file;
char buffer[4096];
DWORD wrote;
int c;
file = CreateFile("test.dat",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
0,
0);
if (file == INVALID_HANDLE_VALUE)
{
printf("Error opening file (Status %lx)\n", GetLastError());
return 1;
}
for( c = 0; c < sizeof( buffer ); c++ )
buffer[c] = (char)c;
printf("Writing file\n");
if (WriteFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error writing file (Status %lx)\n", GetLastError());
exit(2);
}
printf("Reading file\n");
SetFilePointer( file, 0, 0, FILE_BEGIN );
if (ReadFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error reading file (Status %lx)\n", GetLastError());
exit(3);
}
for( c = 0; c < sizeof( buffer ); c++ )
if( buffer[c] != (char)c )
{
printf( "Error: data read back is not what was written\n" );
CloseHandle( file );
return 0;
}
printf("Finished, works fine\n");
CloseHandle( file );
return 0;
}

View File

@@ -0,0 +1,347 @@
/*
* gditest
dec 26, 2001 -- gditest bug fix by Richard Campbell
*/
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
extern BOOL STDCALL GdiDllInitialize(HANDLE hInstance, DWORD Event, LPVOID Reserved);
void __stdcall Background (HDC Desktop)
{
HPEN Pen;
int x, y;
Pen = CreatePen(PS_SOLID, 1, RGB(64, 64, 128));
SelectObject (Desktop, Pen);
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, 640, 480);
for (y = 479, x = 0; x < 640; x+=42)
{
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, x, y);
}
for (y = 0, x = 639; y < 480; y+=42)
{
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, x, y);
}
}
void gditest( void ){
HDC Desktop, MyDC, DC24;
HPEN RedPen, GreenPen, BluePen, WhitePen;
HBITMAP MyBitmap, DIB24;
HFONT hf, tf;
BITMAPINFOHEADER BitInf;
BITMAPINFO BitPalInf;
HRGN hRgn1, hRgn2, hRgn3;
HBRUSH BlueBrush, DefBrush;
// Set up a DC called Desktop that accesses DISPLAY
Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
if (Desktop == NULL){
printf("Can't create desktop\n");
return;
}
// Background
Background (Desktop);
//ei
BlueBrush = CreateSolidBrush( RGB(0, 0, 0xff) );
DefBrush = SelectObject( Desktop, BlueBrush );
hRgn1 = CreateRectRgn( 1, 2, 100, 101 );
hRgn2 = CreateRectRgn( 10, 20, 150, 151 );
hRgn3 = CreateRectRgn( 1, 1, 1, 1);
CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR );
PaintRgn( Desktop, hRgn3 );
SelectObject( Desktop, DefBrush );
DeleteObject( BlueBrush );
// Create a blue pen and select it into the DC
BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
SelectObject(Desktop, BluePen);
// Draw a shape on the DC
MoveToEx(Desktop, 50, 50, NULL);
LineTo(Desktop, 200, 60);
LineTo(Desktop, 200, 300);
LineTo(Desktop, 50, 50);
MoveToEx(Desktop, 50, 50, NULL);
LineTo(Desktop, 200, 50);
WhitePen = CreatePen(PS_SOLID, 3, RGB(0xff, 0xff, 0xff));
SelectObject(Desktop, WhitePen);
MoveToEx(Desktop, 20, 70, NULL);
LineTo(Desktop, 500, 70);
MoveToEx(Desktop, 70, 20, NULL);
LineTo(Desktop, 70, 150);
// Test font support
GreenPen = CreatePen(PS_SOLID, 3, RGB(0, 0xff, 0));
RedPen = CreatePen(PS_SOLID, 3, RGB(0xff, 0, 0));
hf = CreateFontA(24, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Helmet");
SelectObject(Desktop, hf);
SetTextColor(Desktop, RGB(0xff, 0, 0));
TextOutA(Desktop, 70, 70, "React", 5);
SetTextColor(Desktop, RGB(0, 0xff, 0));
TextOutA(Desktop, 140, 70, "OS", 2);
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
SelectObject(Desktop, tf);
SetTextColor(Desktop, RGB(0xff, 0xff, 0xff));
TextOutA(Desktop, 70, 90, "This is a test of ReactOS text, using the FreeType 2 library!", 61);
// TEST 1: Copy from the VGA into a device compatible DC, draw on it, then blt it to the VGA again
MyDC = CreateCompatibleDC(Desktop);
MyBitmap = CreateCompatibleBitmap(Desktop, 151, 251);
SelectObject(MyDC, MyBitmap);
BitBlt(MyDC, 0, 0, 151, 251, Desktop, 50, 50, SRCCOPY); // can we say 151, 251 since bottom corner is not inclusive?
SelectObject(MyDC, GreenPen);
Rectangle(MyDC, 10, 10, 50, 50);
// TEST 2: Copy from the device compatible DC into a 24BPP bitmap, draw on it, then blt to the VGA again
BitInf.biSize = sizeof(BITMAPINFOHEADER);
BitInf.biWidth = 152;
BitInf.biHeight = -252; // it's top down (since BI_RGB is used, the sign is operative of direction)
BitInf.biPlanes = 1;
BitInf.biBitCount = 24;
BitInf.biCompression = BI_RGB;
BitInf.biSizeImage = 0;
BitInf.biXPelsPerMeter = 0;
BitInf.biYPelsPerMeter = 0;
BitInf.biClrUsed = 0;
BitInf.biClrImportant = 0;
BitPalInf.bmiHeader = BitInf;
DIB24 = (HBITMAP) CreateDIBSection(NULL, &BitPalInf, DIB_RGB_COLORS, NULL, NULL, 0);
DC24 = CreateCompatibleDC(NULL);
SelectObject(DC24, DIB24);
BitBlt(DC24, 0, 0, 101, 201, MyDC, 0, 0, SRCCOPY);
SelectObject(DC24, RedPen);
Rectangle(DC24, 80, 90, 100, 110);
MoveToEx(DC24, 80, 90, NULL);
LineTo(DC24, 100, 110);
BitBlt(Desktop, 200, 200, 110, 120, DC24, 0, 0, SRCCOPY);
Sleep( 10000 ); // fixme delay only 10000 (for 10 seconds)
// Free up everything
DeleteDC(Desktop);
DeleteDC(MyDC);
}
void DumpRgnData( HRGN hRgn )
{
int size, ret, i;
LPRGNDATA rgnData;
size = GetRegionData( hRgn, 0, NULL );
if( size == 0 ){
printf("GetRegionData returned 0\n");
return;
}
rgnData = (LPRGNDATA) malloc( size );
ret = GetRegionData( hRgn, size, rgnData );
if( ret == 0 ){
printf("GetRegionData( hRgn, size, rgnData ) returned 0\n");
return;
}
printf("Bounds: left=%lu top=%lu right=%lu bottom=%lu, count: %lu, type: %lu\n\n",
rgnData->rdh.rcBound.left, rgnData->rdh.rcBound.top, rgnData->rdh.rcBound.right, rgnData->rdh.rcBound.bottom,
rgnData->rdh.nCount, rgnData->rdh.iType);
printf("Rects:\t i \t left \t top \t right \t bottom\n");
for ( i = 0; i < rgnData->rdh.nCount; i++ ) {
PRECT pr = (PRECT) rgnData->Buffer + i;
printf("\t %d \t %lu \t %lu \t %lu \t %lu\n", i, pr->left, pr->top, pr->right, pr->bottom );
}
printf("\n");
}
void rgntest( void )
{
HRGN hRgn1, hRgn2, hRgn3;
RECT Rect;
int i;
hRgn1 = CreateRectRgn( 1, 2, 100, 101 );
if( hRgn1 == NULL ) {
printf("Failed at hRgn1 = CreateRectRgn( 1, 2, 100, 101 )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn1, &Rect ): i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn1 );
hRgn2 = CreateRectRgn( 51, 53, 150, 152 );
if( hRgn2 == NULL ) {
printf("Failed at hRgn2 = CreateRectRgn( 51, 53, 150, 152 )\n");
return;
}
i = GetRgnBox( hRgn2, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn2, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn2, &Rect ): i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn2 );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal\n\n");
}
i = OffsetRgn(hRgn1,50,51);
if( i==ERROR ){
printf("Failed OffsetRgn(hRgn1,50,51)\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After offset\nGetRgnBox( hRgn1, &Rect ): i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal after offset\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal after offset!\n\n");
}
i = SetRectRgn(hRgn1, 10, 11, 110, 111 );
if( i==0 ){
printf("Failed SetRectRgn(hRgn1... )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("after SetRectRgn(hRgn1, 10, 11, 110, 111 ):\n i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
hRgn3 = CreateRectRgn( 1, 1, 1, 1);
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ). LastError: %lu\n", GetLastError());
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ). LastError: %lu\n", GetLastError());
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF ). LastError: %lu\n", GetLastError());
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR ). LastError: %lu\n", GetLastError());
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn3, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY ). LastError: %lu\n", GetLastError());
return;
}
if( GetRgnBox( hRgn1, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY ): \nGetRgnBox( hRgn1, &Rect ): CR_i=%u, left=%lu top=%lu right=%lu bottom=%lu\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn1 );
DeleteObject( hRgn1 );
DeleteObject( hRgn2 );
DeleteObject( hRgn3 );
printf("region test finished\n");
}
int main (int argc, char* argv[])
{
printf("Entering GDITest..\n");
printf("use gditest for older tests\n");
printf("use gditest 1 for region test\n");
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
if( argc < 2 )
gditest();
else {
if( !strncmp( argv[1], "1", 1 ) ) {
rgntest();
}
}
return 0;
}

View File

@@ -1,4 +1,4 @@
# $Id: makefile,v 1.1 2004/03/07 20:12:13 hbirr Exp $
# $Id: makefile,v 1.9 2003/11/14 17:13:17 weiden Exp $
PATH_TO_TOP = ../../..
@@ -8,9 +8,9 @@ TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = diskspeed
TARGET_NAME = gditest
TARGET_SDKLIBS = kernel32.a
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -1,181 +0,0 @@
#include <windows.h>
#include <stdio.h>
#include <string.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = "GradientClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow("GradientClass",
"GradientFill Test",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//DeleteObject(tf);
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
switch(msg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
TRIVERTEX vert [5] ;
GRADIENT_TRIANGLE gTRi[3];
GRADIENT_RECT gRect[2];
hDC = BeginPaint(hWnd, &ps);
vert [0] .x = 0;
vert [0] .y = 0;
vert [0] .Red = 0xff00;
vert [0] .Green = 0xff00;
vert [0] .Blue = 0xff00;
vert [0] .Alpha = 0x0000;
vert [1] .x = 300;
vert [1] .y = 20;
vert [1] .Red = 0x0000;
vert [1] .Green = 0x0000;
vert [1] .Blue = 0xff00;
vert [1] .Alpha = 0x0000;
vert [2] .x = 100;
vert [2] .y = 200;
vert [2] .Red = 0xff00;
vert [2] .Green = 0x0000;
vert [2] .Blue = 0x0000;
vert [2] .Alpha = 0x0000;
vert [3] .x = 250;
vert [3] .y = 300;
vert [3] .Red = 0x8000;
vert [3] .Green = 0x8000;
vert [3] .Blue = 0x0000;
vert [3] .Alpha = 0x0000;
vert [4] .x = 325;
vert [4] .y = 300;
vert [4] .Red = 0x0000;
vert [4] .Green = 0xff00;
vert [4] .Blue = 0x0000;
vert [4] .Alpha = 0x0000;
gTRi[0].Vertex1 = 0;
gTRi[0].Vertex2 = 1;
gTRi[0].Vertex3 = 2;
gTRi[1].Vertex1 = 1;
gTRi[1].Vertex2 = 2;
gTRi[1].Vertex3 = 3;
gTRi[2].Vertex1 = 1;
gTRi[2].Vertex2 = 3;
gTRi[2].Vertex3 = 4;
GdiGradientFill(hDC,vert,5,&gTRi,3,GRADIENT_FILL_TRIANGLE);
vert [0] .x = 5;
vert [0] .y = 200;
vert [0] .Red = 0x0000;
vert [0] .Green = 0x0000;
vert [0] .Blue = 0x0000;
vert [0] .Alpha = 0x0000;
vert [1] .x = 90;
vert [1] .y = 240;
vert [1] .Red = 0x0000;
vert [1] .Green = 0x0000;
vert [1] .Blue = 0xff00;
vert [1] .Alpha = 0x0000;
vert [2] .x = 5;
vert [2] .y = 245;
vert [2] .Red = 0x0000;
vert [2] .Green = 0x0000;
vert [2] .Blue = 0x0000;
vert [2] .Alpha = 0x0000;
vert [3] .x = 90;
vert [3] .y = 300;
vert [3] .Red = 0x0000;
vert [3] .Green = 0x0000;
vert [3] .Blue = 0xff00;
vert [3] .Alpha = 0x0000;
gRect[0].UpperLeft = 0;
gRect[0].LowerRight = 1;
gRect[1].UpperLeft = 2;
gRect[1].LowerRight = 3;
GdiGradientFill(hDC,vert,4,&gRect[0],1,GRADIENT_FILL_RECT_H);
GdiGradientFill(hDC,vert,4,&gRect[1],1,GRADIENT_FILL_RECT_V);
EndPaint(hWnd, &ps);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View File

@@ -0,0 +1,115 @@
#include <windows.h>
#include <stdio.h>
#include <string.h>
//HFONT tf;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = "HotkeyTestClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow("HotkeyTestClass",
"Hotkeys Test",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//DeleteObject(tf);
return msg.wParam;
}
#define CTRLC 1
#define ALTF1 2
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
TextOut(hDC, 10, 10, "Press Ctrl+C or Ctrl+Alt+F1",
strlen("Press Ctrl+C or Ctrl+Alt+F1"));
EndPaint(hWnd, &ps);
break;
case WM_HOTKEY:
switch(wParam)
{
case CTRLC:
MessageBox(hWnd, "You just pressed Ctrl+C", "Hotkey", MB_OK | MB_ICONINFORMATION);
break;
case ALTF1:
MessageBox(hWnd, "You just pressed Ctrl+Alt+F1", "Hotkey", MB_OK | MB_ICONINFORMATION);
break;
}
break;
case WM_DESTROY:
UnregisterHotKey(hWnd, CTRLC);
UnregisterHotKey(hWnd, ALTF1);
PostQuitMessage(0);
break;
case WM_CREATE:
/* Register a Ctrl+Alt+C hotkey*/
RegisterHotKey(hWnd, CTRLC, MOD_CONTROL, VK_C);
RegisterHotKey(hWnd, ALTF1, MOD_CONTROL | MOD_ALT, VK_F1);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View File

@@ -1,4 +1,4 @@
# $Id: makefile,v 1.2 2004/03/11 14:44:48 weiden Exp $
# $Id: makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
PATH_TO_TOP = ../../..
@@ -8,7 +8,7 @@ TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = multithrdwin
TARGET_NAME = hotkey
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a

View File

@@ -1,46 +0,0 @@
# $Id: Makefile,v 1.2 2004/05/04 17:25:18 navaraf Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API -DWINVER=0x0500
TARGET_NAME = kernel32_test
TARGET_SDKLIBS = kernel32.a
TARGET_OBJECTS = \
testlist.o \
atom.o \
change.o \
codepage.o \
comm.o \
console.o \
directory.o \
drive.o \
environ.o \
file.o \
format_msg.o \
heap.o \
locale.o \
mailslot.o \
path.o \
pipe.o \
process.o \
profile.o \
thread.o \
virtual.o
#FIXME alloc.o \
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,33 +0,0 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = kernel32.dll
IMPORTS = kernel32
CTESTS = \
alloc.c \
atom.c \
change.c \
codepage.c \
comm.c \
console.c \
directory.c \
drive.c \
environ.c \
file.c \
format_msg.c \
generated.c \
heap.c \
locale.c \
mailslot.c \
path.c \
pipe.c \
process.c \
profile.c \
thread.c \
virtual.c
@MAKE_TEST_RULES@
### Dependencies:

View File

@@ -1,408 +0,0 @@
/*
* Unit test suite for memory allocation functions.
*
* Copyright 2002 Geoffrey Hausheer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
/* The following functions don't have tests, because either I don't know how
to test them, or they are WinNT only, or require multiple threads.
Since the last two issues shouldn't really stop the tests from being
written, assume for now that it is all due to the first case
HeapCompact
HeapLock
HeapQueryInformation
HeapSetInformation
HeapUnlock
HeapValidate
HeapWalk
*/
/* In addition, these features aren't being tested
HEAP_NO_SERIALIZE
HEAP_GENERATE_EXCEPTIONS
STATUS_ACCESS_VIOLATION (error code from HeapAlloc)
*/
static void test_Heap(void)
{
SYSTEM_INFO sysInfo;
ULONG memchunk;
HANDLE heap;
LPVOID mem1,mem1a,mem3;
UCHAR *mem2,*mem2a;
UINT error,i;
DWORD dwSize;
/* Retrieve the page size for this system */
sysInfo.dwPageSize=0;
GetSystemInfo(&sysInfo);
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
/* Create a Heap with a minimum and maximum size */
/* Note that Windows and Wine seem to behave a bit differently with respect
to memory allocation. In Windows, you can't access all the memory
specified in the heap (due to overhead), so choosing a reasonable maximum
size for the heap was done mostly by trial-and-error on Win2k. It may need
more tweaking for otherWindows variants.
*/
memchunk=10*sysInfo.dwPageSize;
heap=HeapCreate(0,2*memchunk,5*memchunk);
/* Check that HeapCreate allocated the right amount of ram */
todo_wine {
/* Today HeapCreate seems to return a memory block larger than specified.
MSDN says the maximum heap size should be dwMaximumSize rounded up to the
nearest page boundary
*/
mem1=HeapAlloc(heap,0,5*memchunk+1);
ok(mem1==NULL,"HeapCreate allocated more Ram than it should have\n");
if(mem1) {
HeapFree(heap,0,mem1);
}
}
/* Check that a normal alloc works */
mem1=HeapAlloc(heap,0,memchunk);
ok(mem1!=NULL,"HeapAlloc failed\n");
if(mem1) {
ok(HeapSize(heap,0,mem1)>=memchunk, "HeapAlloc should return a big enough memory block\n");
}
/* Check that a 'zeroing' alloc works */
mem2=HeapAlloc(heap,HEAP_ZERO_MEMORY,memchunk);
ok(mem2!=NULL,"HeapAlloc failed\n");
if(mem2) {
ok(HeapSize(heap,0,mem2)>=memchunk,"HeapAlloc should return a big enough memory block\n");
error=0;
for(i=0;i<memchunk;i++) {
if(mem2[i]!=0) {
error=1;
}
}
ok(!error,"HeapAlloc should have zeroed out it's allocated memory\n");
}
/* Check that HeapAlloc returns NULL when requested way too much memory */
mem3=HeapAlloc(heap,0,5*memchunk);
ok(mem3==NULL,"HeapAlloc should return NULL\n");
if(mem3) {
ok(HeapFree(heap,0,mem3),"HeapFree didn't pass successfully\n");
}
/* Check that HeapRealloc works */
mem2a=HeapReAlloc(heap,HEAP_ZERO_MEMORY,mem2,memchunk+5*sysInfo.dwPageSize);
ok(mem2a!=NULL,"HeapReAlloc failed\n");
if(mem2a) {
ok(HeapSize(heap,0,mem2a)>=memchunk+5*sysInfo.dwPageSize,"HeapReAlloc failed\n");
error=0;
for(i=0;i<5*sysInfo.dwPageSize;i++) {
if(mem2a[memchunk+i]!=0) {
error=1;
}
}
ok(!error,"HeapReAlloc should have zeroed out it's allocated memory\n");
}
/* Check that HeapRealloc honours HEAP_REALLOC_IN_PLACE_ONLY */
error=0;
mem1a=HeapReAlloc(heap,HEAP_REALLOC_IN_PLACE_ONLY,mem1,memchunk+sysInfo.dwPageSize);
if(mem1a!=NULL) {
if(mem1a!=mem1) {
error=1;
}
}
ok(mem1a==NULL || error==0,"HeapReAlloc didn't honour HEAP_REALLOC_IN_PLACE_ONLY\n");
/* Check that HeapFree works correctly */
if(mem1a) {
ok(HeapFree(heap,0,mem1a),"HeapFree failed\n");
} else {
ok(HeapFree(heap,0,mem1),"HeapFree failed\n");
}
if(mem2a) {
ok(HeapFree(heap,0,mem2a),"HeapFree failed\n");
} else {
ok(HeapFree(heap,0,mem2),"HeapFree failed\n");
}
/* 0-length buffer */
mem1 = HeapAlloc(heap, 0, 0);
ok(mem1 != NULL, "Reserved memory\n");
dwSize = HeapSize(heap, 0, mem1);
/* should work with 0-length buffer */
ok((dwSize >= 0) && (dwSize < 0xFFFFFFFF),
"The size of the 0-length buffer\n");
ok(HeapFree(heap, 0, mem1), "Freed the 0-length buffer\n");
/* Check that HeapDestry works */
ok(HeapDestroy(heap),"HeapDestroy failed\n");
}
/* The following functions don't have tests, because either I don't know how
to test them, or they are WinNT only, or require multiple threads.
Since the last two issues shouldn't really stop the tests from being
written, assume for now that it is all due to the first case
GlobalFlags
GlobalMemoryStatus
GlobalMemoryStatusEx
*/
/* In addition, these features aren't being tested
GMEM_DISCADABLE
GMEM_NOCOMPACT
*/
static void test_Global(void)
{
ULONG memchunk;
HGLOBAL mem1,mem2,mem2a,mem2b;
UCHAR *mem2ptr;
UINT error,i;
memchunk=100000;
SetLastError(NO_ERROR);
/* Check that a normal alloc works */
mem1=GlobalAlloc(0,memchunk);
ok(mem1!=NULL,"GlobalAlloc failed\n");
if(mem1) {
ok(GlobalSize(mem1)>=memchunk, "GlobalAlloc should return a big enough memory block\n");
}
/* Check that a 'zeroing' alloc works */
mem2=GlobalAlloc(GMEM_ZEROINIT,memchunk);
ok(mem2!=NULL,"GlobalAlloc failed: error=%ld\n",GetLastError());
if(mem2) {
ok(GlobalSize(mem2)>=memchunk,"GlobalAlloc should return a big enough memory block\n");
mem2ptr=GlobalLock(mem2);
ok(mem2ptr==mem2,"GlobalLock should have returned the same memory as was allocated\n");
if(mem2ptr) {
error=0;
for(i=0;i<memchunk;i++) {
if(mem2ptr[i]!=0) {
error=1;
}
}
ok(!error,"GlobalAlloc should have zeroed out it's allocated memory\n");
}
}
/* Check that GlobalReAlloc works */
/* Check that we can change GMEM_FIXED to GMEM_MOVEABLE */
mem2a=GlobalReAlloc(mem2,0,GMEM_MODIFY | GMEM_MOVEABLE);
ok(mem2a!=NULL,"GlobalReAlloc failed to convert FIXED to MOVEABLE: error=%ld\n",GetLastError());
if(mem2a!=NULL) {
mem2=mem2a;
}
mem2ptr=GlobalLock(mem2a);
ok(mem2ptr!=NULL && !GlobalUnlock(mem2a)&&GetLastError()==NO_ERROR,
"Converting from FIXED to MOVEABLE didn't REALLY work\n");
/* Check that ReAllocing memory works as expected */
mem2a=GlobalReAlloc(mem2,2*memchunk,GMEM_MOVEABLE | GMEM_ZEROINIT);
ok(mem2a!=NULL,"GlobalReAlloc failed\n");
if(mem2a) {
ok(GlobalSize(mem2a)>=2*memchunk,"GlobalReAlloc failed\n");
mem2ptr=GlobalLock(mem2a);
ok(mem2ptr!=NULL,"GlobalLock Failed\n");
if(mem2ptr) {
error=0;
for(i=0;i<memchunk;i++) {
if(mem2ptr[memchunk+i]!=0) {
error=1;
}
}
ok(!error,"GlobalReAlloc should have zeroed out it's allocated memory\n");
/* Check that GlobalHandle works */
mem2b=GlobalHandle(mem2ptr);
ok(mem2b==mem2a,"GlobalHandle didn't return the correct memory handle\n");
/* Check that we can't discard locked memory */
mem2b=GlobalDiscard(mem2a);
ok(mem2b==NULL,"Discarded memory we shouldn't have\n");
ok(!GlobalUnlock(mem2a) && GetLastError()==NO_ERROR,"GlobalUnlock Failed\n");
}
}
if(mem1) {
ok(GlobalFree(mem1)==NULL,"GlobalFree failed\n");
}
if(mem2a) {
ok(GlobalFree(mem2a)==NULL,"GlobalFree failed\n");
} else {
ok(GlobalFree(mem2)==NULL,"GlobalFree failed\n");
}
}
/* The following functions don't have tests, because either I don't know how
to test them, or they are WinNT only, or require multiple threads.
Since the last two issues shouldn't really stop the tests from being
written, assume for now that it is all due to the first case
LocalDiscard
LocalFlags
*/
/* In addition, these features aren't being tested
LMEM_DISCADABLE
LMEM_NOCOMPACT
*/
static void test_Local(void)
{
ULONG memchunk;
HLOCAL mem1,mem2,mem2a,mem2b;
UCHAR *mem2ptr;
UINT error,i;
memchunk=100000;
/* Check that a normal alloc works */
mem1=LocalAlloc(0,memchunk);
ok(mem1!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
if(mem1) {
ok(LocalSize(mem1)>=memchunk, "LocalAlloc should return a big enough memory block\n");
}
/* Check that a 'zeroing' and lock alloc works */
mem2=LocalAlloc(LMEM_ZEROINIT|LMEM_MOVEABLE,memchunk);
ok(mem2!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
if(mem2) {
ok(LocalSize(mem2)>=memchunk,"LocalAlloc should return a big enough memory block\n");
mem2ptr=LocalLock(mem2);
ok(mem2ptr!=NULL,"LocalLock: error=%ld\n",GetLastError());
if(mem2ptr) {
error=0;
for(i=0;i<memchunk;i++) {
if(mem2ptr[i]!=0) {
error=1;
}
}
ok(!error,"LocalAlloc should have zeroed out it's allocated memory\n");
SetLastError(0);
error=LocalUnlock(mem2);
ok(error==0 && GetLastError()==NO_ERROR,
"LocalUnlock Failed: rc=%d err=%ld\n",error,GetLastError());
}
}
mem2a=LocalFree(mem2);
ok(mem2a==NULL, "LocalFree failed: %p\n",mem2a);
/* Reallocate mem2 as moveable memory */
mem2=LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,memchunk);
ok(mem2!=NULL, "LocalAlloc failed to create moveable memory, error=%ld\n",GetLastError());
/* Check that ReAllocing memory works as expected */
mem2a=LocalReAlloc(mem2,2*memchunk,LMEM_MOVEABLE | LMEM_ZEROINIT);
ok(mem2a!=NULL,"LocalReAlloc failed, error=%ld\n",GetLastError());
if(mem2a) {
ok(LocalSize(mem2a)>=2*memchunk,"LocalReAlloc failed\n");
mem2ptr=LocalLock(mem2a);
ok(mem2ptr!=NULL,"LocalLock Failed\n");
if(mem2ptr) {
error=0;
for(i=0;i<memchunk;i++) {
if(mem2ptr[memchunk+i]!=0) {
error=1;
}
}
ok(!error,"LocalReAlloc should have zeroed out it's allocated memory\n");
/* Check that LocalHandle works */
mem2b=LocalHandle(mem2ptr);
ok(mem2b==mem2a,"LocalHandle didn't return the correct memory handle\n");
/* Check that we can't discard locked memory */
mem2b=LocalDiscard(mem2a);
ok(mem2b==NULL,"Discarded memory we shouldn't have\n");
SetLastError(NO_ERROR);
ok(!LocalUnlock(mem2a) && GetLastError()==NO_ERROR, "LocalUnlock Failed\n");
}
}
if(mem1) {
ok(LocalFree(mem1)==NULL,"LocalFree failed\n");
}
if(mem2a) {
ok(LocalFree(mem2a)==NULL,"LocalFree failed\n");
} else {
ok(LocalFree(mem2)==NULL,"LocalFree failed\n");
}
}
/* The Virtual* routines are not tested as thoroughly,
since I don't really understand how to use them correctly :)
The following routines are not tested at all
VirtualAllocEx
VirtualFreeEx
VirtualLock
VirtualProtect
VirtualProtectEx
VirtualQuery
VirtualQueryEx
VirtualUnlock
And the only features (flags) being tested are
MEM_COMMIT
MEM_RELEASE
PAGE_READWRITE
Testing the rest requires using exceptions, which I really don't
understand well
*/
static void test_Virtual(void)
{
SYSTEM_INFO sysInfo;
ULONG memchunk;
UCHAR *mem1;
UINT error,i;
/* Retrieve the page size for this system */
sysInfo.dwPageSize=0;
GetSystemInfo(&sysInfo);
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
/* Choose a reasonable allocation size */
memchunk=10*sysInfo.dwPageSize;
/* Check that a normal alloc works */
mem1=VirtualAlloc(NULL,memchunk,MEM_COMMIT,PAGE_READWRITE);
ok(mem1!=NULL,"VirtualAlloc failed\n");
if(mem1) {
/* check that memory is initialized to 0 */
error=0;
for(i=0;i<memchunk;i++) {
if(mem1[i]!=0) {
error=1;
}
}
ok(!error,"VirtualAlloc did not initialize memory to '0's\n");
/* Check that we can read/write to memory */
error=0;
for(i=0;i<memchunk;i+=100) {
mem1[i]='a';
if(mem1[i]!='a') {
error=1;
}
}
ok(!error,"Virtual memory was not writable\n");
}
ok(VirtualFree(mem1,0,MEM_RELEASE),"VirtualFree failed\n");
}
START_TEST(alloc)
{
test_Heap();
test_Global();
test_Local();
test_Virtual();
}

View File

@@ -1,191 +0,0 @@
/*
* Unit tests for atom functions
*
* Copyright (c) 2002 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
static const WCHAR FOOBARW[] = {'F','O','O','B','A','R',0};
static const WCHAR _foobarW[] = {'_','f','o','o','b','a','r',0};
static BOOL unicode_OS;
static void test_add_atom(void)
{
ATOM atom, w_atom;
int i;
SetLastError( 0xdeadbeef );
atom = GlobalAddAtomA( "foobar" );
ok( atom >= 0xc000, "bad atom id %x\n", atom );
ok( GetLastError() == 0xdeadbeef, "GlobalAddAtomA set last error\n" );
/* Verify that it can be found (or not) appropriately */
ok( GlobalFindAtomA( "foobar" ) == atom, "could not find atom foobar\n" );
ok( GlobalFindAtomA( "FOOBAR" ) == atom, "could not find atom FOOBAR\n" );
ok( !GlobalFindAtomA( "_foobar" ), "found _foobar\n" );
/* Add the same atom, specifying string as unicode; should
* find the first one, not add a new one */
SetLastError( 0xdeadbeef );
w_atom = GlobalAddAtomW( foobarW );
if (w_atom && GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
unicode_OS = TRUE;
else
trace("WARNING: Unicode atom APIs are not supported on this platform\n");
if (unicode_OS)
{
ok( w_atom == atom, "Unicode atom does not match ASCII\n" );
ok( GetLastError() == 0xdeadbeef, "GlobalAddAtomW set last error\n" );
}
/* Verify that it can be found (or not) appropriately via unicode name */
if (unicode_OS)
{
ok( GlobalFindAtomW( foobarW ) == atom, "could not find atom foobar\n" );
ok( GlobalFindAtomW( FOOBARW ) == atom, "could not find atom FOOBAR\n" );
ok( !GlobalFindAtomW( _foobarW ), "found _foobar\n" );
}
/* Test integer atoms
* (0x0001 .. 0xbfff) should be valid;
* (0xc000 .. 0xffff) should be invalid */
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomA(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
if (unicode_OS)
{
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomW(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
}
SetLastError( 0xdeadbeef );
for (i = 1; i <= 0xbfff; i++)
{
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
if (unicode_OS)
{
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
}
}
for (i = 0xc000; i <= 0xffff; i++)
{
ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %x\n", i );
if (unicode_OS)
ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %x\n", i );
}
}
static void test_get_atom_name(void)
{
char buf[10];
WCHAR bufW[10];
int i;
UINT len;
static const WCHAR resultW[] = {'f','o','o','b','a','r',0,'.','.','.'};
ATOM atom = GlobalAddAtomA( "foobar" );
/* Get the name of the atom we added above */
memset( buf, '.', sizeof(buf) );
len = GlobalGetAtomNameA( atom, buf, 10 );
ok( len == strlen("foobar"), "bad length %d\n", len );
ok( !memcmp( buf, "foobar\0...", 10 ), "bad buffer contents\n" );
/* Repeat, unicode-style */
if (unicode_OS)
{
for (i = 0; i < 10; i++) bufW[i] = '.';
SetLastError( 0xdeadbeef );
len = GlobalGetAtomNameW( atom, bufW, 10 );
ok( len && GetLastError() == 0xdeadbeef, "GlobalGetAtomNameW failed\n" );
ok( len == lstrlenW(foobarW), "bad length %d\n", len );
ok( !memcmp( bufW, resultW, 10*sizeof(WCHAR) ), "bad buffer contents\n" );
}
/* Check error code returns */
memset(buf, '.', 10);
ok( !GlobalGetAtomNameA( atom, buf, 0 ), "succeeded\n" );
ok( !memcmp( buf, "..........", 10 ), "should not touch buffer\n" );
if (unicode_OS)
{
static const WCHAR sampleW[10] = {'.','.','.','.','.','.','.','.','.','.'};
for (i = 0; i < 10; i++) bufW[i] = '.';
ok( !GlobalGetAtomNameW( atom, bufW, 0 ), "succeeded\n" );
ok( !memcmp( bufW, sampleW, 10 * sizeof(WCHAR) ), "should not touch buffer\n" );
}
/* Test integer atoms */
for (i = 0; i <= 0xbfff; i++)
{
memset( buf, 'a', 10 );
len = GlobalGetAtomNameA( (ATOM)i, buf, 10 );
if (i)
{
char res[20];
ok( (len > 1) && (len < 7), "bad length %d\n", len );
sprintf( res, "#%d", i );
memset( res + strlen(res) + 1, 'a', 10 );
ok( !memcmp( res, buf, 10 ), "bad buffer contents %s\n", buf );
}
else
ok( !len, "bad length %d\n", len );
}
}
static void test_error_handling(void)
{
char buffer[260];
WCHAR bufferW[260];
int i;
memset( buffer, 'a', 256 );
buffer[256] = 0;
ok( !GlobalAddAtomA(buffer), "add succeeded\n" );
ok( !GlobalFindAtomA(buffer), "find succeeded\n" );
if (unicode_OS)
{
for (i = 0; i < 256; i++) bufferW[i] = 'b';
bufferW[256] = 0;
ok( !GlobalAddAtomW(bufferW), "add succeeded\n" );
ok( !GlobalFindAtomW(bufferW), "find succeeded\n" );
}
}
START_TEST(atom)
{
test_add_atom();
test_get_atom_name();
test_error_handling();
}

View File

@@ -1,237 +0,0 @@
/*
* Tests for file change notification functions
*
* Copyright (c) 2004 Hans Leidekker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* TODO: - security attribute changes
* - compound filter and multiple notifications
* - subtree notifications
* - non-documented flags FILE_NOTIFY_CHANGE_LAST_ACCESS and
* FILE_NOTIFY_CHANGE_CREATION
*/
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include <windef.h>
#include <winbase.h>
static DWORD CALLBACK NotificationThread(LPVOID arg)
{
HANDLE change = (HANDLE) arg;
BOOL ret = FALSE;
DWORD status;
status = WaitForSingleObject(change, 100);
if (status == WAIT_OBJECT_0 ) {
ret = FindNextChangeNotification(change);
}
ok(FindCloseChangeNotification(change), "FindCloseChangeNotification error: %ld\n",
GetLastError());
ExitThread((DWORD)ret);
}
static HANDLE StartNotificationThread(LPCSTR path, BOOL subtree, DWORD flags)
{
HANDLE change, thread;
DWORD threadId;
change = FindFirstChangeNotificationA(path, subtree, flags);
ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %ld\n", GetLastError());
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NotificationThread, (LPVOID)change,
0, &threadId);
ok(thread != INVALID_HANDLE_VALUE, "CreateThread error: %ld\n", GetLastError());
return thread;
}
static DWORD FinishNotificationThread(HANDLE thread)
{
DWORD status, exitcode;
status = WaitForSingleObject(thread, 5000);
ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %ld error %ld\n", status, GetLastError());
ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n");
return exitcode;
}
static void test_FindFirstChangeNotification(void)
{
HANDLE change, file, thread;
DWORD attributes, count;
BOOL ret;
char workdir[MAX_PATH], dirname1[MAX_PATH], dirname2[MAX_PATH];
char filename1[MAX_PATH], filename2[MAX_PATH];
static const char prefix[] = "FCN";
char buffer[2048];
/* pathetic checks */
change = FindFirstChangeNotificationA("not-a-file", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
ok(change == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND,
"FindFirstChangeNotification error: %ld\n", GetLastError());
if (0) /* This documents win2k behavior. It crashes on win98. */
{
change = FindFirstChangeNotificationA(NULL, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
ok(change == NULL && GetLastError() == ERROR_PATH_NOT_FOUND,
"FindFirstChangeNotification error: %ld\n", GetLastError());
}
ret = FindNextChangeNotification(NULL);
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindNextChangeNotification error: %ld\n",
GetLastError());
ret = FindCloseChangeNotification(NULL);
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindCloseChangeNotification error: %ld\n",
GetLastError());
ret = GetTempPathA(MAX_PATH, workdir);
ok(ret, "GetTempPathA error: %ld\n", GetLastError());
lstrcatA(workdir, "testFileChangeNotification");
ret = CreateDirectoryA(workdir, NULL);
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
ret = GetTempFileNameA(workdir, prefix, 0, filename1);
ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
file = CreateFileA(filename1, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
/* Try to register notification for a file. win98 and win2k behave differently here */
change = FindFirstChangeNotificationA(filename1, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
ok(change == INVALID_HANDLE_VALUE && (GetLastError() == ERROR_DIRECTORY ||
GetLastError() == ERROR_FILE_NOT_FOUND),
"FindFirstChangeNotification error: %ld\n", GetLastError());
lstrcpyA(dirname1, filename1);
lstrcatA(dirname1, "dir");
ret = CreateDirectoryA(dirname1, NULL);
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
/* What if we remove the directory we registered notification for? */
thread = StartNotificationThread(dirname1, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
ret = RemoveDirectoryA(dirname1);
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
/* win98 and win2k behave differently here */
ret = FinishNotificationThread(thread);
ok(ret || !ret, "You'll never read this\n");
/* functional checks */
/* Create a directory */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
ret = CreateDirectoryA(dirname1, NULL);
ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
lstrcpyA(dirname2, dirname1);
lstrcatA(dirname2, "new");
/* Rename a directory */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
ret = MoveFileA(dirname1, dirname2);
ok(ret, "MoveFileA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Delete a directory */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
ret = RemoveDirectoryA(dirname2);
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
lstrcpyA(filename2, filename1);
lstrcatA(filename2, "new");
/* Rename a file */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
ret = MoveFileA(filename1, filename2);
ok(ret, "MoveFileA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Delete a file */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
ret = DeleteFileA(filename2);
ok(ret, "DeleteFileA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Create a file */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
file = CreateFileA(filename2, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
attributes = GetFileAttributesA(filename2);
ok(attributes != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA error: %ld\n", GetLastError());
attributes &= FILE_ATTRIBUTE_READONLY;
/* Change file attributes */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_ATTRIBUTES);
ret = SetFileAttributesA(filename2, attributes);
ok(ret, "SetFileAttributesA error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Change last write time by writing to a file */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ret = WriteFile(file, buffer, sizeof(buffer), &count, NULL);
ok(ret && count == sizeof(buffer), "WriteFile error: %ld\n", GetLastError());
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Change file size by truncating a file */
thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_SIZE);
file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ret = WriteFile(file, buffer, sizeof(buffer) / 2, &count, NULL);
ok(ret && count == sizeof(buffer) / 2, "WriteFileA error: %ld\n", GetLastError());
ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* clean up */
ret = DeleteFileA(filename2);
ok(ret, "DeleteFileA error: %ld\n", GetLastError());
ret = RemoveDirectoryA(workdir);
ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
}
START_TEST(change)
{
test_FindFirstChangeNotification();
}

View File

@@ -1,62 +0,0 @@
/*
* Unit tests for code page to/from unicode translations
*
* Copyright (c) 2002 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
/* lstrcmpW is not supported on Win9x! */
static int mylstrcmpW(const WCHAR* str1, const WCHAR* str2)
{
while (*str1 && *str1==*str2) {
str1++;
str2++;
}
return *str1-*str2;
}
static void test_negative_source_length(void)
{
int len;
char buf[10];
WCHAR bufW[10];
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
/* Test, whether any negative source length works as strlen() + 1 */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -2002, buf, 10, NULL, NULL);
ok(len == 7 && !lstrcmpA(buf, "foobar") && GetLastError() == 0xdeadbeef,
"WideCharToMultiByte(-2002): len=%d error=%ld\n",len,GetLastError());
SetLastError( 0xdeadbeef );
memset(bufW,'x',sizeof(bufW));
len = MultiByteToWideChar(CP_ACP, 0, "foobar", -2002, bufW, 10);
ok(len == 7 && !mylstrcmpW(bufW, foobarW) && GetLastError() == 0xdeadbeef,
"MultiByteToWideChar(-2002): len=%d error=%ld\n",len,GetLastError());
}
START_TEST(codepage)
{
test_negative_source_length();
}

View File

@@ -1,640 +0,0 @@
/* Unit test suite for comm functions
*
* Copyright 2003 Kevin Groeneveld
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include "wine/test.h"
#include "winbase.h"
#include "winnls.h"
typedef struct
{
char string[100];
BOOL result;
BOOL old_style;
DCB dcb1, dcb2;
COMMTIMEOUTS timeouts1, timeouts2;
} TEST;
static TEST test[] =
{
{
"baud=9600 parity=e data=5 stop=1 xon=on odsr=off octs=off dtr=on rts=on idsr=on",
TRUE, FALSE,
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"baud=0 parity=M data=6 stop=1.5 xon=off odsr=on octs=ON dtr=off rts=off idsr=OFF",
TRUE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"BAUD=4000000000 parity=n data=7 stop=2 to=off",
TRUE, FALSE,
{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xee6b2800, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x00, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
},
{
"Baud=115200 Parity=O Data=8 To=On",
TRUE, FALSE,
{ 0x00000000, 0x0001c200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x0001c200, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
},
{
"PaRiTy=s Data=7 DTR=on",
TRUE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x04, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x04, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"data=4",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"data=9",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"parity=no",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"stop=0",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"stop=1.501",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"stop=3",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"to=foobar",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
" baud=9600",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"baud= 9600",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"baud=9600,data=8",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"11,n,8,1",
TRUE, TRUE,
{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"30 ,E, 5,1.5",
TRUE, TRUE,
{ 0x00000000, 0x0000012c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x0000012c, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"60, m, 6, 2 ",
TRUE, TRUE,
{ 0x00000000, 0x00000258, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00000258, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"12 , o , 7 , 1",
TRUE, TRUE,
{ 0x00000000, 0x000004b0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x000004b0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"24,s,8,1.5",
TRUE, TRUE,
{ 0x00000000, 0x00000960, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x04, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00000960, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x04, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"48,n,8,1,p",
TRUE, TRUE,
{ 0x00000000, 0x000012c0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x000012c0, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,8,1 , x ",
TRUE, TRUE,
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"19, e, 7, 1, x",
TRUE, TRUE,
{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"0,M,7,1,P",
TRUE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"4000000000,O,7,1.5,X",
TRUE, TRUE,
{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xee6b2800, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,8,1 to=on",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,NO,8,1",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,4,1",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,9,1",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,8,0",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,8,3",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"96,N,8,1,K",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COM0:baud=115200",
FALSE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx:baud=38400 data=8",
TRUE, FALSE,
{ 0x00000000, 0x00009600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00009600, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx :to=on stop=1.5",
TRUE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
},
{
"COMx: baud=12345 data=7",
TRUE, FALSE,
{ 0x00000000, 0x00003039, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00003039, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx : xon=on odsr=off",
TRUE, FALSE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COM0:9600,N,8,1",
FALSE, TRUE,
{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx:9600,N,8,1",
TRUE, TRUE,
{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx: 11,E,7,2",
TRUE, TRUE,
{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx :19,M,5,1",
TRUE, TRUE,
{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
{
"COMx : 57600,S,6,2,x",
TRUE, TRUE,
{ 0x00000000, 0x0000e100, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x04, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
{ 0xffffffff, 0x0000e100, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x04, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
},
};
#define TEST_COUNT (sizeof(test) / sizeof(TEST))
/* This function can be useful if you are modifiying the test cases and want to
output the contents of a DCB structure. */
/*static print_dcb(DCB *pdcb)
{
printf("0x%08x, 0x%08x, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, 0x%05x, 0x%04x, 0x%04x, 0x%04x, 0x%02x, 0x%02x, 0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, 0x%04x\n",
pdcb->DCBlength,
pdcb->BaudRate,
pdcb->fBinary,
pdcb->fParity,
pdcb->fOutxCtsFlow,
pdcb->fOutxDsrFlow,
pdcb->fDtrControl,
pdcb->fDsrSensitivity,
pdcb->fTXContinueOnXoff,
pdcb->fOutX,
pdcb->fInX,
pdcb->fErrorChar,
pdcb->fNull,
pdcb->fRtsControl,
pdcb->fAbortOnError,
pdcb->fDummy2,
pdcb->wReserved,
pdcb->XonLim,
pdcb->XoffLim,
pdcb->ByteSize,
pdcb->Parity,
pdcb->StopBits,
pdcb->XonChar & 0xff,
pdcb->XoffChar & 0xff,
pdcb->ErrorChar & 0xff,
pdcb->EofChar & 0xff,
pdcb->EvtChar & 0xff,
pdcb->wReserved1 & 0xffff );
} */
static void check_result(char *function, TEST *ptest, int initial_value, BOOL result)
{
DWORD LastError = GetLastError();
DWORD CorrectError = (ptest->result ? 0xdeadbeef : ERROR_INVALID_PARAMETER);
ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned 0x%08lx, should be 0x%08lx\n", function, ptest->string, initial_value, LastError, CorrectError);
ok(result == ptest->result, "%s(\"%s\"), 0x%02x: return value should be %s\n", function, ptest->string, initial_value, ptest->result ? "TRUE" : "FALSE");
}
#define check_dcb_member(a,b) ok(pdcb1->a == pdcb2->a, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a)
#define check_dcb_member2(a,c,b) if(pdcb2->a == c) { check_dcb_member(a,b); } else { ok(pdcb1->a == pdcb2->a || pdcb1->a == c, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b" or "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a, c); }
static void check_dcb(char *function, TEST *ptest, int initial_value, DCB *pdcb1, DCB *pdcb2)
{
/* DCBlength is a special case since Win 9x sets it but NT does not.
We will accept either as correct. */
check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%lu");
/* For old style control strings Win 9x does not set the next five members, NT does. */
if(ptest->old_style && ptest->result)
{
check_dcb_member2(fOutxCtsFlow, ((unsigned int)initial_value & 1), "%u");
check_dcb_member2(fDtrControl, ((unsigned int)initial_value & 3), "%u");
check_dcb_member2(fOutX, ((unsigned int)initial_value & 1), "%u");
check_dcb_member2(fInX, ((unsigned)initial_value & 1), "%u");
check_dcb_member2(fRtsControl, ((unsigned)initial_value & 3), "%u");
}
else
{
check_dcb_member(fOutxCtsFlow, "%u");
check_dcb_member(fDtrControl, "%u");
check_dcb_member(fOutX, "%u");
check_dcb_member(fInX, "%u");
check_dcb_member(fRtsControl, "%u");
}
if(ptest->result)
{
/* For the idsr=xxx parameter, NT sets fDsrSensitivity, 9x sets
fOutxDsrFlow. */
if(!ptest->old_style)
{
check_dcb_member2(fOutxDsrFlow, pdcb2->fDsrSensitivity, "%u");
check_dcb_member2(fDsrSensitivity, pdcb2->fOutxDsrFlow, "%u");
}
else
{
/* For old style control strings Win 9x does not set the
fOutxDsrFlow member, NT does. */
check_dcb_member2(fOutxDsrFlow, ((unsigned int)initial_value & 1), "%u");
check_dcb_member(fDsrSensitivity, "%u");
}
}
else
{
check_dcb_member(fOutxDsrFlow, "%u");
check_dcb_member(fDsrSensitivity, "%u");
}
/* Check the result of the DCB members. */
check_dcb_member(BaudRate, "%lu");
check_dcb_member(fBinary, "%u");
check_dcb_member(fParity, "%u");
check_dcb_member(fTXContinueOnXoff, "%u");
check_dcb_member(fErrorChar, "%u");
check_dcb_member(fNull, "%u");
check_dcb_member(fAbortOnError, "%u");
check_dcb_member(fDummy2, "%u");
check_dcb_member(wReserved, "%u");
check_dcb_member(XonLim, "%u");
check_dcb_member(XoffLim, "%u");
check_dcb_member(ByteSize, "%u");
check_dcb_member(Parity, "%u");
check_dcb_member(StopBits, "%u");
check_dcb_member(XonChar, "%d");
check_dcb_member(XoffChar, "%d");
check_dcb_member(ErrorChar, "%d");
check_dcb_member(EofChar, "%d");
check_dcb_member(EvtChar, "%d");
check_dcb_member(wReserved1, "%u");
}
#define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %lu, should be %lu\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
static void check_timeouts(char *function, TEST *ptest, int initial_value, COMMTIMEOUTS *ptimeouts1, COMMTIMEOUTS *ptimeouts2)
{
check_timeouts_member(ReadIntervalTimeout);
check_timeouts_member(ReadTotalTimeoutMultiplier);
check_timeouts_member(ReadTotalTimeoutConstant);
check_timeouts_member(WriteTotalTimeoutMultiplier);
check_timeouts_member(WriteTotalTimeoutConstant);
}
static void test_BuildCommDCBA(TEST *ptest, int initial_value, DCB *pexpected_dcb)
{
BOOL result;
DCB dcb;
/* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB));
SetLastError(0xdeadbeef);
result = BuildCommDCBA(ptest->string, &dcb);
/* check results */
check_result("BuildCommDCBA", ptest, initial_value, result);
check_dcb("BuildCommDCBA", ptest, initial_value, &dcb, pexpected_dcb);
}
static void test_BuildCommDCBAndTimeoutsA(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
{
BOOL result;
DCB dcb;
COMMTIMEOUTS timeouts;
/* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB));
memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
SetLastError(0xdeadbeef);
result = BuildCommDCBAndTimeoutsA(ptest->string, &dcb, &timeouts);
/* check results */
check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
}
static void test_BuildCommDCBW(TEST *ptest, int initial_value, DCB *pexpected_dcb)
{
BOOL result;
DCB dcb;
WCHAR wide_string[sizeof(ptest->string)];
MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
/* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB));
SetLastError(0xdeadbeef);
result = BuildCommDCBW(wide_string, &dcb);
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
return;
/* check results */
check_result("BuildCommDCBW", ptest, initial_value, result);
check_dcb("BuildCommDCBW", ptest, initial_value, &dcb, pexpected_dcb);
}
static void test_BuildCommDCBAndTimeoutsW(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
{
BOOL result;
DCB dcb;
COMMTIMEOUTS timeouts;
WCHAR wide_string[sizeof(ptest->string)];
MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
/* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB));
memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
SetLastError(0xdeadbeef);
result = BuildCommDCBAndTimeoutsW(wide_string, &dcb, &timeouts);
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
return;
/* check results */
check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
}
static void test_BuildCommDCB(void)
{
char port_name[] = "COMx";
char port = 0;
int i;
char *ptr;
/* Some of these tests require a valid COM port. This loop will try to find
a valid port. */
for(port_name[3] = '1'; port_name[3] <= '9'; port_name[3]++)
{
COMMCONFIG commconfig;
DWORD size = sizeof(COMMCONFIG);
if(GetDefaultCommConfig(port_name, &commconfig, &size))
{
port = port_name[3];
break;
}
}
if(!port)
trace("Could not find a valid COM port. Some tests will be skipped.\n");
for(i = 0; i < TEST_COUNT; i++)
{
/* Check if this test case needs a valid COM port. */
ptr = strstr(test[i].string, "COMx");
/* If required, substitute valid port number into device control string. */
if(ptr)
{
if(port)
ptr[3] = port;
else
continue;
}
test_BuildCommDCBA(&test[i], 0x00, &test[i].dcb1);
test_BuildCommDCBA(&test[i], 0xff, &test[i].dcb2);
test_BuildCommDCBAndTimeoutsA(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
test_BuildCommDCBAndTimeoutsA(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
test_BuildCommDCBW(&test[i], 0x00, &test[i].dcb1);
test_BuildCommDCBW(&test[i], 0xff, &test[i].dcb2);
test_BuildCommDCBAndTimeoutsW(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
test_BuildCommDCBAndTimeoutsW(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
}
}
START_TEST(comm)
{
test_BuildCommDCB();
}

View File

@@ -1,561 +0,0 @@
/*
* Unit tests for console API
*
* Copyright (c) 2003 Eric Pouech
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "wine/test.h"
#include <windows.h>
#include <stdio.h>
/* DEFAULT_ATTRIB is used for all initial filling of the console.
* all modifications are made with TEST_ATTRIB so that we could check
* what has to be modified or not
*/
#define TEST_ATTRIB (BACKGROUND_BLUE | FOREGROUND_GREEN)
#define DEFAULT_ATTRIB (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED)
/* when filling the screen with non-blank chars, this macro defines
* what character should be at position 'c'
*/
#define CONTENT(c) ('A' + (((c).Y * 17 + (c).X) % 23))
#define okCURSOR(hCon, c) do { \
CONSOLE_SCREEN_BUFFER_INFO __sbi; \
BOOL expect = GetConsoleScreenBufferInfo((hCon), &__sbi) && \
__sbi.dwCursorPosition.X == (c).X && __sbi.dwCursorPosition.Y == (c).Y; \
ok(expect, "Expected cursor at (%d,%d), got (%d,%d)\n", \
(c).X, (c).Y, __sbi.dwCursorPosition.X, __sbi.dwCursorPosition.Y); \
} while (0)
#define okCHAR(hCon, c, ch, attr) do { \
char __ch; WORD __attr; DWORD __len; BOOL expect; \
expect = ReadConsoleOutputCharacter((hCon), &__ch, 1, (c), &__len) == 1 && __len == 1 && __ch == (ch); \
ok(expect, "At (%d,%d): expecting char '%c'/%02x got '%c'/%02x\n", (c).X, (c).Y, (ch), (ch), __ch, __ch); \
expect = ReadConsoleOutputAttribute((hCon), &__attr, 1, (c), &__len) == 1 && __len == 1 && __attr == (attr); \
ok(expect, "At (%d,%d): expecting attr %04x got %04x\n", (c).X, (c).Y, (attr), __attr); \
} while (0)
/* FIXME: this could be optimized on a speed point of view */
static void resetContent(HANDLE hCon, COORD sbSize, BOOL content)
{
COORD c;
WORD attr = DEFAULT_ATTRIB;
char ch;
DWORD len;
for (c.X = 0; c.X < sbSize.X; c.X++)
{
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
{
ch = (content) ? CONTENT(c) : ' ';
WriteConsoleOutputAttribute(hCon, &attr, 1, c, &len);
WriteConsoleOutputCharacterA(hCon, &ch, 1, c, &len);
}
}
}
static void testCursor(HANDLE hCon, COORD sbSize)
{
COORD c;
c.X = c.Y = 0;
ok(SetConsoleCursorPosition(0, c) == 0, "No handle\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %lu\n",
ERROR_INVALID_HANDLE, GetLastError());
c.X = c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left\n");
okCURSOR(hCon, c);
c.X = sbSize.X - 1;
c.Y = sbSize.Y - 1;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in lower-right\n");
okCURSOR(hCon, c);
c.X = sbSize.X;
c.Y = sbSize.Y - 1;
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
ERROR_INVALID_PARAMETER, GetLastError());
c.X = sbSize.X - 1;
c.Y = sbSize.Y;
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
ERROR_INVALID_PARAMETER, GetLastError());
c.X = -1;
c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
ERROR_INVALID_PARAMETER, GetLastError());
c.X = 0;
c.Y = -1;
ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
ERROR_INVALID_PARAMETER, GetLastError());
}
static void testWriteSimple(HANDLE hCon, COORD sbSize)
{
COORD c;
DWORD len;
const char* mytest = "abcdefg";
const int mylen = strlen(mytest);
/* single line write */
c.X = c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
c.Y = 0;
for (c.X = 0; c.X < mylen; c.X++)
{
okCHAR(hCon, c, mytest[c.X], TEST_ATTRIB);
}
okCURSOR(hCon, c);
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
}
static void testWriteNotWrappedNotProcessed(HANDLE hCon, COORD sbSize)
{
COORD c;
DWORD len, mode;
char* mytest;
int mylen;
int ret;
int p;
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, mode & ~(ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT)),
"clearing wrap at EOL & processed output\n");
/* write line, wrapping disabled, buffer exceeds sb width */
c.X = sbSize.X - 3; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
mytest = "123";
mylen = strlen(mytest);
ret = WriteConsole(hCon, mytest, mylen, &len, NULL);
ok(ret != 0 && len == mylen, "Couldn't write, ret = %d, len = %ld\n", ret, len);
c.Y = 0;
for (p = mylen - 3; p < mylen; p++)
{
c.X = sbSize.X - 3 + p % 3;
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
}
c.X = 0; c.Y = 1;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
p = sbSize.X - 3 + mylen % 3;
c.X = p; c.Y = 0;
/* write line, wrapping disabled, strings end on end of line */
c.X = sbSize.X - mylen; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
}
static void testWriteNotWrappedProcessed(HANDLE hCon, COORD sbSize)
{
COORD c;
DWORD len, mode;
const char* mytest = "abcd\nf\tg";
const int mylen = strlen(mytest);
const int mylen2 = strchr(mytest, '\n') - mytest;
int p;
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, (mode | ENABLE_PROCESSED_OUTPUT) & ~ENABLE_WRAP_AT_EOL_OUTPUT),
"clearing wrap at EOL & setting processed output\n");
/* write line, wrapping disabled, buffer exceeds sb width */
c.X = sbSize.X - 5; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-5\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
c.Y = 0;
for (c.X = sbSize.X - 5; c.X < sbSize.X - 1; c.X++)
{
okCHAR(hCon, c, mytest[c.X - sbSize.X + 5], TEST_ATTRIB);
}
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
c.X = 0; c.Y++;
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
for (c.X = 1; c.X < 8; c.X++)
okCHAR(hCon, c, ' ', TEST_ATTRIB);
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
okCURSOR(hCon, c);
/* write line, wrapping disabled, strings end on end of line */
c.X = sbSize.X - 4; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-4\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
c.Y = 0;
for (c.X = sbSize.X - 4; c.X < sbSize.X; c.X++)
{
okCHAR(hCon, c, mytest[c.X - sbSize.X + 4], TEST_ATTRIB);
}
c.X = 0; c.Y++;
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
for (c.X = 1; c.X < 8; c.X++)
okCHAR(hCon, c, ' ', TEST_ATTRIB);
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
okCURSOR(hCon, c);
/* write line, wrapping disabled, strings end after end of line */
c.X = sbSize.X - 3; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-4\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
c.Y = 0;
for (p = mylen2 - 3; p < mylen2; p++)
{
c.X = sbSize.X - 3 + p % 3;
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
}
c.X = 0; c.Y = 1;
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
for (c.X = 1; c.X < 8; c.X++)
okCHAR(hCon, c, ' ', TEST_ATTRIB);
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
okCURSOR(hCon, c);
}
static void testWriteWrappedNotProcessed(HANDLE hCon, COORD sbSize)
{
COORD c;
DWORD len, mode;
const char* mytest = "abcd\nf\tg";
const int mylen = strlen(mytest);
int p;
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon,(mode | ENABLE_WRAP_AT_EOL_OUTPUT) & ~(ENABLE_PROCESSED_OUTPUT)),
"setting wrap at EOL & clearing processed output\n");
/* write line, wrapping enabled, buffer doesn't exceed sb width */
c.X = sbSize.X - 9; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-9\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
c.Y = 0;
for (p = 0; p < mylen; p++)
{
c.X = sbSize.X - 9 + p;
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
}
c.X = sbSize.X - 9 + mylen;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
c.X = 0; c.Y = 1;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
/* write line, wrapping enabled, buffer does exceed sb width */
c.X = sbSize.X - 3; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
c.Y = 1;
c.X = mylen - 3;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
}
static void testWriteWrappedProcessed(HANDLE hCon, COORD sbSize)
{
COORD c;
DWORD len, mode;
const char* mytest = "abcd\nf\tg";
const int mylen = strlen(mytest);
int p;
ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, mode | (ENABLE_WRAP_AT_EOL_OUTPUT|ENABLE_PROCESSED_OUTPUT)),
"setting wrap at EOL & processed output\n");
/* write line, wrapping enabled, buffer doesn't exceed sb width */
c.X = sbSize.X - 9; c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-9\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
for (p = 0; p < 4; p++)
{
c.X = sbSize.X - 9 + p;
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
}
c.X = sbSize.X - 9 + p;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
c.X = 0; c.Y++;
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
for (c.X = 1; c.X < 8; c.X++)
okCHAR(hCon, c, ' ', TEST_ATTRIB);
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
okCURSOR(hCon, c);
/* write line, wrapping enabled, buffer does exceed sb width */
c.X = sbSize.X - 3; c.Y = 2;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
for (p = 0; p < 3; p++)
{
c.X = sbSize.X - 3 + p;
okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
}
c.X = 0; c.Y++;
okCHAR(hCon, c, mytest[3], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
c.X = 0; c.Y++;
okCHAR(hCon, c, mytest[5], TEST_ATTRIB);
for (c.X = 1; c.X < 8; c.X++)
okCHAR(hCon, c, ' ', TEST_ATTRIB);
okCHAR(hCon, c, mytest[7], TEST_ATTRIB);
c.X++;
okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
okCURSOR(hCon, c);
}
static void testWrite(HANDLE hCon, COORD sbSize)
{
/* FIXME: should in fact insure that the sb is at least 10 character wide */
ok(SetConsoleTextAttribute(hCon, TEST_ATTRIB), "Setting default text color\n");
resetContent(hCon, sbSize, FALSE);
testWriteSimple(hCon, sbSize);
resetContent(hCon, sbSize, FALSE);
testWriteNotWrappedNotProcessed(hCon, sbSize);
resetContent(hCon, sbSize, FALSE);
testWriteNotWrappedProcessed(hCon, sbSize);
resetContent(hCon, sbSize, FALSE);
testWriteWrappedNotProcessed(hCon, sbSize);
resetContent(hCon, sbSize, FALSE);
testWriteWrappedProcessed(hCon, sbSize);
}
#if 0
static void testScroll(HANDLE hCon, COORD sbSize)
{
SMALL_RECT scroll, clip;
COORD dst, c, tc;
CHAR_INFO ci;
#define W 11
#define H 7
/* no clipping, src & dst rect don't overlap */
resetContent(hCon, sbSize, TRUE);
#define IN_SRECT(r,c) ((r).Left <= (c).X && (c).X <= (r).Right && (r).Top <= (c).Y && (c).Y <= (r).Bottom)
#define IN_SRECT2(r,d,c) ((d).X <= (c).X && (c).X <= (d).X + (r).Right - (r).Left && (d).Y <= (c).Y && (c).Y <= (d).Y + (r).Bottom - (r).Top)
scroll.Left = 0;
scroll.Right = W - 1;
scroll.Top = 0;
scroll.Bottom = H - 1;
dst.X = W + 3;
dst.Y = H + 3;
ci.Char.UnicodeChar = '#';
ci.Attributes = TEST_ATTRIB;
clip.Left = 0;
clip.Right = sbSize.X - 1;
clip.Top = 0;
clip.Bottom = sbSize.Y - 1;
ok(ScrollConsoleScreenBuffer(hCon, &scroll, NULL, dst, &ci), "Scrolling SB\n");
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
{
for (c.X = 0; c.X < sbSize.X; c.X++)
{
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
{
tc.X = c.X - dst.X;
tc.Y = c.Y - dst.Y;
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
}
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
okCHAR(hCon, c, '#', TEST_ATTRIB);
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
}
}
/* no clipping, src & dst rect do overlap */
resetContent(hCon, sbSize, TRUE);
scroll.Left = 0;
scroll.Right = W - 1;
scroll.Top = 0;
scroll.Bottom = H - 1;
dst.X = W /2;
dst.Y = H / 2;
ci.Char.UnicodeChar = '#';
ci.Attributes = TEST_ATTRIB;
clip.Left = 0;
clip.Right = sbSize.X - 1;
clip.Top = 0;
clip.Bottom = sbSize.Y - 1;
ok(ScrollConsoleScreenBuffer(hCon, &scroll, NULL, dst, &ci), "Scrolling SB\n");
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
{
for (c.X = 0; c.X < sbSize.X; c.X++)
{
if (dst.X <= c.X && c.X < dst.X + W && dst.Y <= c.Y && c.Y < dst.Y + H)
{
tc.X = c.X - dst.X;
tc.Y = c.Y - dst.Y;
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
}
else if (c.X < W && c.Y < H) okCHAR(hCon, c, '#', TEST_ATTRIB);
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
}
}
/* clipping, src & dst rect don't overlap */
resetContent(hCon, sbSize, TRUE);
scroll.Left = 0;
scroll.Right = W - 1;
scroll.Top = 0;
scroll.Bottom = H - 1;
dst.X = W + 3;
dst.Y = H + 3;
ci.Char.UnicodeChar = '#';
ci.Attributes = TEST_ATTRIB;
clip.Left = W / 2;
clip.Right = min(W + W / 2, sbSize.X - 1);
clip.Top = H / 2;
clip.Bottom = min(H + H / 2, sbSize.Y - 1);
ok(ScrollConsoleScreenBuffer(hCon, &scroll, &clip, dst, &ci), "Scrolling SB\n");
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
{
for (c.X = 0; c.X < sbSize.X; c.X++)
{
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
{
tc.X = c.X - dst.X;
tc.Y = c.Y - dst.Y;
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
}
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
okCHAR(hCon, c, '#', TEST_ATTRIB);
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
}
}
/* clipping, src & dst rect do overlap */
resetContent(hCon, sbSize, TRUE);
scroll.Left = 0;
scroll.Right = W - 1;
scroll.Top = 0;
scroll.Bottom = H - 1;
dst.X = W / 2 - 3;
dst.Y = H / 2 - 3;
ci.Char.UnicodeChar = '#';
ci.Attributes = TEST_ATTRIB;
clip.Left = W / 2;
clip.Right = min(W + W / 2, sbSize.X - 1);
clip.Top = H / 2;
clip.Bottom = min(H + H / 2, sbSize.Y - 1);
ok(ScrollConsoleScreenBuffer(hCon, &scroll, &clip, dst, &ci), "Scrolling SB\n");
for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
{
for (c.X = 0; c.X < sbSize.X; c.X++)
{
if (IN_SRECT2(scroll, dst, c) && IN_SRECT(clip, c))
{
tc.X = c.X - dst.X;
tc.Y = c.Y - dst.Y;
okCHAR(hCon, c, CONTENT(tc), DEFAULT_ATTRIB);
}
else if (IN_SRECT(scroll, c) && IN_SRECT(clip, c))
okCHAR(hCon, c, '#', TEST_ATTRIB);
else okCHAR(hCon, c, CONTENT(c), DEFAULT_ATTRIB);
}
}
}
#endif
START_TEST(console)
{
HANDLE hConIn, hConOut;
BOOL ret;
CONSOLE_SCREEN_BUFFER_INFO sbi;
/* be sure we have a clean console (and that's our own)
* FIXME: this will make the test fail (currently) if we don't run
* under X11
* Another solution would be to rerun the test under wineconsole with
* the curses backend
*/
hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
/* first, we need to be sure we're attached to a console */
if (hConIn == INVALID_HANDLE_VALUE || hConOut == INVALID_HANDLE_VALUE)
{
/* we're not attached to a console, let's do it */
AllocConsole();
hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
}
/* now verify everything's ok */
ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
ok(ret = GetConsoleScreenBufferInfo(hConOut, &sbi), "Getting sb info\n");
if (!ret) return;
/* Non interactive tests */
testCursor(hConOut, sbi.dwSize);
/* will test wrapped (on/off) & processed (on/off) strings output */
testWrite(hConOut, sbi.dwSize);
/* will test line scrolling at the bottom of the screen */
/* testBottomScroll(); */
/* will test all the scrolling operations */
/* this one is disabled for now, Wine's result are way too bad */
/* testScroll(hCon, sbi.dwSize); */
/* will test sb creation / modification... */
/* testScreenBuffer() */
/* still to be done: events generation, access rights & access on objects */
}

View File

@@ -1,342 +0,0 @@
/*
* Unit test suite for directory functions.
*
* Copyright 2002 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
/* If you change something in these tests, please do the same
* for GetSystemDirectory tests.
*/
static void test_GetWindowsDirectoryA(void)
{
UINT len, len_with_null;
char buf[MAX_PATH];
len_with_null = GetWindowsDirectoryA(NULL, 0);
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
lstrcpyA(buf, "foo");
len_with_null = GetWindowsDirectoryA(buf, 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
lstrcpyA(buf, "foo");
len = GetWindowsDirectoryA(buf, len_with_null - 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyA(buf, "foo");
len = GetWindowsDirectoryA(buf, len_with_null);
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
ok(len == len_with_null-1, "GetWindowsDirectoryA returned %d, expected %d\n",
len, len_with_null-1);
}
static void test_GetWindowsDirectoryW(void)
{
UINT len, len_with_null;
WCHAR buf[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
len_with_null = GetWindowsDirectoryW(NULL, 0);
if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
lstrcpyW(buf, fooW);
len = GetWindowsDirectoryW(buf, 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetWindowsDirectoryW(buf, len_with_null - 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetWindowsDirectoryW(buf, len_with_null);
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
ok(len == len_with_null-1, "GetWindowsDirectoryW returned %d, expected %d\n",
len, len_with_null-1);
}
/* If you change something in these tests, please do the same
* for GetWindowsDirectory tests.
*/
static void test_GetSystemDirectoryA(void)
{
UINT len, len_with_null;
char buf[MAX_PATH];
len_with_null = GetSystemDirectoryA(NULL, 0);
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
lstrcpyA(buf, "foo");
len = GetSystemDirectoryA(buf, 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
len, len_with_null);
lstrcpyA(buf, "foo");
len = GetSystemDirectoryA(buf, len_with_null - 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
len, len_with_null);
lstrcpyA(buf, "foo");
len = GetSystemDirectoryA(buf, len_with_null);
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null-1);
}
static void test_GetSystemDirectoryW(void)
{
UINT len, len_with_null;
WCHAR buf[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
len_with_null = GetSystemDirectoryW(NULL, 0);
if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, len_with_null - 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, len_with_null);
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null-1);
}
static void test_CreateDirectoryA(void)
{
char tmpdir[MAX_PATH];
BOOL ret;
ret = CreateDirectoryA(NULL, NULL);
ok(ret == FALSE && (GetLastError() == ERROR_PATH_NOT_FOUND ||
GetLastError() == ERROR_INVALID_PARAMETER),
"CreateDirectoryA(NULL,NULL): ret=%d error=%ld\n",ret,GetLastError());
ret = CreateDirectoryA("", NULL);
ok(ret == FALSE && (GetLastError() == ERROR_BAD_PATHNAME ||
GetLastError() == ERROR_PATH_NOT_FOUND),
"CreateDirectoryA(\"\",NULL): ret=%d error=%ld\n",ret,GetLastError());
ret = GetSystemDirectoryA(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
ret = SetCurrentDirectoryA(tmpdir);
ok(ret == TRUE, "could not chdir to the System directory\n");
ret = CreateDirectoryA(".", NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ret = CreateDirectoryA("..", NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
GetTempPathA(MAX_PATH, tmpdir);
tmpdir[3] = 0; /* truncate the path */
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && (GetLastError() == ERROR_ALREADY_EXISTS ||
GetLastError() == ERROR_ACCESS_DENIED),
"CreateDirectoryA(drive_root): ret=%d error=%ld\n",ret,GetLastError());
GetTempPathA(MAX_PATH, tmpdir);
lstrcatA(tmpdir, "Please Remove Me");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == TRUE, "CreateDirectoryA should always succeed\n");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ret = RemoveDirectoryA(tmpdir);
ok(ret == TRUE, "RemoveDirectoryA should always succeed\n");
lstrcatA(tmpdir, "?");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryA with ? wildcard name should fail, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryA(tmpdir);
tmpdir[lstrlenA(tmpdir) - 1] = '*';
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryA with * wildcard name should fail, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryA(tmpdir);
}
static void test_CreateDirectoryW(void)
{
WCHAR tmpdir[MAX_PATH];
BOOL ret;
static const WCHAR empty_strW[] = { 0 };
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
static const WCHAR dotW[] = {'.',0};
static const WCHAR dotdotW[] = {'.','.',0};
static const WCHAR questionW[] = {'?',0};
ret = CreateDirectoryW(NULL, NULL);
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create NULL path\n");
ret = CreateDirectoryW(empty_strW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create empty path\n");
ret = GetSystemDirectoryW(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
ret = SetCurrentDirectoryW(tmpdir);
ok(ret == TRUE, "could not chdir to the System directory\n");
ret = CreateDirectoryW(dotW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ret = CreateDirectoryW(dotdotW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
GetTempPathW(MAX_PATH, tmpdir);
tmpdir[3] = 0; /* truncate the path */
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "should deny access to the drive root\n");
GetTempPathW(MAX_PATH, tmpdir);
lstrcatW(tmpdir, tmp_dir_name);
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
lstrcatW(tmpdir, questionW);
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryW(tmpdir);
tmpdir[lstrlenW(tmpdir) - 1] = '*';
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryW(tmpdir);
}
static void test_RemoveDirectoryA(void)
{
char tmpdir[MAX_PATH];
BOOL ret;
GetTempPathA(MAX_PATH, tmpdir);
lstrcatA(tmpdir, "Please Remove Me");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == TRUE, "CreateDirectoryA should always succeed\n");
ret = RemoveDirectoryA(tmpdir);
ok(ret == TRUE, "RemoveDirectoryA should always succeed\n");
lstrcatA(tmpdir, "?");
ret = RemoveDirectoryA(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryA with ? wildcard name should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
tmpdir[lstrlenA(tmpdir) - 1] = '*';
ret = RemoveDirectoryA(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryA with * wildcard name should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
}
static void test_RemoveDirectoryW(void)
{
WCHAR tmpdir[MAX_PATH];
BOOL ret;
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
static const WCHAR questionW[] = {'?',0};
GetTempPathW(MAX_PATH, tmpdir);
lstrcatW(tmpdir, tmp_dir_name);
ret = CreateDirectoryW(tmpdir, NULL);
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
lstrcatW(tmpdir, questionW);
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
tmpdir[lstrlenW(tmpdir) - 1] = '*';
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
ret ? " True" : "False", GetLastError());
}
START_TEST(directory)
{
test_GetWindowsDirectoryA();
test_GetWindowsDirectoryW();
test_GetSystemDirectoryA();
test_GetSystemDirectoryW();
test_CreateDirectoryA();
test_CreateDirectoryW();
test_RemoveDirectoryA();
test_RemoveDirectoryW();
}

View File

@@ -1,183 +0,0 @@
/*
* Unit test suite for drive functions.
*
* Copyright 2002 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
void test_GetDriveTypeA(void)
{
char drive[] = "?:\\";
DWORD logical_drives;
UINT type;
logical_drives = GetLogicalDrives();
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
{
type = GetDriveTypeA(drive);
ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
if (!(logical_drives & 1))
ok(type == DRIVE_NO_ROOT_DIR,
"GetDriveTypeA should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
drive[0], type);
logical_drives >>= 1;
}
}
void test_GetDriveTypeW(void)
{
WCHAR drive[] = {'?',':','\\',0};
DWORD logical_drives;
UINT type;
logical_drives = GetLogicalDrives();
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
{
type = GetDriveTypeW(drive);
if (type == DRIVE_UNKNOWN && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
/* Must be Win9x which doesn't support the Unicode functions */
return;
}
ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
if (!(logical_drives & 1))
ok(type == DRIVE_NO_ROOT_DIR,
"GetDriveTypeW should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
drive[0], type);
logical_drives >>= 1;
}
}
void test_GetDiskFreeSpaceA(void)
{
BOOL ret;
DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
char drive[] = "?:\\";
DWORD logical_drives;
ret = GetDiskFreeSpaceA(NULL, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
ret = GetDiskFreeSpaceA("", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_NAME),
"GetDiskFreeSpaceA(\"\"): ret=%d GetLastError=%ld\n",
ret, GetLastError());
ret = GetDiskFreeSpaceA("\\", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
ret = GetDiskFreeSpaceA("/", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
logical_drives = GetLogicalDrives();
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
{
/* Skip floppy drives because NT pops up a MessageBox if no
* floppy is present
*/
if (GetDriveTypeA(drive)!=DRIVE_REMOVABLE)
{
ret = GetDiskFreeSpaceA(drive, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
if (!(logical_drives & 1))
ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_DRIVE),
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
drive, ret, GetLastError());
else
ok(ret ||
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
drive, ret, GetLastError());
}
logical_drives >>= 1;
}
}
void test_GetDiskFreeSpaceW(void)
{
BOOL ret;
DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
WCHAR drive[] = {'?',':','\\',0};
DWORD logical_drives;
static const WCHAR empty_pathW[] = { 0 };
static const WCHAR root_pathW[] = { '\\', 0 };
static const WCHAR unix_style_root_pathW[] = { '/', 0 };
ret = GetDiskFreeSpaceW(NULL, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
if (ret == 0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
/* Must be Win9x which doesn't support the Unicode functions */
return;
}
ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
ret = GetDiskFreeSpaceW(empty_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
"GetDiskFreeSpaceW(\"\"): ret=%d GetLastError=%ld\n",
ret, GetLastError());
ret = GetDiskFreeSpaceW(root_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(ret, "GetDiskFreeSpaceW(\"\") error %ld\n", GetLastError());
ret = GetDiskFreeSpaceW(unix_style_root_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
logical_drives = GetLogicalDrives();
ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
{
/* Skip floppy drives because NT4 pops up a MessageBox if no floppy is present */
if (GetDriveTypeW(drive)!=DRIVE_REMOVABLE)
{
ret = GetDiskFreeSpaceW(drive, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
if (!(logical_drives & 1))
ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
drive[0], ret, GetLastError());
else
ok(ret || GetLastError() == ERROR_NOT_READY,
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
drive[0], ret, GetLastError());
}
logical_drives >>= 1;
}
}
START_TEST(drive)
{
test_GetDriveTypeA();
test_GetDriveTypeW();
test_GetDiskFreeSpaceA();
test_GetDiskFreeSpaceW();
}

View File

@@ -1,218 +0,0 @@
/*
* Unit test suite for environment functions.
*
* Copyright 2002 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
static void test_GetSetEnvironmentVariableA(void)
{
char buf[256];
BOOL ret;
DWORD ret_size;
static const char name[] = "SomeWildName";
static const char name_cased[] = "sOMEwILDnAME";
static const char value[] = "SomeWildValue";
ret = SetEnvironmentVariableA(name, value);
ok(ret == TRUE,
"unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
GetLastError());
/* Try to retrieve the environment variable we just set */
ret_size = GetEnvironmentVariableA(name, NULL, 0);
ok(ret_size == strlen(value) + 1,
"should return length with terminating 0 ret_size=%ld\n", ret_size);
lstrcpyA(buf, "foo");
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value));
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
ok(ret_size == strlen(value) + 1,
"should return length with terminating 0 ret_size=%ld\n", ret_size);
lstrcpyA(buf, "foo");
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == strlen(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
lstrcpyA(buf, "foo");
ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == strlen(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
/* Remove that environment variable */
ret = SetEnvironmentVariableA(name_cased, NULL);
ok(ret == TRUE, "should erase existing variable\n");
lstrcpyA(buf, "foo");
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
/* Check behavior of SetEnvironmentVariableA(name, "") */
ret = SetEnvironmentVariableA(name, value);
ok(ret == TRUE,
"unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
GetLastError());
lstrcpyA(buf, "foo");
ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == strlen(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
ret = SetEnvironmentVariableA(name_cased, "");
ok(ret == TRUE,
"should not fail with empty value but GetLastError=%ld\n", GetLastError());
lstrcpyA(buf, "foo");
SetLastError(0);
ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
ok(ret_size == 0 &&
((GetLastError() == 0 && lstrcmpA(buf, "") == 0) ||
(GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
"%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%ld GetLastError=%ld and buf=%s\n",
name, ret_size, GetLastError(), buf);
/* Test the limits */
ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
ret_size = GetEnvironmentVariableA(NULL, buf, lstrlenA(value) + 1);
ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
ret_size = GetEnvironmentVariableA("", buf, lstrlenA(value) + 1);
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
}
static void test_GetSetEnvironmentVariableW(void)
{
WCHAR buf[256];
BOOL ret;
DWORD ret_size;
static const WCHAR name[] = {'S','o','m','e','W','i','l','d','N','a','m','e',0};
static const WCHAR value[] = {'S','o','m','e','W','i','l','d','V','a','l','u','e',0};
static const WCHAR name_cased[] = {'s','O','M','E','w','I','L','D','n','A','M','E',0};
static const WCHAR empty_strW[] = { 0 };
static const WCHAR fooW[] = {'f','o','o',0};
ret = SetEnvironmentVariableW(name, value);
if (ret == FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
/* Must be Win9x which doesn't support the Unicode functions */
return;
}
ok(ret == TRUE,
"unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
GetLastError());
/* Try to retrieve the environment variable we just set */
ret_size = GetEnvironmentVariableW(name, NULL, 0);
ok(ret_size == lstrlenW(value) + 1,
"should return length with terminating 0 ret_size=%ld\n",
ret_size);
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value));
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(ret_size == lstrlenW(value) + 1,
"should return length with terminating 0 ret_size=%ld\n", ret_size);
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == lstrlenW(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name_cased, buf, lstrlenW(value) + 1);
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == lstrlenW(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
/* Remove that environment variable */
ret = SetEnvironmentVariableW(name_cased, NULL);
ok(ret == TRUE, "should erase existing variable\n");
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
/* Check behavior of SetEnvironmentVariableW(name, "") */
ret = SetEnvironmentVariableW(name, value);
ok(ret == TRUE,
"unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
GetLastError());
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
ok(ret_size == lstrlenW(value),
"should return length without terminating 0 ret_size=%ld\n", ret_size);
ret = SetEnvironmentVariableW(name_cased, empty_strW);
ok(ret == TRUE, "should not fail with empty value but GetLastError=%ld\n", GetLastError());
lstrcpyW(buf, fooW);
ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
/* Test the limits */
ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
ret_size = GetEnvironmentVariableW(NULL, buf, lstrlenW(value) + 1);
ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
"should not find variable but ret_size=%ld GetLastError=%ld\n",
ret_size, GetLastError());
ret = SetEnvironmentVariableW(NULL, NULL);
ok(ret == FALSE && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
"should fail with NULL, NULL but ret=%d and GetLastError=%ld\n",
ret, GetLastError());
}
START_TEST(environ)
{
test_GetSetEnvironmentVariableA();
test_GetSetEnvironmentVariableW();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,226 +0,0 @@
/* Unit test suite for FormatMessageA
*
* Copyright 2002 Mike McCormack for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
/* #define ok(cond,failstr) if(!(cond)) {printf("line %d : %s\n",__LINE__,failstr);exit(1);} */
DWORD doit(DWORD flags, LPCVOID src, DWORD msg_id, DWORD lang_id,
LPSTR out, DWORD outsize, ... )
{
va_list list;
DWORD r;
va_start(list, outsize);
r = FormatMessageA(flags, src, msg_id,
lang_id, out, outsize, &list);
va_end(list);
return r;
}
void test_message_from_string(void)
{
CHAR out[0x100] = {0};
DWORD r;
static const WCHAR szwTest[] = { 't','e','s','t',0};
/* the basics */
r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0,
0, out, sizeof(out)/sizeof(CHAR),NULL);
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* using the format feature */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!s!", 0,
0, out, sizeof(out)/sizeof(CHAR), "test");
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* no format */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1", 0,
0, out, sizeof(out)/sizeof(CHAR), "test");
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* two pieces */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%2", 0,
0, out, sizeof(out)/sizeof(CHAR), "te","st");
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* three pieces */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%3%2%1", 0,
0, out, sizeof(out)/sizeof(CHAR), "t","s","e");
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* s doesn't seem to work in format strings */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%!s!", 0,
0, out, sizeof(out)/sizeof(CHAR), "test");
ok(!strcmp("!s!", out),"failed out=[%s]\n",out);
ok(r==3,"failed: r=%ld\n",r);
/* S is unicode */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!S!", 0,
0, out, sizeof(out)/sizeof(CHAR), szwTest);
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* as characters */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!c!%2!c!%3!c!%1!c!", 0,
0, out, sizeof(out)/sizeof(CHAR), 't','e','s');
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* some numbers */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!d!%2!d!%3!d!", 0,
0, out, sizeof(out)/sizeof(CHAR), 1,2,3);
ok(!strcmp("123", out),"failed out=[%s]\n",out);
ok(r==3,"failed: r=%ld\n",r);
/* a single digit with some spacing */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0,
0, out, sizeof(out)/sizeof(CHAR), 1);
ok(!strcmp(" 1", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* a single digit, left justified */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4d!", 0,
0, out, sizeof(out)/sizeof(CHAR), 1);
ok(!strcmp("1 ", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* two digit decimal number */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0,
0, out, sizeof(out)/sizeof(CHAR), 11);
ok(!strcmp(" 11", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* a hex number */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4x!", 0,
0, out, sizeof(out)/sizeof(CHAR), 11);
ok(!strcmp(" b", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* a hex number, upper case */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0,
0, out, sizeof(out)/sizeof(CHAR), 11);
ok(!strcmp(" B", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* a hex number, upper case, left justified */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4X!", 0,
0, out, sizeof(out)/sizeof(CHAR), 11);
ok(!strcmp("B ", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* a long hex number, upper case */
r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0,
0, out, sizeof(out)/sizeof(CHAR), 0x1ab);
ok(!strcmp(" 1AB", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* two percent... */
r = doit(FORMAT_MESSAGE_FROM_STRING, " %%%% ", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp(" %% ", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* periods are special cases */
r = doit(FORMAT_MESSAGE_FROM_STRING, " %.%. %1!d!", 0,
0, out, sizeof(out)/sizeof(CHAR), 0x1ab);
ok(!strcmp(" .. 427", out),"failed out=[%s]\n",out);
ok(r==7,"failed: r=%ld\n",r);
/* %0 ends the line */
r = doit(FORMAT_MESSAGE_FROM_STRING, "test%0test", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("test", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* %! prints an exclaimation */
r = doit(FORMAT_MESSAGE_FROM_STRING, "yah%!%0 ", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("yah!", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* %space */
r = doit(FORMAT_MESSAGE_FROM_STRING, "% % ", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\r\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING, "\r", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("\r\n", out),"failed out=[%s]\n",out);
ok(r==2,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING, "\r\r\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("\r\n\r\n", out),"failed out=[%s]\n",out);
ok(r==4,"failed: r=%ld\n",r);
/* change of pace... test the low byte of dwflags */
/* line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("hi ", out) || !strcmp("hi\r\n", out),"failed out=[%s]\n",out);
ok(r==3 || r==4,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\r\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp("hi ", out),"failed out=[%s]\n",out);
ok(r==3,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
ok(r==1,"failed: r=%ld\n",r);
/* carriage return line feed */
r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r\r\n", 0,
0, out, sizeof(out)/sizeof(CHAR));
ok(!strcmp(" ", out),"failed out=[%s]\n",out);
ok(r==2,"failed: r=%ld\n",r);
}
START_TEST(format_msg)
{
test_message_from_string();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,89 +0,0 @@
/*
* Unit test suite for heap functions
*
* Copyright 2003 Dimitrie O. Paun
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wine/test.h"
START_TEST(heap)
{
void *mem;
HGLOBAL gbl;
SIZE_T size;
/* Heap*() functions */
mem = HeapAlloc(GetProcessHeap(), 0, 0);
ok(mem != NULL, "memory not allocated for size 0\n");
mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10);
ok(mem == NULL, "memory allocated by HeapReAlloc\n");
/* Global*() functions */
gbl = GlobalAlloc(GMEM_MOVEABLE, 0);
ok(gbl != NULL, "global memory not allocated for size 0\n");
gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
ok(gbl != NULL, "Can't realloc global memory\n");
size = GlobalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
}
size = GlobalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
ok(GlobalFree(gbl) == NULL, "Memory not freed\n");
size = GlobalSize(gbl);
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
ok(gbl == NULL, "global realloc allocated memory\n");
/* Local*() functions */
gbl = LocalAlloc(GMEM_MOVEABLE, 0);
ok(gbl != NULL, "local memory not allocated for size 0\n");
gbl = LocalReAlloc(gbl, 10, GMEM_MOVEABLE);
ok(gbl != NULL, "Can't realloc local memory\n");
size = LocalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = LocalReAlloc(gbl, 0, GMEM_MOVEABLE);
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
}
size = LocalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
ok(LocalFree(gbl) == NULL, "Memory not freed\n");
size = LocalSize(gbl);
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
gbl = LocalReAlloc(0, 10, GMEM_MOVEABLE);
ok(gbl == NULL, "local realloc allocated memory\n");
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,330 +0,0 @@
/*
* Mailslot regression test
*
* Copyright 2003 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#ifndef STANDALONE
#include "wine/test.h"
#else
#define START_TEST(name) main(int argc, char **argv)
#define ok(cond,str) do{ if(!(cond)) printf("line %d: %s\n",__LINE__,str); }while (0)
#define todo_wine
#endif
static const char szmspath[] = "\\\\.\\mailslot\\wine_mailslot_test";
static int mailslot_test()
{
HANDLE hSlot, hSlot2, hWriter, hWriter2;
unsigned char buffer[16];
DWORD count, dwMax, dwNext, dwMsgCount, dwTimeout;
/* sanity check on GetMailslotInfo */
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
ok( !GetMailslotInfo( INVALID_HANDLE_VALUE, &dwMax, &dwNext,
&dwMsgCount, &dwTimeout ), "getmailslotinfo succeeded\n");
/* open a mailslot that doesn't exist */
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter == INVALID_HANDLE_VALUE, "non-existing mailslot\n");
/* open a mailslot without the right name */
hSlot = CreateMailslot( "blah", 0, 0, NULL );
ok( hSlot == INVALID_HANDLE_VALUE,
"Created mailslot with invalid name\n");
todo_wine
{
ok( GetLastError() == ERROR_INVALID_NAME,
"error should be ERROR_INVALID_NAME\n");
}
/* open a mailslot with a null name */
hSlot = CreateMailslot( NULL, 0, 0, NULL );
ok( hSlot == INVALID_HANDLE_VALUE,
"Created mailslot with invalid name\n");
todo_wine
{
ok( GetLastError() == ERROR_PATH_NOT_FOUND,
"error should be ERROR_PATH_NOT_FOUND\n");
}
todo_wine
{
/* valid open, but with wacky parameters ... then check them */
hSlot = CreateMailslot( szmspath, -1, -1, NULL );
ok( hSlot != INVALID_HANDLE_VALUE , "mailslot with valid name failed\n");
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
"getmailslotinfo failed\n");
ok( dwMax == -1, "dwMax incorrect\n");
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
}
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
todo_wine
{
ok( dwTimeout == -1, "dwTimeout incorrect\n");
ok( GetMailslotInfo( hSlot, NULL, NULL, NULL, NULL ),
"getmailslotinfo failed\n");
ok( CloseHandle(hSlot), "failed to close mailslot\n");
}
todo_wine
{
/* now open it for real */
hSlot = CreateMailslot( szmspath, 0, 0, NULL );
ok( hSlot != INVALID_HANDLE_VALUE , "valid mailslot failed\n");
}
/* try and read/write to it */
count = 0;
memset(buffer, 0, sizeof buffer);
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"slot read\n");
ok( !WriteFile( hSlot, buffer, sizeof buffer, &count, NULL),
"slot write\n");
/* now try and openthe client, but with the wrong sharing mode */
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter == INVALID_HANDLE_VALUE, "bad sharing mode\n");
todo_wine
{
ok( GetLastError() == ERROR_SHARING_VIOLATION,
"error should be ERROR_SHARING_VIOLATION\n");
/* now open the client with the correct sharing mode */
hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter != INVALID_HANDLE_VALUE, "existing mailslot\n");
}
/*
* opening a client should make no difference to
* whether we can read or write the mailslot
*/
ok( !ReadFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
"slot read\n");
ok( !WriteFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
"slot write\n");
/*
* we can't read from this client,
* but we should be able to write to it
*/
ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
"can read client\n");
todo_wine
{
ok( WriteFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
"can't write client\n");
}
ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
"can read client\n");
/*
* seeing as there's something in the slot,
* we should be able to read it once
*/
todo_wine
{
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"slot read\n");
ok( count == (sizeof buffer/2), "short read\n" );
}
/* but not again */
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"slot read\n");
/* now try open another writer... should fail */
hWriter2 = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter2 == INVALID_HANDLE_VALUE, "two writers\n");
/* now try open another as a reader ... also fails */
hWriter2 = CreateFile(szmspath, GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter2 == INVALID_HANDLE_VALUE, "writer + reader\n");
/* now try open another as a writer ... still fails */
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter2 == INVALID_HANDLE_VALUE, "writer\n");
/* now open another one */
hSlot2 = CreateMailslot( szmspath, 0, 0, NULL );
ok( hSlot2 == INVALID_HANDLE_VALUE , "opened two mailslots\n");
todo_wine
{
/* close the client again */
ok( CloseHandle( hWriter ), "closing the client\n");
/*
* now try reopen it with slightly different permissions ...
* shared writing
*/
hWriter = CreateFile(szmspath, GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter != INVALID_HANDLE_VALUE, "sharing writer\n");
}
/*
* now try open another as a writer ...
* but don't share with the first ... fail
*/
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter2 == INVALID_HANDLE_VALUE, "greedy writer succeeded\n");
todo_wine
{
/* now try open another as a writer ... and share with the first */
hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
ok( hWriter2 != INVALID_HANDLE_VALUE, "2nd sharing writer\n");
/* check the mailslot info */
dwMax = dwNext = dwMsgCount = dwTimeout = 0;
ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
"getmailslotinfo failed\n");
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
}
ok( dwMax == 0, "dwMax incorrect\n");
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
ok( dwTimeout == 0, "dwTimeout incorrect\n");
/* check there's still no data */
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL), "slot read\n");
/* write two messages */
todo_wine
{
buffer[0] = 'a';
ok( WriteFile( hWriter, buffer, 1, &count, NULL), "1st write failed\n");
/* check the mailslot info */
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
ok( dwNext == 1, "dwNext incorrect\n");
ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
buffer[0] = 'b';
buffer[1] = 'c';
ok( WriteFile( hWriter2, buffer, 2, &count, NULL), "2nd write failed\n");
/* check the mailslot info */
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
ok( dwNext == 1, "dwNext incorrect\n");
ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
/* write a 3rd message with zero size */
ok( WriteFile( hWriter2, buffer, 0, &count, NULL), "3rd write failed\n");
/* check the mailslot info */
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
ok( dwNext == 1, "dwNext incorrect\n");
ok( dwMsgCount == 3, "dwMsgCount incorrect\n");
buffer[0]=buffer[1]=0;
/*
* then check that they come out with the correct order and size,
* then the slot is empty
*/
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"1st slot read failed\n");
ok( count == 1, "failed to get 1st message\n");
ok( buffer[0] == 'a', "1st message wrong\n");
/* check the mailslot info */
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
ok( dwNext == 2, "dwNext incorrect\n");
ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
/* read the second message */
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"2nd slot read failed\n");
ok( count == 2, "failed to get 2nd message\n");
ok( ( buffer[0] == 'b' ) && ( buffer[1] == 'c' ), "2nd message wrong\n");
/* check the mailslot info */
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
}
ok( dwNext == 0, "dwNext incorrect\n");
todo_wine
{
ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
/* read the 3rd (zero length) message */
ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"3rd slot read failed\n");
}
ok( count == 0, "failed to get 3rd message\n");
/*
* now there should be no more messages
* check the mailslot info
*/
todo_wine
{
dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n");
ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
}
ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
/* check that reads fail */
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
"3rd slot read succeeded\n");
/* finally close the mailslot and its client */
todo_wine
{
ok( CloseHandle( hWriter2 ), "closing 2nd client\n");
ok( CloseHandle( hWriter ), "closing the client\n");
ok( CloseHandle( hSlot ), "closing the mailslot\n");
}
return 0;
}
START_TEST(mailslot)
{
mailslot_test();
}

View File

@@ -1,924 +0,0 @@
/*
* Unit test suite for Get*PathNamesA and (Get|Set)CurrentDirectoryA.
*
* Copyright 2002 Geoffrey Hausheer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "winnls.h"
#define HAS_TRAIL_SLASH_A(string) (string[lstrlenA(string)-1]=='\\')
#define LONGFILE "Long File test.path"
#define SHORTFILE "pathtest.pth"
#define SHORTDIR "shortdir"
#define LONGDIR "Long Directory"
#define NONFILE_SHORT "noexist.pth"
#define NONFILE_LONG "Non Existent File"
#define NONDIR_SHORT "notadir"
#define NONDIR_LONG "Non Existent Directory"
#define NOT_A_VALID_DRIVE '@'
/* the following characters don't work well with GetFullPathNameA
in Win98. I don't know if this is a FAT thing, or if it is an OS thing
but I don't test these characters now.
NOTE: Win2k allows GetFullPathNameA to work with them though
|<>"
*/
static const CHAR funny_chars[]="!@#$%^&*()=+{}[],?'`";
static const CHAR is_char_ok[] ="11111110111111111011";
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR,LPSTR,DWORD);
/* a structure to deal with wine todos somewhat cleanly */
typedef struct {
DWORD shortlen;
DWORD shorterror;
DWORD s2llen;
DWORD s2lerror;
DWORD longlen;
DWORD longerror;
} SLpassfail;
/* function that tests GetFullPathNameA, GetShortPathNameA,GetLongPathNameA */
/* NOTE: the passfail structure is used to allow cutomizeable todo checking
for wine. It is not very pretty, but it sure beats duplicating this
function lots of times
*/
static void test_ValidPathA(CHAR *curdir, CHAR *subdir, CHAR *filename,
CHAR *shortstr, SLpassfail *passfail, CHAR *errstr) {
CHAR tmpstr[MAX_PATH],
fullpath[MAX_PATH], /*full path to the file (not short/long) */
subpath[MAX_PATH], /*relative path to the file */
fullpathshort[MAX_PATH], /*absolue path to the file (short format) */
fullpathlong[MAX_PATH], /*absolute path to the file (long format) */
curdirshort[MAX_PATH], /*absolute path to the current dir (short) */
curdirlong[MAX_PATH]; /*absolute path to the current dir (long) */
LPSTR strptr; /*ptr to the filename portion of the path */
DWORD len;
/* if passfail is NULL, we can perform all checks within this function,
otherwise, we will return the relevant data in the passfail struct, so
we must initialize it first
*/
if(passfail!=NULL) {
passfail->shortlen=-1;passfail->s2llen=-1;passfail->longlen=-1;
passfail->shorterror=0;passfail->s2lerror=0;passfail->longerror=0;
}
/* GetLongPathNameA is only supported on Win2k+ and Win98+ */
if(pGetLongPathNameA) {
ok((len=pGetLongPathNameA(curdir,curdirlong,MAX_PATH)),
"%s: GetLongPathNameA failed\n",errstr);
/*GetLongPathNameA can return a trailing '\\' but shouldn't do so here */
ok(! HAS_TRAIL_SLASH_A(curdirlong),
"%s: GetLongPathNameA should not have a trailing \\\n",errstr);
}
ok((len=GetShortPathNameA(curdir,curdirshort,MAX_PATH)),
"%s: GetShortPathNameA failed\n",errstr);
/*GetShortPathNameA can return a trailing '\\' but shouldn't do so here */
ok(! HAS_TRAIL_SLASH_A(curdirshort),
"%s: GetShortPathNameA should not have a trailing \\\n",errstr);
/* build relative and absolute paths from inputs */
if(lstrlenA(subdir)) {
sprintf(subpath,"%s\\%s",subdir,filename);
} else {
lstrcpyA(subpath,filename);
}
sprintf(fullpath,"%s\\%s",curdir,subpath);
sprintf(fullpathshort,"%s\\%s",curdirshort,subpath);
sprintf(fullpathlong,"%s\\%s",curdirlong,subpath);
/* Test GetFullPathNameA functionality */
len=GetFullPathNameA(subpath,MAX_PATH,tmpstr,&strptr);
ok(len, "GetFullPathNameA failed for: '%s'\n",subpath);
if(HAS_TRAIL_SLASH_A(subpath)) {
ok(strptr==NULL,
"%s: GetFullPathNameA should not return a filename ptr\n",errstr);
ok(lstrcmpiA(fullpath,tmpstr)==0,
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
errstr,tmpstr,fullpath);
} else {
ok(lstrcmpiA(strptr,filename)==0,
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
errstr,strptr,filename);
ok(lstrcmpiA(fullpath,tmpstr)==0,
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
errstr,tmpstr,fullpath);
}
/* Test GetShortPathNameA functionality */
SetLastError(0);
len=GetShortPathNameA(fullpathshort,shortstr,MAX_PATH);
if(passfail==NULL) {
ok(len, "%s: GetShortPathNameA failed\n",errstr);
} else {
passfail->shortlen=len;
passfail->shorterror=GetLastError();
}
/* Test GetLongPathNameA functionality
We test both conversion from GetFullPathNameA and from GetShortPathNameA
*/
if(pGetLongPathNameA) {
if(len!=0) {
SetLastError(0);
len=pGetLongPathNameA(shortstr,tmpstr,MAX_PATH);
if(passfail==NULL) {
ok(len,
"%s: GetLongPathNameA failed during Short->Long conversion\n", errstr);
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
errstr,tmpstr,fullpathlong);
} else {
passfail->s2llen=len;
passfail->s2lerror=GetLastError();
}
}
SetLastError(0);
len=pGetLongPathNameA(fullpath,tmpstr,MAX_PATH);
if(passfail==NULL) {
ok(len, "%s: GetLongPathNameA failed\n",errstr);
if(HAS_TRAIL_SLASH_A(fullpath)) {
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
errstr,tmpstr,fullpathlong);
} else {
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
errstr,tmpstr,fullpathlong);
}
} else {
passfail->longlen=len;
passfail->longerror=GetLastError();
}
}
}
/* split path into leading directory, and 8.3 filename */
static void test_SplitShortPathA(CHAR *path,CHAR *dir,CHAR *eight,CHAR *three) {
int done,error;
int ext,fil;
int len,i;
len=lstrlenA(path);
ext=len; fil=len; done=0; error=0;
/* walk backwards over path looking for '.' or '\\' separators */
for(i=len-1;(i>=0) && (!done);i--) {
if(path[i]=='.')
if(ext!=len) error=1; else ext=i;
else if(path[i]=='\\') {
if(i==len-1) {
error=1;
} else {
fil=i;
done=1;
}
}
}
/* Check that we didn't find a trailing '\\' or multiple '.' */
ok(!error,"Illegal file found in 8.3 path '%s'\n",path);
/* Separate dir, root, and extension */
if(ext!=len) lstrcpyA(three,path+ext+1); else lstrcpyA(three,"");
if(fil!=len) {
lstrcpynA(eight,path+fil+1,ext-fil);
lstrcpynA(dir,path,fil+1);
} else {
lstrcpynA(eight,path,ext+1);
lstrcpyA(dir,"");
}
/* Validate that root and extension really are 8.3 */
ok(lstrlenA(eight)<=8 && lstrlenA(three)<=3,
"GetShortPathNAmeA did not return an 8.3 path\n");
}
/* Check that GetShortPathNameA returns a valid 8.3 path */
static void test_LongtoShortA(CHAR *teststr,CHAR *goodstr,
CHAR *ext,CHAR *errstr) {
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
test_SplitShortPathA(teststr,dir,eight,three);
ok(lstrcmpiA(dir,goodstr)==0,
"GetShortPathNameA returned '%s' instead of '%s'\n",dir,goodstr);
ok(lstrcmpiA(three,ext)==0,
"GetShortPathNameA returned '%s' with incorrect extension\n",three);
}
/* Test that Get(Short|Long|Full)PathNameA work correctly with interesting
characters in the filename.
'valid' indicates whether this would be an allowed filename
'todo' indicates that wine doesn't get this right yet.
NOTE: We always call this routine with a non-existent filename, so
Get(Short|Long)PathNameA should never pass, but GetFullPathNameA
should.
*/
static void test_FunnyChars(CHAR *curdir,CHAR *filename, INT valid,CHAR *errstr)
{
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
SLpassfail passfail;
test_ValidPathA(curdir,"",filename,tmpstr,&passfail,errstr);
if(valid) {
sprintf(tmpstr1,"%s\\%s",curdir,filename);
ok((passfail.shortlen==0 &&
(passfail.shorterror==ERROR_FILE_NOT_FOUND || passfail.shorterror==ERROR_PATH_NOT_FOUND || !passfail.shorterror)) ||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
"%s: GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
errstr,passfail.shortlen,passfail.shorterror,tmpstr);
} else {
ok(passfail.shortlen==0 &&
(passfail.shorterror==ERROR_INVALID_NAME || passfail.shorterror==ERROR_FILE_NOT_FOUND || !passfail.shorterror),
"%s: GetShortPathA should have failed len=%ld, error=%ld\n",
errstr,passfail.shortlen,passfail.shorterror);
}
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
if(valid) {
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"%s: GetLongPathA returned %ld and not %d\n",
errstr,passfail.longerror,ERROR_FILE_NOT_FOUND);
} else {
ok(passfail.longerror==ERROR_INVALID_NAME ||
passfail.longerror==ERROR_FILE_NOT_FOUND,
"%s: GetLongPathA returned %ld and not %d or %d'\n",
errstr, passfail.longerror,ERROR_INVALID_NAME,ERROR_FILE_NOT_FOUND);
}
}
}
/* Routine to test that SetCurrentDirectory behaves as expected. */
static void test_setdir(CHAR *olddir,CHAR *newdir,
CHAR *cmprstr, INT pass,CHAR *errstr)
{
CHAR tmppath[MAX_PATH], *dirptr;
DWORD val,len,chklen;
val=SetCurrentDirectoryA(newdir);
len=GetCurrentDirectoryA(MAX_PATH,tmppath);
/* if 'pass' then the SetDirectoryA was supposed to pass */
if(pass) {
dirptr=(cmprstr==NULL) ? newdir : cmprstr;
chklen=lstrlenA(dirptr);
ok(val,"%s: SetCurrentDirectoryA failed\n",errstr);
ok(len==chklen,
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
errstr);
ok(lstrcmpiA(dirptr,tmppath)==0,
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
errstr);
ok(SetCurrentDirectoryA(olddir),
"%s: Couldn't set directory to it's original value\n",errstr);
} else {
/* else thest that it fails correctly */
chklen=lstrlenA(olddir);
ok(val==0,
"%s: SetCurrentDirectoryA passed when it should have failed\n",errstr);
ok(len==chklen,
"%s: SetCurrentDirectory changed the directory, though it failed\n",
errstr);
ok(lstrcmpiA(olddir,tmppath)==0,
"%s: SetCurrentDirectory changed the directory, though it failed\n",
errstr);
}
}
static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
{
CHAR tmppath[MAX_PATH], /*path to TEMP */
tmpstr[MAX_PATH],
tmpstr1[MAX_PATH];
DWORD len,len1,drives;
INT id;
HANDLE hndl;
*curDrive = *otherDrive = NOT_A_VALID_DRIVE;
/* Get the current drive letter */
if( GetCurrentDirectoryA( MAX_PATH, tmpstr))
*curDrive = tmpstr[0];
else
trace( "Unable to discover current drive, some tests will not be conducted.\n");
/* Test GetTempPathA */
len=GetTempPathA(MAX_PATH,tmppath);
ok(len!=0 && len < MAX_PATH,"GetTempPathA failed\n");
ok(HAS_TRAIL_SLASH_A(tmppath),
"GetTempPathA returned a path that did not end in '\\'\n");
lstrcpyA(tmpstr,"aaaaaaaa");
len1=GetTempPathA(len,tmpstr);
ok(len1==len+1,
"GetTempPathA should return string length %ld instead of %ld\n",len+1,len1);
/* Test GetTmpFileNameA
The only test we do here is whether GetTempFileNameA passes or not.
We do not thoroughly test this function yet (specifically, whether
it behaves correctly when 'unique' is non zero)
*/
ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
sprintf(tmpstr,"pat%.4x.tmp",id & 0xffff);
sprintf(tmpstr1,"pat%x.tmp",id & 0xffff);
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
"GetTempPath returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
newdir,tmpstr,tmpstr1,id);
/* Find first valid drive letter that is neither newdir[0] nor curDrive */
drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A'));
if( *curDrive != NOT_A_VALID_DRIVE)
drives &= ~(1<<(*curDrive-'A'));
if( drives)
for( *otherDrive='A'; (drives & 1) == 0; drives>>=1, (*otherDrive)++);
else
trace( "Could not find alternative drive, some tests will not be conducted.\n");
/* Do some CreateDirectoryA tests */
/* It would be nice to do test the SECURITY_ATTRIBUTES, but I don't
really understand how they work.
More formal tests should be done along with CreateFile tests
*/
ok(CreateDirectoryA(newdir,NULL)==0,
"CreateDirectoryA succeeded even though a file of the same name exists\n");
ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
ok(CreateDirectoryA(newdir,NULL),"CreateDirectoryA failed\n");
/* Create some files to test other functions. Note, we will test CreateFileA
at some later point
*/
sprintf(tmpstr,"%s\\%s",newdir,SHORTDIR);
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,SHORTFILE);
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
ok(CloseHandle(hndl),"CloseHandle failed\n");
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,LONGFILE);
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
ok(CloseHandle(hndl),"CloseHandle failed\n");
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,SHORTFILE);
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
ok(CloseHandle(hndl),"CloseHandle failed\n");
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,LONGFILE);
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
ok(CloseHandle(hndl),"CloseHandle failed\n");
}
/* Test GetCurrentDirectory & SetCurrentDirectory */
static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
{
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
DWORD len,len1;
/* Save the original directory, so that we can return to it at the end
of the test
*/
len=GetCurrentDirectoryA(MAX_PATH,origdir);
ok(len!=0 && len < MAX_PATH,"GetCurrentDirectoryA failed\n");
ok(lstrcmpiA(origdir+(len-1),"\\")!=0,
"GetCurrentDirectoryA should not have a trailing \\\n");
/* Make sure that CetCurrentDirectoryA doesn't overwrite the buffer when the
buffer size is too small to hold the current directory
*/
lstrcpyA(tmpstr,"aaaaaaa");
len1=GetCurrentDirectoryA(len,tmpstr);
ok(len1==len+1, "GetCurrentDirectoryA returned %ld instead of %ld\n",len1,len+1);
ok(lstrcmpiA(tmpstr,"aaaaaaa")==0,
"GetCurrentDirectoryA should not have modified the buffer\n");
/* SetCurrentDirectoryA shouldn't care whether the string has a
trailing '\\' or not
*/
sprintf(tmpstr,"%s\\",newdir);
test_setdir(origdir,tmpstr,newdir,1,"check 1");
test_setdir(origdir,newdir,NULL,1,"check 2");
/* Set the directory to the working area. We just tested that this works,
so why check it again.
*/
SetCurrentDirectoryA(newdir);
/* Check that SetCurrentDirectory fails when a non-existent dir is specified */
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_SHORT);
test_setdir(newdir,tmpstr,NULL,0,"check 3");
/* Check that SetCurrentDirectory fails for a non-existent lond directory */
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_LONG);
test_setdir(newdir,tmpstr,NULL,0,"check 4");
/* Check that SetCurrentDirectory passes with a long directory */
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
test_setdir(newdir,tmpstr,NULL,1,"check 5");
/* Check that SetCurrentDirectory passes with a short relative directory */
sprintf(tmpstr,"%s",SHORTDIR);
sprintf(tmpstr1,"%s\\%s",newdir,SHORTDIR);
test_setdir(newdir,tmpstr,tmpstr1,1,"check 6");
/* starting with a '.' */
sprintf(tmpstr,".\\%s",SHORTDIR);
test_setdir(newdir,tmpstr,tmpstr1,1,"check 7");
/* Check that SetCurrentDirectory passes with a short relative directory */
sprintf(tmpstr,"%s",LONGDIR);
sprintf(tmpstr1,"%s\\%s",newdir,LONGDIR);
test_setdir(newdir,tmpstr,tmpstr1,1,"check 8");
/* starting with a '.' */
sprintf(tmpstr,".\\%s",LONGDIR);
test_setdir(newdir,tmpstr,tmpstr1,1,"check 9");
}
/* Cleanup the mess we made while executing these tests */
static void test_CleanupPathA(CHAR *origdir, CHAR *curdir)
{
CHAR tmpstr[MAX_PATH];
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,LONGFILE);
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,SHORTFILE);
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
sprintf(tmpstr,"%s\\%s",curdir,SHORTDIR);
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
sprintf(tmpstr,"%s\\%s",curdir,LONGDIR);
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
ok(SetCurrentDirectoryA(origdir),"SetCurrentDirectoryA failed\n");
ok(RemoveDirectoryA(curdir),"RemoveDirectoryA failed\n");
}
/* This routine will test Get(Full|Short|Long)PathNameA */
static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
{
CHAR curdir_short[MAX_PATH],
longdir_short[MAX_PATH];
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH],tmpstr2[MAX_PATH];
LPSTR strptr; /*ptr to the filename portion of the path */
DWORD len;
INT i;
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
SLpassfail passfail;
/* Get the short form of the current directory */
ok((len=GetShortPathNameA(curdir,curdir_short,MAX_PATH)),
"GetShortPathNameA failed\n");
ok(!HAS_TRAIL_SLASH_A(curdir_short),
"GetShortPathNameA should not have a trailing \\\n");
/* Get the short form of the absolute-path to LONGDIR */
sprintf(tmpstr,"%s\\%s",curdir_short,LONGDIR);
ok((len=GetShortPathNameA(tmpstr,longdir_short,MAX_PATH)),
"GetShortPathNameA failed\n");
ok(lstrcmpiA(longdir_short+(len-1),"\\")!=0,
"GetShortPathNameA should not have a trailing \\\n");
if (pGetLongPathNameA) {
DWORD rc1,rc2;
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
rc1=(*pGetLongPathNameA)(tmpstr,NULL,0);
rc2=(*pGetLongPathNameA)(curdir,NULL,0);
ok((rc1-strlen(tmpstr))==(rc2-strlen(curdir)),
"GetLongPathNameA: wrong return code, %ld instead of %d\n",
rc1, strlen(tmpstr)+1);
sprintf(dir,"%c:",curDrive);
rc1=(*pGetLongPathNameA)(dir,tmpstr,sizeof(tmpstr));
ok(strcmp(dir,tmpstr)==0,
"GetLongPathNameA: returned '%s' instead of '%s' (rc=%ld)\n",
tmpstr,dir,rc1);
}
/* Check the cases where both file and directory exist first */
/* Start with a 8.3 directory, 8.3 filename */
test_ValidPathA(curdir,SHORTDIR,SHORTFILE,tmpstr,NULL,"test1");
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
/* Now try a 8.3 directory, long file name */
test_ValidPathA(curdir,SHORTDIR,LONGFILE,tmpstr,NULL,"test2");
sprintf(tmpstr1,"%s\\%s",curdir_short,SHORTDIR);
test_LongtoShortA(tmpstr,tmpstr1,"PAT","test2");
/* Next is a long directory, 8.3 file */
test_ValidPathA(curdir,LONGDIR,SHORTFILE,tmpstr,NULL,"test3");
sprintf(tmpstr1,"%s\\%s",longdir_short,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
/*Lastly a long directory, long file */
test_ValidPathA(curdir,LONGDIR,LONGFILE,tmpstr,NULL,"test4");
test_LongtoShortA(tmpstr,longdir_short,"PAT","test4");
/* Now check all of the invalid file w/ valid directory combinations */
/* Start with a 8.3 directory, 8.3 filename */
test_ValidPathA(curdir,SHORTDIR,NONFILE_SHORT,tmpstr,&passfail,"test5");
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,NONFILE_SHORT);
ok((passfail.shortlen==0 &&
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
passfail.shortlen,passfail.shorterror,tmpstr);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
}
/* Now try a 8.3 directory, long file name */
test_ValidPathA(curdir,SHORTDIR,NONFILE_LONG,tmpstr,&passfail,"test6");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
}
/* Next is a long directory, 8.3 file */
test_ValidPathA(curdir,LONGDIR,NONFILE_SHORT,tmpstr,&passfail,"test7");
sprintf(tmpstr2,"%s\\%s",curdir_short,LONGDIR);
GetShortPathNameA(tmpstr2,tmpstr1,MAX_PATH);
strcat(tmpstr1,"\\" NONFILE_SHORT);
ok((passfail.shortlen==0 &&
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
passfail.shortlen,passfail.shorterror,tmpstr);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
}
/*Lastly a long directory, long file */
test_ValidPathA(curdir,LONGDIR,NONFILE_LONG,tmpstr,&passfail,"test8");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
}
/* Now try again with directories that don't exist */
/* 8.3 directory, 8.3 filename */
test_ValidPathA(curdir,NONDIR_SHORT,SHORTFILE,tmpstr,&passfail,"test9");
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,NONDIR_SHORT,SHORTFILE);
ok((passfail.shortlen==0 &&
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
passfail.shortlen,passfail.shorterror,tmpstr);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.longerror);
}
/* Now try a 8.3 directory, long file name */
test_ValidPathA(curdir,NONDIR_SHORT,LONGFILE,tmpstr,&passfail,"test10");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.shorterror);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.longerror);
}
/* Next is a long directory, 8.3 file */
test_ValidPathA(curdir,NONDIR_LONG,SHORTFILE,tmpstr,&passfail,"test11");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.shorterror);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.longerror);
}
/*Lastly a long directory, long file */
test_ValidPathA(curdir,NONDIR_LONG,LONGFILE,tmpstr,&passfail,"test12");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.shorterror);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
passfail.longerror);
}
/* Next try directories ending with '\\' */
/* Existing Directories */
sprintf(tmpstr,"%s\\",SHORTDIR);
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test13");
sprintf(tmpstr,"%s\\",LONGDIR);
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test14");
/* Non-existent directories */
sprintf(tmpstr,"%s\\",NONDIR_SHORT);
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test15");
sprintf(tmpstr2,"%s\\%s",curdir,tmpstr);
ok((passfail.shortlen==0 &&
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
(passfail.shortlen==strlen(tmpstr2) && lstrcmpiA(tmpstr1,tmpstr2)==0),
"GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
passfail.shortlen,passfail.shorterror,tmpstr);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
passfail.longerror);
}
sprintf(tmpstr,"%s\\",NONDIR_LONG);
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test16");
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
!passfail.shorterror,
"GetShortPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
passfail.shorterror);
if(pGetLongPathNameA) {
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
"GetLongPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
passfail.longerror);
}
/* Test GetFullPathNameA with drive letters */
if( curDrive != NOT_A_VALID_DRIVE) {
sprintf(tmpstr,"%c:",curdir[0]);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr2,&strptr),
"GetFullPathNameA(%c:) failed\n", curdir[0]);
GetCurrentDirectoryA(MAX_PATH,tmpstr);
sprintf(tmpstr1,"%s\\",tmpstr);
ok(lstrcmpiA(tmpstr,tmpstr2)==0 || lstrcmpiA(tmpstr1,tmpstr2)==0,
"GetFullPathNameA(%c:) returned '%s' instead of '%s' or '%s'\n",
curdir[0],tmpstr2,tmpstr,tmpstr1);
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
}
/* Without a leading slash, insert the current directory if on the current drive */
sprintf(tmpstr,"%c:%s\\%s",curdir[0],SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
/* Otherwise insert the missing leading slash */
if( otherDrive != NOT_A_VALID_DRIVE) {
sprintf(tmpstr,"%c:%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed for %s\n", tmpstr);
sprintf(tmpstr,"%c:\\%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
}
/* Xilinx tools like to mix Unix and DOS formats, which Windows handles fine.
So test for them. */
if( curDrive != NOT_A_VALID_DRIVE) {
sprintf(tmpstr,"%c:/%s\\%s",curDrive,SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
}
/**/
sprintf(tmpstr,"%c:%s/%s",curdir[0],SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
/* Windows will insert a drive letter in front of an absolute UNIX path, but
Wine probably shouldn't. */
sprintf(tmpstr,"/%s/%s",SHORTDIR,SHORTFILE);
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
todo_wine {
if( curDrive != NOT_A_VALID_DRIVE) {
sprintf(tmpstr,"C:\\%s\\%s",SHORTDIR,SHORTFILE);
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
}
}
/* This passes in Wine because it still contains the pointer from the previous test */
ok(lstrcmpiA(SHORTFILE,strptr)==0,
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
/* Now try some relative paths */
ok(GetShortPathNameA(LONGDIR,tmpstr,MAX_PATH),"GetShortPathNameA failed\n");
test_SplitShortPathA(tmpstr,dir,eight,three);
if(pGetLongPathNameA) {
ok(pGetLongPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetLongPathNameA failed\n");
ok(lstrcmpiA(tmpstr1,LONGDIR)==0,
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,LONGDIR);
}
sprintf(tmpstr,".\\%s",LONGDIR);
ok(GetShortPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetShortPathNameA failed\n");
test_SplitShortPathA(tmpstr1,dir,eight,three);
ok(lstrcmpiA(dir,".")==0 || dir[0]=='\0',
"GetShortPathNameA did not keep relative directory [%s]\n",tmpstr1);
if(pGetLongPathNameA) {
ok(pGetLongPathNameA(tmpstr1,tmpstr1,MAX_PATH),"GetLongPathNameA failed %s\n",
tmpstr);
ok(lstrcmpiA(tmpstr1,tmpstr)==0,
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
}
/* Check out Get*PathNameA on some funny characters */
for(i=0;i<lstrlenA(funny_chars);i++) {
INT valid;
valid=(is_char_ok[i]=='0') ? 0 : 1;
sprintf(tmpstr1,"check%d-1",i);
sprintf(tmpstr,"file%c000.ext",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-2",i);
sprintf(tmpstr,"file000.e%ct",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-3",i);
sprintf(tmpstr,"%cfile000.ext",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-4",i);
sprintf(tmpstr,"file000%c.ext",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-5",i);
sprintf(tmpstr,"Long %c File",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-6",i);
sprintf(tmpstr,"%c Long File",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
sprintf(tmpstr1,"check%d-7",i);
sprintf(tmpstr,"Long File %c",funny_chars[i]);
test_FunnyChars(curdir,tmpstr,valid,tmpstr1);
}
}
static void test_GetTempPathA(char* tmp_dir)
{
DWORD len, len_with_null;
char buf[MAX_PATH];
len_with_null = strlen(tmp_dir) + 1;
lstrcpyA(buf, "foo");
len = GetTempPathA(MAX_PATH, buf);
ok(len <= MAX_PATH, "should fit into MAX_PATH\n");
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
/* Some versions of Windows touch the buffer, some don't so we don't
* test that. Also, NT sometimes exagerates the required buffer size
* so we cannot test for an exact match. Finally, the
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
* For instance in some cases Win98 returns len_with_null - 1 instead
* of len_with_null.
*/
len = GetTempPathA(1, buf);
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
len = GetTempPathA(0, NULL);
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
/* The call above gave us the buffer size that Windows thinks is needed
* so the next call should work
*/
lstrcpyA(buf, "foo");
len = GetTempPathA(len, buf);
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
}
static void test_GetTempPathW(char* tmp_dir)
{
DWORD len, len_with_null;
WCHAR buf[MAX_PATH];
WCHAR tmp_dirW[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
MultiByteToWideChar(CP_ACP,0,tmp_dir,-1,tmp_dirW,sizeof(tmp_dirW)/sizeof(*tmp_dirW));
len_with_null = lstrlenW(tmp_dirW) + 1;
/* This one is different from ANSI version: ANSI version doesn't
* touch the buffer, unicode version usually truncates the buffer
* to zero size. NT still exagerates the required buffer size
* sometimes so we cannot test for an exact match. Finally, the
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
* For instance on NT4 it will sometimes return a path without the
* trailing '\\' and sometimes return an error.
*/
lstrcpyW(buf, fooW);
len = GetTempPathW(MAX_PATH, buf);
if (len==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
lstrcpyW(buf, fooW);
len = GetTempPathW(1, buf);
ok(buf[0] == 0, "unicode version should truncate the buffer to zero size\n");
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
len = GetTempPathW(0, NULL);
ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
lstrcpyW(buf, fooW);
len = GetTempPathW(len, buf);
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
}
static void test_GetTempPath(void)
{
char save_TMP[MAX_PATH];
char windir[MAX_PATH];
char buf[MAX_PATH];
GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP));
/* test default configuration */
trace("TMP=%s\n", save_TMP);
strcpy(buf,save_TMP);
if (buf[strlen(buf)-1]!='\\')
strcat(buf,"\\");
test_GetTempPathA(buf);
test_GetTempPathW(buf);
/* TMP=C:\WINDOWS */
GetWindowsDirectoryA(windir, sizeof(windir));
SetEnvironmentVariableA("TMP", windir);
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
trace("TMP=%s\n", buf);
strcat(windir,"\\");
test_GetTempPathA(windir);
test_GetTempPathW(windir);
/* TMP=C:\ */
GetWindowsDirectoryA(windir, sizeof(windir));
windir[3] = 0;
SetEnvironmentVariableA("TMP", windir);
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
trace("TMP=%s\n", buf);
test_GetTempPathA(windir);
test_GetTempPathW(windir);
/* TMP=C: i.e. use current working directory of the specified drive */
GetWindowsDirectoryA(windir, sizeof(windir));
SetCurrentDirectoryA(windir);
windir[2] = 0;
SetEnvironmentVariableA("TMP", windir);
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
trace("TMP=%s\n", buf);
GetWindowsDirectoryA(windir, sizeof(windir));
strcat(windir,"\\");
test_GetTempPathA(windir);
test_GetTempPathW(windir);
SetEnvironmentVariableA("TMP", save_TMP);
}
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
pGetLongPathNameA = (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
"GetLongPathNameA" );
test_InitPathA(curdir, &curDrive, &otherDrive);
test_CurrentDirectoryA(origdir,curdir);
test_PathNameA(curdir, curDrive, otherDrive);
test_CleanupPathA(origdir,curdir);
test_GetTempPath();
}

View File

@@ -1,763 +0,0 @@
/*
* Unit tests for named pipe functions in Wine
*
* Copyright (c) 2002 Dan Kegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <windef.h>
#include <winbase.h>
#include <winsock.h>
#ifndef STANDALONE
#include "wine/test.h"
#else
#include <assert.h>
#define START_TEST(name) main(int argc, char **argv)
#define ok(condition, msg) \
do { \
if(!(condition)) \
{ \
fprintf(stderr,"failed at %d\n",__LINE__); \
exit(0); \
} \
} while(0)
#define todo_wine
#endif
#include <wtypes.h>
#include <winerror.h>
#define PIPENAME "\\\\.\\PiPe\\tests_" __FILE__
#define NB_SERVER_LOOPS 8
static HANDLE alarm_event;
static void test_CreateNamedPipe(pipemode)
{
HANDLE hnp;
HANDLE hFile;
static const char obuf[] = "Bit Bucket";
static const char obuf2[] = "More bits";
char ibuf[32], *pbuf;
DWORD written;
DWORD readden;
DWORD avail;
DWORD lpmode;
if (pipemode == PIPE_TYPE_BYTE)
trace("test_CreateNamedPipe starting in byte mode\n");
else
trace("test_CreateNamedPipe starting in message mode\n");
/* Bad parameter checks */
hnp = CreateNamedPipe("not a named pipe", PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
if (hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
/* Is this the right way to notify user of skipped tests? */
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
"CreateNamedPipe not supported on this platform, skipping tests.\n");
return;
}
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_NAME,
"CreateNamedPipe should fail if name doesn't start with \\\\.\\pipe\n");
hnp = CreateNamedPipe(NULL,
PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
"CreateNamedPipe should fail if name is NULL\n");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_FILE_NOT_FOUND,
"connecting to nonexistent named pipe should fail with ERROR_FILE_NOT_FOUND\n");
/* Functional checks */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed\n");
/* don't try to do i/o if one side couldn't be opened, as it hangs */
if (hFile != INVALID_HANDLE_VALUE) {
HANDLE hFile2;
/* Make sure we can read and write a few bytes in both directions */
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
ok(written == sizeof(obuf), "write file len 1\n");
ok(PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL), "Peek\n");
ok(readden == sizeof(obuf), "peek 1 got %ld bytes\n", readden);
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
ok(readden == sizeof(obuf), "read 1 got %ld bytes\n", readden);
ok(memcmp(obuf, ibuf, written) == 0, "content 1 check\n");
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
ok(written == sizeof(obuf2), "write file len 2\n");
ok(PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL), "Peek\n");
ok(readden == sizeof(obuf2), "peek 2 got %ld bytes\n", readden);
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
ok(readden == sizeof(obuf2), "read 2 got %ld bytes\n", readden);
ok(memcmp(obuf2, ibuf, written) == 0, "content 2 check\n");
/* Test reading of multiple writes */
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile3a\n");
ok(written == sizeof(obuf), "write file len 3a\n");
ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile3b\n");
ok(written == sizeof(obuf2), "write file len 3b\n");
ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek3\n");
if (pipemode == PIPE_TYPE_BYTE) {
todo_wine {
/* should return all 23 bytes */
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes\n", readden);
}
}
else
ok(readden == sizeof(obuf), "peek3 got %ld bytes\n", readden);
todo_wine {
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes available\n", avail);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 3a check\n");
if (pipemode == PIPE_TYPE_BYTE) {
todo_wine {
pbuf += sizeof(obuf);
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 3b check\n");
}
}
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
ok(readden == sizeof(obuf) + sizeof(obuf2), "read 3 got %ld bytes\n", readden);
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 3a check\n");
pbuf += sizeof(obuf);
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 3b check\n");
/* Multiple writes in the reverse direction */
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile4a\n");
ok(written == sizeof(obuf), "write file len 4a\n");
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile4b\n");
ok(written == sizeof(obuf2), "write file len 4b\n");
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek4\n");
if (pipemode == PIPE_TYPE_BYTE) {
todo_wine {
/* should return all 23 bytes */
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes\n", readden);
}
}
else
ok(readden == sizeof(obuf), "peek4 got %ld bytes\n", readden);
todo_wine {
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes available\n", avail);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 4a check\n");
if (pipemode == PIPE_TYPE_BYTE) {
todo_wine {
pbuf += sizeof(obuf);
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 4b check\n");
}
}
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
if (pipemode == PIPE_TYPE_BYTE) {
ok(readden == sizeof(obuf) + sizeof(obuf2), "read 4 got %ld bytes\n", readden);
}
else {
todo_wine {
ok(readden == sizeof(obuf), "read 4 got %ld bytes\n", readden);
}
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 4a check\n");
if (pipemode == PIPE_TYPE_BYTE) {
pbuf += sizeof(obuf);
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 4b check\n");
}
/* Test reading of multiple writes after a mode change
(CreateFile always creates a byte mode pipe) */
lpmode = PIPE_READMODE_MESSAGE;
if (pipemode == PIPE_TYPE_BYTE) {
/* trying to change the client end of a byte pipe to message mode should fail */
ok(!SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
}
else {
todo_wine {
ok(SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
}
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile5a\n");
ok(written == sizeof(obuf), "write file len 3a\n");
ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile5b\n");
ok(written == sizeof(obuf2), "write file len 3b\n");
ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek5\n");
ok(readden == sizeof(obuf), "peek5 got %ld bytes\n", readden);
todo_wine {
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek5 got %ld bytes available\n", avail);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
todo_wine {
ok(readden == sizeof(obuf), "read 5 got %ld bytes\n", readden);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
/* Multiple writes in the reverse direction */
/* the write of obuf2 from write4 should still be in the buffer */
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6a\n");
todo_wine {
ok(readden == sizeof(obuf2), "peek6a got %ld bytes\n", readden);
ok(avail == sizeof(obuf2), "peek6a got %ld bytes available\n", avail);
}
if (avail > 0) {
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
ok(readden == sizeof(obuf2), "read 6a got %ld bytes\n", readden);
pbuf = ibuf;
ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 6a check\n");
}
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile6a\n");
ok(written == sizeof(obuf), "write file len 6a\n");
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile6b\n");
ok(written == sizeof(obuf2), "write file len 6b\n");
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6\n");
ok(readden == sizeof(obuf), "peek6 got %ld bytes\n", readden);
todo_wine {
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek6b got %ld bytes available\n", avail);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
todo_wine {
ok(readden == sizeof(obuf), "read 6b got %ld bytes\n", readden);
}
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
}
/* Picky conformance tests */
/* Verify that you can't connect to pipe again
* until server calls DisconnectNamedPipe+ConnectNamedPipe
* or creates a new pipe
* case 1: other client not yet closed
*/
hFile2 = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile2 == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe before other client closes should fail with ERROR_PIPE_BUSY\n");
ok(CloseHandle(hFile), "CloseHandle\n");
/* case 2: other client already closed */
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail with ERROR_PIPE_BUSY\n");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
/* case 3: server has called DisconnectNamedPipe but not ConnectNamed Pipe */
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail\n");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe after other client closes but before ConnectNamedPipe should fail with ERROR_PIPE_BUSY\n");
/* to be complete, we'd call ConnectNamedPipe here and loop,
* but by default that's blocking, so we'd either have
* to turn on the uncommon nonblocking mode, or
* use another thread.
*/
}
ok(CloseHandle(hnp), "CloseHandle\n");
trace("test_CreateNamedPipe returning\n");
}
void test_CreateNamedPipe_instances_must_match(void)
{
HANDLE hnp, hnp2;
/* Check no mismatch */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
ok(CloseHandle(hnp), "CloseHandle\n");
ok(CloseHandle(hnp2), "CloseHandle\n");
/* Check nMaxInstances */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_PIPE_BUSY, "nMaxInstances not obeyed\n");
ok(CloseHandle(hnp), "CloseHandle\n");
/* Check PIPE_ACCESS_* */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_ACCESS_DENIED, "PIPE_ACCESS_* mismatch allowed\n");
ok(CloseHandle(hnp), "CloseHandle\n");
/* etc, etc */
}
/** implementation of alarm() */
static DWORD CALLBACK alarmThreadMain(LPVOID arg)
{
DWORD timeout = (DWORD) arg;
trace("alarmThreadMain\n");
if (WaitForSingleObject( alarm_event, timeout ) == WAIT_TIMEOUT)
{
ok(FALSE, "alarm\n");
ExitProcess(1);
}
return 1;
}
HANDLE hnp = INVALID_HANDLE_VALUE;
/** Trivial byte echo server - disconnects after each session */
static DWORD CALLBACK serverThreadMain1(LPVOID arg)
{
int i;
trace("serverThreadMain1 start\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain1", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
for (i = 0; i < NB_SERVER_LOOPS; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD success;
/* Wait for client to connect */
trace("Server calling ConnectNamedPipe...\n");
ok(ConnectNamedPipe(hnp, NULL)
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
trace("ConnectNamedPipe returned.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
trace("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
trace("Server done reading.\n");
ok(success, "ReadFile\n");
ok(readden, "short read\n");
trace("Server writing...\n");
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
trace("Server done writing.\n");
ok(written == readden, "write file len\n");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
trace("Server done flushing.\n");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
trace("Server done disconnecting.\n");
}
return 0;
}
/** Trivial byte echo server - closes after each connection */
static DWORD CALLBACK serverThreadMain2(LPVOID arg)
{
int i;
HANDLE hnpNext = 0;
trace("serverThreadMain2\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
for (i = 0; i < NB_SERVER_LOOPS; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD success;
/* Wait for client to connect */
trace("Server calling ConnectNamedPipe...\n");
ok(ConnectNamedPipe(hnp, NULL)
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
trace("ConnectNamedPipe returned.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
trace("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
trace("Server done reading.\n");
ok(success, "ReadFile\n");
trace("Server writing...\n");
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
trace("Server done writing.\n");
ok(written == readden, "write file len\n");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
/* Set up next echo server */
hnpNext =
CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnpNext != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
ok(CloseHandle(hnp), "CloseHandle\n");
hnp = hnpNext;
}
return 0;
}
/** Trivial byte echo server - uses overlapped named pipe calls */
static DWORD CALLBACK serverThreadMain3(LPVOID arg)
{
int i;
HANDLE hEvent;
trace("serverThreadMain3\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain3", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hEvent = CreateEvent(NULL, /* security attribute */
TRUE, /* manual reset event */
FALSE, /* initial state */
NULL); /* name */
ok(hEvent != NULL, "CreateEvent\n");
for (i = 0; i < NB_SERVER_LOOPS; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD dummy;
DWORD success;
OVERLAPPED oOverlap;
int letWFSOEwait = (i & 2);
int letGORwait = (i & 1);
DWORD err;
memset(&oOverlap, 0, sizeof(oOverlap));
oOverlap.hEvent = hEvent;
/* Wait for client to connect */
trace("Server calling overlapped ConnectNamedPipe...\n");
success = ConnectNamedPipe(hnp, &oOverlap);
err = GetLastError();
ok(success || err == ERROR_IO_PENDING
|| err == ERROR_PIPE_CONNECTED, "overlapped ConnectNamedPipe\n");
trace("overlapped ConnectNamedPipe returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ConnectNamedPipe\n");
success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &dummy, TRUE);
}
ok(success, "GetOverlappedResult ConnectNamedPipe\n");
trace("overlapped ConnectNamedPipe operation complete.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
trace("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), NULL, &oOverlap);
trace("Server ReadFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile\n");
trace("overlapped ReadFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ReadFile\n");
success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE);
}
trace("Server done reading.\n");
ok(success, "overlapped ReadFile\n");
trace("Server writing...\n");
success = WriteFile(hnp, buf, readden, NULL, &oOverlap);
trace("Server WriteFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile\n");
trace("overlapped WriteFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait WriteFile\n");
success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE);
}
trace("Server done writing.\n");
ok(success, "overlapped WriteFile\n");
ok(written == readden, "write file len\n");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
}
return 0;
}
static void exercizeServer(const char *pipename, HANDLE serverThread)
{
int i;
trace("exercizeServer starting\n");
for (i = 0; i < NB_SERVER_LOOPS; i++) {
HANDLE hFile=INVALID_HANDLE_VALUE;
static const char obuf[] = "Bit Bucket";
char ibuf[32];
DWORD written;
DWORD readden;
int loop;
for (loop = 0; loop < 3; loop++) {
DWORD err;
trace("Client connecting...\n");
/* Connect to the server */
hFile = CreateFileA(pipename, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE)
break;
err = GetLastError();
if (loop == 0)
ok(err == ERROR_PIPE_BUSY || err == ERROR_FILE_NOT_FOUND, "connecting to pipe\n");
else
ok(err == ERROR_PIPE_BUSY, "connecting to pipe\n");
trace("connect failed, retrying\n");
Sleep(200);
}
ok(hFile != INVALID_HANDLE_VALUE, "client opening named pipe\n");
/* Make sure it can echo */
memset(ibuf, 0, sizeof(ibuf));
trace("Client writing...\n");
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile to client end of pipe\n");
ok(written == sizeof(obuf), "write file len\n");
trace("Client reading...\n");
ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile from client end of pipe\n");
ok(readden == sizeof(obuf), "read file len\n");
ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
trace("Client closing...\n");
ok(CloseHandle(hFile), "CloseHandle\n");
}
ok(WaitForSingleObject(serverThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n");
CloseHandle(hnp);
trace("exercizeServer returning\n");
}
static void test_NamedPipe_2(void)
{
HANDLE serverThread;
DWORD serverThreadId;
HANDLE alarmThread;
DWORD alarmThreadId;
trace("test_NamedPipe_2 starting\n");
/* Set up a ten second timeout */
alarm_event = CreateEvent( NULL, TRUE, FALSE, NULL );
alarmThread = CreateThread(NULL, 0, alarmThreadMain, (void *) 10000, 0, &alarmThreadId);
/* The servers we're about to exercize do try to clean up carefully,
* but to reduce the change of a test failure due to a pipe handle
* leak in the test code, we'll use a different pipe name for each server.
*/
/* Try server #1 */
serverThread = CreateThread(NULL, 0, serverThreadMain1, (void *)8, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain1", serverThread);
/* Try server #2 */
serverThread = CreateThread(NULL, 0, serverThreadMain2, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain2", serverThread);
if( 0 ) /* overlapped pipe server doesn't work yet - it randomly fails */
{
/* Try server #3 */
serverThread = CreateThread(NULL, 0, serverThreadMain3, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain3", serverThread);
}
ok(SetEvent( alarm_event ), "SetEvent\n");
CloseHandle( alarm_event );
trace("test_NamedPipe_2 returning\n");
}
static void test_DisconnectNamedPipe(void)
{
HANDLE hnp;
HANDLE hFile;
static const char obuf[] = "Bit Bucket";
char ibuf[32];
DWORD written;
DWORD readden;
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL) == 0
&& GetLastError() == ERROR_PIPE_LISTENING, "WriteFile to not-yet-connected pipe\n");
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
&& GetLastError() == ERROR_PIPE_LISTENING, "ReadFile from not-yet-connected pipe\n");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed\n");
/* don't try to do i/o if one side couldn't be opened, as it hangs */
if (hFile != INVALID_HANDLE_VALUE) {
/* see what happens if server calls DisconnectNamedPipe
* when there are bytes in the pipe
*/
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
ok(written == sizeof(obuf), "write file len\n");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe while messages waiting\n");
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL) == 0
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED, "WriteFile to disconnected pipe\n");
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED,
"ReadFile from disconnected pipe with bytes waiting\n");
ok(CloseHandle(hFile), "CloseHandle\n");
}
ok(CloseHandle(hnp), "CloseHandle\n");
}
START_TEST(pipe)
{
trace("test 1 of 4:\n");
test_DisconnectNamedPipe();
trace("test 2 of 4:\n");
test_CreateNamedPipe_instances_must_match();
trace("test 3 of 4:\n");
test_NamedPipe_2();
trace("test 4 of 4:\n");
test_CreateNamedPipe(PIPE_TYPE_BYTE);
trace("all tests done\n");
test_CreateNamedPipe(PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE);
trace("all tests done\n");
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +0,0 @@
/*
* Unit tests for profile functions
*
* Copyright (c) 2003 Stefan Leichter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "windows.h"
#define KEY "ProfileInt"
#define SECTION "Test"
#define TESTFILE ".\\testwine.ini"
struct _profileInt {
LPCSTR section;
LPCSTR key;
LPCSTR value;
LPCSTR iniFile;
INT defaultVal;
UINT result;
};
static void test_profile_int(void)
{
struct _profileInt profileInt[]={
{ NULL, NULL, NULL, NULL, 70, 0 }, /* 0 */
{ NULL, NULL, NULL, TESTFILE, -1, 4294967295U},
{ NULL, NULL, NULL, TESTFILE, 1, 1 },
{ SECTION, NULL, NULL, TESTFILE, -1, 4294967295U},
{ SECTION, NULL, NULL, TESTFILE, 1, 1 },
{ NULL, KEY, NULL, TESTFILE, -1, 4294967295U}, /* 5 */
{ NULL, KEY, NULL, TESTFILE, 1, 1 },
{ SECTION, KEY, NULL, TESTFILE, -1, 4294967295U},
{ SECTION, KEY, NULL, TESTFILE, 1, 1 },
{ SECTION, KEY, "-1", TESTFILE, -1, 4294967295U},
{ SECTION, KEY, "-1", TESTFILE, 1, 4294967295U}, /* 10 */
{ SECTION, KEY, "1", TESTFILE, -1, 1 },
{ SECTION, KEY, "1", TESTFILE, 1, 1 },
{ SECTION, KEY, "+1", TESTFILE, -1, 1 },
{ SECTION, KEY, "+1", TESTFILE, 1, 1 },
{ SECTION, KEY, "4294967296", TESTFILE, -1, 0 }, /* 15 */
{ SECTION, KEY, "4294967296", TESTFILE, 1, 0 },
{ SECTION, KEY, "4294967297", TESTFILE, -1, 1 },
{ SECTION, KEY, "4294967297", TESTFILE, 1, 1 },
{ SECTION, KEY, "-4294967297", TESTFILE, -1, 4294967295U},
{ SECTION, KEY, "-4294967297", TESTFILE, 1, 4294967295U}, /* 20 */
{ SECTION, KEY, "42A94967297", TESTFILE, -1, 42 },
{ SECTION, KEY, "42A94967297", TESTFILE, 1, 42 },
{ SECTION, KEY, "B4294967297", TESTFILE, -1, 0 },
{ SECTION, KEY, "B4294967297", TESTFILE, 1, 0 },
};
int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
UINT res;
DeleteFileA( TESTFILE);
for (i=0; i < num_test; i++) {
if (profileInt[i].value)
WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value,
profileInt[i].iniFile);
res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key,
profileInt[i].defaultVal, profileInt[i].iniFile);
ok(res == profileInt[i].result, "test<%02d>: ret<%010u> exp<%010u>\n",
i, res, profileInt[i].result);
}
DeleteFileA( TESTFILE);
}
START_TEST(profile)
{
test_profile_int();
}

View File

@@ -1,66 +0,0 @@
/* Automatically generated file; DO NOT EDIT!! */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#if 0
extern void func_alloc(void);
#endif
extern void func_atom(void);
extern void func_change(void);
extern void func_codepage(void);
extern void func_comm(void);
extern void func_console(void);
extern void func_directory(void);
extern void func_drive(void);
extern void func_environ(void);
extern void func_file(void);
extern void func_format_msg(void);
extern void func_heap(void);
extern void func_locale(void);
extern void func_mailslot(void);
extern void func_path(void);
extern void func_pipe(void);
extern void func_process(void);
extern void func_profile(void);
extern void func_thread(void);
extern void func_virtual(void);
struct test
{
const char *name;
void (*func)(void);
};
static const struct test winetest_testlist[] =
{
#if 0
{ "alloc", func_alloc },
#endif
{ "atom", func_atom },
{ "change", func_change },
{ "codepage", func_codepage },
{ "comm", func_comm },
{ "console", func_console },
{ "directory", func_directory },
{ "drive", func_drive },
{ "environ", func_environ },
{ "file", func_file },
{ "format_msg", func_format_msg },
{ "heap", func_heap },
{ "locale", func_locale },
{ "mailslot", func_mailslot },
{ "path", func_path },
{ "pipe", func_pipe },
{ "process", func_process },
{ "profile", func_profile },
{ "thread", func_thread },
{ "virtual", func_virtual },
{ 0, 0 }
};
#define WINETEST_WANT_MAIN
#include "wine/test.h"

View File

@@ -1,572 +0,0 @@
/*
* Unit test suite for directory functions.
*
* Copyright 2002 Geoffrey Hausheer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Define _WIN32_WINNT to get SetThreadIdealProcessor on Windows */
#define _WIN32_WINNT 0x0500
#include <stdarg.h>
#include "wine/test.h"
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <winerror.h>
/* Specify the number of simultaneous threads to test */
#define NUM_THREADS 4
/* Specify whether to test the extended priorities for Win2k/XP */
#define USE_EXTENDED_PRIORITIES 0
/* Specify whether to test the stack allocation in CreateThread */
#define CHECK_STACK 0
/* Set CHECK_STACK to 1 if you want to try to test the stack-limit from
CreateThread. So far I have been unable to make this work, and
I am in doubt as to how portable it is. Also, according to MSDN,
you shouldn't mix C-run-time-libraries (i.e. alloca) with CreateThread.
Anyhow, the check is currently commented out
*/
#if CHECK_STACK
#ifdef __try
#define __TRY __try
#define __EXCEPT __except
#define __ENDTRY
#else
#include "wine/exception.h"
#endif
#endif
typedef BOOL (WINAPI *GetThreadPriorityBoost_t)(HANDLE,PBOOL);
static GetThreadPriorityBoost_t pGetThreadPriorityBoost=NULL;
typedef HANDLE (WINAPI *OpenThread_t)(DWORD,BOOL,DWORD);
static OpenThread_t pOpenThread=NULL;
typedef DWORD (WINAPI *SetThreadIdealProcessor_t)(HANDLE,DWORD);
static SetThreadIdealProcessor_t pSetThreadIdealProcessor=NULL;
typedef BOOL (WINAPI *SetThreadPriorityBoost_t)(HANDLE,BOOL);
static SetThreadPriorityBoost_t pSetThreadPriorityBoost=NULL;
/* Functions not tested yet:
AttachThreadInput
CreateRemoteThread
SetThreadContext
SwitchToThread
In addition there are no checks that the inheritance works properly in
CreateThread
*/
DWORD tlsIndex;
typedef struct {
int threadnum;
HANDLE *event;
DWORD *threadmem;
} t1Struct;
/* Basic test that simulatneous threads can access shared memory,
that the thread local storage routines work correctly, and that
threads actually run concurrently
*/
VOID WINAPI threadFunc1(t1Struct *tstruct)
{
int i;
/* write our thread # into shared memory */
tstruct->threadmem[tstruct->threadnum]=GetCurrentThreadId();
ok(TlsSetValue(tlsIndex,(LPVOID)(tstruct->threadnum+1))!=0,
"TlsSetValue failed\n");
/* The threads synchronize before terminating. This is done by
Signaling an event, and waiting for all events to occur
*/
SetEvent(tstruct->event[tstruct->threadnum]);
WaitForMultipleObjects(NUM_THREADS,tstruct->event,TRUE,INFINITE);
/* Double check that all threads really did run by validating that
they have all written to the shared memory. There should be no race
here, since all threads were synchronized after the write.*/
for(i=0;i<NUM_THREADS;i++) {
while(tstruct->threadmem[i]==0) ;
}
/* Check that noone cahnged our tls memory */
ok((int)TlsGetValue(tlsIndex)-1==tstruct->threadnum,
"TlsGetValue failed\n");
ExitThread(NUM_THREADS+tstruct->threadnum);
}
VOID WINAPI threadFunc2()
{
ExitThread(99);
}
VOID WINAPI threadFunc3()
{
HANDLE thread;
thread=GetCurrentThread();
SuspendThread(thread);
ExitThread(99);
}
VOID WINAPI threadFunc4(HANDLE event)
{
if(event != NULL) {
SetEvent(event);
}
Sleep(99000);
ExitThread(0);
}
#if CHECK_STACK
VOID WINAPI threadFunc5(DWORD *exitCode)
{
SYSTEM_INFO sysInfo;
sysInfo.dwPageSize=0;
GetSystemInfo(&sysInfo);
*exitCode=0;
__TRY
{
alloca(2*sysInfo.dwPageSize);
}
__EXCEPT(1) {
*exitCode=1;
}
__ENDTRY
ExitThread(0);
}
#endif
/* Check basic funcationality of CreateThread and Tls* functions */
VOID test_CreateThread_basic()
{
HANDLE thread[NUM_THREADS],event[NUM_THREADS];
DWORD threadid[NUM_THREADS],curthreadId;
DWORD threadmem[NUM_THREADS];
DWORD exitCode;
t1Struct tstruct[NUM_THREADS];
int error;
DWORD i,j;
/* Retrieve current Thread ID for later comparisons */
curthreadId=GetCurrentThreadId();
/* Allocate some local storage */
ok((tlsIndex=TlsAlloc())!=TLS_OUT_OF_INDEXES,"TlsAlloc failed\n");
/* Create events for thread synchronization */
for(i=0;i<NUM_THREADS;i++) {
threadmem[i]=0;
/* Note that it doesn't matter what type of event we chose here. This
test isn't trying to thoroughly test events
*/
event[i]=CreateEventA(NULL,TRUE,FALSE,NULL);
tstruct[i].threadnum=i;
tstruct[i].threadmem=threadmem;
tstruct[i].event=event;
}
/* Test that passing arguments to threads works okay */
for(i=0;i<NUM_THREADS;i++) {
thread[i] = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc1,
&tstruct[i],0,&threadid[i]);
ok(thread[i]!=NULL,"Create Thread failed\n");
}
/* Test that the threads actually complete */
for(i=0;i<NUM_THREADS;i++) {
error=WaitForSingleObject(thread[i],5000);
ok(error==WAIT_OBJECT_0, "Thread did not complete within timelimit\n");
if(error!=WAIT_OBJECT_0) {
TerminateThread(thread[i],i+NUM_THREADS);
}
ok(GetExitCodeThread(thread[i],&exitCode),"Could not retrieve ext code\n");
ok(exitCode==i+NUM_THREADS,"Thread returned an incorrect exit code\n");
}
/* Test that each thread executed in its parent's address space
(it was able to change threadmem and pass that change back to its parent)
and that each thread id was independant). Note that we prove that the
threads actually execute concurrently by having them block on each other
in threadFunc1
*/
for(i=0;i<NUM_THREADS;i++) {
error=0;
for(j=i+1;j<NUM_THREADS;j++) {
if (threadmem[i]==threadmem[j]) {
error=1;
}
}
ok(!error && threadmem[i]==threadid[i] && threadmem[i]!=curthreadId,
"Thread did not execute successfully\n");
ok(CloseHandle(thread[i])!=0,"CloseHandle failed\n");
}
ok(TlsFree(tlsIndex)!=0,"TlsFree failed\n");
}
/* Check that using the CREATE_SUSPENDED flag works */
VOID test_CreateThread_suspended()
{
HANDLE thread;
DWORD threadId;
int error;
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc2,NULL,
CREATE_SUSPENDED,&threadId);
ok(thread!=NULL,"Create Thread failed\n");
/* Check that the thread is suspended */
ok(SuspendThread(thread)==1,"Thread did not start suspended\n");
ok(ResumeThread(thread)==2,"Resume thread returned an invalid value\n");
/* Check that resume thread didn't actually start the thread. I can't think
of a better way of checking this than just waiting. I am not sure if this
will work on slow computers.
*/
ok(WaitForSingleObject(thread,1000)==WAIT_TIMEOUT,
"ResumeThread should not have actually started the thread\n");
/* Now actually resume the thread and make sure that it actually completes*/
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
ok((error=WaitForSingleObject(thread,1000))==WAIT_OBJECT_0,
"Thread did not resume\n");
if(error!=WAIT_OBJECT_0) {
TerminateThread(thread,1);
}
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
}
/* Check that SuspendThread and ResumeThread work */
VOID test_SuspendThread()
{
HANDLE thread,access_thread;
DWORD threadId,exitCode;
int i,error;
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc3,NULL,
0,&threadId);
ok(thread!=NULL,"Create Thread failed\n");
/* Check that the thread is suspended */
/* Note that this is a polling method, and there is a race between
SuspendThread being called (in the child, and the loop below timing out,
so the test could fail on a heavily loaded or slow computer.
*/
error=0;
for(i=0;error==0 && i<100;i++) {
error=SuspendThread(thread);
ResumeThread(thread);
if(error==0) {
Sleep(50);
i++;
}
}
ok(error==1,"SuspendThread did not work\n");
/* check that access restrictions are obeyed */
if (pOpenThread) {
access_thread=pOpenThread(THREAD_ALL_ACCESS & (~THREAD_SUSPEND_RESUME),
0,threadId);
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
if (access_thread!=NULL) {
ok(SuspendThread(access_thread)==-1,
"SuspendThread did not obey access restrictions\n");
ok(ResumeThread(access_thread)==-1,
"ResumeThread did not obey access restrictions\n");
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
}
}
/* Double check that the thread really is suspended */
ok((error=GetExitCodeThread(thread,&exitCode))!=0 && exitCode==STILL_ACTIVE,
"Thread did not really suspend\n");
/* Resume the thread, and make sure it actually completes */
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
ok((error=WaitForSingleObject(thread,1000))==WAIT_OBJECT_0,
"Thread did not resume\n");
if(error!=WAIT_OBJECT_0) {
TerminateThread(thread,1);
}
/* Trying to suspend a terminated thread should fail */
error=SuspendThread(thread);
ok(error==0xffffffff, "wrong return code: %d\n", error);
ok(GetLastError()==ERROR_ACCESS_DENIED || GetLastError()==ERROR_NO_MORE_ITEMS, "unexpected error code: %ld\n", GetLastError());
ok(CloseHandle(thread)!=0,"CloseHandle Failed\n");
}
/* Check that TerminateThread works properly
*/
VOID test_TerminateThread()
{
HANDLE thread,access_thread,event;
DWORD threadId,exitCode;
int i,error;
i=0; error=0;
event=CreateEventA(NULL,TRUE,FALSE,NULL);
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc4,
(LPVOID)event, 0,&threadId);
ok(thread!=NULL,"Create Thread failed\n");
/* Terminate thread has a race condition in Wine. If the thread is terminated
before it starts, it leaves a process behind. Therefore, we wait for the
thread to signal that it has started. There is no easy way to force the
race to occur, so we don't try to find it.
*/
ok(WaitForSingleObject(event,5000)==WAIT_OBJECT_0,
"TerminateThread didn't work\n");
/* check that access restrictions are obeyed */
if (pOpenThread) {
access_thread=pOpenThread(THREAD_ALL_ACCESS & (~THREAD_TERMINATE),
0,threadId);
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
if (access_thread!=NULL) {
ok(TerminateThread(access_thread,99)==0,
"TerminateThread did not obey access restrictions\n");
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
}
}
/* terminate a job and make sure it terminates */
ok(TerminateThread(thread,99)!=0,"TerminateThread failed\n");
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
"TerminateThread didn't work\n");
ok(GetExitCodeThread(thread,&exitCode)!=STILL_ACTIVE,
"TerminateThread should not leave the thread 'STILL_ACTIVE'\n");
ok(exitCode==99, "TerminateThread returned invalid exit code\n");
ok(CloseHandle(thread)!=0,"Error Closing thread handle\n");
}
/* Check if CreateThread obeys the specified stack size. This code does
not work properly, and is currently disabled
*/
VOID test_CreateThread_stack()
{
#if CHECK_STACK
/* The only way I know of to test the stack size is to use alloca
and __try/__except. However, this is probably not portable,
and I couldn't get it to work under Wine anyhow. However, here
is the code which should allow for testing that CreateThread
respects the stack-size limit
*/
HANDLE thread;
DWORD threadId,exitCode;
SYSTEM_INFO sysInfo;
sysInfo.dwPageSize=0;
GetSystemInfo(&sysInfo);
ok(sysInfo.dwPageSize>0,"GetSystemInfo should return a valid page size\n");
thread = CreateThread(NULL,sysInfo.dwPageSize,
(LPTHREAD_START_ROUTINE)threadFunc5,&exitCode,
0,&threadId);
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
"TerminateThread didn't work\n");
ok(exitCode==1,"CreateThread did not obey stack-size-limit\n");
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
#endif
}
/* Check whether setting/retrieving thread priorities works */
VOID test_thread_priority()
{
HANDLE curthread,access_thread;
DWORD curthreadId,exitCode;
int min_priority=-2,max_priority=2;
BOOL disabled;
int i;
curthread=GetCurrentThread();
curthreadId=GetCurrentThreadId();
/* Check thread priority */
/* NOTE: on Win2k/XP priority can be from -7 to 6. All other platforms it
is -2 to 2. However, even on a real Win2k system, using thread
priorities beyond the -2 to 2 range does not work. If you want to try
anyway, enable USE_EXTENDED_PRIORITIES
*/
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_NORMAL,
"GetThreadPriority Failed\n");
if (pOpenThread) {
/* check that access control is obeyed */
access_thread=pOpenThread(THREAD_ALL_ACCESS &
(~THREAD_QUERY_INFORMATION) & (~THREAD_SET_INFORMATION),
0,curthreadId);
ok(access_thread!=NULL,"OpenThread returned an invalid handle\n");
if (access_thread!=NULL) {
ok(SetThreadPriority(access_thread,1)==0,
"SetThreadPriority did not obey access restrictions\n");
ok(GetThreadPriority(access_thread)==THREAD_PRIORITY_ERROR_RETURN,
"GetThreadPriority did not obey access restrictions\n");
if (pSetThreadPriorityBoost)
ok(pSetThreadPriorityBoost(access_thread,1)==0,
"SetThreadPriorityBoost did not obey access restrictions\n");
if (pGetThreadPriorityBoost)
ok(pGetThreadPriorityBoost(access_thread,&disabled)==0,
"GetThreadPriorityBoost did not obey access restrictions\n");
ok(GetExitCodeThread(access_thread,&exitCode)==0,
"GetExitCodeThread did not obey access restrictions\n");
ok(CloseHandle(access_thread),"Error Closing thread handle\n");
}
#if USE_EXTENDED_PRIORITIES
min_priority=-7; max_priority=6;
#endif
}
for(i=min_priority;i<=max_priority;i++) {
ok(SetThreadPriority(curthread,i)!=0,
"SetThreadPriority Failed for priority: %d\n",i);
ok(GetThreadPriority(curthread)==i,
"GetThreadPriority Failed for priority: %d\n",i);
}
ok(SetThreadPriority(curthread,THREAD_PRIORITY_TIME_CRITICAL)!=0,
"SetThreadPriority Failed\n");
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_TIME_CRITICAL,
"GetThreadPriority Failed\n");
ok(SetThreadPriority(curthread,THREAD_PRIORITY_IDLE)!=0,
"SetThreadPriority Failed\n");
ok(GetThreadPriority(curthread)==THREAD_PRIORITY_IDLE,
"GetThreadPriority Failed\n");
ok(SetThreadPriority(curthread,0)!=0,"SetThreadPriority Failed\n");
/* Check thread priority boost */
if (pGetThreadPriorityBoost && pSetThreadPriorityBoost) {
BOOL rc;
todo_wine {
SetLastError(0);
rc=pGetThreadPriorityBoost(curthread,&disabled);
if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
ok(rc!=0,"error=%ld\n",GetLastError());
ok(pSetThreadPriorityBoost(curthread,1)!=0,
"error=%ld\n",GetLastError());
rc=pGetThreadPriorityBoost(curthread,&disabled);
ok(rc!=0 && disabled==1,
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
ok(pSetThreadPriorityBoost(curthread,0)!=0,
"error=%ld\n",GetLastError());
rc=pGetThreadPriorityBoost(curthread,&disabled);
ok(rc!=0 && disabled==0,
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
}
}
}
}
/* check the GetThreadTimes function */
VOID test_GetThreadTimes()
{
HANDLE thread,access_thread=NULL;
FILETIME creationTime,exitTime,kernelTime,userTime;
DWORD threadId;
int error;
thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc2,NULL,
CREATE_SUSPENDED,&threadId);
ok(thread!=NULL,"Create Thread failed\n");
/* check that access control is obeyed */
if (pOpenThread) {
access_thread=pOpenThread(THREAD_ALL_ACCESS &
(~THREAD_QUERY_INFORMATION), 0,threadId);
ok(access_thread!=NULL,
"OpenThread returned an invalid handle\n");
}
ok(ResumeThread(thread)==1,"Resume thread returned an invalid value\n");
ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0,
"ResumeThread didn't work\n");
if(access_thread!=NULL) {
error=GetThreadTimes(access_thread,&creationTime,&exitTime,
&kernelTime,&userTime);
ok(error==0, "GetThreadTimes did not obey access restrictions\n");
ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n");
}
creationTime.dwLowDateTime=99; creationTime.dwHighDateTime=99;
exitTime.dwLowDateTime=99; exitTime.dwHighDateTime=99;
kernelTime.dwLowDateTime=99; kernelTime.dwHighDateTime=99;
userTime.dwLowDateTime=99; userTime.dwHighDateTime=99;
/* GetThreadTimes should set all of the parameters passed to it */
error=GetThreadTimes(thread,&creationTime,&exitTime,
&kernelTime,&userTime);
if (error!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
ok(error!=0,"GetThreadTimes failed\n");
ok(creationTime.dwLowDateTime!=99 || creationTime.dwHighDateTime!=99,
"creationTime was invalid\n");
ok(exitTime.dwLowDateTime!=99 || exitTime.dwHighDateTime!=99,
"exitTime was invalid\n");
ok(kernelTime.dwLowDateTime!=99 || kernelTime.dwHighDateTime!=99,
"kernelTimewas invalid\n");
ok(userTime.dwLowDateTime!=99 || userTime.dwHighDateTime!=99,
"userTime was invalid\n");
ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
}
}
/* Check the processor affinity functions */
/* NOTE: These functions should also be checked that they obey access control
*/
VOID test_thread_processor()
{
HANDLE curthread,curproc;
DWORD processMask,systemMask;
SYSTEM_INFO sysInfo;
int error=0;
sysInfo.dwNumberOfProcessors=0;
GetSystemInfo(&sysInfo);
ok(sysInfo.dwNumberOfProcessors>0,
"GetSystemInfo failed to return a valid # of processors\n");
/* Use the current Thread/process for all tests */
curthread=GetCurrentThread();
ok(curthread!=NULL,"GetCurrentThread failed\n");
curproc=GetCurrentProcess();
ok(curproc!=NULL,"GetCurrentProcess failed\n");
/* Check the Affinity Mask functions */
ok(GetProcessAffinityMask(curproc,&processMask,&systemMask)!=0,
"GetProcessAffinityMask failed\n");
ok(SetThreadAffinityMask(curthread,processMask)==1,
"SetThreadAffinityMask failed\n");
ok(SetThreadAffinityMask(curthread,processMask+1)==0,
"SetThreadAffinityMask passed for an illegal processor\n");
/* NOTE: This only works on WinNT/2000/XP) */
if (pSetThreadIdealProcessor) {
todo_wine {
SetLastError(0);
error=pSetThreadIdealProcessor(curthread,0);
if (GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
ok(error!=-1, "SetThreadIdealProcessor failed\n");
}
}
if (GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1);
ok(error==-1,
"SetThreadIdealProcessor succeeded with an illegal processor #\n");
todo_wine {
error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS);
ok(error==0, "SetThreadIdealProcessor returned an incorrect value\n");
}
}
}
}
START_TEST(thread)
{
HINSTANCE lib;
/* Neither Cygwin nor mingW export OpenThread, so do a dynamic check
so that the compile passes
*/
lib=LoadLibraryA("kernel32");
ok(lib!=NULL,"Couldn't load kernel32.dll\n");
pGetThreadPriorityBoost=(GetThreadPriorityBoost_t)GetProcAddress(lib,"GetThreadPriorityBoost");
pOpenThread=(OpenThread_t)GetProcAddress(lib,"OpenThread");
pSetThreadIdealProcessor=(SetThreadIdealProcessor_t)GetProcAddress(lib,"SetThreadIdealProcessor");
pSetThreadPriorityBoost=(SetThreadPriorityBoost_t)GetProcAddress(lib,"SetThreadPriorityBoost");
test_CreateThread_basic();
test_CreateThread_suspended();
test_SuspendThread();
test_TerminateThread();
test_CreateThread_stack();
test_thread_priority();
test_GetThreadTimes();
test_thread_processor();
}

View File

@@ -1,123 +0,0 @@
/*
* Unit test suite for time functions
*
* Copyright 2004 Uwe Bonnes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "wine/test.h"
#include "winbase.h"
#define SECSPERMIN 60
#define SECSPERDAY 86400
/* 1601 to 1970 is 369 years plus 89 leap days */
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
void test_GetTimeZoneInformation()
{
TIME_ZONE_INFORMATION tzinfo, tzinfo1;
DWORD res = GetTimeZoneInformation(&tzinfo);
ok(res != 0, "GetTimeZoneInformation failed\n");
ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
"SetEnvironmentVariableA failed\n");
res = GetTimeZoneInformation(&tzinfo1);
ok(res != 0, "GetTimeZoneInformation failed\n");
ok(((tzinfo.Bias == tzinfo1.Bias) &&
(tzinfo.StandardBias == tzinfo1.StandardBias) &&
(tzinfo.DaylightBias == tzinfo1.DaylightBias)),
"Bias influenced by TZ variable\n");
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
"SetEnvironmentVariableA failed\n");
}
void test_FileTimeToSystemTime()
{
FILETIME ft;
SYSTEMTIME st;
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
ft.dwHighDateTime = 0;
ft.dwLowDateTime = 0;
ok(FileTimeToSystemTime(&ft, &st),
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
(st.wMilliseconds == 0)),
"Got Year %4d Month %2d Day %2d\n", st.wYear, st.wMonth, st.wDay);
ft.dwHighDateTime = (UINT)(time >> 32);
ft.dwLowDateTime = (UINT)time;
ok(FileTimeToSystemTime(&ft, &st),
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
(st.wMilliseconds == 0)),
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
st.wMilliseconds);
}
void test_FileTimeToLocalFileTime()
{
FILETIME ft, lft;
SYSTEMTIME st;
TIME_ZONE_INFORMATION tzinfo;
DWORD res = GetTimeZoneInformation(&tzinfo);
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970
+ (ULONGLONG)tzinfo.Bias*SECSPERMIN *TICKSPERSEC;
ok( res != 0, "GetTimeZoneInformation failed\n");
ft.dwHighDateTime = (UINT)(time >> 32);
ft.dwLowDateTime = (UINT)time;
ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
FileTimeToSystemTime(&lft, &st);
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
(st.wMilliseconds == 0)),
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
st.wMilliseconds);
ok(SetEnvironmentVariableA("TZ","GMT") != 0,
"SetEnvironmentVariableA failed\n");
ok(res != 0, "GetTimeZoneInformation failed\n");
ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
FileTimeToSystemTime(&lft, &st);
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
(st.wMilliseconds == 0)),
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
st.wMilliseconds);
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
"SetEnvironmentVariableA failed\n");
}
START_TEST(time)
{
test_GetTimeZoneInformation();
test_FileTimeToSystemTime();
test_FileTimeToLocalFileTime();
}

View File

@@ -1,113 +0,0 @@
/*
* Unit test suite for Virtual* family of APIs.
*
* Copyright 2004 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"
static void test_VirtualAlloc(void)
{
void *addr1, *addr2;
DWORD old_prot;
MEMORY_BASIC_INFORMATION info;
SetLastError(0xdeadbeef);
addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 != NULL, "VirtualAlloc failed\n");
/* test a not committed memory */
ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
"VirtualQuery failed\n");
ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
/* NT reports Protect == 0 for a not committed memory block */
ok(info.Protect == 0 /* NT */ ||
info.Protect == PAGE_NOACCESS, /* Win9x */
"%lx != PAGE_NOACCESS\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
SetLastError(0xdeadbeef);
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtect should fail on a not committed memory\n");
ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
"got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
ok(addr1 == addr2, "VirtualAlloc failed\n");
/* test a committed memory */
ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
"VirtualQuery failed\n");
ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
/* this time NT reports PAGE_NOACCESS as well */
ok(info.Protect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
/* this should fail, since not the whole range is committed yet */
SetLastError(0xdeadbeef);
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtect should fail on a not committed memory\n");
ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
"got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
ok(old_prot == PAGE_NOACCESS,
"wrong old protection: got %04lx instead of PAGE_NOACCESS\n", old_prot);
ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
ok(old_prot == PAGE_READONLY,
"wrong old protection: got %04lx instead of PAGE_READONLY\n", old_prot);
ok(!VirtualFree(addr1, 0x10000, 0), "VirtualFree should fail with type 0\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
ok(VirtualFree(addr1, 0x10000, MEM_DECOMMIT), "VirtualFree failed\n");
/* if the type is MEM_RELEASE, size must be 0 */
ok(!VirtualFree(addr1, 1, MEM_RELEASE), "VirtualFree should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
}
START_TEST(virtual)
{
test_VirtualAlloc();
}

View File

@@ -1,6 +1,6 @@
*.exe
*.sym
*.coff
*.d
*.o
*.d
*.exe
*.coff
*.sym
*.map

View File

@@ -1,4 +1,4 @@
# $Id: makefile,v 1.1 2004/01/11 17:06:21 ea Exp $
# $Id: Makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
PATH_TO_TOP = ../../..
@@ -8,9 +8,9 @@ TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = nts2w32err
TARGET_NAME = lock
TARGET_SDKLIBS = ntdll.a
TARGET_SDKLIBS = kernel32.a user32.a
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -0,0 +1,113 @@
#include <windows.h>
#include <stdio.h>
HANDLE hFile;
BOOL Slock(DWORD start,DWORD len)
{
OVERLAPPED overl;
BOOL stat;
overl.Offset = start;
overl.OffsetHigh = 0;
overl.hEvent = 0;
stat = LockFileEx(hFile,LOCKFILE_FAIL_IMMEDIATELY,0,len,0,&overl) ;
printf("Slock %li-%li %s\n",start,start+len,stat!=0 ? "OK" : "FAILED");
return stat;
}
BOOL Xlock(DWORD start,DWORD len)
{
OVERLAPPED overl;
BOOL stat;
overl.Offset = start;
overl.OffsetHigh = 0;
overl.hEvent = 0;
stat = LockFileEx(hFile,LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY,0,len,0,&overl);
printf("Xlock %li-%li %s\n",start,start+len,stat!=0 ? "OK" : "FAILED");
return stat;
}
BOOL unlock(DWORD start,DWORD len)
{
OVERLAPPED overl;
BOOL stat;
overl.Offset = start;
overl.OffsetHigh = 0;
overl.hEvent = 0;
stat = UnlockFileEx(hFile,0,len,0,&overl) ;
printf("unlock %li-%li %s\n",start,start+len,stat!=0 ? "OK" : "FAILED");
return stat;
}
BOOL mkfile()
{
hFile = CreateFile("C:\\lock.test",
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
printf("mkfile %s\n",(hFile == INVALID_HANDLE_VALUE) ? "FAILED" : "OK");
return !(hFile == INVALID_HANDLE_VALUE);
}
int main(void)
{
DWORD ass;
printf("enter main\n");
mkfile();
Slock(8,10);
Slock(10,5);
Slock(10,5);
Slock(15,5);
Slock(5,10);
Slock(0,100);
Xlock(30,10);
Xlock(30,1);
unlock(30,1);
unlock(30,10);
Xlock(30,5);
Slock(35,5);
unlock(50,5);
unlock(0,100);
unlock(10,5);
if (WriteFile(hFile,"ass",4,&ass,NULL) == 0) printf("write 1 failed\n");
else printf("write 1 success\n");
CloseHandle(hFile);
mkfile();
Slock(0,100);
if (WriteFile(hFile,"ass",4,&ass,NULL) == 0) printf("write 2 failed\n");
else printf("write 2 success\n");
CloseHandle(hFile);
Sleep(10000);
return(0);
}

View File

@@ -1,4 +1,4 @@
/* $Id: lpcclt.c,v 1.14 2004/01/06 16:07:21 ekohl Exp $
/* $Id: lpcclt.c,v 1.13 2003/11/17 02:12:48 hyperion Exp $
*
* DESCRIPTION: Simple LPC Client
* PROGRAMMER: David Welch
@@ -6,6 +6,7 @@
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
#include <windows.h>
#include <napi/lpc.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>

View File

@@ -1,4 +1,4 @@
/* $Id: lpcsrv.c,v 1.14 2004/01/06 16:07:21 ekohl Exp $
/* $Id: lpcsrv.c,v 1.13 2003/11/17 02:12:48 hyperion Exp $
*
* DESCRIPTION: Simple LPC Server
* PROGRAMMER: David Welch
@@ -6,6 +6,7 @@
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
#include <windows.h>
#include <napi/lpc.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>

View File

@@ -10,7 +10,7 @@ CLT_OBJECTS= lpcclt.o
PROGS= lpcsrv.exe lpcclt.exe
CFLAGS = $(STD_CFLAGS)
BASE_CFLAGS = -I$(PATH_TO_TOP)/include -Wall -Werror
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
@@ -42,6 +42,11 @@ $(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
endif # BOOTCD_INSTALL
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
lpcsrv.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o lpcsrv.exe
$(NM) --numeric-sort lpcsrv.exe > lpcsrv.sym

View File

@@ -1,6 +0,0 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View File

@@ -1,25 +0,0 @@
# $Id: makefile,v 1.1 2003/12/10 19:18:06 weiden Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = no
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = mdi
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a comctl32.a
TARGET_GCCLIBS = comdlg32
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,521 +0,0 @@
/*
Thanks to theForger from winprog.org
*/
#include <windows.h>
#include <string.h>
#include "resource.h"
const char g_szClassName[] = "myWindowClass";
const char g_szChildClassName[] = "myMDIChildWindowClass";
#define IDC_MAIN_MDI 101
#define IDC_MAIN_TOOL 102
#define IDC_MAIN_STATUS 103
#define IDC_CHILD_EDIT 101
#define ID_MDI_FIRSTCHILD 50000
HWND g_hMDIClient = NULL;
HWND g_hMainWindow = NULL;
BOOL LoadTextFileToEdit(HWND hEdit, LPCTSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwFileSize;
dwFileSize = GetFileSize(hFile, NULL);
if(dwFileSize != 0xFFFFFFFF)
{
LPSTR pszFileText;
pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
if(pszFileText != NULL)
{
DWORD dwRead;
if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
{
pszFileText[dwFileSize] = 0; // Add null terminator
if(SetWindowText(hEdit, pszFileText))
bSuccess = TRUE; // It worked!
}
GlobalFree(pszFileText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}
BOOL SaveTextFileFromEdit(HWND hEdit, LPCTSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwTextLength;
dwTextLength = GetWindowTextLength(hEdit);
// No need to bother if there's no text.
if(dwTextLength > 0)
{
LPSTR pszText;
DWORD dwBufferSize = dwTextLength + 1;
pszText = GlobalAlloc(GPTR, dwBufferSize);
if(pszText != NULL)
{
if(GetWindowText(hEdit, pszText, dwBufferSize))
{
DWORD dwWritten;
if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
bSuccess = TRUE;
}
GlobalFree(pszText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}
void DoFileOpen(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
if(LoadTextFileToEdit(hEdit, szFileName))
{
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM)"Opened...");
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM)szFileName);
SetWindowText(hwnd, szFileName);
}
}
}
void DoFileSave(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "txt";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
if(SaveTextFileFromEdit(hEdit, szFileName))
{
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM)"Saved...");
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM)szFileName);
SetWindowText(hwnd, szFileName);
}
}
}
HWND CreateNewMDIChild(HWND hMDIClient)
{
MDICREATESTRUCT mcs;
HWND hChild;
mcs.szTitle = "[Untitled]";
mcs.szClass = g_szChildClassName;
mcs.hOwner = GetModuleHandle(NULL);
mcs.x = mcs.cx = CW_USEDEFAULT;
mcs.y = mcs.cy = CW_USEDEFAULT;
mcs.style = MDIS_ALLCHILDSTYLES;
hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
if(!hChild)
{
MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
MB_ICONEXCLAMATION | MB_OK);
}
return hChild;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HWND hTool;
TBBUTTON tbb[3];
TBADDBITMAP tbab;
HWND hStatus;
int statwidths[] = {100, -1};
CLIENTCREATESTRUCT ccs;
// Create MDI Client
// Find window menu where children will be listed
ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 2);
ccs.idFirstChild = ID_MDI_FIRSTCHILD;
g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);
if(g_hMDIClient == NULL)
MessageBox(hwnd, "Could not create MDI client.", "Error", MB_OK | MB_ICONERROR);
// Create Toolbar
hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
if(hTool == NULL)
MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
tbab.hInst = HINST_COMMCTRL;
tbab.nID = IDB_STD_SMALL_COLOR;
SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = STD_FILENEW;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].idCommand = ID_FILE_NEW;
tbb[1].iBitmap = STD_FILEOPEN;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = ID_FILE_OPEN;
tbb[2].iBitmap = STD_FILESAVE;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = ID_FILE_SAVEAS;
SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
// Create Status bar
hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);
SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
}
break;
case WM_SIZE:
{
HWND hTool;
RECT rcTool;
int iToolHeight;
HWND hStatus;
RECT rcStatus;
int iStatusHeight;
HWND hMDI;
int iMDIHeight;
RECT rcClient;
// Size toolbar and get height
hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
SendMessage(hTool, TB_AUTOSIZE, 0, 0);
GetWindowRect(hTool, &rcTool);
iToolHeight = rcTool.bottom - rcTool.top;
// Size status bar and get height
hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
SendMessage(hStatus, WM_SIZE, 0, 0);
GetWindowRect(hStatus, &rcStatus);
iStatusHeight = rcStatus.bottom - rcStatus.top;
// Calculate remaining height and size edit
GetClientRect(hwnd, &rcClient);
iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case ID_FILE_NEW:
CreateNewMDIChild(g_hMDIClient);
break;
case ID_FILE_OPEN:
{
HWND hChild = CreateNewMDIChild(g_hMDIClient);
if(hChild)
{
DoFileOpen(hChild);
}
}
break;
case ID_FILE_CLOSE:
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
{
SendMessage(hChild, WM_CLOSE, 0, 0);
}
}
break;
case ID_WINDOW_TILE:
SendMessage(g_hMDIClient, WM_MDITILE, 0, 0);
break;
case ID_WINDOW_CASCADE:
SendMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
break;
default:
{
if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
{
DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
}
else
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
{
SendMessage(hChild, WM_COMMAND, wParam, lParam);
}
}
}
}
break;
default:
return DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HFONT hfDefault;
HWND hEdit;
// Create Edit Control
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
if(hEdit == NULL)
MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
hfDefault = GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
break;
case WM_MDIACTIVATE:
{
HMENU hMenu, hFileMenu;
UINT EnableFlag;
hMenu = GetMenu(g_hMainWindow);
if(hwnd == (HWND)lParam)
{ //being activated, enable the menus
EnableFlag = MF_ENABLED;
}
else
{ //being de-activated, gray the menus
EnableFlag = MF_GRAYED;
}
EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);
hFileMenu = GetSubMenu(hMenu, 0);
EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);
DrawMenuBar(g_hMainWindow);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_OPEN:
DoFileOpen(hwnd);
break;
case ID_FILE_SAVEAS:
DoFileSave(hwnd);
break;
case ID_EDIT_CUT:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0);
break;
case ID_EDIT_COPY:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0);
break;
case ID_EDIT_PASTE:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0);
break;
}
break;
case WM_SIZE:
{
HWND hEdit;
RECT rcClient;
// Calculate remaining height and size edit
GetClientRect(hwnd, &rcClient);
hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
return DefMDIChildProc(hwnd, msg, wParam, lParam);
default:
return DefMDIChildProc(hwnd, msg, wParam, lParam);
}
return 0;
}
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MDIChildWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szChildClassName;
wc.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(0, "Could Not Register Child Window", "Oh Oh...",
MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
else
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
InitCommonControls();
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
if(!SetUpMDIChildWindowClass(hInstance))
return 0;
hwnd = CreateWindowEx(
0,
g_szClassName,
"MDI Test Application",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
g_hMainWindow = hwnd;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
if (!TranslateMDISysAccel(g_hMDIClient, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}

View File

@@ -1,30 +0,0 @@
#include <defines.h>
#include <reactos/resource.h>
#include "resource.h"
IDR_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", ID_FILE_NEW
MENUITEM "&Open...", ID_FILE_OPEN
MENUITEM "Save &As...", ID_FILE_SAVEAS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Close", ID_FILE_CLOSE, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit", GRAYED
BEGIN
MENUITEM "C&ut", ID_EDIT_CUT
MENUITEM "&Copy", ID_EDIT_COPY
MENUITEM "&Paste", ID_EDIT_PASTE
END
POPUP "&Window", GRAYED
BEGIN
MENUITEM "&Tile", ID_WINDOW_TILE
MENUITEM "&Cascade", ID_WINDOW_CASCADE
END
END

View File

@@ -1,27 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by app_four.rc
//
#define IDR_MAINMENU 102
#define ID_FILE_EXIT 40001
#define ID_FILE_NEW 40002
#define ID_FILE_OPEN 40003
#define ID_FILE_SAVEAS 40005
#define ID_WINDOW_CASCADE 40008
#define ID_WINDOW_TILE 40009
#define ID_FILE_CLOSE 40010
#define ID_FILE_CLOSEALL 40011
#define ID_EDIT_CUT 40015
#define ID_EDIT_COPY 40016
#define ID_EDIT_PASTE 40017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40020
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -7,13 +7,13 @@ TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = alphablend
TARGET_NAME = simple
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak

View File

@@ -0,0 +1,15 @@
/*
* The simplest Windows program you will ever write.
*
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
*
* Colin Peters <colinp at ma.kcom.ne.jp>, July 1, 2001.
*/
#include <windows.h>
int STDCALL
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
MessageBox (NULL, "Hello, ReactOS!", "Hello", MB_OK);
return 0;
}

View File

@@ -1,6 +0,0 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View File

@@ -1,52 +0,0 @@
#include <windows.h>
#include <stdio.h>
#include <mmsystem.h>
// WINE's mmsystem.h doesn't seem to define these properly:
#define MIDIOUTCAPS MIDIOUTCAPSA
#define MIDIINCAPS MIDIINCAPSA
#undef midiOutGetDevCaps
#define midiOutGetDevCaps midiOutGetDevCapsA
#undef midiInGetDevCaps
#define midiInGetDevCaps midiInGetDevCapsA
int main()
{
UINT outs = midiOutGetNumDevs();
// UINT ins = midiInGetNumDevs();
MIDIOUTCAPS outcaps;
// MIDIINCAPS incaps;
int c;
printf("MIDI output devices: %d\n", outs);
for (c = 0; c < outs; c ++)
{
if (midiOutGetDevCaps(c, &outcaps, sizeof(MIDIOUTCAPS)) == MMSYSERR_NOERROR)
printf("Device #%d: %s\n", c, outcaps.szPname);
}
printf("Opening MIDI output #0\n");
HMIDIOUT Handle = NULL;
UINT Result = midiOutOpen(&Handle, 0, 0, 0, CALLBACK_NULL);
printf("Result == %d Handle == %d\n", Result, (int)Handle);
// play something:
midiOutShortMsg(Handle, 0x007f3090);
/*
printf("\nMIDI input devices: %d\n", ins);
for (c = 0; c < ins; c ++)
{
midiInGetDevCaps(c, &incaps, sizeof(incaps));
printf("Device #%d: %s\n", c, incaps.szPname);
}
*/
return 0;
}

View File

@@ -1,30 +0,0 @@
#include <defines.h>
#include <reactos/resource.h>
#include "resource.h"
IDR_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", ID_FILE_NEW
MENUITEM "&Open...", ID_FILE_OPEN
MENUITEM "Save &As...", ID_FILE_SAVEAS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Close", ID_FILE_CLOSE, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit", GRAYED
BEGIN
MENUITEM "C&ut", ID_EDIT_CUT
MENUITEM "&Copy", ID_EDIT_COPY
MENUITEM "&Paste", ID_EDIT_PASTE
END
POPUP "&Window", GRAYED
BEGIN
MENUITEM "&Tile", ID_WINDOW_TILE
MENUITEM "&Cascade", ID_WINDOW_CASCADE
END
END

View File

@@ -1,6 +0,0 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View File

@@ -1,21 +0,0 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = moztest
TARGET_SDKLIBS = ntdll.a ws2_32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,250 +0,0 @@
/*
* Mozilla Test
* Copyright (C) 2004 Filip Navara
*/
#include <winsock.h>
#include <stdio.h>
ULONG DbgPrint(PCH Format,...);
#define DBG(x) \
printf("%s:%i - %s", __FILE__, __LINE__, x); \
DbgPrint("%s:%i - %s", __FILE__, __LINE__, x);
int SocketTest()
{
/*
* A socket pair is often used for interprocess communication,
* so we need to make sure neither socket is associated with
* the I/O completion port; otherwise it can't be used by a
* child process.
*
* The default implementation below cannot be used for NT
* because PR_Accept would have associated the I/O completion
* port with the listening and accepted sockets.
*/
SOCKET listenSock;
SOCKET osfd[2];
struct sockaddr_in selfAddr, peerAddr;
int addrLen;
WORD wVersionRequested;
WSADATA wsaData;
int err;
/*
* Initialization.
*/
wVersionRequested = MAKEWORD( 2, 2 );
DBG("Calling WSAStartup\n");
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
DBG("WSAStartup failed\n");
return 1;
}
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
DBG("WSAStartup version unacceptable\n");
WSACleanup( );
return 1;
}
/* The WinSock DLL is acceptable. Proceed. */
DBG("Calling socket\n");
osfd[0] = osfd[1] = INVALID_SOCKET;
listenSock = socket(AF_INET, SOCK_STREAM, 0);
if (listenSock == INVALID_SOCKET) {
DBG("socket failed\n");
goto failed;
}
selfAddr.sin_family = AF_INET;
selfAddr.sin_port = 0;
selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */
addrLen = sizeof(selfAddr);
DBG("Calling bind\n");
if (bind(listenSock, (struct sockaddr *) &selfAddr,
addrLen) == SOCKET_ERROR) {
DBG("bind failed\n");
goto failed;
}
DBG("Calling getsockname\n");
if (getsockname(listenSock, (struct sockaddr *) &selfAddr,
&addrLen) == SOCKET_ERROR) {
DBG("getsockname failed\n");
goto failed;
}
DBG("Calling listen\n");
if (listen(listenSock, 5) == SOCKET_ERROR) {
DBG("listen failed\n");
goto failed;
}
DBG("Calling socket\n");
osfd[0] = socket(AF_INET, SOCK_STREAM, 0);
if (osfd[0] == INVALID_SOCKET) {
DBG("socket failed\n");
goto failed;
}
selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
/*
* Only a thread is used to do the connect and accept.
* I am relying on the fact that connect returns
* successfully as soon as the connect request is put
* into the listen queue (but before accept is called).
* This is the behavior of the BSD socket code. If
* connect does not return until accept is called, we
* will need to create another thread to call connect.
*/
DBG("Calling connect\n");
if (connect(osfd[0], (struct sockaddr *) &selfAddr,
addrLen) == SOCKET_ERROR) {
DBG("connect failed\n");
goto failed;
}
/*
* A malicious local process may connect to the listening
* socket, so we need to verify that the accepted connection
* is made from our own socket osfd[0].
*/
DBG("Calling getsockname\n");
if (getsockname(osfd[0], (struct sockaddr *) &selfAddr,
&addrLen) == SOCKET_ERROR) {
DBG("getsockname failed\n");
goto failed;
}
DBG("Calling accept\n");
osfd[1] = accept(listenSock, (struct sockaddr *) &peerAddr, &addrLen);
if (osfd[1] == INVALID_SOCKET) {
DBG("accept failed\n");
goto failed;
}
if (peerAddr.sin_port != selfAddr.sin_port) {
/* the connection we accepted is not from osfd[0] */
DBG("peerAddr.sin_port != selfAddr.sin_port\n");
goto failed;
}
DBG("Hurray!\n");
closesocket(listenSock);
closesocket(osfd[0]);
closesocket(osfd[1]);
WSACleanup();
return 0;
failed:
if (listenSock != INVALID_SOCKET) {
closesocket(listenSock);
}
if (osfd[0] != INVALID_SOCKET) {
closesocket(osfd[0]);
}
if (osfd[1] != INVALID_SOCKET) {
closesocket(osfd[1]);
}
WSACleanup();
return 1;
}
int VirtualTest()
{
DWORD dwErr;
SYSTEM_INFO si;
HANDLE hMap;
PBYTE pBufferStart;
PCHAR pszFileName = "test.txt";
ULONG dwMaxSize = strlen(pszFileName);
DBG("Calling CreateFileMappingA\n");
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE | SEC_RESERVE, 0, dwMaxSize, pszFileName);
if (!hMap)
{
DBG("CreateFileMappingA failed\n");
return 1;
}
dwErr = GetLastError();
DBG("Calling MapViewOfFile\n");
pBufferStart = (BYTE *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pBufferStart)
{
DBG("MapViewOfFile failed\n");
return 1;
}
GetSystemInfo(&si);
if (dwErr == ERROR_ALREADY_EXISTS)
{
DBG("MapViewOfFile returned ERROR_ALREADY_EXISTS\n");
DBG("This really shouldn't happen, but it's not fatal.\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 1;
}
else
{
DBG("Calling VirtualAlloc\n");
if (!VirtualAlloc(pBufferStart, si.dwPageSize, MEM_COMMIT, PAGE_READWRITE))
{
DBG("VirtualAlloc failed\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 1;
}
}
DBG("Hurray!\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 0;
}
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Usage: %s test_name\n\n", argv[0]);
printf("Valid test names:\n");
printf("\tsocket\n");
printf("\tvirtual\n");
return 0;
}
if (!stricmp(argv[1], "socket"))
return SocketTest();
if (!stricmp(argv[1], "virtual"))
return VirtualTest();
printf("Test '%s' doesn't exist\n", argv[1]);
return 0;
}

View File

@@ -10,7 +10,7 @@ CLT_OBJECTS = msclient.o
PROGS = msserver.exe msclient.exe
CFLAGS = $(STD_CFLAGS)
BASE_CFLAGS = -I$(PATH_TO_TOP)/include -Wall -Werror
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
@@ -42,6 +42,11 @@ $(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
endif # BOOTCD_INSTALL
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
msserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o msserver.exe
$(NM) --numeric-sort msserver.exe > msserver.sym

View File

@@ -1,236 +0,0 @@
#include <windows.h>
#include <stdio.h>
typedef struct _THRDCREATEWIN
{
HANDLE hThread;
DWORD ThreadId;
LPSTR Caption;
HWND *Parent;
HWND Window;
DWORD Style;
POINT Position;
SIZE Size;
} THRDCREATEWIN, *PTHRDCREATEWIN;
static HINSTANCE hAppInstance;
static HANDLE WinCreatedEvent;
static THRDCREATEWIN wnds[3];
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI
WindowThreadProc(LPVOID lpParameter)
{
MSG msg;
char caption[64];
PTHRDCREATEWIN cw = (PTHRDCREATEWIN)lpParameter;
sprintf(caption, cw->Caption, GetCurrentThreadId());
cw->Window = CreateWindow("MultiClass",
caption,
cw->Style | WS_VISIBLE,
cw->Position.x,
cw->Position.y,
cw->Size.cx,
cw->Size.cy,
(cw->Parent ? *(cw->Parent) : 0),
NULL,
hAppInstance,
NULL);
SetEvent(WinCreatedEvent);
if(!cw->Window)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return 1;
}
CreateWindow("BUTTON","Sleep",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 10, 10, 70, 23, cw->Window, (PVOID)1, hAppInstance, NULL);
CreateWindow("BUTTON","1",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 83, 10, 20, 23, cw->Window, (PVOID)2, hAppInstance, NULL);
CreateWindow("BUTTON","2",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 105, 10, 20, 23, cw->Window, (PVOID)3, hAppInstance, NULL);
CreateWindow("BUTTON","3",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 127, 10, 20, 23, cw->Window, (PVOID)4, hAppInstance, NULL);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
int i;
HANDLE Threads[3];
hAppInstance = hInstance;
WinCreatedEvent = CreateEvent(NULL,
FALSE,
FALSE,
NULL);
if(!WinCreatedEvent)
{
fprintf(stderr, "Failed to create event (last error 0x%lX)\n",
GetLastError());
return 1;
}
wc.lpszClassName = "MultiClass";
wc.lpfnWndProc = MultiWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR) IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR) IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
wnds[0].Caption = "TopLevel1 (ThreadID: %d)";
wnds[0].Parent = NULL;
wnds[0].Style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[0].Position.x = wnds[0].Position.y = 0;
wnds[0].Size.cx = 320;
wnds[0].Size.cy = 240;
wnds[1].Caption = "Child1 of TopLevel1 (ThreadID: %d)";
wnds[1].Parent = &wnds[0].Window;
wnds[1].Style = WS_CHILD | WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[1].Position.x = 20;
wnds[1].Position.y = 120;
wnds[1].Size.cx = wnds[1].Size.cy = 240;
wnds[2].Caption = "TopLevel2 (ThreadID: %d)";
wnds[2].Parent = NULL;
wnds[2].Style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[2].Position.x = 400;
wnds[2].Position.y = 0;
wnds[2].Size.cx = 160;
wnds[2].Size.cy = 490;
for(i = 0; i < (sizeof(wnds) / sizeof(THRDCREATEWIN)); i++)
{
wnds[i].hThread = CreateThread(NULL,
0,
WindowThreadProc,
&wnds[i],
0,
&wnds[i].ThreadId);
Threads[i] = wnds[i].hThread;
if(!wnds[i].hThread)
{
fprintf(stderr, "CreateThread #%i failed (last error 0x%lX)\n",
i, GetLastError());
return 1;
}
WaitForSingleObject(WinCreatedEvent, INFINITE);
}
WaitForMultipleObjects(sizeof(Threads) / sizeof(HANDLE), &Threads[0], TRUE, INFINITE);
UnregisterClass("MultiClass", hInstance);
return 0;
}
LRESULT CALLBACK MultiWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT Client;
HBRUSH Brush;
DWORD Ret;
static COLORREF Colors[] =
{
RGB(0x00, 0x00, 0x00),
RGB(0x80, 0x00, 0x00),
RGB(0x00, 0x80, 0x00),
RGB(0x00, 0x00, 0x80),
RGB(0x80, 0x80, 0x00),
RGB(0x80, 0x00, 0x80),
RGB(0x00, 0x80, 0x80),
RGB(0x80, 0x80, 0x80),
RGB(0xff, 0x00, 0x00),
RGB(0x00, 0xff, 0x00),
RGB(0x00, 0x00, 0xff),
RGB(0xff, 0xff, 0x00),
RGB(0xff, 0x00, 0xff),
RGB(0x00, 0xff, 0xff),
RGB(0xff, 0xff, 0xff)
};
static unsigned CurrentColor = 0;
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &Client);
Brush = CreateSolidBrush(Colors[CurrentColor]);
FillRect(hDC, &Client, Brush);
DeleteObject(Brush);
CurrentColor++;
if (sizeof(Colors) / sizeof(Colors[0]) <= CurrentColor)
{
CurrentColor = 0;
}
EndPaint(hWnd, &ps);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case 1:
Sleep(20000);
break;
case 2:
case 3:
case 4:
if(SendMessageTimeout(wnds[LOWORD(wParam) - 2].Window, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 1000, &Ret))
{
DbgPrint("SendMessageTimeout() OK");
MessageBox(hWnd, "SendMessageTimeout() OK", NULL, 0);
}
else
{
if(GetLastError() == ERROR_TIMEOUT)
{
DbgPrint("SendMessageTimeout() Timeout");
MessageBox(hWnd, "SendMessageTimeout() Timeout", NULL, 0);
}
else
{
DbgPrint("SendMessageTimeout() Failed");
MessageBox(hWnd, "SendMessageTimeout() Failed", NULL, 0);
}
}
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View File

@@ -99,7 +99,7 @@ int main(int argc, char* argv[])
hMutex = CreateMutexW(NULL, FALSE, L"TestMutex");
if (hMutex == INVALID_HANDLE_VALUE)
{
dprintf("CreateMutex() failed! Error: %lu\n", GetLastError());
dprintf("CreateMutex() failed! Error: %lu\n", GetLastError);
return 0;
}
dprintf("CreateMutex() succeeded!\n");

View File

@@ -1,22 +0,0 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = nameserverlist
TARGET_SDKLIBS = iphlpapi.a ws2_32.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -1,32 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <iphlpapi.h>
int main( int argc, char **argv ) {
ULONG OutBufLen = 0;
PFIXED_INFO pFixedInfo;
PIP_ADDR_STRING Addr;
GetNetworkParams(NULL, &OutBufLen);
pFixedInfo = malloc(OutBufLen);
if (!pFixedInfo) {
printf( "Failed to alloc %d bytes.\n", (int)OutBufLen );
return 1;
}
printf( "%d Bytes allocated\n", (int)OutBufLen );
GetNetworkParams(pFixedInfo,&OutBufLen);
for( Addr = &pFixedInfo->DnsServerList;
Addr;
Addr = Addr->Next ) {
printf( "%c%s\n",
Addr == pFixedInfo->CurrentDnsServer ? '*' : ' ',
Addr->IpAddress.String );
}
free( pFixedInfo );
return 0;
}

View File

@@ -10,7 +10,7 @@ CLT_OBJECTS = npclient.o
PROGS = npserver.exe npclient.exe
CFLAGS = $(STD_CFLAGS)
BASE_CFLAGS = -I$(PATH_TO_TOP)/include -Wall -Werror
LIBS = $(SDK_PATH_LIB)/kernel32.a
@@ -41,6 +41,11 @@ $(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
endif # BOOTCD_INSTALL
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
npserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o npserver.exe
$(NM) --numeric-sort npserver.exe > npserver.sym

View File

@@ -5,7 +5,6 @@
* Version: 1.0 */
#include <windows.h>
#include <stdlib.h>
#define W_WIDTH 320
#define W_HEIGHT 240

View File

@@ -1,4 +1,3 @@
# $Id: makefile,v 1.1 2004/02/11 21:04:18 hbirr Exp $
PATH_TO_TOP = ../../..
@@ -8,8 +7,11 @@ TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = pesum
TARGET_NAME = pipe
TARGET_CFLAGS = -DSTANDALONE -Wall -Werror
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o

View File

@@ -0,0 +1,605 @@
/*
* Unit tests for named pipe functions in Wine
*
* Copyright (c) 2002 Dan Kegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#ifndef STANDALONE
#include "wine/test.h"
#else
#include <assert.h>
#define START_TEST(name) main(int argc, char **argv)
#define ok(condition, msg) assert(condition)
#define todo_wine
#endif
#ifndef STANDALONE
#include <wtypes.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#else
#include <windows.h>
#endif
#define PIPENAME "\\\\.\\PiPe\\tests_" __FILE__
static void msg(const char *s)
{
DWORD cbWritten;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), s, strlen(s), &cbWritten, NULL);
}
void test_CreateNamedPipe(void)
{
HANDLE hnp;
HANDLE hFile;
const char obuf[] = "Bit Bucket";
char ibuf[32];
DWORD written;
DWORD readden;
msg("test_CreateNamedPipe starting\n");
/* Bad parameter checks */
hnp = CreateNamedPipe("not a named pipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
if (hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
/* Is this the right way to notify user of skipped tests? */
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
"CreateNamedPipe not supported on this platform, skipping tests.");
return;
}
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_NAME,
"CreateNamedPipe should fail if name doesn't start with \\\\.\\pipe");
hnp = CreateNamedPipe(NULL,
PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
"CreateNamedPipe should fail if name is NULL");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_FILE_NOT_FOUND,
"connecting to nonexistent named pipe should fail with ERROR_FILE_NOT_FOUND");
/* Functional checks */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
todo_wine {
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed");
}
/* don't try to do i/o if one side couldn't be opened, as it hangs */
if (hFile != INVALID_HANDLE_VALUE) {
HANDLE hFile2;
/* Make sure we can read and write a few bytes in both directions */
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile");
ok(written == sizeof(obuf), "write file len");
ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile");
ok(readden == sizeof(obuf), "read file len");
ok(memcmp(obuf, ibuf, written) == 0, "content check");
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile");
ok(written == sizeof(obuf), "write file len");
ok(ReadFile(hnp, ibuf, sizeof(obuf), &readden, NULL), "ReadFile");
ok(readden == sizeof(obuf), "read file len");
ok(memcmp(obuf, ibuf, written) == 0, "content check");
/* Picky conformance tests */
/* Verify that you can't connect to pipe again
* until server calls DisconnectNamedPipe+ConnectNamedPipe
* or creates a new pipe
* case 1: other client not yet closed
*/
hFile2 = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile2 == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe before other client closes should fail with ERROR_PIPE_BUSY");
ok(CloseHandle(hFile), "CloseHandle");
/* case 2: other client already closed */
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail with ERROR_PIPE_BUSY");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe");
/* case 3: server has called DisconnectNamedPipe but not ConnectNamed Pipe */
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile == INVALID_HANDLE_VALUE,
"connecting to named pipe after other client closes but before DisconnectNamedPipe should fail");
ok(GetLastError() == ERROR_PIPE_BUSY,
"connecting to named pipe after other client closes but before ConnectNamedPipe should fail with ERROR_PIPE_BUSY");
/* to be complete, we'd call ConnectNamedPipe here and loop,
* but by default that's blocking, so we'd either have
* to turn on the uncommon nonblocking mode, or
* use another thread.
*/
}
ok(CloseHandle(hnp), "CloseHandle");
msg("test_CreateNamedPipe returning\n");
}
void test_CreateNamedPipe_instances_must_match(void)
{
HANDLE hnp, hnp2;
/* Check no mismatch */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
ok(CloseHandle(hnp), "CloseHandle");
ok(CloseHandle(hnp2), "CloseHandle");
/* Check nMaxInstances */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
todo_wine {
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_PIPE_BUSY, "nMaxInstances not obeyed");
}
ok(CloseHandle(hnp), "CloseHandle");
/* Check PIPE_ACCESS_* */
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
todo_wine {
hnp2 = CreateNamedPipe(PIPENAME, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp2 == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_ACCESS_DENIED, "PIPE_ACCESS_* mismatch allowed");
}
ok(CloseHandle(hnp), "CloseHandle");
/* etc, etc */
}
/** implementation of alarm() */
static DWORD CALLBACK alarmThreadMain(LPVOID arg)
{
DWORD timeout = (DWORD) arg;
msg("alarmThreadMain\n");
Sleep(timeout);
ok(FALSE, "alarm");
ExitProcess(1);
return 1;
}
HANDLE hnp = INVALID_HANDLE_VALUE;
/** Trivial byte echo server - disconnects after each session */
static DWORD CALLBACK serverThreadMain1(LPVOID arg)
{
int i;
msg("serverThreadMain1 start\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain1", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
for (i = 0; ; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD success;
/* Wait for client to connect */
msg("Server calling ConnectNamedPipe...\n");
ok(ConnectNamedPipe(hnp, NULL)
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe");
msg("ConnectNamedPipe returned.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
msg("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
msg("Server done reading.\n");
ok(success, "ReadFile");
msg("Server writing...\n");
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile");
msg("Server done writing.\n");
ok(written == readden, "write file len");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe");
}
}
/** Trivial byte echo server - closes after each connection */
static DWORD CALLBACK serverThreadMain2(LPVOID arg)
{
int i;
HANDLE hnpNext = 0;
msg("serverThreadMain2\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
for (i = 0; ; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD success;
/* Wait for client to connect */
msg("Server calling ConnectNamedPipe...\n");
ok(ConnectNamedPipe(hnp, NULL)
|| GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe");
msg("ConnectNamedPipe returned.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
msg("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
msg("Server done reading.\n");
ok(success, "ReadFile");
msg("Server writing...\n");
ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile");
msg("Server done writing.\n");
ok(written == readden, "write file len");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe");
/* Set up next echo server */
hnpNext =
CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 2,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnpNext != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
ok(CloseHandle(hnp), "CloseHandle");
hnp = hnpNext;
}
}
/** Trivial byte echo server - uses overlapped named pipe calls */
static DWORD CALLBACK serverThreadMain3(LPVOID arg)
{
int i;
HANDLE hEvent;
msg("serverThreadMain3\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain3", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
hEvent = CreateEvent(NULL, // security attribute
TRUE, // manual reset event
FALSE, // initial state
NULL); // name
ok(hEvent != NULL, "CreateEvent");
for (i = 0; ; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD dummy;
DWORD success;
OVERLAPPED oOverlap;
int letWFSOEwait = (i & 2);
int letGORwait = (i & 1);
DWORD err;
memset(&oOverlap, 0, sizeof(oOverlap));
oOverlap.hEvent = hEvent;
/* Wait for client to connect */
msg("Server calling overlapped ConnectNamedPipe...\n");
success = ConnectNamedPipe(hnp, &oOverlap);
err = GetLastError();
ok(success || err == ERROR_IO_PENDING
|| err == ERROR_PIPE_CONNECTED, "overlapped ConnectNamedPipe");
msg("overlapped ConnectNamedPipe returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ConnectNamedPipe");
success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult");
success = GetOverlappedResult(hnp, &oOverlap, &dummy, TRUE);
}
ok(success, "GetOverlappedResult ConnectNamedPipe");
msg("overlapped ConnectNamedPipe operation complete.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
msg("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), NULL, &oOverlap);
msg("Server ReadFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile");
msg("overlapped ReadFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ReadFile");
success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult");
success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE);
}
msg("Server done reading.\n");
ok(success, "overlapped ReadFile");
msg("Server writing...\n");
success = WriteFile(hnp, buf, readden, NULL, &oOverlap);
msg("Server WriteFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile");
msg("overlapped WriteFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait WriteFile");
success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult");
success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE);
}
msg("Server done writing.\n");
ok(success, "overlapped WriteFile");
ok(written == readden, "write file len");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe");
}
}
static void exercizeServer(const char *pipename, HANDLE serverThread)
{
int i;
msg("exercizeServer starting\n");
for (i = 0; i < 8; i++) {
HANDLE hFile;
const char obuf[] = "Bit Bucket";
char ibuf[32];
DWORD written;
DWORD readden;
int loop;
for (loop = 0; loop < 3; loop++) {
DWORD err;
msg("Client connecting...\n");
/* Connect to the server */
hFile = CreateFileA(pipename, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE)
break;
err = GetLastError();
if (loop == 0)
ok(err == ERROR_PIPE_BUSY || err == ERROR_FILE_NOT_FOUND, "connecting to pipe");
else
ok(err == ERROR_PIPE_BUSY, "connecting to pipe");
msg("connect failed, retrying\n");
Sleep(200);
}
ok(hFile != INVALID_HANDLE_VALUE, "client opening named pipe");
/* Make sure it can echo */
memset(ibuf, 0, sizeof(ibuf));
msg("Client writing...\n");
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile to client end of pipe");
ok(written == sizeof(obuf), "write file len");
msg("Client reading...\n");
ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile from client end of pipe");
ok(readden == sizeof(obuf), "read file len");
ok(memcmp(obuf, ibuf, written) == 0, "content check");
msg("Client closing...\n");
ok(CloseHandle(hFile), "CloseHandle");
}
ok(TerminateThread(serverThread, 0), "TerminateThread");
CloseHandle(hnp);
msg("exercizeServer returning\n");
}
void test_NamedPipe_2(void)
{
HANDLE serverThread;
DWORD serverThreadId;
HANDLE alarmThread;
DWORD alarmThreadId;
msg("test_NamedPipe_2 starting\n");
/* Set up a ten second timeout */
alarmThread = CreateThread(NULL, 0, alarmThreadMain, (void *) 10000, 0, &alarmThreadId);
/* The servers we're about to exercize do try to clean up carefully,
* but to reduce the change of a test failure due to a pipe handle
* leak in the test code, we'll use a different pipe name for each server.
*/
/* Try server #1 */
serverThread = CreateThread(NULL, 0, serverThreadMain1, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread");
exercizeServer(PIPENAME "serverThreadMain1", serverThread);
/* Try server #2 */
serverThread = CreateThread(NULL, 0, serverThreadMain2, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread");
exercizeServer(PIPENAME "serverThreadMain2", serverThread);
/* Try server #3 */
serverThread = CreateThread(NULL, 0, serverThreadMain3, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread");
exercizeServer(PIPENAME "serverThreadMain3", serverThread);
ok(TerminateThread(alarmThread, 0), "TerminateThread");
msg("test_NamedPipe_2 returning\n");
}
void test_DisconnectNamedPipe(void)
{
HANDLE hnp;
HANDLE hFile;
const char obuf[] = "Bit Bucket";
char ibuf[32];
DWORD written;
DWORD readden;
hnp = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL) == 0
&& GetLastError() == ERROR_PIPE_LISTENING, "WriteFile to not-yet-connected pipe");
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
&& GetLastError() == ERROR_PIPE_LISTENING, "ReadFile from not-yet-connected pipe");
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
todo_wine {
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed");
}
/* don't try to do i/o if one side couldn't be opened, as it hangs */
if (hFile != INVALID_HANDLE_VALUE) {
/* see what happens if server calls DisconnectNamedPipe
* when there are bytes in the pipe
*/
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile");
ok(written == sizeof(obuf), "write file len");
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe while messages waiting");
ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL) == 0
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED, "WriteFile to disconnected pipe");
ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL) == 0
&& GetLastError() == ERROR_PIPE_NOT_CONNECTED,
"ReadFile from disconnected pipe with bytes waiting");
ok(CloseHandle(hFile), "CloseHandle");
}
ok(CloseHandle(hnp), "CloseHandle");
}
int
START_TEST(pipe)
{
msg("test 1 of 4:\n");
test_DisconnectNamedPipe();
msg("test 2 of 4:\n");
test_CreateNamedPipe_instances_must_match();
msg("test 3 of 4:\n");
test_NamedPipe_2();
msg("test 4 of 4:\n");
test_CreateNamedPipe();
msg("all tests done\n");
return 0;
}

View File

@@ -1,6 +0,0 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

Some files were not shown because too many files have changed in this diff Show More