r6038: adding more flesh to 'net rpc service'
[ira/wip.git] / source3 / libsmb / doserr.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  DOS error routines
4  *  Copyright (C) Tim Potter 2002.
5  *  
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 /* DOS error codes.  please read doserr.h */
22
23 #include "includes.h"
24
25 typedef const struct
26 {
27         const char *dos_errstr;
28         WERROR werror;
29 } werror_code_struct;
30
31 werror_code_struct dos_errs[] =
32 {
33         { "WERR_OK", WERR_OK },
34         { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE },
35         { "WERR_BADFILE", WERR_BADFILE },
36         { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
37         { "WERR_BADFID", WERR_BADFID },
38         { "WERR_BADFUNC", WERR_BADFUNC },
39         { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER },
40         { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE },
41         { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS },
42         { "WERR_INVALID_PARAM", WERR_INVALID_PARAM },
43         { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED },
44         { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD },
45         { "WERR_NOMEM", WERR_NOMEM },
46         { "WERR_INVALID_NAME", WERR_INVALID_NAME },
47         { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL },
48         { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID },
49         { "WERR_NO_MORE_ITEMS", WERR_NO_MORE_ITEMS },
50         { "WERR_MORE_DATA", WERR_MORE_DATA },
51         { "WERR_UNKNOWN_PRINTER_DRIVER", WERR_UNKNOWN_PRINTER_DRIVER },
52         { "WERR_INVALID_PRINTER_NAME", WERR_INVALID_PRINTER_NAME },
53         { "WERR_PRINTER_ALREADY_EXISTS", WERR_PRINTER_ALREADY_EXISTS },
54         { "WERR_INVALID_DATATYPE", WERR_INVALID_DATATYPE },
55         { "WERR_INVALID_ENVIRONMENT", WERR_INVALID_ENVIRONMENT },
56         { "WERR_INVALID_FORM_NAME", WERR_INVALID_FORM_NAME },
57         { "WERR_INVALID_FORM_SIZE", WERR_INVALID_FORM_SIZE },
58         { "WERR_BUF_TOO_SMALL", WERR_BUF_TOO_SMALL },
59         { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND },
60         { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND },
61         { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN },
62         { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE },
63         { "WERR_STATUS_MORE_ENTRIES  ", WERR_STATUS_MORE_ENTRIES },
64         { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL },
65         { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE },
66         { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER },
67         { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR },
68         { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT },
69         { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR },
70         { "WERR_INVALID_OWNER", WERR_INVALID_OWNER },
71         { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE },
72         { "WERR_IO_PENDING", WERR_IO_PENDING },
73         { NULL, W_ERROR(0) }
74 };
75
76 /*****************************************************************************
77  returns a DOS error message.  not amazingly helpful, but better than a number.
78  *****************************************************************************/
79 const char *dos_errstr(WERROR werror)
80 {
81         static pstring msg;
82         int idx = 0;
83
84         slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
85
86         while (dos_errs[idx].dos_errstr != NULL) {
87                 if (W_ERROR_V(dos_errs[idx].werror) == 
88                     W_ERROR_V(werror))
89                         return dos_errs[idx].dos_errstr;
90                 idx++;
91         }
92
93         return msg;
94 }