errno.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. /**
  22. * @file errno.h
  23. * @brief PJLIB Error Subsystem
  24. */
  25. #include <pj/types.h>
  26. #include <pj/compat/errno.h>
  27. #include <stdarg.h>
  28. PJ_BEGIN_DECL
  29. /**
  30. * @defgroup pj_errno Error Subsystem
  31. * @{
  32. *
  33. * The PJLIB Error Subsystem is a framework to unify all error codes
  34. * produced by all components into a single error space, and provide
  35. * uniform set of APIs to access them. With this framework, any error
  36. * codes are encoded as pj_status_t value. The framework is extensible,
  37. * application may register new error spaces to be recognized by
  38. * the framework.
  39. *
  40. * @section pj_errno_retval Return Values
  41. *
  42. * All functions that returns @a pj_status_t returns @a PJ_SUCCESS if the
  43. * operation was completed successfully, or non-zero value to indicate
  44. * error. If the error came from operating system, then the native error
  45. * code is translated/folded into PJLIB's error namespace by using
  46. * #PJ_STATUS_FROM_OS() macro. The function will do this automatically
  47. * before returning the error to caller.
  48. *
  49. * @section err_services Retrieving and Displaying Error Messages
  50. *
  51. * The framework provides the following APIs to retrieve and/or display
  52. * error messages:
  53. *
  54. * - #pj_strerror(): this is the base API to retrieve error string
  55. * description for the specified pj_status_t error code.
  56. *
  57. * - #PJ_PERROR() macro: use this macro similar to PJ_LOG to format
  58. * an error message and display them to the log
  59. *
  60. * - #pj_perror(): this function is similar to PJ_PERROR() but unlike
  61. * #PJ_PERROR(), this function will always be included in the
  62. * link process. Due to this reason, prefer to use #PJ_PERROR()
  63. * if the application is concerned about the executable size.
  64. *
  65. * Application MUST NOT pass native error codes (such as error code from
  66. * functions like GetLastError() or errno) to PJLIB functions expecting
  67. * @a pj_status_t.
  68. *
  69. * @section err_extending Extending the Error Space
  70. *
  71. * Application may register new error space to be recognized by the
  72. * framework by using #pj_register_strerror(). Use the range started
  73. * from PJ_ERRNO_START_USER to avoid conflict with existing error
  74. * spaces.
  75. *
  76. */
  77. /**
  78. * Guidelines on error message length.
  79. */
  80. #ifndef PJ_ERR_MSG_SIZE
  81. # define PJ_ERR_MSG_SIZE 80
  82. #endif
  83. /**
  84. * Buffer for title string of #PJ_PERROR().
  85. */
  86. #ifndef PJ_PERROR_TITLE_BUF_SIZE
  87. # define PJ_PERROR_TITLE_BUF_SIZE 120
  88. #endif
  89. /**
  90. * On Windows XP and later, force the use of GetThreadLocale() in pj_strerror()
  91. * to obtain the required locale and corresponding language for the platform
  92. * error message string.
  93. * Default value is set to "no" for compatibility reason, which means use
  94. * "User default language".
  95. *
  96. * Default: 0 (no)
  97. */
  98. #ifndef PJ_STRERROR_USE_WIN_GET_THREAD_LOCALE
  99. # define PJ_STRERROR_USE_WIN_GET_THREAD_LOCALE 0
  100. #endif
  101. /**
  102. * Get the last platform error/status, folded into pj_status_t.
  103. * @return OS dependent error code, folded into pj_status_t.
  104. * @remark This function gets errno, or calls GetLastError() function and
  105. * convert the code into pj_status_t with PJ_STATUS_FROM_OS. Do
  106. * not call this for socket functions!
  107. * @see pj_get_netos_error()
  108. */
  109. PJ_DECL(pj_status_t) pj_get_os_error(void);
  110. /**
  111. * Set last error.
  112. * @param code pj_status_t
  113. */
  114. PJ_DECL(void) pj_set_os_error(pj_status_t code);
  115. /**
  116. * Get the last error from socket operations.
  117. * @return Last socket error, folded into pj_status_t.
  118. */
  119. PJ_DECL(pj_status_t) pj_get_netos_error(void);
  120. /**
  121. * Set error code.
  122. * @param code pj_status_t.
  123. */
  124. PJ_DECL(void) pj_set_netos_error(pj_status_t code);
  125. /**
  126. * Get the error message for the specified error code. The message
  127. * string will be NULL terminated.
  128. *
  129. * @param statcode The error code.
  130. * @param buf Buffer to hold the error message string.
  131. * @param bufsize Size of the buffer.
  132. *
  133. * @return The error message as NULL terminated string,
  134. * wrapped with pj_str_t.
  135. */
  136. PJ_DECL(pj_str_t) pj_strerror( pj_status_t statcode,
  137. char *buf, pj_size_t bufsize);
  138. /**
  139. * A utility macro to print error message pertaining to the specified error
  140. * code to the log. This macro will construct the error message title
  141. * according to the 'title_fmt' argument, and add the error string pertaining
  142. * to the error code after the title string. A colon (':') will be added
  143. * automatically between the title and the error string.
  144. *
  145. * This function is similar to pj_perror() function, but has the advantage
  146. * that the function call can be omitted from the link process if the
  147. * log level argument is below PJ_LOG_MAX_LEVEL threshold.
  148. *
  149. * Note that the title string constructed from the title_fmt will be built on
  150. * a string buffer which size is PJ_PERROR_TITLE_BUF_SIZE, which normally is
  151. * allocated from the stack. By default this buffer size is small (around
  152. * 120 characters). Application MUST ensure that the constructed title string
  153. * will not exceed this limit, since not all platforms support truncating
  154. * the string.
  155. *
  156. * @see pj_perror()
  157. *
  158. * @param level The logging verbosity level, valid values are 0-6. Lower
  159. * number indicates higher importance, with level zero
  160. * indicates fatal error. Only numeral argument is
  161. * permitted (e.g. not variable).
  162. * @param arg Enclosed 'printf' like arguments, with the following
  163. * arguments:
  164. * - the sender (NULL terminated string),
  165. * - the error code (pj_status_t)
  166. * - the format string (title_fmt), and
  167. * - optional variable number of arguments suitable for the
  168. * format string.
  169. *
  170. * Sample:
  171. * \verbatim
  172. PJ_PERROR(2, (__FILE__, PJ_EBUSY, "Error making %s", "coffee"));
  173. \endverbatim
  174. * @hideinitializer
  175. */
  176. #define PJ_PERROR(level,arg) do { \
  177. pj_perror_wrapper_##level(arg); \
  178. } while (0)
  179. /**
  180. * A utility function to print error message pertaining to the specified error
  181. * code to the log. This function will construct the error message title
  182. * according to the 'title_fmt' argument, and add the error string pertaining
  183. * to the error code after the title string. A colon (':') will be added
  184. * automatically between the title and the error string.
  185. *
  186. * Unlike the PJ_PERROR() macro, this function takes the \a log_level argument
  187. * as a normal argument, unlike in PJ_PERROR() where a numeral value must be
  188. * given. However this function will always be linked to the executable,
  189. * unlike PJ_PERROR() which can be omitted when the level is below the
  190. * PJ_LOG_MAX_LEVEL.
  191. *
  192. * Note that the title string constructed from the title_fmt will be built on
  193. * a string buffer which size is PJ_PERROR_TITLE_BUF_SIZE, which normally is
  194. * allocated from the stack. By default this buffer size is small (around
  195. * 120 characters). Application MUST ensure that the constructed title string
  196. * will not exceed this limit, since not all platforms support truncating
  197. * the string.
  198. *
  199. * @see PJ_PERROR()
  200. */
  201. PJ_DECL(void) pj_perror(int log_level, const char *sender, pj_status_t status,
  202. const char *title_fmt, ...)
  203. PJ_PRINT_FUNC_DECOR(4);
  204. /**
  205. * Type of callback to be specified in #pj_register_strerror()
  206. *
  207. * @param e The error code to lookup.
  208. * @param msg Buffer to store the error message.
  209. * @param max Length of the buffer.
  210. *
  211. * @return The error string.
  212. */
  213. typedef pj_str_t (*pj_error_callback)(pj_status_t e, char *msg, pj_size_t max);
  214. /**
  215. * Register strerror message handler for the specified error space.
  216. * Application can register its own handler to supply the error message
  217. * for the specified error code range. This handler will be called
  218. * by #pj_strerror().
  219. *
  220. * @param start_code The starting error code where the handler should
  221. * be called to retrieve the error message.
  222. * @param err_space The size of error space. The error code range then
  223. * will fall in start_code to start_code+err_space-1
  224. * range.
  225. * @param f The handler to be called when #pj_strerror() is
  226. * supplied with error code that falls into this range.
  227. *
  228. * @return PJ_SUCCESS or the specified error code. The
  229. * registration may fail when the error space has been
  230. * occupied by other handler, or when there are too many
  231. * handlers registered to PJLIB.
  232. */
  233. PJ_DECL(pj_status_t) pj_register_strerror(pj_status_t start_code,
  234. pj_status_t err_space,
  235. pj_error_callback f);
  236. /**
  237. * @hideinitializer
  238. * Return platform os error code folded into pj_status_t code. This is
  239. * the macro that is used throughout the library for all PJLIB's functions
  240. * that returns error from operating system. Application may override
  241. * this macro to reduce size (e.g. by defining it to always return
  242. * #PJ_EUNKNOWN).
  243. *
  244. * Note:
  245. * This macro MUST return non-zero value regardless whether zero is
  246. * passed as the argument. The reason is to protect logic error when
  247. * the operating system doesn't report error codes properly.
  248. *
  249. * @param os_code Platform OS error code. This value may be evaluated
  250. * more than once.
  251. * @return The platform os error code folded into pj_status_t.
  252. */
  253. #ifndef PJ_RETURN_OS_ERROR
  254. # define PJ_RETURN_OS_ERROR(os_code) (os_code ? \
  255. PJ_STATUS_FROM_OS(os_code) : -1)
  256. #endif
  257. /**
  258. * @hideinitializer
  259. * Fold a platform specific error into an pj_status_t code.
  260. *
  261. * @param e The platform os error code.
  262. * @return pj_status_t
  263. * @warning Macro implementation; the syserr argument may be evaluated
  264. * multiple times.
  265. */
  266. #if PJ_NATIVE_ERR_POSITIVE
  267. # define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  268. #else
  269. # define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
  270. #endif
  271. /**
  272. * @hideinitializer
  273. * Fold an pj_status_t code back to the native platform defined error.
  274. *
  275. * @param e The pj_status_t folded platform os error code.
  276. * @return pj_os_err_type
  277. * @warning macro implementation; the statcode argument may be evaluated
  278. * multiple times. If the statcode was not created by
  279. * pj_get_os_error or PJ_STATUS_FROM_OS, the results are undefined.
  280. */
  281. #if PJ_NATIVE_ERR_POSITIVE
  282. # define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
  283. #else
  284. # define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : PJ_ERRNO_START_SYS - e)
  285. #endif
  286. /**
  287. * @defgroup pj_errnum PJLIB's Own Error Codes
  288. * @ingroup pj_errno
  289. * @{
  290. */
  291. /**
  292. * Use this macro to generate error message text for your error code,
  293. * so that they look uniformly as the rest of the libraries.
  294. *
  295. * @param code The error code
  296. * @param msg The error test.
  297. */
  298. #ifndef PJ_BUILD_ERR
  299. # define PJ_BUILD_ERR(code,msg) { code, msg " (" #code ")" }
  300. #endif
  301. /**
  302. * @hideinitializer
  303. * Unknown error has been reported.
  304. */
  305. #define PJ_EUNKNOWN (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  306. /**
  307. * @hideinitializer
  308. * The operation is pending and will be completed later.
  309. */
  310. #define PJ_EPENDING (PJ_ERRNO_START_STATUS + 2) /* 70002 */
  311. /**
  312. * @hideinitializer
  313. * Too many connecting sockets.
  314. */
  315. #define PJ_ETOOMANYCONN (PJ_ERRNO_START_STATUS + 3) /* 70003 */
  316. /**
  317. * @hideinitializer
  318. * Invalid argument.
  319. */
  320. #define PJ_EINVAL (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  321. /**
  322. * @hideinitializer
  323. * Name too long (eg. hostname too long).
  324. */
  325. #define PJ_ENAMETOOLONG (PJ_ERRNO_START_STATUS + 5) /* 70005 */
  326. /**
  327. * @hideinitializer
  328. * Not found.
  329. */
  330. #define PJ_ENOTFOUND (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  331. /**
  332. * @hideinitializer
  333. * Not enough memory.
  334. */
  335. #define PJ_ENOMEM (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  336. /**
  337. * @hideinitializer
  338. * Bug detected!
  339. */
  340. #define PJ_EBUG (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  341. /**
  342. * @hideinitializer
  343. * Operation timed out.
  344. */
  345. #define PJ_ETIMEDOUT (PJ_ERRNO_START_STATUS + 9) /* 70009 */
  346. /**
  347. * @hideinitializer
  348. * Too many objects.
  349. */
  350. #define PJ_ETOOMANY (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  351. /**
  352. * @hideinitializer
  353. * Object is busy.
  354. */
  355. #define PJ_EBUSY (PJ_ERRNO_START_STATUS + 11)/* 70011 */
  356. /**
  357. * @hideinitializer
  358. * The specified option is not supported.
  359. */
  360. #define PJ_ENOTSUP (PJ_ERRNO_START_STATUS + 12)/* 70012 */
  361. /**
  362. * @hideinitializer
  363. * Invalid operation.
  364. */
  365. #define PJ_EINVALIDOP (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  366. /**
  367. * @hideinitializer
  368. * Operation is cancelled.
  369. */
  370. #define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  371. /**
  372. * @hideinitializer
  373. * Object already exists.
  374. */
  375. #define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 15)/* 70015 */
  376. /**
  377. * @hideinitializer
  378. * End of file.
  379. */
  380. #define PJ_EEOF (PJ_ERRNO_START_STATUS + 16)/* 70016 */
  381. /**
  382. * @hideinitializer
  383. * Size is too big.
  384. */
  385. #define PJ_ETOOBIG (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  386. /**
  387. * @hideinitializer
  388. * Error in gethostbyname(). This is a generic error returned when
  389. * gethostbyname() has returned an error.
  390. */
  391. #define PJ_ERESOLVE (PJ_ERRNO_START_STATUS + 18)/* 70018 */
  392. /**
  393. * @hideinitializer
  394. * Size is too small.
  395. */
  396. #define PJ_ETOOSMALL (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  397. /**
  398. * @hideinitializer
  399. * Ignored
  400. */
  401. #define PJ_EIGNORED (PJ_ERRNO_START_STATUS + 20)/* 70020 */
  402. /**
  403. * @hideinitializer
  404. * IPv6 is not supported
  405. */
  406. #define PJ_EIPV6NOTSUP (PJ_ERRNO_START_STATUS + 21)/* 70021 */
  407. /**
  408. * @hideinitializer
  409. * Unsupported address family
  410. */
  411. #define PJ_EAFNOTSUP (PJ_ERRNO_START_STATUS + 22)/* 70022 */
  412. /**
  413. * @hideinitializer
  414. * Object no longer exists
  415. */
  416. #define PJ_EGONE (PJ_ERRNO_START_STATUS + 23)/* 70023 */
  417. /**
  418. * @hideinitializer
  419. * Socket is stopped
  420. */
  421. #define PJ_ESOCKETSTOP (PJ_ERRNO_START_STATUS + 24)/* 70024 */
  422. /** @} */ /* pj_errnum */
  423. /** @} */ /* pj_errno */
  424. /**
  425. * PJ_ERRNO_START is where PJLIB specific error values start.
  426. */
  427. #define PJ_ERRNO_START 20000
  428. /**
  429. * PJ_ERRNO_SPACE_SIZE is the maximum number of errors in one of
  430. * the error/status range below.
  431. */
  432. #define PJ_ERRNO_SPACE_SIZE 50000
  433. /**
  434. * PJ_ERRNO_START_STATUS is where PJLIB specific status codes start.
  435. * Effectively the error in this class would be 70000 - 119000.
  436. */
  437. #define PJ_ERRNO_START_STATUS (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  438. /**
  439. * PJ_ERRNO_START_SYS converts platform specific error codes into
  440. * pj_status_t values.
  441. * Effectively the error in this class would be 120000 - 169000.
  442. */
  443. #define PJ_ERRNO_START_SYS (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  444. /**
  445. * PJ_ERRNO_START_USER are reserved for applications that use error
  446. * codes along with PJLIB codes.
  447. * Effectively the error in this class would be 170000 - 219000.
  448. */
  449. #define PJ_ERRNO_START_USER (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  450. /*
  451. * Below are list of error spaces that have been taken so far:
  452. * - PJSIP_ERRNO_START (PJ_ERRNO_START_USER)
  453. * - PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  454. * - PJSIP_SIMPLE_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*2)
  455. * - PJLIB_UTIL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
  456. * - PJNATH_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  457. * - PJMEDIA_AUDIODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
  458. * - PJ_SSL_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*6)
  459. * - PJMEDIA_VIDEODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*7)
  460. */
  461. /** Internal */
  462. void pj_errno_clear_handlers(void);
  463. /****** Internal for PJ_PERROR *******/
  464. /**
  465. * @def pj_perror_wrapper_1(arg)
  466. * Internal function to write log with verbosity 1. Will evaluate to
  467. * empty expression if PJ_LOG_MAX_LEVEL is below 1.
  468. * @param arg Log expression.
  469. */
  470. #if PJ_LOG_MAX_LEVEL >= 1
  471. #define pj_perror_wrapper_1(arg) pj_perror_1 arg
  472. /** Internal function. */
  473. PJ_DECL(void) pj_perror_1(const char *sender, pj_status_t status,
  474. const char *title_fmt, ...)
  475. PJ_PRINT_FUNC_DECOR(3);
  476. #else
  477. #define pj_perror_wrapper_1(arg)
  478. #endif
  479. /**
  480. * @def pj_perror_wrapper_2(arg)
  481. * Internal function to write log with verbosity 2. Will evaluate to
  482. * empty expression if PJ_LOG_MAX_LEVEL is below 2.
  483. * @param arg Log expression.
  484. */
  485. #if PJ_LOG_MAX_LEVEL >= 2
  486. #define pj_perror_wrapper_2(arg) pj_perror_2 arg
  487. /** Internal function. */
  488. PJ_DECL(void) pj_perror_2(const char *sender, pj_status_t status,
  489. const char *title_fmt, ...)
  490. PJ_PRINT_FUNC_DECOR(3);
  491. #else
  492. #define pj_perror_wrapper_2(arg)
  493. #endif
  494. /**
  495. * @def pj_perror_wrapper_3(arg)
  496. * Internal function to write log with verbosity 3. Will evaluate to
  497. * empty expression if PJ_LOG_MAX_LEVEL is below 3.
  498. * @param arg Log expression.
  499. */
  500. #if PJ_LOG_MAX_LEVEL >= 3
  501. #define pj_perror_wrapper_3(arg) pj_perror_3 arg
  502. /** Internal function. */
  503. PJ_DECL(void) pj_perror_3(const char *sender, pj_status_t status,
  504. const char *title_fmt, ...)
  505. PJ_PRINT_FUNC_DECOR(3);
  506. #else
  507. #define pj_perror_wrapper_3(arg)
  508. #endif
  509. /**
  510. * @def pj_perror_wrapper_4(arg)
  511. * Internal function to write log with verbosity 4. Will evaluate to
  512. * empty expression if PJ_LOG_MAX_LEVEL is below 4.
  513. * @param arg Log expression.
  514. */
  515. #if PJ_LOG_MAX_LEVEL >= 4
  516. #define pj_perror_wrapper_4(arg) pj_perror_4 arg
  517. /** Internal function. */
  518. PJ_DECL(void) pj_perror_4(const char *sender, pj_status_t status,
  519. const char *title_fmt, ...)
  520. PJ_PRINT_FUNC_DECOR(3);
  521. #else
  522. #define pj_perror_wrapper_4(arg)
  523. #endif
  524. /**
  525. * @def pj_perror_wrapper_5(arg)
  526. * Internal function to write log with verbosity 5. Will evaluate to
  527. * empty expression if PJ_LOG_MAX_LEVEL is below 5.
  528. * @param arg Log expression.
  529. */
  530. #if PJ_LOG_MAX_LEVEL >= 5
  531. #define pj_perror_wrapper_5(arg) pj_perror_5 arg
  532. /** Internal function. */
  533. PJ_DECL(void) pj_perror_5(const char *sender, pj_status_t status,
  534. const char *title_fmt, ...)
  535. PJ_PRINT_FUNC_DECOR(3);
  536. #else
  537. #define pj_perror_wrapper_5(arg)
  538. #endif
  539. /**
  540. * @def pj_perror_wrapper_6(arg)
  541. * Internal function to write log with verbosity 6. Will evaluate to
  542. * empty expression if PJ_LOG_MAX_LEVEL is below 6.
  543. * @param arg Log expression.
  544. */
  545. #if PJ_LOG_MAX_LEVEL >= 6
  546. #define pj_perror_wrapper_6(arg) pj_perror_6 arg
  547. /** Internal function. */
  548. PJ_DECL(void) pj_perror_6(const char *sender, pj_status_t status,
  549. const char *title_fmt, ...)
  550. PJ_PRINT_FUNC_DECOR(3);
  551. #else
  552. #define pj_perror_wrapper_6(arg)
  553. #endif
  554. PJ_END_DECL
  555. #endif /* __PJ_ERRNO_H__ */