diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-02-21 23:47:00 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-02-21 23:47:00 +0000 |
commit | fcba4d392ea03e8ac4cfde87d8efd7999ff4a38c (patch) | |
tree | 285e65a630c72b80dd533ec88d4d8ef9b1aa7029 /pjsip/src/pjsip-simple/errno.c | |
parent | 5c7386b0e38e69ae6b275b1048d59e7ec4eaf6bf (diff) |
Implemented major feature: call hold and transfer
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@212 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-simple/errno.c')
-rw-r--r-- | pjsip/src/pjsip-simple/errno.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/pjsip/src/pjsip-simple/errno.c b/pjsip/src/pjsip-simple/errno.c index 374178e2..e26b5a7b 100644 --- a/pjsip/src/pjsip-simple/errno.c +++ b/pjsip/src/pjsip-simple/errno.c @@ -17,4 +17,83 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <pjsip-simple/errno.h> +#include <pj/string.h> + +/* PJSIP-SIMPLE's own error codes/messages + * MUST KEEP THIS ARRAY SORTED!! + * Message must be limited to 64 chars! + */ +static const struct +{ + int code; + const char *msg; +} err_str[] = +{ + { PJSIP_SIMPLE_ENOPKG, "No SIP event package with the specified name" }, + { PJSIP_SIMPLE_EPKGEXISTS, "SIP event package already exist" }, + + { PJSIP_SIMPLE_ENOTSUBSCRIBE, "Expecting SUBSCRIBE request" }, + { PJSIP_SIMPLE_ENOPRESENCE, "No presence associated with the subscription" }, + { PJSIP_SIMPLE_ENOPRESENCEINFO, "No presence info in the server subscription" }, + { PJSIP_SIMPLE_EBADCONTENT, "Bad Content-Type for presence" }, + { PJSIP_SIMPLE_EBADPIDF, "Bad PIDF content for presence" }, + { PJSIP_SIMPLE_EBADXPIDF, "Bad XPIDF content for presence" }, +}; + + + +/* + * pjsipsimple_strerror() + */ +PJ_DEF(pj_str_t) pjsipsimple_strerror( pj_status_t statcode, + char *buf, pj_size_t bufsize ) +{ + pj_str_t errstr; + + if (statcode >= PJSIP_SIMPLE_ERRNO_START && + statcode < PJSIP_SIMPLE_ERRNO_START + PJ_ERRNO_SPACE_SIZE) + { + /* Find the error in the table. + * Use binary search! + */ + int first = 0; + int n = PJ_ARRAY_SIZE(err_str); + + while (n > 0) { + int half = n/2; + int mid = first + half; + + if (err_str[mid].code < statcode) { + first = mid+1; + n -= (half+1); + } else if (err_str[mid].code > statcode) { + n = half; + } else { + first = mid; + break; + } + } + + + if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) { + pj_str_t msg; + + msg.ptr = (char*)err_str[first].msg; + msg.slen = pj_ansi_strlen(err_str[first].msg); + + errstr.ptr = buf; + pj_strncpy_with_null(&errstr, &msg, bufsize); + return errstr; + + } + } + + /* Error not found. */ + errstr.ptr = buf; + errstr.slen = pj_snprintf(buf, bufsize, + "Unknown error %d", + statcode); + + return errstr; +} |