- API files update.
- Fixed options --cross-call-{unicode-ascii,win32-win16}.
- Minor reorganization of the global checks.

diff --git a/tools/winapi/win16.api b/tools/winapi/win16.api
index a46a5e6..479ae88 100644
--- a/tools/winapi/win16.api
+++ b/tools/winapi/win16.api
@@ -1173,8 +1173,8 @@
 
 LPCVOID
 LPDWORD
-LPMEMORY_BASIC_INFORMATION
 LPVOID
+PMEMORY_BASIC_INFORMATION
 
 %segptr
 
diff --git a/tools/winapi/win32.api b/tools/winapi/win32.api
index e39eb11..9b7647e 100644
--- a/tools/winapi/win32.api
+++ b/tools/winapi/win32.api
@@ -857,7 +857,6 @@
 LPINPUT_RECORD
 LPLDT_ENTRY
 LPMEMORYSTATUS
-LPMEMORY_BASIC_INFORMATION
 LPMODULEENTRY32
 LPOSVERSIONINFOEXA
 LPOSVERSIONINFOEXW
@@ -897,6 +896,7 @@
 PHANDLER_ROUTINE
 PLARGE_INTEGER
 PLONG
+PMEMORY_BASIC_INFORMATION
 PSIZE_T
 PVOID
 PTIMERAPCROUTINE
@@ -1688,6 +1688,7 @@
 
 BOOL
 BYTE
+CALLCONV
 CHAR
 DISPID
 DWORD
@@ -1765,6 +1766,7 @@
 USHORT *
 VARIANT *
 VARIANTARG *
+VARIANTARG **
 VARIANT_BOOL *
 VARTYPE *
 VOID *
@@ -1987,21 +1989,26 @@
 %ptr
 
 LPBOOL
+LPBYTE
 LPCSTR *
 LPCWSTR *
 LPDWORD
 LPRASAUTODIALENTRYA
 LPRASAUTODIALENTRYW
 LPRASCONNA
+LPRASCONNW
 LPRASDEVINFOA
 LPRASDEVINFOW
 LPRASDIALPARAMSA
+LPRASENTRYA
+LPRASENTRYW
 LPRASENTRYNAMEA
 LPVOID
 
 %str
 
 LPCSTR
+LPSTR
 
 %wstr
 
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index fcf3dcb..af77595 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -252,7 +252,6 @@
 }
 
 my %module2functions = ();
-my %type_found = ();
 
 foreach my $file (@c_files) {
     my %functions = ();
@@ -350,10 +349,6 @@
 	    if(defined($refargument_types)) {
 		push @types, @$refargument_types;
 	    }
-
-	    for my $type (@types) {
-		$type_found{$module}{$type}++;
-	    }
 	}
 
 	foreach my $module ($function->modules) {
@@ -663,56 +658,9 @@
 }
 
 if($options->global) {
-    my @complete_modules = sort(keys(%complete_module));
-
-    if($options->declared) {
-	foreach my $module (@complete_modules) {
-	    foreach my $winapi (@winapis) {
-		if(!$winapi->is_module($module)) { next; }
-		my $functions = $module2functions{$module};
-		foreach my $internal_name ($winapi->all_internal_functions_in_module($module)) {
-		    my $function = $functions->{$internal_name};
-		    if(!defined($function) && !$nativeapi->is_function($internal_name) &&
-		       !($module eq "user" && $internal_name =~
-			 /^(?:GlobalAddAtomA|GlobalDeleteAtom|GlobalFindAtomA|
-			    GlobalGetAtomNameA|lstrcmpiA)$/x))
-		    {
-			$output->write("*.c: $module: $internal_name: " .
-				       "function declared but not implemented or declared external\n");
-		    }
-		}
-	    }
-	}
-    }
-
-    if($options->argument && $options->argument_forbidden) {
-	foreach my $winapi (@winapis) {
-	    my $types_not_used = $winapi->types_not_used;
-	    foreach my $module (sort(keys(%$types_not_used))) {
-		if(!$complete_module{$module}) { next; }
-		foreach my $type (sort(keys(%{$$types_not_used{$module}}))) {
-		    $output->write("*.c: $module: type ($type) not used\n");
-		}
-	    }
-	}
-    }
+    &winapi_global::check_modules(\%complete_module, \%module2functions);
 
     if($all_modules) {
-	&winapi_documentation::report_documentation;
-
-	if($options->headers_unused) {
-	    foreach my $name (sort(keys(%include2info))) {
-		if(!$include2info{$name}{used}) {
-		    if($options->include) {
-			$output->write("*.c: $name: include file is never used\n");
-		    }
-		}
-	    }
-	}
-
-	&winapi_global::check(\%type_found);
-
-	$modules->global_report;
-	$nativeapi->global_report;
+	&winapi_global::check_all_modules(\%include2info);
     }
 }
diff --git a/tools/winapi_check/winapi_function.pm b/tools/winapi_check/winapi_function.pm
index 4564d43..fe0c45d 100644
--- a/tools/winapi_check/winapi_function.pm
+++ b/tools/winapi_check/winapi_function.pm
@@ -140,6 +140,10 @@
 	return undef;
     }
 
+    if(!defined($file)) {
+	return undef;
+    }
+
     my @modules;
     foreach my $module (split(/\s*&\s*/, $module)) {
 	if($modules->is_allowed_module_in_file($module, "$current_dir/$file")) {
diff --git a/tools/winapi_check/winapi_global.pm b/tools/winapi_check/winapi_global.pm
index 495737e..130b426 100644
--- a/tools/winapi_check/winapi_global.pm
+++ b/tools/winapi_check/winapi_global.pm
@@ -20,52 +20,66 @@
 
 use strict;
 
+use modules qw($modules);
 use nativeapi qw($nativeapi);
 use options qw($options);
 use output qw($output);
-use winapi qw($win16api $win32api @winapis);
+use winapi qw(@winapis);
 
-sub check {
-    my $type_found = shift;
+sub check_modules {
+    my $complete_module = shift;
+    my $module2functions = shift;
 
-    if($options->win16) {
-	_check($win16api, $type_found);
-    }
+    my @complete_modules = sort(keys(%$complete_module));
 
-    if($options->win32) {
-	_check($win32api, $type_found);
-    }
-}
-
-sub _check {
-    my $winapi = shift;
-    my $type_found = shift;
-
-    my $winver = $winapi->name;
-
-    if($options->argument) {
-	foreach my $type ($winapi->all_declared_types) {
-	    if(!$$type_found{$type} && !$winapi->is_limited_type($type) && $type ne "CONTEXT86 *") {
-		$output->write("*.c: $winver: ");
-		$output->write("type ($type) not used\n");
+    if($options->declared) {
+	foreach my $module (@complete_modules) {
+	    foreach my $winapi (@winapis) {
+		if(!$winapi->is_module($module)) { next; }
+		my $functions = $$module2functions{$module};
+		foreach my $internal_name ($winapi->all_internal_functions_in_module($module)) {
+		    my $function = $functions->{$internal_name};
+		    if(!defined($function) && !$nativeapi->is_function($internal_name) &&
+		       !($module eq "user" && $internal_name =~
+			 /^(?:GlobalAddAtomA|GlobalDeleteAtom|GlobalFindAtomA|
+			    GlobalGetAtomNameA|lstrcmpiA)$/x))
+		    {
+			$output->write("*.c: $module: $internal_name: " .
+				       "function declared but not implemented or declared external\n");
+		    }
+		}
 	    }
 	}
     }
 
     if($options->argument && $options->argument_forbidden) {
-	my $types_used = $winapi->types_unlimited_used_in_modules;
-
-	foreach my $type (sort(keys(%$types_used))) {
-	    $output->write("*.c: type ($type) only used in module[s] (");
-	    my $count = 0;
-	    foreach my $module (sort(keys(%{$$types_used{$type}}))) {
-		if($count++) { $output->write(", "); }
-		$output->write("$module");
+	foreach my $winapi (@winapis) {
+	    my $types_not_used = $winapi->types_not_used;
+	    foreach my $module (sort(keys(%$types_not_used))) {
+		if(!$$complete_module{$module}) { next; }
+		foreach my $type (sort(keys(%{$$types_not_used{$module}}))) {
+		    $output->write("*.c: $module: type ($type) not used\n");
+		}
 	    }
-	    $output->write(")\n");
 	}
     }
 }
 
-1;
+sub check_all_modules {
+    my $include2info = shift;
 
+    &winapi_documentation::report_documentation;
+    
+    if($options->headers_unused && $options->include) {
+	foreach my $name (sort(keys(%$include2info))) {
+	    if(!$$include2info{$name}{used}) {
+		$output->write("*.c: $name: include file is never used\n");
+	    }
+	}
+    }
+    
+    $modules->global_report;
+    $nativeapi->global_report;
+}
+
+1;
diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm
index 6e6e1f5..93c6113 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -351,9 +351,14 @@
 		    }
 		}
 	    } elsif($options->cross_call) {
+		# $output->write("$internal_name: called $called_name\n");
 		$$functions{$internal_name}->function_called($called_name);
 		if(!defined($$functions{$called_name})) {
-		    $$functions{$called_name} = 'winapi_function'->new;
+		    my $called_function = 'winapi_function'->new;
+
+		    $called_function->internal_name($called_name);
+
+		    $$functions{$called_name} = $called_function;	
 		}
 		$$functions{$called_name}->function_called_by($internal_name);
 	    }
@@ -370,18 +375,22 @@
     if($options->cross_call) {
 	my @names = sort(keys(%$functions));
 	for my $name (@names) {
-	    my @called_names = $$functions{$name}->called_function_names;
-	    my @called_by_names = $$functions{$name}->called_by_function_names;
-	    my $module = $$functions{$name}->module;
+	    my $function = $$functions{$name};
+
+	    my @called_names = $function->called_function_names;
+	    my @called_by_names = $function->called_by_function_names;
+	    my $module = $function->module;
 
 	    if($options->cross_call_win32_win16) {
-		my $module16 = $$functions{$name}->module16;
-		my $module32 = $$functions{$name}->module32;
+		my $module16 = $function->module16;
+		my $module32 = $function->module32;
 
 		if($#called_names >= 0 && (defined($module16) || defined($module32)) ) {
 		    for my $called_name (@called_names) {
-			my $called_module16 = $$functions{$called_name}->module16;
-			my $called_module32 = $$functions{$called_name}->module32;
+			my $called_function = $$functions{$called_name};
+
+			my $called_module16 = $called_function->module16;
+			my $called_module32 = $called_function->module32;
 			if(defined($module32) &&
 			   defined($called_module16) && !defined($called_module32) &&
 			   $name ne $called_name)