s4-samba-tool: add password verification in change user pass
[Samba/gebeck_regimport.git] / source4 / libcli / util / pyerrors.h
blob4c526c6ed284459aaa1cb0cffd7771afc67e9d9c
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
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 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __PYERRORS_H__
21 #define __PYERRORS_H__
23 #define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))
25 #define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status)))
27 #define PyErr_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str))
29 #define PyErr_SetWERROR(err) \
30 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
32 #define PyErr_SetNTSTATUS(status) \
33 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
35 #define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
36 if (NT_STATUS_IS_ERR(status)) { \
37 PyErr_SetNTSTATUS(status); \
38 return NULL; \
41 #define PyErr_WERROR_IS_ERR_RAISE(status) \
42 if (!W_ERROR_IS_OK(status)) { \
43 PyErr_SetWERROR(status); \
44 return NULL; \
47 #endif /* __PYERRORS_H__ */