Added handle_t type to server interface so that we can make handles
pointers later on.
Always use 0 to signal invalid handle in server requests.

diff --git a/files/dos_fs.c b/files/dos_fs.c
index db203f9..2aa9b8b 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -697,7 +697,7 @@
  */
 static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
 {
-    HANDLE ret = INVALID_HANDLE_VALUE;
+    HANDLE ret;
     char devname[40];
 
     TRACE("%s %lx\n", name, access);
@@ -718,7 +718,8 @@
         req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
         memcpy( server_data_ptr(req), devname, len );
         SetLastError(0);
-        if (!(server_call( REQ_CREATE_SERIAL ))) ret = req->handle;
+        server_call( REQ_CREATE_SERIAL );
+        ret = req->handle;
     }
     SERVER_END_REQ;
 
@@ -730,14 +731,14 @@
  *           DOSFS_OpenDevice
  *
  * Open a DOS device. This might not map 1:1 into the UNIX device concept.
+ * Returns 0 on failure.
  */
-HFILE DOSFS_OpenDevice( const char *name, DWORD access )
+HANDLE DOSFS_OpenDevice( const char *name, DWORD access )
 {
     int i;
     const char *p;
-    HFILE handle;
+    HANDLE handle;
 
-    if (!name) return (HFILE)NULL; /* if FILE_DupUnixHandle was used */
     if (name[0] && (name[1] == ':')) name += 2;
     if ((p = strrchr( name, '/' ))) name = p + 1;
     if ((p = strrchr( name, '\\' ))) name = p + 1;
@@ -752,9 +753,9 @@
 		if (!strcmp(DOSFS_Devices[i].name,"NUL"))
                     return FILE_CreateFile( "/dev/null", access,
                                             FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
-                                            OPEN_EXISTING, 0, -1, TRUE );
+                                            OPEN_EXISTING, 0, 0, TRUE );
 		if (!strcmp(DOSFS_Devices[i].name,"CON")) {
-			HFILE to_dup;
+			HANDLE to_dup;
 			switch (access & (GENERIC_READ|GENERIC_WRITE)) {
 			case GENERIC_READ:
 				to_dup = GetStdHandle( STD_INPUT_HANDLE );
@@ -764,12 +765,11 @@
 				break;
 			default:
 				FIXME("can't open CON read/write\n");
-				return HFILE_ERROR;
-				break;
+				return 0;
 			}
 			if (!DuplicateHandle( GetCurrentProcess(), to_dup, GetCurrentProcess(),
 					      &handle, 0, FALSE, DUPLICATE_SAME_ACCESS ))
-			    handle = HFILE_ERROR;
+			    handle = 0;
 			return handle;
 		}
 		if (!strcmp(DOSFS_Devices[i].name,"SCSIMGR$") ||
@@ -782,11 +782,11 @@
                     return handle;
 
 		FIXME("device open %s not supported (yet)\n",DOSFS_Devices[i].name);
-    		return HFILE_ERROR;
+    		return 0;
 	    }
         }
     }
-    return HFILE_ERROR;
+    return 0;
 }
 
 
diff --git a/files/file.c b/files/file.c
index 804ae33..b1b5a98 100644
--- a/files/file.c
+++ b/files/file.c
@@ -181,7 +181,7 @@
  *
  * Duplicate a Unix handle into a task handle.
  */
-HFILE FILE_DupUnixHandle( int fd, DWORD access )
+HANDLE FILE_DupUnixHandle( int fd, DWORD access )
 {
     struct alloc_file_handle_request *req = get_req_buffer();
     req->access  = access;
@@ -219,10 +219,11 @@
  * 		FILE_OpenConsole
  *
  * Open a handle to the current process console.
+ * Returns 0 on failure.
  */
 static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa )
 {
-    int ret = -1;
+    HANDLE ret;
 
     SERVER_START_REQ
     {
@@ -232,7 +233,8 @@
         req->access  = access;
         req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
         SetLastError(0);
-        if (!server_call( REQ_OPEN_CONSOLE )) ret = req->handle;
+        server_call( REQ_OPEN_CONSOLE );
+        ret = req->handle;
     }
     SERVER_END_REQ;
     return ret;
@@ -243,6 +245,7 @@
  *           FILE_CreateFile
  *
  * Implementation of CreateFile. Takes a Unix path name.
+ * Returns 0 on failure.
  */
 HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
                         LPSECURITY_ATTRIBUTES sa, DWORD creation,
@@ -256,7 +259,7 @@
     {
         FIXME("filename '%s' too long\n", filename );
         SetLastError( ERROR_INVALID_PARAMETER );
-        return -1;
+        return 0;
     }
 
  restart:
@@ -277,7 +280,7 @@
 
     /* If write access failed, retry without GENERIC_WRITE */
 
-    if ((ret == -1) && !fail_read_only && (access & GENERIC_WRITE)) 
+    if (!ret && !fail_read_only && (access & GENERIC_WRITE))
     {
 	if ((err == STATUS_MEDIA_WRITE_PROTECTED) || (err == STATUS_ACCESS_DENIED))
         {
@@ -288,7 +291,7 @@
         }
     }
 
-    if (ret == -1)
+    if (!ret)
 	WARN("Unable to create file '%s' (GLE %ld)\n", filename,
 	     GetLastError());
 
@@ -300,10 +303,11 @@
  *           FILE_CreateDevice
  *
  * Same as FILE_CreateFile but for a device
+ * Returns 0 on failure.
  */
-HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
+HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
 {
-    HFILE ret;
+    HANDLE ret;
     SERVER_START_REQ
     {
         struct create_device_request *req = server_alloc_req( sizeof(*req), 0 );
@@ -353,11 +357,12 @@
                               DWORD attributes, HANDLE template )
 {
     DOS_FULL_NAME full_name;
+    HANDLE ret;
 
     if (!filename)
     {
         SetLastError( ERROR_INVALID_PARAMETER );
-        return HFILE_ERROR;
+        return INVALID_HANDLE_VALUE;
     }
     TRACE("%s %s%s%s%s%s%s%s\n",filename,
 	  ((access & GENERIC_READ)==GENERIC_READ)?"GENERIC_READ ":"",
@@ -380,13 +385,16 @@
 	{
             FIXME("UNC name (%s) not supported.\n", filename );
             SetLastError( ERROR_PATH_NOT_FOUND );
-            return HFILE_ERROR;
+            return INVALID_HANDLE_VALUE;
 	}
     }
 
     if (!strncmp(filename, "\\\\.\\", 4)) {
         if (!DOSFS_GetDevice( filename ))
-        	return DEVICE_Open( filename+4, access, sa );
+        {
+            ret = DEVICE_Open( filename+4, access, sa );
+            goto done;
+        }
 	else
         	filename+=4; /* fall into DOSFS_Device case below */
     }
@@ -396,30 +404,36 @@
     {
         FIXME("UNC name (%s) not supported.\n", filename );
         SetLastError( ERROR_PATH_NOT_FOUND );
-        return HFILE_ERROR;
+        return INVALID_HANDLE_VALUE;
     }
 
     /* If the name contains a DOS wild card (* or ?), do no create a file */
     if(strchr(filename,'*') || strchr(filename,'?'))
-        return HFILE_ERROR;
+        return INVALID_HANDLE_VALUE;
 
     /* Open a console for CONIN$ or CONOUT$ */
-    if (!strcasecmp(filename, "CONIN$")) return FILE_OpenConsole( FALSE, access, sa );
-    if (!strcasecmp(filename, "CONOUT$")) return FILE_OpenConsole( TRUE, access, sa );
+    if (!strcasecmp(filename, "CONIN$"))
+    {
+        ret = FILE_OpenConsole( FALSE, access, sa );
+        goto done;
+    }
+    if (!strcasecmp(filename, "CONOUT$"))
+    {
+        ret = FILE_OpenConsole( TRUE, access, sa );
+        goto done;
+    }
 
     if (DOSFS_GetDevice( filename ))
     {
-    	HFILE	ret;
-
         TRACE("opening device '%s'\n", filename );
 
-	if (HFILE_ERROR!=(ret=DOSFS_OpenDevice( filename, access )))
-		return ret;
-
-	/* Do not silence this please. It is a critical error. -MM */
-        ERR("Couldn't open device '%s'!\n",filename);
-        SetLastError( ERROR_FILE_NOT_FOUND );
-        return HFILE_ERROR;
+        if (!(ret = DOSFS_OpenDevice( filename, access )))
+        {
+            /* Do not silence this please. It is a critical error. -MM */
+            ERR("Couldn't open device '%s'!\n",filename);
+            SetLastError( ERROR_FILE_NOT_FOUND );
+        }
+        goto done;
     }
 
     /* check for filename, don't check for last entry if creating */
@@ -429,12 +443,15 @@
 			    &full_name )) {
 	WARN("Unable to get full filename from '%s' (GLE %ld)\n",
 	     filename, GetLastError());
-        return HFILE_ERROR;
+        return INVALID_HANDLE_VALUE;
     }
 
-    return FILE_CreateFile( full_name.long_name, access, sharing,
-                            sa, creation, attributes, template,
-                            DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
+    ret = FILE_CreateFile( full_name.long_name, access, sharing,
+                           sa, creation, attributes, template,
+                           DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
+ done:
+    if (!ret) ret = INVALID_HANDLE_VALUE;
+    return ret;
 }
 
 
@@ -877,9 +894,9 @@
     }
 
     hFileRet = FILE_CreateFile( full_name.long_name, access, sharing,
-                                NULL, OPEN_EXISTING, 0, -1,
+                                NULL, OPEN_EXISTING, 0, 0,
                                 DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
-    if (hFileRet == HFILE_ERROR) goto not_found;
+    if (!hFileRet) goto not_found;
 
     GetFileTime( hFileRet, NULL, NULL, &filetime );
     FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] );