2 Unix SMB/CIFS implementation.
3 Wrap win32 errors around tevent_req
4 Copyright (C) Kai Blin 2010
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 #include "../replace/replace.h"
21 #include "tevent_werror.h"
22 #include "libcli/util/error.h"
24 bool _tevent_req_werror(struct tevent_req
*req
,
28 return _tevent_req_error(req
, W_ERROR_V(werror
),
32 bool tevent_req_is_werror(struct tevent_req
*req
, WERROR
*error
)
34 enum tevent_req_state state
;
37 if (!tevent_req_is_error(req
, &state
, &err
)) {
41 case TEVENT_REQ_TIMED_OUT
:
42 *error
= WERR_TIMEOUT
;
44 case TEVENT_REQ_NO_MEMORY
:
47 case TEVENT_REQ_USER_ERROR
:
48 *error
= W_ERROR(err
);
51 *error
= WERR_INTERNAL_ERROR
;
57 WERROR
tevent_req_simple_recv_werror(struct tevent_req
*req
)
61 if (tevent_req_is_werror(req
, &werror
)) {
62 tevent_req_received(req
);
65 tevent_req_received(req
);
69 void tevent_req_simple_finish_werror(struct tevent_req
*subreq
,
72 struct tevent_req
*req
= tevent_req_callback_data(
73 subreq
, struct tevent_req
);
77 if (!W_ERROR_IS_OK(subreq_error
)) {
78 tevent_req_werror(req
, subreq_error
);
84 bool tevent_req_poll_werror(struct tevent_req
*req
,
85 struct tevent_context
*ev
,
88 bool ret
= tevent_req_poll(req
, ev
);
90 NTSTATUS status
= map_nt_error_from_unix_common(errno
);
91 *err
= ntstatus_to_werror(status
);