summaryrefslogtreecommitdiff
path: root/source3/libsmb/nterr.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-08-10 06:00:33 +0000
committerTim Potter <tpot@samba.org>2001-08-10 06:00:33 +0000
commit2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc (patch)
tree7c6072ae27cf5ed587989c8006ba948eaa0f59c6 /source3/libsmb/nterr.c
parent4bbd1ddb274438e00f83fffa2051d8f7d6c2b17c (diff)
downloadsamba-2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc.tar.gz
samba-2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc.tar.bz2
samba-2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc.zip
A rewrite of the error handling in the libsmb client code. I've separated
out the error handling into a bunch of separate functions rather than all being handled in one big function. Fetch error codes from the last received packet: void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num); uint32 cli_nt_error(struct cli_state *); Convert errors to UNIX errno values: int cli_errno_from_dos(uint8 eclass, uint32 num); int cli_errno_from_nt(uint32 status); int cli_errno(struct cli_state *cli); Detect different kinds of errors: BOOL cli_is_dos_error(struct cli_state *cli); BOOL cli_is_nt_error(struct cli_state *cli); BOOL cli_is_error(struct cli_state *cli); This also means we now support CAP_STATUS32 as we can decode and understand NT errors instead of just DOS errors. Yay! Ported a whole bunch of files in libsmb to use this new API instead of the just the DOS error. (This used to be commit 6dbdb0d813f3c7ab20b38baa1223b0b479aadec9)
Diffstat (limited to 'source3/libsmb/nterr.c')
-rw-r--r--source3/libsmb/nterr.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
index 36dd65cda2..1b8e8737f7 100644
--- a/source3/libsmb/nterr.c
+++ b/source3/libsmb/nterr.c
@@ -1,3 +1,24 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Luke Kenneth Casson Leighton 1997-2001.
+ *
+ * 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.
+ */
+
/* NT error codes. please read nterr.h */
#include "includes.h"
@@ -519,33 +540,20 @@ nt_err_code_struct nt_errs[] =
/*****************************************************************************
returns an NT error message. not amazingly helpful, but better than a number.
*****************************************************************************/
-BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len)
+char *get_nt_error_msg(uint32 nt_code)
{
- int idx = 0;
+ static pstring msg;
+ int idx = 0;
- slprintf(msg, len-1, "NT code 0x%08x", nt_code);
+ slprintf(msg, sizeof(msg), "NT code 0x%08x", nt_code);
- while (nt_errs[idx].nt_errstr != NULL)
- {
- if ((nt_errs[idx].nt_errcode & 0xFFFFFF) == (nt_code & 0xFFFFFF))
- {
- safe_strcpy(msg, nt_errs[idx].nt_errstr, len);
- return True;
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if ((nt_errs[idx].nt_errcode & 0xFFFFFF) ==
+ (nt_code & 0xFFFFFF)) {
+ return nt_errs[idx].nt_errstr;
}
idx++;
}
- return False;
-}
-/*****************************************************************************
- returns an NT error message. not amazingly helpful, but better than a number.
- *****************************************************************************/
-char *get_nt_error_msg(uint32 nt_code)
-{
- static pstring msg;
-
- get_safe_nt_error_msg(nt_code, msg, sizeof(msg));
return msg;
}
-
-