summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-03-18 12:26:55 +0000
committerBenny Prijono <bennylp@teluu.com>2006-03-18 12:26:55 +0000
commit1ef58d201f4613f91a9cbafa4545f37f3fab3cf6 (patch)
tree7169f9c55ab05f6140bc6f2faa0d583166b1eb94
parentf8793f52a83dd232eddf2bb61f48cca6dd759ffd (diff)
Added option to disable error message altogether, to save space footprint
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@330 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib-util/src/pjlib-util/errno.c10
-rw-r--r--pjlib/src/pj/errno.c11
-rw-r--r--pjlib/src/pj/os_error_win32.c8
-rw-r--r--pjmedia/src/pjmedia/errno.c11
-rw-r--r--pjsip/src/pjsip-simple/errno.c12
-rw-r--r--pjsip/src/pjsip/sip_errno.c32
6 files changed, 62 insertions, 22 deletions
diff --git a/pjlib-util/src/pjlib-util/errno.c b/pjlib-util/src/pjlib-util/errno.c
index b5e43e7a..bce785ae 100644
--- a/pjlib-util/src/pjlib-util/errno.c
+++ b/pjlib-util/src/pjlib-util/errno.c
@@ -25,6 +25,7 @@
* MUST KEEP THIS ARRAY SORTED!!
* Message must be limited to 64 chars!
*/
+#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
static const struct
{
int code;
@@ -47,7 +48,7 @@ static const struct
/* XML errors */
{ PJLIB_UTIL_EINXML, "Invalid XML message" },
};
-
+#endif /* PJ_HAS_ERROR_STRING */
/*
@@ -58,6 +59,8 @@ PJ_DEF(pj_str_t) pjlib_util_strerror( pj_status_t statcode,
{
pj_str_t errstr;
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
if (statcode >= PJLIB_UTIL_ERRNO_START &&
statcode < PJLIB_UTIL_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
{
@@ -96,10 +99,13 @@ PJ_DEF(pj_str_t) pjlib_util_strerror( pj_status_t statcode,
}
}
+#endif /* PJ_HAS_ERROR_STRING */
+
+
/* Error not found. */
errstr.ptr = buf;
errstr.slen = pj_ansi_snprintf(buf, bufsize,
- "Unknown error %d",
+ "Unknown pjlib-util error %d",
statcode);
return errstr;
diff --git a/pjlib/src/pj/errno.c b/pjlib/src/pj/errno.c
index 9843105c..086bfcd7 100644
--- a/pjlib/src/pj/errno.c
+++ b/pjlib/src/pj/errno.c
@@ -39,6 +39,7 @@ static struct err_msg_hnd
} err_msg_hnd[PJLIB_MAX_ERR_MSG_HANDLER];
/* PJLIB's own error codes/messages */
+#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
static const struct
{
int code;
@@ -62,6 +63,8 @@ static const struct
{ PJ_EEXISTS, "Object already exists" },
{ PJ_EEOF, "End of file" },
};
+#endif /* PJ_HAS_ERROR_STRING */
+
/*
* pjlib_error()
@@ -70,6 +73,7 @@ static const struct
*/
static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
{
+#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
unsigned i;
for (i=0; i<sizeof(err_str)/sizeof(err_str[0]); ++i) {
@@ -81,12 +85,9 @@ static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
return len;
}
}
+#endif
- *buf++ = '?';
- *buf++ = '?';
- *buf++ = '?';
- *buf++ = '\0';
- return 3;
+ return pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code);
}
#define IN_RANGE(val,start,end) ((val)>=(start) && (val)<(end))
diff --git a/pjlib/src/pj/os_error_win32.c b/pjlib/src/pj/os_error_win32.c
index 8c6d56c3..80a4eb23 100644
--- a/pjlib/src/pj/os_error_win32.c
+++ b/pjlib/src/pj/os_error_win32.c
@@ -33,6 +33,8 @@
/*
* From Apache's APR:
*/
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0)
+
static const struct {
pj_os_err_type code;
const char *msg;
@@ -89,6 +91,9 @@ static const struct {
{0, NULL}
};
+#endif /* PJ_HAS_ERROR_STRING */
+
+
PJ_DEF(pj_status_t) pj_get_os_error(void)
{
@@ -155,6 +160,8 @@ int platform_strerror( pj_os_err_type os_errcode,
#endif
if (!len) {
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0)
int i;
for (i = 0; gaErrorList[i].msg; ++i) {
if (gaErrorList[i].code == os_errcode) {
@@ -167,6 +174,7 @@ int platform_strerror( pj_os_err_type os_errcode,
break;
}
}
+#endif /* PJ_HAS_ERROR_STRING */
} else {
/* Remove trailing newlines. */
diff --git a/pjmedia/src/pjmedia/errno.c b/pjmedia/src/pjmedia/errno.c
index e6eeccdf..5a63e07e 100644
--- a/pjmedia/src/pjmedia/errno.c
+++ b/pjmedia/src/pjmedia/errno.c
@@ -26,6 +26,9 @@
* MUST KEEP THIS ARRAY SORTED!!
* Message must be limited to 64 chars!
*/
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
static const struct
{
int code;
@@ -121,6 +124,8 @@ static const struct
{ PJMEDIA_EWAVETOOSHORT, "WAVE file too short" },
};
+#endif /* PJ_HAS_ERROR_STRING */
+
/*
@@ -131,6 +136,8 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode,
{
pj_str_t errstr;
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
/* See if the error comes from PortAudio. */
if (statcode >= PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized) &&
statcode < PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized + 10000))
@@ -184,10 +191,12 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode,
}
}
+#endif /* PJ_HAS_ERROR_STRING */
+
/* Error not found. */
errstr.ptr = buf;
errstr.slen = pj_ansi_snprintf(buf, bufsize,
- "Unknown error %d",
+ "Unknown pjmedia error %d",
statcode);
return errstr;
diff --git a/pjsip/src/pjsip-simple/errno.c b/pjsip/src/pjsip-simple/errno.c
index a2e588d9..3f5c2e6b 100644
--- a/pjsip/src/pjsip-simple/errno.c
+++ b/pjsip/src/pjsip-simple/errno.c
@@ -23,6 +23,9 @@
* MUST KEEP THIS ARRAY SORTED!!
* Message must be limited to 64 chars!
*/
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
static const struct
{
int code;
@@ -46,6 +49,8 @@ static const struct
};
+#endif /* PJ_HAS_ERROR_STRING */
+
/*
* pjsipsimple_strerror()
@@ -55,6 +60,8 @@ PJ_DEF(pj_str_t) pjsipsimple_strerror( pj_status_t statcode,
{
pj_str_t errstr;
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
if (statcode >= PJSIP_SIMPLE_ERRNO_START &&
statcode < PJSIP_SIMPLE_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
{
@@ -93,10 +100,13 @@ PJ_DEF(pj_str_t) pjsipsimple_strerror( pj_status_t statcode,
}
}
+#endif /* PJ_HAS_ERROR_STRING */
+
+
/* Error not found. */
errstr.ptr = buf;
errstr.slen = pj_ansi_snprintf(buf, bufsize,
- "Unknown error %d",
+ "Unknown pjsip-simple error %d",
statcode);
return errstr;
diff --git a/pjsip/src/pjsip/sip_errno.c b/pjsip/src/pjsip/sip_errno.c
index ab4d72da..6bac6f96 100644
--- a/pjsip/src/pjsip/sip_errno.c
+++ b/pjsip/src/pjsip/sip_errno.c
@@ -24,6 +24,9 @@
/* PJSIP's own error codes/messages
* MUST KEEP THIS ARRAY SORTED!!
*/
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
static const struct
{
int code;
@@ -91,6 +94,9 @@ static const struct
};
+#endif /* PJ_HAS_ERROR_STRING */
+
+
/*
* pjsip_strerror()
*/
@@ -99,6 +105,8 @@ PJ_DEF(pj_str_t) pjsip_strerror( pj_status_t statcode,
{
pj_str_t errstr;
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
if (statcode >= PJSIP_ERRNO_START && statcode < PJSIP_ERRNO_START+800)
{
/* Status code. */
@@ -144,20 +152,18 @@ PJ_DEF(pj_str_t) pjsip_strerror( pj_status_t statcode,
pj_strncpy_with_null(&errstr, &msg, bufsize);
return errstr;
- } else {
- /* Error not found. */
- errstr.ptr = buf;
- errstr.slen = pj_ansi_snprintf(buf, bufsize,
- "Unknown error %d",
- statcode);
-
- return errstr;
- }
- }
- else {
- /* Not our code. Give it to PJLIB. */
- return pj_strerror(statcode, buf, bufsize);
+ }
}
+#endif /* PJ_HAS_ERROR_STRING */
+
+ /* Error not found. */
+ errstr.ptr = buf;
+ errstr.slen = pj_ansi_snprintf(buf, bufsize,
+ "Unknown pjsip error %d",
+ statcode);
+
+ return errstr;
+
}