From c5f948c2568dc9b0518569b3febcc9ad09965e3b Mon Sep 17 00:00:00 2001
From: Patrik Stridvall <ps@leissner.se>
Date: Sat, 15 Jul 2000 21:32:55 +0000
Subject: [PATCH] - Minor API files fixes. - Minor bug fixes and additions.

---
 tools/winapi_check/modules.dat        | 27 +++++++++++++----------
 tools/winapi_check/win32/crtdll.api   |  3 +--
 tools/winapi_check/win32/kernel32.api |  3 +++
 tools/winapi_check/win32/ntdll.api    |  4 +++-
 tools/winapi_check/win32/oleaut32.api |  2 ++
 tools/winapi_check/win32/setupapi.api | 15 +++++++++++++
 tools/winapi_check/win32/shlwapi.api  |  1 +
 tools/winapi_check/win32/user32.api   |  1 +
 tools/winapi_check/win32/ws2_32.api   | 30 +++++++++++++++++++++++++-
 tools/winapi_check/winapi.pm          | 31 +++++++++++++++++++++++++++
 tools/winapi_check/winapi_check       |  6 ++++++
 tools/winapi_check/winapi_local.pm    |  2 +-
 tools/winapi_check/winapi_options.pm  |  4 ++--
 13 files changed, 111 insertions(+), 18 deletions(-)
 create mode 100644 tools/winapi_check/win32/setupapi.api

diff --git a/tools/winapi_check/modules.dat b/tools/winapi_check/modules.dat
index e33f5f00daa..7f3abad1a22 100644
--- a/tools/winapi_check/modules.dat
+++ b/tools/winapi_check/modules.dat
@@ -41,9 +41,9 @@ dlls/ddraw/dclipper
 
 dlls/dinput
 
-% dlls/dplayx/dplay.spec
+% dlls/dplay/dplay.spec
 
-dlls/dplayx
+dlls/dplay
 
 % dlls/dplayx/dplayx.spec
 
@@ -128,10 +128,6 @@ memory
 misc
 windows
 
-% dlls/kernel/wow32.spec
-
-relay32
-
 % dlls/kernel/wprocs.spec
 
 if1632
@@ -267,6 +263,10 @@ dlls/rasapi32
 
 dlls/richedit
 
+% dlls/setupapi/setupapi.spec
+
+dlls/setupapi
+
 % dlls/setupx/setupx.spec
 
 dlls/setupx
@@ -281,14 +281,14 @@ misc
 dlls/shell32
 memory
 
-% dlls/shell32/shfolder.spec
+% dlls/shfolder/shfolder.spec
 
-dlls/shell32
+dlls/shfolder
 
-% dlls/shell32/shlwapi.spec
+% dlls/shlwapi/shlwapi.spec
 
 dlls/shell32
-memory
+dlls/shlwapi
 
 % dlls/sound/sound.spec
 
@@ -461,9 +461,10 @@ dlls/winsock
 
 dlls/winsock
 
-% dlls/winsock/wsock32.spec
+% dlls/wsock32/wsock32.spec
 
 dlls/winsock
+dlls/wsock32
 misc
 
 % dlls/winspool/winspool.drv.spec
@@ -471,6 +472,10 @@ misc
 dlls/winspool
 win32
 
+% dlls/wow32/wow32.spec
+
+relay32
+
 % dlls/x11drv/x11drv.spec
 
 dlls/x11drv
diff --git a/tools/winapi_check/win32/crtdll.api b/tools/winapi_check/win32/crtdll.api
index c8faf4850b9..3b25e00d154 100644
--- a/tools/winapi_check/win32/crtdll.api
+++ b/tools/winapi_check/win32/crtdll.api
@@ -14,12 +14,12 @@ LONG
 UINT
 WCHAR
 clock_t
+size_t
 time_t
 
 %long # --forbidden
 
 int
-long
 unsigned int
 unsigned long
 
@@ -35,7 +35,6 @@ LPINT
 LPSTR *
 LPSTR **
 LPVOID
-LPWSTR *
 PCONTEXT
 PEXCEPTION_FRAME
 PEXCEPTION_FRAME *
diff --git a/tools/winapi_check/win32/kernel32.api b/tools/winapi_check/win32/kernel32.api
index e293880ddce..d5a589c4411 100644
--- a/tools/winapi_check/win32/kernel32.api
+++ b/tools/winapi_check/win32/kernel32.api
@@ -23,6 +23,7 @@ LONG
 UINT
 WCHAR
 WORD
+WOW_HANDLE_TYPE
 
 %long --pointer
 
@@ -78,6 +79,7 @@ LONG *
 LPBOOL
 LPBYTE
 LPCHAR_INFO
+LPCOMMCONFIG
 LPCOMMPROP
 LPCOMMTIMEOUTS
 LPCOMSTAT
@@ -122,6 +124,7 @@ OFSTRUCT *
 OSVERSIONINFOA *
 OSVERSIONINFOW *
 PAPCFUNC
+PBOOL
 PDWORD
 PEXCEPTION_POINTERS
 PHANDLE
diff --git a/tools/winapi_check/win32/ntdll.api b/tools/winapi_check/win32/ntdll.api
index e81dea6ff42..9d726089137 100644
--- a/tools/winapi_check/win32/ntdll.api
+++ b/tools/winapi_check/win32/ntdll.api
@@ -31,7 +31,10 @@ WCHAR
 %long # --forbidden
 
 int
+long
+size_t
 unsigned int
+unsigned long
 
 %longlong
 
@@ -90,7 +93,6 @@ PVOID *
 PWCHAR
 VOID *
 struct _TEB *
-va_list
 void *
 
 %str
diff --git a/tools/winapi_check/win32/oleaut32.api b/tools/winapi_check/win32/oleaut32.api
index 1fec81ce7fc..b2bad2f0459 100644
--- a/tools/winapi_check/win32/oleaut32.api
+++ b/tools/winapi_check/win32/oleaut32.api
@@ -71,6 +71,7 @@ USHORT *
 VARIANT *
 VARIANTARG *
 VARIANT_BOOL *
+VARTYPE *
 char *
 double *
 short *
@@ -81,6 +82,7 @@ void **
 
 LPCOLESTR
 LPOLESTR
+LPSTR
 
 %void
 
diff --git a/tools/winapi_check/win32/setupapi.api b/tools/winapi_check/win32/setupapi.api
new file mode 100644
index 00000000000..fb2a4a068ac
--- /dev/null
+++ b/tools/winapi_check/win32/setupapi.api
@@ -0,0 +1,15 @@
+%long
+
+BOOL
+DWORD
+
+%ptr
+
+PSP_FILE_CALLBACK_A
+PSP_FILE_CALLBACK_W
+PVOID
+
+%str
+
+PCSTR
+PWSTR
diff --git a/tools/winapi_check/win32/shlwapi.api b/tools/winapi_check/win32/shlwapi.api
index f143722fa81..584f7fc1fe5 100644
--- a/tools/winapi_check/win32/shlwapi.api
+++ b/tools/winapi_check/win32/shlwapi.api
@@ -11,6 +11,7 @@ HMENU
 HPALETTE
 HRESULT
 HWND
+UCHAR
 UINT
 WCHAR
 WORD
diff --git a/tools/winapi_check/win32/user32.api b/tools/winapi_check/win32/user32.api
index b5c6e3f835d..5a59faa0421 100644
--- a/tools/winapi_check/win32/user32.api
+++ b/tools/winapi_check/win32/user32.api
@@ -16,6 +16,7 @@ HCURSOR
 HDC
 HDDEDATA
 HDESK
+HDEVNOTIFY
 HDWP
 HFONT
 HHOOK
diff --git a/tools/winapi_check/win32/ws2_32.api b/tools/winapi_check/win32/ws2_32.api
index 03579549359..e2fb857125c 100644
--- a/tools/winapi_check/win32/ws2_32.api
+++ b/tools/winapi_check/win32/ws2_32.api
@@ -3,18 +3,46 @@
 BOOL
 DWORD
 GROUP
+HANDLE
+HWND
 INT
 LONG
 SOCKET
 UINT
 WSAEVENT
+int
+u_long
+u_short
 
 %long # --forbidden
 
-int
+SOCKET16
 
 %ptr
 
+FARPROC
+INT *
 LPWSADATA
 LPWSANETWORKEVENTS
 LPWSAPROTOCOL_INFOA
+ULONG *
+char *
+struct WIN_hostent *
+struct WIN_protoent *
+struct WIN_servent *
+struct sockaddr *
+struct timeval *
+ws_fd_set32 *
+
+%str
+
+LPCSTR
+LPSTR
+
+%unknown
+
+struct in_addr
+
+%void
+
+void
\ No newline at end of file
diff --git a/tools/winapi_check/winapi.pm b/tools/winapi_check/winapi.pm
index ccf9bacd85f..cb5299267d1 100644
--- a/tools/winapi_check/winapi.pm
+++ b/tools/winapi_check/winapi.pm
@@ -183,6 +183,21 @@ sub read_spec_files {
 	    $win32api->parse_spec_file("$wine_dir/$file");
 	}
     }
+
+    foreach my $self ($win16api, $win32api) {
+	my $function_forward = \%{$self->{FUNCTION_FORWARD}};
+	my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
+	my $function_module = \%{$self->{FUNCTION_MODULE}};
+	
+	foreach my $forward_name (sort(keys(%$function_forward))) {
+	    $$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/;
+	    (my $from_module, my $to_module, my $external_name) = ($1, $2, $3);
+	    my $internal_name = $$function_internal_name{$external_name};
+	    if(defined($internal_name)) {
+		$$function_module{$internal_name} .= " & $from_module";
+	    }
+	}
+    }
 }
 
 sub read_all_spec_files {
@@ -215,8 +230,10 @@ sub parse_spec_file {
     my $output = \${$self->{OUTPUT}};
     my $function_arguments = \%{$self->{FUNCTION_ARGUMENTS}};
     my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
+    my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
     my $function_external_name = \%{$self->{FUNCTION_EXTERNAL_NAME}};
     my $function_stub = \%{$self->{FUNCTION_STUB}};
+    my $function_forward = \%{$self->{FUNCTION_FORWARD}};
     my $function_module = \%{$self->{FUNCTION_MODULE}};
     my $modules = \%{$self->{MODULES}};
     my $module_files = \%{$self->{MODULE_FILES}};
@@ -260,13 +277,19 @@ sub parse_spec_file {
 	    $ordinal = $1;
 
 	    # FIXME: Internal name existing more than once not handled properly
+	    $$function_internal_name{$external_name} = $internal_name;
 	    $$function_external_name{$internal_name} = $external_name;
 	    $$function_arguments{$internal_name} = $arguments;
 	    $$function_calling_convention{$internal_name} = $calling_convention;
 	    if(!$$function_module{$internal_name}) {
 		$$function_module{$internal_name} = "$module";
 	    } elsif($$function_module{$internal_name} !~ /$module/) {
+		if(0) {
+		    $$output->write("$file: $external_name: the internal function ($internal_name) " . 
+				    "already belongs to a module ($$function_module{$internal_name})\n");
+		}
 		$$function_module{$internal_name} .= " & $module";
+
 	    }
 
 	    if(0 && $$options->spec_mismatch) {
@@ -319,6 +342,14 @@ sub parse_spec_file {
 	    } elsif($$function_module{$internal_name} !~ /$module/) {
 		$$function_module{$internal_name} .= " & $module";
 	    }
+	} elsif(/^(\d+|@)\s+forward\s+(\S+)\s+(\S+)\.(\S+)$/) {
+	    $ordinal = $1;
+
+	    my $external_name = $2;
+	    my $forward_module = lc($3);
+	    my $forward_name = $4;
+
+	    $$function_forward{$external_name} = "$module:$forward_module.$forward_name";
 	} elsif(/^(\d+|@)\s+(equate|long|word|extern|forward)/) {
 	    # ignore
 	} else {
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index f5cedace8b8..407400f607d 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -447,6 +447,12 @@ foreach my $file ($options->c_files) {
 		    my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
 		    push @uc_modules32, "wine";
 
+		    foreach my $uc_module32 (@uc_modules32) {
+			if($uc_module32 =~ /^WS2_32$/) {
+			    push @uc_modules32, "WSOCK32"; 
+			}
+		    }
+
 		    $name1 = $internal_name;
 		    foreach my $uc_module32 (@uc_modules32) {
 			if($name1 =~ s/^$uc_module32\_//) { last; }
diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm
index 54ea0157f89..c1bef9cf85e 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -122,7 +122,7 @@ sub check_function {
 	$#argument_types--;
     }
     
-    if($internal_name =~ /^CRTDLL__ftol|CRTDLL__CIpow$/) { # FIXME: Kludge
+    if($internal_name =~ /^NTDLL__ftol|NTDLL__CIpow$/) { # FIXME: Kludge
 	# ignore
     } else {
 	my $n = 0;
diff --git a/tools/winapi_check/winapi_options.pm b/tools/winapi_check/winapi_options.pm
index 589424a94ff..2c374b56b4d 100644
--- a/tools/winapi_check/winapi_options.pm
+++ b/tools/winapi_check/winapi_options.pm
@@ -31,7 +31,7 @@ my %options = (
     "shared" =>  { default => 0, description => "show shared functions between Win16 and Win32" },
     "shared-segmented" =>  { default => 0, description => "segmented shared functions between Win16 and Win32 checking" },
 
-    "config" => { default => 1, description => "check configuration include consistancy" },
+    "config" => { default => 1, parent => "local", description => "check configuration include consistancy" },
     "config-unnessary" => { default => 0, parent => "config", description => "check for unnessary #include \"config.h\"" },
 
     "spec-mismatch" => { default => 0, description => "spec file mismatch checking" },
@@ -77,7 +77,7 @@ my %options = (
 
     "global" => { default => 1, description => "global checking" },
     "declared" => { default => 1, parent => "global", description => "declared checking" },
-    "implemented" => { default => 1, parent => "global", description => "implemented checking" },
+    "implemented" => { default => 1, parent => "local", description => "implemented checking" },
     "implemented-win32" => { default => 0, parent => "implemented", description => "implemented as win32 checking" },
     "include" => { default => 1, parent => "global", description => "include checking" },
     "headers" => { default => 0, parent => "global", description => "headers checking" },
-- 
GitLab