BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

errno.h
Go to the documentation of this file.
1 /* $Id: errno.h 4359 2013-02-21 11:18:36Z bennylp $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_ERRNO_H__
21 #define __PJ_ERRNO_H__
22 
27 #include <pj/types.h>
28 #include <pj/compat/errno.h>
29 #include <stdarg.h>
30 
32 
85 #define PJ_ERR_MSG_SIZE 80
86 
90 #ifndef PJ_PERROR_TITLE_BUF_SIZE
91 # define PJ_PERROR_TITLE_BUF_SIZE 120
92 #endif
93 
94 
103 PJ_DECL(pj_status_t) pj_get_os_error(void);
104 
109 PJ_DECL(void) pj_set_os_error(pj_status_t code);
110 
115 PJ_DECL(pj_status_t) pj_get_netos_error(void);
116 
121 PJ_DECL(void) pj_set_netos_error(pj_status_t code);
122 
123 
135 PJ_DECL(pj_str_t) pj_strerror( pj_status_t statcode,
136  char *buf, pj_size_t bufsize);
137 
176 #define PJ_PERROR(level,arg) do { \
177  pj_perror_wrapper_##level(arg); \
178  } while (0)
179 
202 PJ_DECL(void) pj_perror(int log_level, const char *sender, pj_status_t status,
203  const char *title_fmt, ...);
204 
205 
215 typedef pj_str_t (*pj_error_callback)(pj_status_t e, char *msg, pj_size_t max);
216 
217 
237 PJ_DECL(pj_status_t) pj_register_strerror(pj_status_t start_code,
238  pj_status_t err_space,
240 
258 #ifndef PJ_RETURN_OS_ERROR
259 # define PJ_RETURN_OS_ERROR(os_code) (os_code ? \
260  PJ_STATUS_FROM_OS(os_code) : -1)
261 #endif
262 
263 
273 #if PJ_NATIVE_ERR_POSITIVE
274 # define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
275 #else
276 # define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
277 #endif
278 
289 #if PJ_NATIVE_ERR_POSITIVE
290 # define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
291 #else
292 # define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
293 #endif
294 
295 
309 #ifndef PJ_BUILD_ERR
310 # define PJ_BUILD_ERR(code,msg) { code, msg " (" #code ")" }
311 #endif
312 
313 
318 #define PJ_EUNKNOWN (PJ_ERRNO_START_STATUS + 1) /* 70001 */
319 
323 #define PJ_EPENDING (PJ_ERRNO_START_STATUS + 2) /* 70002 */
324 
328 #define PJ_ETOOMANYCONN (PJ_ERRNO_START_STATUS + 3) /* 70003 */
329 
333 #define PJ_EINVAL (PJ_ERRNO_START_STATUS + 4) /* 70004 */
334 
338 #define PJ_ENAMETOOLONG (PJ_ERRNO_START_STATUS + 5) /* 70005 */
339 
343 #define PJ_ENOTFOUND (PJ_ERRNO_START_STATUS + 6) /* 70006 */
344 
348 #define PJ_ENOMEM (PJ_ERRNO_START_STATUS + 7) /* 70007 */
349 
353 #define PJ_EBUG (PJ_ERRNO_START_STATUS + 8) /* 70008 */
354 
358 #define PJ_ETIMEDOUT (PJ_ERRNO_START_STATUS + 9) /* 70009 */
359 
363 #define PJ_ETOOMANY (PJ_ERRNO_START_STATUS + 10)/* 70010 */
364 
368 #define PJ_EBUSY (PJ_ERRNO_START_STATUS + 11)/* 70011 */
369 
373 #define PJ_ENOTSUP (PJ_ERRNO_START_STATUS + 12)/* 70012 */
374 
378 #define PJ_EINVALIDOP (PJ_ERRNO_START_STATUS + 13)/* 70013 */
379 
383 #define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14)/* 70014 */
384 
388 #define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 15)/* 70015 */
389 
393 #define PJ_EEOF (PJ_ERRNO_START_STATUS + 16)/* 70016 */
394 
398 #define PJ_ETOOBIG (PJ_ERRNO_START_STATUS + 17)/* 70017 */
399 
404 #define PJ_ERESOLVE (PJ_ERRNO_START_STATUS + 18)/* 70018 */
405 
409 #define PJ_ETOOSMALL (PJ_ERRNO_START_STATUS + 19)/* 70019 */
410 
414 #define PJ_EIGNORED (PJ_ERRNO_START_STATUS + 20)/* 70020 */
415 
419 #define PJ_EIPV6NOTSUP (PJ_ERRNO_START_STATUS + 21)/* 70021 */
420 
424 #define PJ_EAFNOTSUP (PJ_ERRNO_START_STATUS + 22)/* 70022 */
425 
429 #define PJ_EGONE (PJ_ERRNO_START_STATUS + 23)/* 70023 */
430  /* pj_errnum */
432  /* pj_errno */
434 
435 
439 #define PJ_ERRNO_START 20000
440 
445 #define PJ_ERRNO_SPACE_SIZE 50000
446 
451 #define PJ_ERRNO_START_STATUS (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
452 
458 #define PJ_ERRNO_START_SYS (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
459 
465 #define PJ_ERRNO_START_USER (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
466 
467 
468 /*
469  * Below are list of error spaces that have been taken so far:
470  * - PJSIP_ERRNO_START (PJ_ERRNO_START_USER)
471  * - PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
472  * - PJSIP_SIMPLE_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*2)
473  * - PJLIB_UTIL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
474  * - PJNATH_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
475  * - PJMEDIA_AUDIODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
476  * - PJ_SSL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*6)
477  * - PJMEDIA_VIDEODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*7)
478  */
479 
480 /* Internal */
481 void pj_errno_clear_handlers(void);
482 
483 
484 /****** Internal for PJ_PERROR *******/
485 
492 #if PJ_LOG_MAX_LEVEL >= 1
493  #define pj_perror_wrapper_1(arg) pj_perror_1 arg
494 
495  PJ_DECL(void) pj_perror_1(const char *sender, pj_status_t status,
496  const char *title_fmt, ...);
497 #else
498  #define pj_perror_wrapper_1(arg)
499 #endif
500 
507 #if PJ_LOG_MAX_LEVEL >= 2
508  #define pj_perror_wrapper_2(arg) pj_perror_2 arg
509 
510  PJ_DECL(void) pj_perror_2(const char *sender, pj_status_t status,
511  const char *title_fmt, ...);
512 #else
513  #define pj_perror_wrapper_2(arg)
514 #endif
515 
522 #if PJ_LOG_MAX_LEVEL >= 3
523  #define pj_perror_wrapper_3(arg) pj_perror_3 arg
524 
525  PJ_DECL(void) pj_perror_3(const char *sender, pj_status_t status,
526  const char *title_fmt, ...);
527 #else
528  #define pj_perror_wrapper_3(arg)
529 #endif
530 
537 #if PJ_LOG_MAX_LEVEL >= 4
538  #define pj_perror_wrapper_4(arg) pj_perror_4 arg
539 
540  PJ_DECL(void) pj_perror_4(const char *sender, pj_status_t status,
541  const char *title_fmt, ...);
542 #else
543  #define pj_perror_wrapper_4(arg)
544 #endif
545 
552 #if PJ_LOG_MAX_LEVEL >= 5
553  #define pj_perror_wrapper_5(arg) pj_perror_5 arg
554 
555  PJ_DECL(void) pj_perror_5(const char *sender, pj_status_t status,
556  const char *title_fmt, ...);
557 #else
558  #define pj_perror_wrapper_5(arg)
559 #endif
560 
567 #if PJ_LOG_MAX_LEVEL >= 6
568  #define pj_perror_wrapper_6(arg) pj_perror_6 arg
569 
570  PJ_DECL(void) pj_perror_6(const char *sender, pj_status_t status,
571  const char *title_fmt, ...);
572 #else
573  #define pj_perror_wrapper_6(arg)
574 #endif
575 
576 
577 
578 
580 
581 #endif /* __PJ_ERRNO_H__ */
582 

 


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