1
/* $Id: errno.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
20
#include <pjsip-simple/errno.h>
21
#include <pj/string.h>
23
/* PJSIP-SIMPLE's own error codes/messages
24
* MUST KEEP THIS ARRAY SORTED!!
25
* Message must be limited to 64 chars!
28
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
37
{ PJSIP_SIMPLE_ENOPKG, "No SIP event package with the specified name" },
38
{ PJSIP_SIMPLE_EPKGEXISTS, "SIP event package already exist" },
41
{ PJSIP_SIMPLE_ENOTSUBSCRIBE, "Expecting SUBSCRIBE request" },
42
{ PJSIP_SIMPLE_ENOPRESENCE, "No presence associated with the subscription" },
43
{ PJSIP_SIMPLE_ENOPRESENCEINFO, "No presence info in the server subscription" },
44
{ PJSIP_SIMPLE_EBADCONTENT, "Bad Content-Type for presence" },
45
{ PJSIP_SIMPLE_EBADPIDF, "Bad PIDF content for presence" },
46
{ PJSIP_SIMPLE_EBADXPIDF, "Bad XPIDF content for presence" },
47
{ PJSIP_SIMPLE_EBADRPID, "Invalid or bad RPID document"},
49
/* isComposing errors. */
50
{ PJSIP_SIMPLE_EBADISCOMPOSE, "Bad isComposing indication/XML message" },
54
#endif /* PJ_HAS_ERROR_STRING */
58
* pjsipsimple_strerror()
60
PJ_DEF(pj_str_t) pjsipsimple_strerror( pj_status_t statcode,
61
char *buf, pj_size_t bufsize )
65
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
67
if (statcode >= PJSIP_SIMPLE_ERRNO_START &&
68
statcode < PJSIP_SIMPLE_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
70
/* Find the error in the table.
74
int n = PJ_ARRAY_SIZE(err_str);
78
int mid = first + half;
80
if (err_str[mid].code < statcode) {
83
} else if (err_str[mid].code > statcode) {
92
if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) {
95
msg.ptr = (char*)err_str[first].msg;
96
msg.slen = pj_ansi_strlen(err_str[first].msg);
99
pj_strncpy_with_null(&errstr, &msg, bufsize);
105
#endif /* PJ_HAS_ERROR_STRING */
108
/* Error not found. */
110
errstr.slen = pj_ansi_snprintf(buf, bufsize,
111
"Unknown pjsip-simple error %d",