- Added support for auto allocated ordinals
- Fixed varargs (16 bit) bug
- Minor fixes

diff --git a/tools/winapi_check/win32/shell32.api b/tools/winapi_check/win32/shell32.api
index 367c116..f072099 100644
--- a/tools/winapi_check/win32/shell32.api
+++ b/tools/winapi_check/win32/shell32.api
@@ -6,3 +6,6 @@
 HICON
 HWND
 
+%ptr
+
+PNOTIFYICONDATAW
diff --git a/tools/winapi_check/winapi.pm b/tools/winapi_check/winapi.pm
index 7e588c1..f7a6a88 100644
--- a/tools/winapi_check/winapi.pm
+++ b/tools/winapi_check/winapi.pm
@@ -175,12 +175,12 @@
 	if($header)  {
 	    if(/^name\s*(\S*)/) { $module = $1; }
 	    if(/^type\s*(\w+)/) { $type = $1; }
-	    if(/^\d+/) { $header = 0 };
+	    if(/^\d+|@/) { $header = 0 };
 	    next;
 	} 
 
 	my $ordinal;
-	if(/^(\d+)\s+(pascal|pascal16|stdcall|cdecl|register|interrupt|varargs)\s+(\S+)\s*\(\s*(.*?)\s*\)\s*(\S+)$/) {
+	if(/^(\d+|@)\s+(pascal|pascal16|stdcall|cdecl|register|interrupt|varargs)\s+(\S+)\s*\(\s*(.*?)\s*\)\s*(\S+)$/) {
 	    my $calling_convention = $2;
 	    my $external_name = $3;
 	    my $arguments = $4;
@@ -196,7 +196,7 @@
 	    } elsif($$function_module{$internal_name} !~ /$module/) {
 		$$function_module{$internal_name} .= " & $module";
 	    }
-	} elsif(/^(\d+)\s+stub\s+(\S+)$/) {
+	} elsif(/^(\d+|@)\s+stub\s+(\S+)$/) {
 	    my $external_name = $2;
 
 	    $ordinal = $1;
@@ -215,11 +215,11 @@
 	    } elsif($$function_module{$internal_name} !~ /$module/) {
 		$$function_module{$internal_name} .= " & $module";
 	    }
-	} elsif(/^\d+\s+(equate|long|word|extern|forward)/) {
+	} elsif(/^(\d+|@)\s+(equate|long|word|extern|forward)/) {
 	    # ignore
 	} else {
 	    my $next_line = <IN>;
-	    if($next_line =~ /^\d/) {
+	    if($next_line =~ /^\d|@/) {
 		die "$file: $.: syntax error: '$_'\n";
 	    } else {
 		$_ .= $next_line;
@@ -228,7 +228,7 @@
 	}
 	
 	if(defined($ordinal)) {
-	    if($ordinals{$ordinal}) {
+	    if($ordinal ne "@" && $ordinals{$ordinal}) {
 		$$output->write("$file: ordinal redefined: $_\n");
 	    }
 	    $ordinals{$ordinal}++;
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index a8d3cd5..171d1de 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -125,12 +125,13 @@
     }
 
     my $file_type;
-    if($file_dir =~ /^(libtest|program|rc)/) {
+    if($file_dir =~ /^(libtest|program|rc|tools)/ || 
+       $file =~ /dbgmain\.c$/ ||
+       $file =~ /wineclipsrv\.c$/) # FIXME: Kludge
+    {
 	$file_type = "application";
     } elsif($file_dir =~ /^(debug|miscemu)/) {
 	$file_type = "emulator";
-    } elsif($file_dir =~ /^(tools)/) {
-	$file_type = "tool";
     } else {
 	$file_type = "library";
     }
@@ -156,7 +157,7 @@
 	    $win32api->found_function($name) if $options->win32;
 	}
 	
-	if($options->local) {
+	if($options->local && $file_type ne "application") {
 	    my $module16 = $win16api->function_module($name);
 	    my $module32 = $win32api->function_module($name);
 
@@ -269,18 +270,20 @@
 	}
     };
     my $found_conditional = sub {
-	local $_ = shift;
-	if(!$nativeapi->is_conditional($_)) {
-	    if(/^HAVE_/ && !/^HAVE_(IPX|MESAGL|BUGGY_MESAGL|WINE_CONSTRUCTOR)$/)
-	    {
-		$output->write("$file: $_ is not a declared as a conditional\n");
-	    }
-	} else {
-	    $conditional++;
-	    if(!$config) {
-		$output->write("$file: conditional $_ used but config.h is not included\n");
-	    }
-	}
+	if($file_type ne "application") {
+	   local $_ = shift;
+	   if(!$nativeapi->is_conditional($_)) {
+	       if(/^HAVE_/ && !/^HAVE_(IPX|MESAGL|BUGGY_MESAGL|WINE_CONSTRUCTOR)$/)
+	       {
+		   $output->write("$file: $_ is not a declared as a conditional\n");
+	       }
+	   } else {
+	       $conditional++;
+	       if(!$config) {
+		   $output->write("$file: conditional $_ used but config.h is not included\n");
+	       }
+	   }
+       }
     };
     my $preprocessor = 'preprocessor'->new($found_include, $found_conditional);
     my $found_preprocessor = sub {
@@ -291,10 +294,25 @@
 
 	if($options->config) {
 	    if($directive eq "include") {
+		my $header;
+		my $check_protection;
+		my $check_local;
 		if($argument =~ /^<(.*?)>$/) {
-		    my $header = $1;
+		   $header = $1;
+		   if($file_type ne "application") {
+		       $check_protection = 1;
+		   } else {
+		       $check_protection = 0;
+		   }
+		   $check_local = 0;
+		} elsif($argument =~ /^"(.*?)"$/) {
+		   $header = $1;
+		   $check_protection = 0;
+		   $check_local = 1;
+		}
 
-		    if((-e "$wine_dir/include/$header" || -e "$file_dir/$header") && $file_type ne "application") {
+		if($check_protection) {
+		    if((-e "$wine_dir/include/$header" || -e "$file_dir/$header")) {
 			$output->write("$file: #include \<$header\> is a local include\n");
 		    }
 
@@ -306,20 +324,23 @@
 			if(!$preprocessor->is_def($macro)) {
 			    if($macro =~ /^HAVE_X11/) {
 				if(!$preprocessor->is_undef("X_DISPLAY_MISSING")) {
-				    $output->write("$file: #$directive $argument: is a conditional include, but is not protected\n");
+				    $output->write("$file: #$directive $argument: is a conditional include, " .
+						   "but is not protected\n");
 				}
 			    } elsif($macro =~ /^HAVE_(.*?)_H$/) {
 				if($header ne "alloca.h" && !$preprocessor->is_def("STATFS_DEFINED_BY_$1")) {
-				    $output->write("$file: #$directive $argument: is a conditional include, but is not protected\n");
+				    $output->write("$file: #$directive $argument: is a conditional include, " . 
+						   "but is not protected\n");
 				}
 			    }
 			}
 		    } elsif($preprocessor->is_def($macro)) {
-			$output->write("$file: #$directive $argument: is protected, but is not a conditional include\n");
+			$output->write("$file: #$directive $argument: is protected, " .
+				       "but is not a conditional include\n");
 		    }
-		} elsif($argument =~ /^"(.*?)"$/) {
-		    my $header = $1;
+		}
 
+		if($check_local) {
 		    if(-e "$file_dir/$header") {
 			$includes{"$file_dir/$header"}{used}++;
 			foreach my $name (keys(%{$includes{"$file_dir/$header"}{includes}})) {
diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm
index f73b231..e5f5489 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -58,6 +58,8 @@
     if($winapi->name eq "win16") {
 	if($calling_convention =~ /^__cdecl$/) {
 	    $implemented_calling_convention = "cdecl";
+	} elsif($calling_convention =~ /^VFWAPIV|WINAPIV$/) {
+	    $implemented_calling_convention = "varargs";
 	} elsif($calling_convention = ~ /^__stdcall|VFWAPI|WINAPI$/) {
 	    if($implemented_return_kind =~ /^s_word|word|void$/) {
 		$implemented_calling_convention = "pascal16";
@@ -90,7 +92,8 @@
     {
 	# correct
     } elsif($implemented_calling_convention ne $declared_calling_convention && 
-       !($declared_calling_convention =~ /^pascal/ && $forbidden_return_type)) 
+       !($declared_calling_convention =~ /^pascal/ && $forbidden_return_type) &&
+       !($implemented_calling_convention =~ /^cdecl|varargs$/ && $declared_calling_convention =~ /^cdecl|varargs$/))
     {
 	if($options->calling_convention) {
 	    &$output("calling convention mismatch: $implemented_calling_convention != $declared_calling_convention");