BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

errno.h
Go to the documentation of this file.
1 /* $Id: errno.h 4461 2013-04-05 03:02:19Z riza $ */
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 
434 #define PJ_ESOCKETSTOP (PJ_ERRNO_START_STATUS + 24)/* 70024 */
435  /* pj_errnum */
437  /* pj_errno */
439 
440 
444 #define PJ_ERRNO_START 20000
445 
450 #define PJ_ERRNO_SPACE_SIZE 50000
451 
456 #define PJ_ERRNO_START_STATUS (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
457 
463 #define PJ_ERRNO_START_SYS (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
464 
470 #define PJ_ERRNO_START_USER (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
471 
472 
473 /*
474  * Below are list of error spaces that have been taken so far:
475  * - PJSIP_ERRNO_START (PJ_ERRNO_START_USER)
476  * - PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
477  * - PJSIP_SIMPLE_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*2)
478  * - PJLIB_UTIL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
479  * - PJNATH_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
480  * - PJMEDIA_AUDIODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
481  * - PJ_SSL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*6)
482  * - PJMEDIA_VIDEODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*7)
483  */
484 
485 /* Internal */
486 void pj_errno_clear_handlers(void);
487 
488 
489 /****** Internal for PJ_PERROR *******/
490 
497 #if PJ_LOG_MAX_LEVEL >= 1
498  #define pj_perror_wrapper_1(arg) pj_perror_1 arg
499 
500  PJ_DECL(void) pj_perror_1(const char *sender, pj_status_t status,
501  const char *title_fmt, ...);
502 #else
503  #define pj_perror_wrapper_1(arg)
504 #endif
505 
512 #if PJ_LOG_MAX_LEVEL >= 2
513  #define pj_perror_wrapper_2(arg) pj_perror_2 arg
514 
515  PJ_DECL(void) pj_perror_2(const char *sender, pj_status_t status,
516  const char *title_fmt, ...);
517 #else
518  #define pj_perror_wrapper_2(arg)
519 #endif
520 
527 #if PJ_LOG_MAX_LEVEL >= 3
528  #define pj_perror_wrapper_3(arg) pj_perror_3 arg
529 
530  PJ_DECL(void) pj_perror_3(const char *sender, pj_status_t status,
531  const char *title_fmt, ...);
532 #else
533  #define pj_perror_wrapper_3(arg)
534 #endif
535 
542 #if PJ_LOG_MAX_LEVEL >= 4
543  #define pj_perror_wrapper_4(arg) pj_perror_4 arg
544 
545  PJ_DECL(void) pj_perror_4(const char *sender, pj_status_t status,
546  const char *title_fmt, ...);
547 #else
548  #define pj_perror_wrapper_4(arg)
549 #endif
550 
557 #if PJ_LOG_MAX_LEVEL >= 5
558  #define pj_perror_wrapper_5(arg) pj_perror_5 arg
559 
560  PJ_DECL(void) pj_perror_5(const char *sender, pj_status_t status,
561  const char *title_fmt, ...);
562 #else
563  #define pj_perror_wrapper_5(arg)
564 #endif
565 
572 #if PJ_LOG_MAX_LEVEL >= 6
573  #define pj_perror_wrapper_6(arg) pj_perror_6 arg
574 
575  PJ_DECL(void) pj_perror_6(const char *sender, pj_status_t status,
576  const char *title_fmt, ...);
577 #else
578  #define pj_perror_wrapper_6(arg)
579 #endif
580 
581 
582 
583 
585 
586 #endif /* __PJ_ERRNO_H__ */
587 
pj_str_t(* pj_error_callback)(pj_status_t e, char *msg, pj_size_t max)
Definition: errno.h:215
void pj_set_os_error(pj_status_t code)
Declaration of basic types and utility.
int pj_status_t
Definition: types.h:68
Definition: types.h:119
void pj_perror_3(const char *sender, pj_status_t status, const char *title_fmt,...)
#define PJ_END_DECL
Definition: config.h:1067
void pj_perror(int log_level, const char *sender, pj_status_t status, const char *title_fmt,...)
#define PJ_BEGIN_DECL
Definition: config.h:1066
pj_status_t pj_get_netos_error(void)
pj_status_t pj_register_strerror(pj_status_t start_code, pj_status_t err_space, pj_error_callback f)
pj_str_t pj_strerror(pj_status_t statcode, char *buf, pj_size_t bufsize)
void pj_perror_2(const char *sender, pj_status_t status, const char *title_fmt,...)
void pj_perror_4(const char *sender, pj_status_t status, const char *title_fmt,...)
void pj_set_netos_error(pj_status_t code)
void pj_perror_1(const char *sender, pj_status_t status, const char *title_fmt,...)
pj_status_t pj_get_os_error(void)
size_t pj_size_t
Definition: types.h:58

 


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