My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
soc_common.c
Go to the documentation of this file.
1 #include "soc_common.h"
2 #include <errno.h>
3 
5 int SOCU_errno = 0;
7 
8 //This is based on the array from libogc network_wii.c.
9 static u8 _net_error_code_map[] = {
10  0, // 0
11  E2BIG,
12  EACCES,
13  EADDRINUSE,
14  EADDRNOTAVAIL,
15  EAFNOSUPPORT, // 5
16  EAGAIN,
17  EALREADY,
18  EBADF,
19  EBADMSG,
20  EBUSY, // 10
21  ECANCELED,
22  ECHILD,
23  ECONNABORTED,
24  ECONNREFUSED,
25  ECONNRESET, // 15
26  EDEADLK,
27  EDESTADDRREQ,
28  EDOM,
29  EDQUOT,
30  EEXIST, // 20
31  EFAULT,
32  EFBIG,
33  EHOSTUNREACH,
34  EIDRM,
35  EILSEQ, // 25
36  EINPROGRESS,
37  EINTR,
38  EINVAL,
39  EIO,
40  EISCONN, // 30
41  EISDIR,
42  ELOOP,
43  EMFILE,
44  EMLINK,
45  EMSGSIZE, // 35
46  EMULTIHOP,
47  ENAMETOOLONG,
48  ENETDOWN,
49  ENETRESET,
50  ENETUNREACH, // 40
51  ENFILE,
52  ENOBUFS,
53  ENODATA,
54  ENODEV,
55  ENOENT, // 45
56  ENOEXEC,
57  ENOLCK,
58  ENOLINK,
59  ENOMEM,
60  ENOMSG, // 50
61  ENOPROTOOPT,
62  ENOSPC,
63  ENOSR,
64  ENOSTR,
65  ENOSYS, // 55
66  ENOTCONN,
67  ENOTDIR,
68  ENOTEMPTY,
69  ENOTSOCK,
70  ENOTSUP, // 60
71  ENOTTY,
72  ENXIO,
73  EOPNOTSUPP,
74  EOVERFLOW,
75  EPERM, // 65
76  EPIPE,
77  EPROTO,
78  EPROTONOSUPPORT,
79  EPROTOTYPE,
80  ERANGE, // 70
81  EROFS,
82  ESPIPE,
83  ESRCH,
84  ESTALE,
85  ETIME, // 75
86  ETIMEDOUT,
87 };
88 
89 #define NET_UNKNOWN_ERROR_OFFSET -10000//This is from libogc network_wii.c.
90 
91 //This is based on the function from libogc network_wii.c.
93 {
94  if (sock_retval >= 0) return sock_retval;
95  if (sock_retval < -sizeof(_net_error_code_map)
96  || !_net_error_code_map[-sock_retval])
97  return NET_UNKNOWN_ERROR_OFFSET + sock_retval;
98  return -_net_error_code_map[-sock_retval];
99 }
100 
101 int SOC_GetErrno(void)
102 {
103  return SOCU_errno;
104 }
u32 Handle
Definition: types.h:41
uint8_t u8
Definition: types.h:21
int SOCU_errno
Definition: soc_common.c:5
int SOC_GetErrno(void)
Definition: soc_common.c:101
int32_t s32
Definition: types.h:28
Handle socMemhandle
Definition: soc_common.c:6
s32 _net_convert_error(s32 sock_retval)
Definition: soc_common.c:92
#define NET_UNKNOWN_ERROR_OFFSET
Definition: soc_common.c:89
Handle SOCU_handle
Definition: soc_common.c:4