PARA_ERROR(ALREADY_MAPPED, "file already mapped"), \
PARA_ERROR(BAD_SIZE, "invalid size specified"), \
PARA_ERROR(TRUNC, "failed to truncate file"), \
PARA_ERROR(ALREADY_MAPPED, "file already mapped"), \
PARA_ERROR(BAD_SIZE, "invalid size specified"), \
PARA_ERROR(TRUNC, "failed to truncate file"), \
PARA_ERROR(BAD_TABLE, "table not open"), \
PARA_ERROR(BAD_TABLE_DESC, "invalid table description"), \
PARA_ERROR(RB_KEY_EXISTS, "key already exists in rbtree"), \
PARA_ERROR(BAD_TABLE, "table not open"), \
PARA_ERROR(BAD_TABLE_DESC, "invalid table description"), \
PARA_ERROR(RB_KEY_EXISTS, "key already exists in rbtree"), \
PARA_ERROR(INDEX_CORRUPTION, "index corruption detected"), \
PARA_ERROR(INVALID_OBJECT, "reference to invalid object"), \
PARA_ERROR(STAT, "can not stat file"), \
PARA_ERROR(INDEX_CORRUPTION, "index corruption detected"), \
PARA_ERROR(INVALID_OBJECT, "reference to invalid object"), \
PARA_ERROR(STAT, "can not stat file"), \
PARA_ERROR(WRITE, "write error"), \
PARA_ERROR(LSEEK, "lseek error"), \
PARA_ERROR(BUSY, "table is busy"), \
PARA_ERROR(SHORT_TABLE, "table too short"), \
PARA_ERROR(NO_MAGIC, "missing table header magic"), \
PARA_ERROR(WRITE, "write error"), \
PARA_ERROR(LSEEK, "lseek error"), \
PARA_ERROR(BUSY, "table is busy"), \
PARA_ERROR(SHORT_TABLE, "table too short"), \
PARA_ERROR(NO_MAGIC, "missing table header magic"), \
PARA_ERROR(BAD_COLUMN_NUM, "invalid column number"), \
PARA_ERROR(BAD_TABLE_FLAGS, "invalid flags in table description"), \
PARA_ERROR(BAD_ROW, "invalid row"), \
PARA_ERROR(BAD_COLUMN_NUM, "invalid column number"), \
PARA_ERROR(BAD_TABLE_FLAGS, "invalid flags in table description"), \
PARA_ERROR(BAD_ROW, "invalid row"), \
#define MOOD_ERRORS \
PARA_ERROR(MOOD_SYNTAX, "mood syntax error"), \
PARA_ERROR(NO_MOOD, "no mood available"), \
#define MOOD_ERRORS \
PARA_ERROR(MOOD_SYNTAX, "mood syntax error"), \
PARA_ERROR(NO_MOOD, "no mood available"), \
- PARA_ERROR(MOOD_LOADED, "mood loaded"), \
- PARA_ERROR(NOT_ADMISSIBLE, "file is not admussible"), \
+ PARA_ERROR(NOT_ADMISSIBLE, "file is not admissible"), \
#define ATTRIBUTE_ERRORS \
PARA_ERROR(ATTR_SYNTAX, "attribute syntax error"), \
PARA_ERROR(NO_ATTRIBUTES, "no attributes defined yet"), \
#define ATTRIBUTE_ERRORS \
PARA_ERROR(ATTR_SYNTAX, "attribute syntax error"), \
PARA_ERROR(NO_ATTRIBUTES, "no attributes defined yet"), \
PARA_ERROR(PLAYLIST_LOADED, ""), /* not really an error */ \
PARA_ERROR(PATH_FOUND, ""), /* not really an error */ \
PARA_ERROR(PLAYLIST_EMPTY, "attempted to load empty playlist"), \
#define AFT_ERRORS \
PARA_ERROR(PLAYLIST_LOADED, ""), /* not really an error */ \
PARA_ERROR(PATH_FOUND, ""), /* not really an error */ \
PARA_ERROR(PLAYLIST_EMPTY, "attempted to load empty playlist"), \
#define AFT_ERRORS \
PARA_ERROR(LOCALTIME, "localtime() failed"), \
PARA_ERROR(STRFTIME, "strftime() failed"), \
PARA_ERROR(BAD_PATH, "invalid path"), \
PARA_ERROR(LOCALTIME, "localtime() failed"), \
PARA_ERROR(STRFTIME, "strftime() failed"), \
PARA_ERROR(BAD_PATH, "invalid path"), \
#define CLIENT_COMMON_ERRORS \
PARA_ERROR(CLIENT_SYNTAX, "syntax error"), \
PARA_ERROR(INVALID_CHALLENGE, "did not receive valid challenge"), \
PARA_ERROR(NO_CONFIG, "config file not found"), \
PARA_ERROR(CLIENT_AUTH, "authentication failed"), \
PARA_ERROR(SERVER_EOF, "connection closed by para_server"), \
#define CLIENT_COMMON_ERRORS \
PARA_ERROR(CLIENT_SYNTAX, "syntax error"), \
PARA_ERROR(INVALID_CHALLENGE, "did not receive valid challenge"), \
PARA_ERROR(NO_CONFIG, "config file not found"), \
PARA_ERROR(CLIENT_AUTH, "authentication failed"), \
PARA_ERROR(SERVER_EOF, "connection closed by para_server"), \
PARA_ERROR(CHMOD, "failed to set socket mode"), \
PARA_ERROR(SENDMSG, "sendmsg() failed"), \
PARA_ERROR(RECVMSG, "recvmsg() failed"), \
PARA_ERROR(CHMOD, "failed to set socket mode"), \
PARA_ERROR(SENDMSG, "sendmsg() failed"), \
PARA_ERROR(RECVMSG, "recvmsg() failed"), \
#define ORTP_RECV_ERRORS \
PARA_ERROR(MSG_TO_BUF, "failed to extract rtp packet"), \
#define ORTP_RECV_ERRORS \
PARA_ERROR(MSG_TO_BUF, "failed to extract rtp packet"), \
PARA_ERROR(TOO_MANY_BAD_CHUNKS, "too many consecutive bad chunks"), \
PARA_ERROR(INVALID_HEADER, "invalid header packet"), \
PARA_ERROR(TOO_MANY_BAD_CHUNKS, "too many consecutive bad chunks"), \
PARA_ERROR(INVALID_HEADER, "invalid header packet"), \
PARA_ERROR(ORTP_RECV_EOF, "ortp_recv: end of file"), \
#define HTTP_RECV_ERRORS \
PARA_ERROR(ORTP_RECV_EOF, "ortp_recv: end of file"), \
#define HTTP_RECV_ERRORS \
- PARA_ERROR(HTTP_RECV_EOF, "http_recv: end of file"), \
- PARA_ERROR(HTTP_RECV_OVERRUN, "http_recv: outout buffer overrun"), \
+ PARA_ERROR(HTTP_RECV_OVERRUN, "http_recv: output buffer overrun"), \
+
#define RECV_COMMON_ERRORS \
PARA_ERROR(RECV_SYNTAX, "recv syntax error"), \
#define RECV_COMMON_ERRORS \
PARA_ERROR(RECV_SYNTAX, "recv syntax error"), \
PARA_ERROR(MISSING_COLON, "syntax error: missing colon"), \
PARA_ERROR(UNSUPPORTED_AUDIO_FORMAT, "given audio format not supported"), \
PARA_ERROR(SIGNAL_CAUGHT, "caught signal"), \
PARA_ERROR(MISSING_COLON, "syntax error: missing colon"), \
PARA_ERROR(UNSUPPORTED_AUDIO_FORMAT, "given audio format not supported"), \
PARA_ERROR(SIGNAL_CAUGHT, "caught signal"), \
#define COMMAND_ERRORS \
PARA_ERROR(COMMAND_SYNTAX, "syntax error in command"), \
PARA_ERROR(AUTH, "did not receive auth request"), \
#define COMMAND_ERRORS \
PARA_ERROR(COMMAND_SYNTAX, "syntax error in command"), \
PARA_ERROR(AUTH, "did not receive auth request"), \
PARA_ERROR(NO_AUDIO_FILE, "no audio file"), \
PARA_ERROR(BAD_CMD, "invalid command"), \
PARA_ERROR(PERM, "permission denied"), \
PARA_ERROR(NO_AUDIO_FILE, "no audio file"), \
PARA_ERROR(BAD_CMD, "invalid command"), \
PARA_ERROR(PERM, "permission denied"), \
PARA_ERROR(DCCP_WRITE, "dccp write error"), \
#define FD_ERRORS \
PARA_ERROR(FGETS, "fgets error"), \
PARA_ERROR(DCCP_WRITE, "dccp write error"), \
#define FD_ERRORS \
PARA_ERROR(FGETS, "fgets error"), \
- PARA_ERROR(CHDIR, "failed to change directory"), \
- PARA_ERROR(OPEN, "failed to open file"), \
- PARA_ERROR(CHDIR_PERM, "insufficient permissions to chdir"), \
PARA_ERROR(EMPTY, "file empty"), \
PARA_ERROR(MMAP, "mmap error"), \
PARA_ERROR(MUNMAP, "munmap failed"), \
PARA_ERROR(EMPTY, "file empty"), \
PARA_ERROR(MMAP, "mmap error"), \
PARA_ERROR(MUNMAP, "munmap failed"), \
#define WRITE_COMMON_ERRORS \
PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \
#define WRITE_COMMON_ERRORS \
PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \
#define CHUNK_QUEUE_ERRORS \
PARA_ERROR(QUEUE, "packet queue overrun"), \
#define CHUNK_QUEUE_ERRORS \
PARA_ERROR(QUEUE, "packet queue overrun"), \
*
* As zero should not be an error, we define a dummy enum entry with value
* 2**ss. That lets the real errors start at 2**ss + 1.
*
* As zero should not be an error, we define a dummy enum entry with value
* 2**ss. That lets the real errors start at 2**ss + 1.
*
* Easy, it's just \a num / 2**8.
*/
#define ERRNUM_TO_SS(num) ((num) >> SS_SHIFT)
/**
*
* Easy, it's just \a num / 2**8.
*/
#define ERRNUM_TO_SS(num) ((num) >> SS_SHIFT)
/**
*
* Also easy: It's the lower 8 bits of num.
*/
#define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num))
*
* Also easy: It's the lower 8 bits of num.
*/
#define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num))
-static inline int is_errno(int val, int _errno)
+/** Check whether a given number is a system error number.
+ *
+ * \param num The value to be checked.
+ * \param _errno The system error number.
+ *
+ * \return True if \a num is paraslash's representation of the system
+ * error identified by \a _errno.
+ */
+_static_inline_ int is_errno(int num, int _errno)
-#define PARA_STRERROR(num) IS_SYSTEM_ERROR(num)? \
- strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1)) : \
- para_errlist[ERRNUM_TO_SS(num)] [ERRNUM_TO_INDEX(num)]
-
+_static_inline_ const char *para_strerror(int num)
+{
+ assert(num > 0);
+ if (IS_SYSTEM_ERROR(num))
+ return strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1));
+ else
+ return para_errlist[ERRNUM_TO_SS(num)][ERRNUM_TO_INDEX(num)];
+}
- * Each executable needs only the error lists of those subssystems it is
- * actually linked with. We always reserve space for NUM_SS char ** pointers,
+ * Each executable needs only the error lists of those subsystems it is
+ * actually linked with. We always reserve space for NUM_SS char pointers,
* but only init those of the needed subsystems. This macro is used by macros
* in config.h (generated by configure).
*/
* but only init those of the needed subsystems. This macro is used by macros
* in config.h (generated by configure).
*/