- Minor API files fixes.
- Minor bug fixes and additions.

diff --git a/tools/winapi_check/modules.dat b/tools/winapi_check/modules.dat
index e33f5f0..7f3abad 100644
--- a/tools/winapi_check/modules.dat
+++ b/tools/winapi_check/modules.dat
@@ -41,9 +41,9 @@
 
 dlls/dinput
 
-% dlls/dplayx/dplay.spec
+% dlls/dplay/dplay.spec
 
-dlls/dplayx
+dlls/dplay
 
 % dlls/dplayx/dplayx.spec
 
@@ -128,10 +128,6 @@
 misc
 windows
 
-% dlls/kernel/wow32.spec
-
-relay32
-
 % dlls/kernel/wprocs.spec
 
 if1632
@@ -267,6 +263,10 @@
 
 dlls/richedit
 
+% dlls/setupapi/setupapi.spec
+
+dlls/setupapi
+
 % dlls/setupx/setupx.spec
 
 dlls/setupx
@@ -281,14 +281,14 @@
 dlls/shell32
 memory
 
-% dlls/shell32/shfolder.spec
+% dlls/shfolder/shfolder.spec
+
+dlls/shfolder
+
+% dlls/shlwapi/shlwapi.spec
 
 dlls/shell32
-
-% dlls/shell32/shlwapi.spec
-
-dlls/shell32
-memory
+dlls/shlwapi
 
 % dlls/sound/sound.spec
 
@@ -461,9 +461,10 @@
 
 dlls/winsock
 
-% dlls/winsock/wsock32.spec
+% dlls/wsock32/wsock32.spec
 
 dlls/winsock
+dlls/wsock32
 misc
 
 % dlls/winspool/winspool.drv.spec
@@ -471,6 +472,10 @@
 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 c8faf48..3b25e00 100644
--- a/tools/winapi_check/win32/crtdll.api
+++ b/tools/winapi_check/win32/crtdll.api
@@ -14,12 +14,12 @@
 UINT
 WCHAR
 clock_t
+size_t
 time_t
 
 %long # --forbidden
 
 int
-long
 unsigned int
 unsigned long
 
@@ -35,7 +35,6 @@
 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 e293880..d5a589c 100644
--- a/tools/winapi_check/win32/kernel32.api
+++ b/tools/winapi_check/win32/kernel32.api
@@ -23,6 +23,7 @@
 UINT
 WCHAR
 WORD
+WOW_HANDLE_TYPE
 
 %long --pointer
 
@@ -78,6 +79,7 @@
 LPBOOL
 LPBYTE
 LPCHAR_INFO
+LPCOMMCONFIG
 LPCOMMPROP
 LPCOMMTIMEOUTS
 LPCOMSTAT
@@ -122,6 +124,7 @@
 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 e81dea6..9d72608 100644
--- a/tools/winapi_check/win32/ntdll.api
+++ b/tools/winapi_check/win32/ntdll.api
@@ -31,7 +31,10 @@
 %long # --forbidden
 
 int
+long
+size_t
 unsigned int
+unsigned long
 
 %longlong
 
@@ -90,7 +93,6 @@
 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 1fec81c..b2bad2f 100644
--- a/tools/winapi_check/win32/oleaut32.api
+++ b/tools/winapi_check/win32/oleaut32.api
@@ -71,6 +71,7 @@
 VARIANT *
 VARIANTARG *
 VARIANT_BOOL *
+VARTYPE *
 char *
 double *
 short *
@@ -81,6 +82,7 @@
 
 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 0000000..fb2a4a0
--- /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 f143722..584f7fc 100644
--- a/tools/winapi_check/win32/shlwapi.api
+++ b/tools/winapi_check/win32/shlwapi.api
@@ -11,6 +11,7 @@
 HPALETTE
 HRESULT
 HWND
+UCHAR
 UINT
 WCHAR
 WORD
diff --git a/tools/winapi_check/win32/user32.api b/tools/winapi_check/win32/user32.api
index b5c6e3f..5a59faa 100644
--- a/tools/winapi_check/win32/user32.api
+++ b/tools/winapi_check/win32/user32.api
@@ -16,6 +16,7 @@
 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 0357954..e2fb857 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 ccf9bac..cb52992 100644
--- a/tools/winapi_check/winapi.pm
+++ b/tools/winapi_check/winapi.pm
@@ -183,6 +183,21 @@
 	    $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 @@
     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 @@
 	    $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 @@
 	    } 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 f5cedac..407400f 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -447,6 +447,12 @@
 		    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 54ea015..c1bef9c 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -122,7 +122,7 @@
 	$#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 589424a..2c374b5 100644
--- a/tools/winapi_check/winapi_options.pm
+++ b/tools/winapi_check/winapi_options.pm
@@ -31,7 +31,7 @@
     "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 @@
 
     "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" },