Added dos_errstr() function. Not all errors in list yet.
authorTim Potter <tpot@samba.org>
Sun, 17 Mar 2002 06:04:15 +0000 (06:04 +0000)
committerTim Potter <tpot@samba.org>
Sun, 17 Mar 2002 06:04:15 +0000 (06:04 +0000)
(This used to be commit ddb5753e36b8c5efb48ce5c82c16d970fb8e76b6)

source3/Makefile.in
source3/libsmb/doserr.c [new file with mode: 0644]
source3/libsmb/smberr.c
source3/printing/nt_printing.c
source3/rpc_parse/parse_prs.c
source3/rpc_server/srv_spoolss_nt.c

index 30f616c097143196115b3ab7e95c02efe906fbbf..756898365b366261257ce1a4156e2bcde713fd72 100644 (file)
@@ -152,8 +152,8 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
              libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \
              libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
             libsmb/clioplock.o libsmb/errormap.o libsmb/clirap2.o \
-            libsmb/passchange.o libsmb/unexpected.o $(RPC_PARSE_OBJ1) \
-            $(LIBADS_OBJ)
+            libsmb/passchange.o libsmb/unexpected.o libsmb/doserr.o \
+            $(RPC_PARSE_OBJ1) $(LIBADS_OBJ)
 
 LIBMSRPC_OBJ = libsmb/cli_lsarpc.o libsmb/cli_samr.o libsmb/cli_spoolss.o \
               libsmb/cli_netlogon.o libsmb/cli_srvsvc.o libsmb/cli_wkssvc.o \
diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c
new file mode 100644 (file)
index 0000000..5e9da2f
--- /dev/null
@@ -0,0 +1,88 @@
+/* 
+ *  Unix SMB/CIFS implementation.
+ *  DOS error routines
+ *  Copyright (C) Tim Potter 2002.
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* DOS error codes.  please read doserr.h */
+
+#include "includes.h"
+
+typedef const struct
+{
+       char *dos_errstr;
+       WERROR werror;
+} werror_code_struct;
+
+werror_code_struct dos_errs[] =
+{
+       { "WERR_OK", WERR_OK },
+       { "WERR_BADFILE", WERR_BADFILE },
+       { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
+       { "WERR_BADFID", WERR_BADFID },
+       { "WERR_BADFUNC", WERR_BADFUNC },
+       { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER },
+       { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE },
+       { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS },
+       { "WERR_INVALID_PARAM", WERR_INVALID_PARAM },
+       { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED },
+       { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD },
+       { "WERR_NOMEM", WERR_NOMEM },
+       { "WERR_INVALID_NAME", WERR_INVALID_NAME },
+       { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL },
+       { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID },
+       { "WERR_NO_MORE_ITEMS", WERR_NO_MORE_ITEMS },
+       { "WERR_MORE_DATA", WERR_MORE_DATA },
+       { "WERR_UNKNOWN_PRINTER_DRIVER", WERR_UNKNOWN_PRINTER_DRIVER },
+       { "WERR_INVALID_PRINTER_NAME", WERR_INVALID_PRINTER_NAME },
+       { "WERR_PRINTER_ALREADY_EXISTS", WERR_PRINTER_ALREADY_EXISTS },
+       { "WERR_INVALID_DATATYPE", WERR_INVALID_DATATYPE },
+       { "WERR_INVALID_ENVIRONMENT", WERR_INVALID_ENVIRONMENT },
+       { "WERR_INVALID_FORM_SIZE", WERR_INVALID_FORM_SIZE },
+       { "WERR_BUF_TOO_SMALL", WERR_BUF_TOO_SMALL },
+       { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND },
+       { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND },
+       { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN },
+       { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE },
+       { "WERR_STATUS_MORE_ENTRIES  ", WERR_STATUS_MORE_ENTRIES },
+       { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL },
+       { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE },
+       { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER },
+       { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR },
+       { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT },
+       { NULL, W_ERROR(0) }
+};
+
+/*****************************************************************************
+ returns a DOS error message.  not amazingly helpful, but better than a number.
+ *****************************************************************************/
+char *dos_errstr(WERROR werror)
+{
+        static pstring msg;
+        int idx = 0;
+
+       slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
+
+       while (dos_errs[idx].dos_errstr != NULL) {
+               if (W_ERROR_V(dos_errs[idx].werror) == 
+                    W_ERROR_V(werror))
+                        return dos_errs[idx].dos_errstr;
+               idx++;
+       }
+
+        return msg;
+}
index 757629a2d5290abefc846b51e99e0b24be512980..84b3f507e6364a41077396d6b6fe9b11ae882bbe 100644 (file)
@@ -245,18 +245,6 @@ char *smb_dos_errstr(char *inbuf)
        return(ret);
 }
 
-
-/*****************************************************************************
- returns an WERROR error message.
- *****************************************************************************/
-char *werror_str(WERROR status)
-{
-       static fstring msg;
-       slprintf(msg, sizeof(msg), "WIN32 code 0x%08x", W_ERROR_V(status));
-       return msg;
-}
-
-
 /*****************************************************************************
 map a unix errno to a win32 error
  *****************************************************************************/
index 4cd9a0ec91fc52d3820a58eeb1d9c5fbc997ca68..aff3bdebedf513195c959c7abeae32e31e66668f 100644 (file)
@@ -3210,7 +3210,7 @@ WERROR get_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, fstring s
                        break;
        }
        
-       DEBUG(10,("get_a_printer: [%s] level %u returning %s\n", sharename, (unsigned int)level, werror_str(result)));
+       DEBUG(10,("get_a_printer: [%s] level %u returning %s\n", sharename, (unsigned int)level, dos_errstr(result)));
 
        return result;
 }
index 5d06cf7a7e6b8f32655ab21208f599ee4215d405..6d65d5cc7f474d9cdf03652e8788fda79ed3eda8 100644 (file)
@@ -633,7 +633,7 @@ BOOL prs_werror(char *name, prs_struct *ps, int depth, WERROR *status)
        }
 
        DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, 
-                werror_str(*status)));
+                dos_errstr(*status)));
 
        ps->data_offset += sizeof(uint32);
 
index a861aa1905bd6bba5abc6244cfdac1a6e409b012..850d4281659076f2ef7f953ceaac99b6655bf152 100644 (file)
@@ -3858,12 +3858,12 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst
        ZERO_STRUCT(driver);
 
        status=get_a_printer(&printer, 2, lp_servicename(snum) );
-       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status)));
+       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status)));
        if (!W_ERROR_IS_OK(status))
                return WERR_INVALID_PRINTER_NAME;
 
        status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);    
-       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status)));
+       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status)));
 
 #if 0  /* JERRY */
 
@@ -3883,7 +3883,7 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst
                        /* Yes - try again with a WinNT driver. */
                        version = 2;
                        status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);    
-                       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status)));
+                       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status)));
                }
 #endif
 
@@ -3981,12 +3981,12 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
        ZERO_STRUCT(driver);
 
        status=get_a_printer(&printer, 2, lp_servicename(snum) );
-       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status)));
+       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status)));
        if (!W_ERROR_IS_OK(status))
                return WERR_INVALID_PRINTER_NAME;
 
        status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);    
-       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status)));
+       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status)));
        if (!W_ERROR_IS_OK(status)) {
                /*
                 * Is this a W2k client ?
@@ -4000,7 +4000,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
                /* Yes - try again with a WinNT driver. */
                version = 2;
                status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);    
-               DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status)));
+               DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status)));
                if (!W_ERROR_IS_OK(status)) {
                        free_a_printer(&printer,2);
                        return WERR_UNKNOWN_PRINTER_DRIVER;
@@ -5957,7 +5957,7 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
                if(numlines) {
                        if((ports=(PORT_INFO_1 *)malloc( numlines * sizeof(PORT_INFO_1) )) == NULL) {
                                DEBUG(10,("Returning WERR_NOMEM [%s]\n", 
-                                         werror_str(WERR_NOMEM)));
+                                         dos_errstr(WERR_NOMEM)));
                                file_lines_free(qlines);
                                return WERR_NOMEM;
                        }