BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

errno.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_ERRNO_H__
20#define __PJ_ERRNO_H__
21
26#include <pj/types.h>
27#include <pj/compat/errno.h>
28#include <stdarg.h>
29
31
84#define PJ_ERR_MSG_SIZE 80
85
89#ifndef PJ_PERROR_TITLE_BUF_SIZE
90# define PJ_PERROR_TITLE_BUF_SIZE 120
91#endif
92
93
103
108PJ_DECL(void) pj_set_os_error(pj_status_t code);
109
115
120PJ_DECL(void) pj_set_netos_error(pj_status_t code);
121
122
134PJ_DECL(pj_str_t) pj_strerror( pj_status_t statcode,
135 char *buf, pj_size_t bufsize);
136
175#define PJ_PERROR(level,arg) do { \
176 pj_perror_wrapper_##level(arg); \
177 } while (0)
178
201PJ_DECL(void) pj_perror(int log_level, const char *sender, pj_status_t status,
202 const char *title_fmt, ...);
203
204
214typedef pj_str_t (*pj_error_callback)(pj_status_t e, char *msg, pj_size_t max);
215
216
237 pj_status_t err_space,
239
257#ifndef PJ_RETURN_OS_ERROR
258# define PJ_RETURN_OS_ERROR(os_code) (os_code ? \
259 PJ_STATUS_FROM_OS(os_code) : -1)
260#endif
261
262
272#if PJ_NATIVE_ERR_POSITIVE
273# define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
274#else
275# define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
276#endif
277
288#if PJ_NATIVE_ERR_POSITIVE
289# define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
290#else
291# define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
292#endif
293
294
308#ifndef PJ_BUILD_ERR
309# define PJ_BUILD_ERR(code,msg) { code, msg " (" #code ")" }
310#endif
311
312
317#define PJ_EUNKNOWN (PJ_ERRNO_START_STATUS + 1) /* 70001 */
322#define PJ_EPENDING (PJ_ERRNO_START_STATUS + 2) /* 70002 */
327#define PJ_ETOOMANYCONN (PJ_ERRNO_START_STATUS + 3) /* 70003 */
332#define PJ_EINVAL (PJ_ERRNO_START_STATUS + 4) /* 70004 */
337#define PJ_ENAMETOOLONG (PJ_ERRNO_START_STATUS + 5) /* 70005 */
342#define PJ_ENOTFOUND (PJ_ERRNO_START_STATUS + 6) /* 70006 */
347#define PJ_ENOMEM (PJ_ERRNO_START_STATUS + 7) /* 70007 */
352#define PJ_EBUG (PJ_ERRNO_START_STATUS + 8) /* 70008 */
357#define PJ_ETIMEDOUT (PJ_ERRNO_START_STATUS + 9) /* 70009 */
362#define PJ_ETOOMANY (PJ_ERRNO_START_STATUS + 10)/* 70010 */
367#define PJ_EBUSY (PJ_ERRNO_START_STATUS + 11)/* 70011 */
372#define PJ_ENOTSUP (PJ_ERRNO_START_STATUS + 12)/* 70012 */
377#define PJ_EINVALIDOP (PJ_ERRNO_START_STATUS + 13)/* 70013 */
382#define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14)/* 70014 */
387#define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 15)/* 70015 */
392#define PJ_EEOF (PJ_ERRNO_START_STATUS + 16)/* 70016 */
397#define PJ_ETOOBIG (PJ_ERRNO_START_STATUS + 17)/* 70017 */
403#define PJ_ERESOLVE (PJ_ERRNO_START_STATUS + 18)/* 70018 */
408#define PJ_ETOOSMALL (PJ_ERRNO_START_STATUS + 19)/* 70019 */
413#define PJ_EIGNORED (PJ_ERRNO_START_STATUS + 20)/* 70020 */
418#define PJ_EIPV6NOTSUP (PJ_ERRNO_START_STATUS + 21)/* 70021 */
423#define PJ_EAFNOTSUP (PJ_ERRNO_START_STATUS + 22)/* 70022 */
428#define PJ_EGONE (PJ_ERRNO_START_STATUS + 23)/* 70023 */
433#define PJ_ESOCKETSTOP (PJ_ERRNO_START_STATUS + 24)/* 70024 */
434 /* pj_errnum */
436 /* pj_errno */
438
439
443#define PJ_ERRNO_START 20000
444
449#define PJ_ERRNO_SPACE_SIZE 50000
450
455#define PJ_ERRNO_START_STATUS (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
456
462#define PJ_ERRNO_START_SYS (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
463
469#define PJ_ERRNO_START_USER (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
470
471
472/*
473 * Below are list of error spaces that have been taken so far:
474 * - PJSIP_ERRNO_START (PJ_ERRNO_START_USER)
475 * - PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
476 * - PJSIP_SIMPLE_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*2)
477 * - PJLIB_UTIL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
478 * - PJNATH_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
479 * - PJMEDIA_AUDIODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
480 * - PJ_SSL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*6)
481 * - PJMEDIA_VIDEODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*7)
482 */
483
486
487
488/****** Internal for PJ_PERROR *******/
489
496#if PJ_LOG_MAX_LEVEL >= 1
497 #define pj_perror_wrapper_1(arg) pj_perror_1 arg
499 PJ_DECL(void) pj_perror_1(const char *sender, pj_status_t status,
500 const char *title_fmt, ...);
501#else
502 #define pj_perror_wrapper_1(arg)
503#endif
504
511#if PJ_LOG_MAX_LEVEL >= 2
512 #define pj_perror_wrapper_2(arg) pj_perror_2 arg
514 PJ_DECL(void) pj_perror_2(const char *sender, pj_status_t status,
515 const char *title_fmt, ...);
516#else
517 #define pj_perror_wrapper_2(arg)
518#endif
519
526#if PJ_LOG_MAX_LEVEL >= 3
527 #define pj_perror_wrapper_3(arg) pj_perror_3 arg
529 PJ_DECL(void) pj_perror_3(const char *sender, pj_status_t status,
530 const char *title_fmt, ...);
531#else
532 #define pj_perror_wrapper_3(arg)
533#endif
534
541#if PJ_LOG_MAX_LEVEL >= 4
542 #define pj_perror_wrapper_4(arg) pj_perror_4 arg
544 PJ_DECL(void) pj_perror_4(const char *sender, pj_status_t status,
545 const char *title_fmt, ...);
546#else
547 #define pj_perror_wrapper_4(arg)
548#endif
549
556#if PJ_LOG_MAX_LEVEL >= 5
557 #define pj_perror_wrapper_5(arg) pj_perror_5 arg
559 PJ_DECL(void) pj_perror_5(const char *sender, pj_status_t status,
560 const char *title_fmt, ...);
561#else
562 #define pj_perror_wrapper_5(arg)
563#endif
564
571#if PJ_LOG_MAX_LEVEL >= 6
572 #define pj_perror_wrapper_6(arg) pj_perror_6 arg
574 PJ_DECL(void) pj_perror_6(const char *sender, pj_status_t status,
575 const char *title_fmt, ...);
576#else
577 #define pj_perror_wrapper_6(arg)
578#endif
579
580
581
582
584
585#endif /* __PJ_ERRNO_H__ */
586
void pj_errno_clear_handlers(void)
void pj_perror_4(const char *sender, pj_status_t status, const char *title_fmt,...)
void pj_perror_1(const char *sender, pj_status_t status, const char *title_fmt,...)
void pj_perror_3(const char *sender, pj_status_t status, const char *title_fmt,...)
void pj_perror_2(const char *sender, pj_status_t status, const char *title_fmt,...)
size_t pj_size_t
Definition: types.h:58
int pj_status_t
Definition: types.h:68
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
pj_str_t(* pj_error_callback)(pj_status_t e, char *msg, pj_size_t max)
Definition: errno.h:214
void pj_perror(int log_level, const char *sender, pj_status_t status, const char *title_fmt,...)
pj_str_t pj_strerror(pj_status_t statcode, char *buf, pj_size_t bufsize)
void pj_set_os_error(pj_status_t code)
void pj_set_netos_error(pj_status_t code)
pj_status_t pj_get_os_error(void)
pj_status_t pj_register_strerror(pj_status_t start_code, pj_status_t err_space, pj_error_callback f)
pj_status_t pj_get_netos_error(void)
Definition: types.h:120
Declaration of basic types and utility.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.