File: strerror_defs.cpp

package info (click to toggle)
srt 1.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,804 kB
  • sloc: cpp: 52,175; ansic: 5,746; tcl: 1,183; sh: 318; python: 99; makefile: 38
file content (154 lines) | stat: -rw-r--r-- 5,439 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

 /*
  WARNING: Generated from ../scripts/generate-error-types.tcl

  DO NOT MODIFY.

  Copyright applies as per the generator script.
 */

#include <cstddef>


namespace srt
{
// MJ_SUCCESS 'Success'

const char* strerror_msgs_success [] = {
    "Success", // MN_NONE = 0
    ""
};

// MJ_SETUP 'Connection setup failure'

const char* strerror_msgs_setup [] = {
    "Connection setup failure", // MN_NONE = 0
    "Connection setup failure: connection timed out", // MN_TIMEOUT = 1
    "Connection setup failure: connection rejected", // MN_REJECTED = 2
    "Connection setup failure: unable to create/configure SRT socket", // MN_NORES = 3
    "Connection setup failure: aborted for security reasons", // MN_SECURITY = 4
    "Connection setup failure: socket closed during operation", // MN_CLOSED = 5
    ""
};

// MJ_CONNECTION ''

const char* strerror_msgs_connection [] = {
    "", // MN_NONE = 0
    "Connection was broken", // MN_CONNLOST = 1
    "Connection does not exist", // MN_NOCONN = 2
    ""
};

// MJ_SYSTEMRES 'System resource failure'

const char* strerror_msgs_systemres [] = {
    "System resource failure", // MN_NONE = 0
    "System resource failure: unable to create new threads", // MN_THREAD = 1
    "System resource failure: unable to allocate buffers", // MN_MEMORY = 2
    "System resource failure: unable to allocate a system object", // MN_OBJECT = 3
    ""
};

// MJ_FILESYSTEM 'File system failure'

const char* strerror_msgs_filesystem [] = {
    "File system failure", // MN_NONE = 0
    "File system failure: cannot seek read position", // MN_SEEKGFAIL = 1
    "File system failure: failure in read", // MN_READFAIL = 2
    "File system failure: cannot seek write position", // MN_SEEKPFAIL = 3
    "File system failure: failure in write", // MN_WRITEFAIL = 4
    ""
};

// MJ_NOTSUP 'Operation not supported'

const char* strerror_msgs_notsup [] = {
    "Operation not supported", // MN_NONE = 0
    "Operation not supported: Cannot do this operation on a BOUND socket", // MN_ISBOUND = 1
    "Operation not supported: Cannot do this operation on a CONNECTED socket", // MN_ISCONNECTED = 2
    "Operation not supported: Bad parameters", // MN_INVAL = 3
    "Operation not supported: Invalid socket ID", // MN_SIDINVAL = 4
    "Operation not supported: Cannot do this operation on an UNBOUND socket", // MN_ISUNBOUND = 5
    "Operation not supported: Socket is not in listening state", // MN_NOLISTEN = 6
    "Operation not supported: Listen/accept is not supported in rendezvous connection setup", // MN_ISRENDEZVOUS = 7
    "Operation not supported: Cannot call connect on UNBOUND socket in rendezvous connection setup", // MN_ISRENDUNBOUND = 8
    "Operation not supported: Incorrect use of Message API (sendmsg/recvmsg)", // MN_INVALMSGAPI = 9
    "Operation not supported: Incorrect use of Buffer API (send/recv) or File API (sendfile/recvfile)", // MN_INVALBUFFERAPI = 10
    "Operation not supported: Another socket is already listening on the same port", // MN_BUSY = 11
    "Operation not supported: Message is too large to send", // MN_XSIZE = 12
    "Operation not supported: Invalid epoll ID", // MN_EIDINVAL = 13
    "Operation not supported: All sockets removed from epoll, waiting would deadlock", // MN_EEMPTY = 14
    "Operation not supported: Another socket is bound to that port and is not reusable for requested settings", // MN_BUSYPORT = 15
    ""
};

// MJ_AGAIN 'Non-blocking call failure'

const char* strerror_msgs_again [] = {
    "Non-blocking call failure", // MN_NONE = 0
    "Non-blocking call failure: no buffer available for sending", // MN_WRAVAIL = 1
    "Non-blocking call failure: no data available for reading", // MN_RDAVAIL = 2
    "Non-blocking call failure: transmission timed out", // MN_XMTIMEOUT = 3
    "Non-blocking call failure: early congestion notification", // MN_CONGESTION = 4
    ""
};

// MJ_PEERERROR 'The peer side has signaled an error'

const char* strerror_msgs_peererror [] = {
    "The peer side has signaled an error", // MN_NONE = 0
    ""
};


const char** strerror_array_major [] = {
    strerror_msgs_success, // MJ_SUCCESS = 0
    strerror_msgs_setup, // MJ_SETUP = 1
    strerror_msgs_connection, // MJ_CONNECTION = 2
    strerror_msgs_systemres, // MJ_SYSTEMRES = 3
    strerror_msgs_filesystem, // MJ_FILESYSTEM = 4
    strerror_msgs_notsup, // MJ_NOTSUP = 5
    strerror_msgs_again, // MJ_AGAIN = 6
    strerror_msgs_peererror, // MJ_PEERERROR = 7
    NULL
};

#define SRT_ARRAY_SIZE(ARR) sizeof(ARR) / sizeof(ARR[0])

const size_t strerror_array_sizes [] = {
    SRT_ARRAY_SIZE(strerror_msgs_success) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_setup) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_connection) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_systemres) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_filesystem) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_notsup) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_again) - 1,
    SRT_ARRAY_SIZE(strerror_msgs_peererror) - 1,
    0
};


const char* strerror_get_message(size_t major, size_t minor)
{
    static const char* const undefined = "UNDEFINED ERROR";

    // Extract the major array
    if (major >= sizeof(strerror_array_major)/sizeof(const char**))
    {
        return undefined;
    }

    const char** array = strerror_array_major[major];
    const size_t size = strerror_array_sizes[major];

    if (minor >= size)
    {
        return undefined;
    }

    return array[minor];
}


} // namespace srt