tsocket: remove tsocket_context related stuff
[jra/samba/.git] / lib / tsocket / tsocket_helpers.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Stefan Metzmacher 2009
5
6      ** NOTE! The following LGPL license applies to the tevent
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 3 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #include "replace.h"
25 #include "system/network.h"
26 #include "system/filesys.h"
27 #include "tsocket.h"
28 #include "tsocket_internal.h"
29
30 int tsocket_simple_int_recv(struct tevent_req *req, int *perrno)
31 {
32         enum tevent_req_state state;
33         uint64_t error;
34
35         if (!tevent_req_is_error(req, &state, &error)) {
36                 return 0;
37         }
38
39         switch (state) {
40         case TEVENT_REQ_NO_MEMORY:
41                 *perrno = ENOMEM;
42                 return -1;
43         case TEVENT_REQ_TIMED_OUT:
44                 *perrno = ETIMEDOUT;
45                 return -1;
46         case TEVENT_REQ_USER_ERROR:
47                 *perrno = (int)error;
48                 return -1;
49         default:
50                 *perrno = EIO;
51                 return -1;
52         }
53
54         *perrno = EIO;
55         return -1;
56 }