| 1 | /*
|
|---|
| 2 | Unix SMB/Netbios implementation.
|
|---|
| 3 | SMB client library implementation
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1998
|
|---|
| 5 | Copyright (C) Richard Sharpe 2000, 2002
|
|---|
| 6 | Copyright (C) John Terpstra 2000
|
|---|
| 7 | Copyright (C) Tom Jansen (Ninja ISD) 2002
|
|---|
| 8 | Copyright (C) Derrell Lipman 2003-2008
|
|---|
| 9 | Copyright (C) Jeremy Allison 2007, 2008
|
|---|
| 10 |
|
|---|
| 11 | This program is free software; you can redistribute it and/or modify
|
|---|
| 12 | it under the terms of the GNU General Public License as published by
|
|---|
| 13 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 14 | (at your option) any later version.
|
|---|
| 15 |
|
|---|
| 16 | This program is distributed in the hope that it will be useful,
|
|---|
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | GNU General Public License for more details.
|
|---|
| 20 |
|
|---|
| 21 | You should have received a copy of the GNU General Public License
|
|---|
| 22 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | #include "includes.h"
|
|---|
| 26 | #include "libsmbclient.h"
|
|---|
| 27 | #include "libsmb_internal.h"
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | /*
|
|---|
| 31 | * check if an element is part of the list.
|
|---|
| 32 | */
|
|---|
| 33 | int
|
|---|
| 34 | SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p)
|
|---|
| 35 | {
|
|---|
| 36 | if (!p || !list) return False;
|
|---|
| 37 | do {
|
|---|
| 38 | if (p == list) return True;
|
|---|
| 39 | list = list->next;
|
|---|
| 40 | } while (list);
|
|---|
| 41 | return False;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /*
|
|---|
| 46 | * Convert an SMB error into a UNIX error ...
|
|---|
| 47 | */
|
|---|
| 48 | int
|
|---|
| 49 | SMBC_errno(SMBCCTX *context,
|
|---|
| 50 | struct cli_state *c)
|
|---|
| 51 | {
|
|---|
| 52 | int ret = cli_errno(c);
|
|---|
| 53 |
|
|---|
| 54 | if (cli_is_dos_error(c)) {
|
|---|
| 55 | uint8 eclass;
|
|---|
| 56 | uint32 ecode;
|
|---|
| 57 |
|
|---|
| 58 | cli_dos_error(c, &eclass, &ecode);
|
|---|
| 59 |
|
|---|
| 60 | DEBUG(3,("smbc_error %d %d (0x%x) -> %d\n",
|
|---|
| 61 | (int)eclass, (int)ecode, (int)ecode, ret));
|
|---|
| 62 | } else {
|
|---|
| 63 | NTSTATUS status;
|
|---|
| 64 |
|
|---|
| 65 | status = cli_nt_error(c);
|
|---|
| 66 |
|
|---|
| 67 | DEBUG(3,("smbc errno %s -> %d\n",
|
|---|
| 68 | nt_errstr(status), ret));
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | return ret;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|