lwpa  0.1.0
LightWeight Platform Abstraction (lwpa)
View other versions:
lwpa_error.h
1 /******************************************************************************
2  * Copyright 2018 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of lwpa. For more information, go to:
17  * https://github.com/ETCLabs/lwpa
18  ******************************************************************************/
19 
20 /* lwpa_error.h: Platform-neutral error codes. */
21 #ifndef _LWPA_ERROR_H_
22 #define _LWPA_ERROR_H_
23 
24 #include <stdlib.h>
25 
36 typedef enum
37 {
39  LWPA_OK = 0,
45  LWPA_NOMEM = -2,
47  LWPA_BUSY = -3,
49  LWPA_EXIST = -4,
66  LWPA_NETERR = -12,
73  LWPA_ISCONN = -15,
75  LWPA_NOTCONN = -16,
83  LWPA_ALREADY = -20,
88  LWPA_BUFSIZE = -22,
91  LWPA_NOTINIT = -23,
96  LWPA_NOTIMPL = -25,
99  LWPA_SYSERR = -26,
100 } lwpa_error_t;
101 
102 #define LWPA_NUM_ERROR_CODES 27
103 
104 #ifdef __cplusplus
105 extern "C" {
106 #endif
107 
108 extern const char *lwpa_error_strings[LWPA_NUM_ERROR_CODES];
109 
115 #define lwpa_strerror(errcode) \
116  (((int)errcode <= 0 && (int)errcode > -LWPA_NUM_ERROR_CODES) ? lwpa_error_strings[-((int)errcode)] : NULL)
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
124 #endif /* _LWPA_ERROR_H_ */
lwpa_error_t
A set of error codes that can be returned by library functions.
Definition: lwpa_error.h:37
@ LWPA_NOTIMPL
A function or specific use of a function is not implemented yet.
Definition: lwpa_error.h:96
@ LWPA_NODATA
Returned from a function that is meant to be called repeatedly to indicate that there is no more data...
Definition: lwpa_error.h:56
@ LWPA_NOTINIT
An API function was called from a module that was not previously initialized.
Definition: lwpa_error.h:91
@ LWPA_INPROGRESS
The operation requested is now in progress and will complete later.
Definition: lwpa_error.h:85
@ LWPA_BUFSIZE
A buffer provided to a function was not big enough to hold the data that needed to be packed into it.
Definition: lwpa_error.h:88
@ LWPA_NOMEM
A dynamic memory allocation failed, or there is no space left in a statically allocated array.
Definition: lwpa_error.h:45
@ LWPA_EXIST
The item being created already exists.
Definition: lwpa_error.h:49
@ LWPA_TIMEDOUT
A connection timed out.
Definition: lwpa_error.h:79
@ LWPA_ADDRINUSE
The requested address is already in use.
Definition: lwpa_error.h:62
@ LWPA_NOTFOUND
An identifier or handle passed to a function was not valid or not previously initialized.
Definition: lwpa_error.h:42
@ LWPA_NOIFACES
No network interfaces were found on the system, or there are no network interfaces of a type that can...
Definition: lwpa_error.h:94
@ LWPA_ALREADY
The operation requested is already in progress.
Definition: lwpa_error.h:83
@ LWPA_CONNREFUSED
A connection was refused.
Definition: lwpa_error.h:81
@ LWPA_PROTERR
A protocol parsing function encountered a malformed packet.
Definition: lwpa_error.h:58
@ LWPA_WOULDBLOCK
The requested operation would block.
Definition: lwpa_error.h:53
@ LWPA_SHUTDOWN
Transport endpoint is shut down.
Definition: lwpa_error.h:77
@ LWPA_MSGSIZE
Message too long.
Definition: lwpa_error.h:60
@ LWPA_OK
The call was successful, no error occurred.
Definition: lwpa_error.h:39
@ LWPA_NOTCONN
Transport endpoint is not connected.
Definition: lwpa_error.h:75
@ LWPA_INVALID
An invalid argument was provided to an API function.
Definition: lwpa_error.h:51
@ LWPA_CONNCLOSED
A connection was gracefully closed by the remote peer.
Definition: lwpa_error.h:71
@ LWPA_CONNRESET
A connection was reset (hard/abortive close) by the remote peer.
Definition: lwpa_error.h:68
@ LWPA_BUSY
The resource being requested is temporarily unavailable.
Definition: lwpa_error.h:47
@ LWPA_SYSERR
A system call or C library call failed in a way not covered by other errors.
Definition: lwpa_error.h:99
@ LWPA_ADDRNOTAVAIL
Cannot assign the requested address.
Definition: lwpa_error.h:64
@ LWPA_ISCONN
Transport endpoint is already connected.
Definition: lwpa_error.h:73
@ LWPA_NETERR
The operation failed because a network was down or unreachable.
Definition: lwpa_error.h:66