summaryrefslogtreecommitdiff
path: root/pjlib/src/pj/errno.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2005-11-13 19:40:44 +0000
committerBenny Prijono <bennylp@teluu.com>2005-11-13 19:40:44 +0000
commita08b589d09d5197f9a76d549a189e4686bd2ca8c (patch)
tree549904e7680dfab96b3ce579b1843c5d58107100 /pjlib/src/pj/errno.c
parent8df70c6d5fef443506618bf31b686d53fef3f259 (diff)
Applying license to pjproject
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@49 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/errno.c')
-rw-r--r--pjlib/src/pj/errno.c215
1 files changed, 118 insertions, 97 deletions
diff --git a/pjlib/src/pj/errno.c b/pjlib/src/pj/errno.c
index 5a986514..6d05576a 100644
--- a/pjlib/src/pj/errno.c
+++ b/pjlib/src/pj/errno.c
@@ -1,99 +1,120 @@
-/* $Id$
- */
-#include <pj/errno.h>
-#include <pj/string.h>
-#include <pj/compat/sprintf.h>
-
-/* Prototype for platform specific error message, which will be defined
- * in separate file.
- */
-extern int platform_strerror( pj_os_err_type code,
- char *buf, pj_size_t bufsize );
-
-/* PJLIB's own error codes/messages */
-static const struct
-{
- int code;
- const char *msg;
-} err_str[] =
-{
- { PJ_EUNKNOWN, "Unknown Error" },
- { PJ_EPENDING, "Pending operation" },
- { PJ_ETOOMANYCONN, "Too many connecting sockets" },
- { PJ_EINVAL, "Invalid value or argument" },
- { PJ_ENAMETOOLONG, "Name too long" },
- { PJ_ENOTFOUND, "Not found" },
- { PJ_ENOMEM, "Not enough memory" },
- { PJ_EBUG, "BUG DETECTED!" },
- { PJ_ETIMEDOUT, "Operation timed out" },
- { PJ_ETOOMANY, "Too many objects of the specified type"},
- { PJ_EBUSY, "Object is busy"},
- { PJ_ENOTSUP, "Option/operation is not supported"},
+/* $Id$
+ */
+/*
+ * PJLIB - PJ Foundation Library
+ * (C)2003-2005 Benny Prijono <bennylp@bulukucing.org>
+ *
+ * Author:
+ * Benny Prijono <bennylp@bulukucing.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pj/errno.h>
+#include <pj/string.h>
+#include <pj/compat/sprintf.h>
+
+/* Prototype for platform specific error message, which will be defined
+ * in separate file.
+ */
+extern int platform_strerror( pj_os_err_type code,
+ char *buf, pj_size_t bufsize );
+
+/* PJLIB's own error codes/messages */
+static const struct
+{
+ int code;
+ const char *msg;
+} err_str[] =
+{
+ { PJ_EUNKNOWN, "Unknown Error" },
+ { PJ_EPENDING, "Pending operation" },
+ { PJ_ETOOMANYCONN, "Too many connecting sockets" },
+ { PJ_EINVAL, "Invalid value or argument" },
+ { PJ_ENAMETOOLONG, "Name too long" },
+ { PJ_ENOTFOUND, "Not found" },
+ { PJ_ENOMEM, "Not enough memory" },
+ { PJ_EBUG, "BUG DETECTED!" },
+ { PJ_ETIMEDOUT, "Operation timed out" },
+ { PJ_ETOOMANY, "Too many objects of the specified type"},
+ { PJ_EBUSY, "Object is busy"},
+ { PJ_ENOTSUP, "Option/operation is not supported"},
{ PJ_EINVALIDOP, "Invalid operation"},
{ PJ_ECANCELLED, "Operation cancelled"},
- { PJ_EEXISTS, "Object already exists" }
-};
-
-/*
- * pjlib_error()
- *
- * Retrieve message string for PJLIB's own error code.
- */
-static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
-{
- unsigned i;
-
- for (i=0; i<sizeof(err_str)/sizeof(err_str[0]); ++i) {
- if (err_str[i].code == code) {
- pj_size_t len = strlen(err_str[i].msg);
- if (len >= size) len = size-1;
- pj_memcpy(buf, err_str[i].msg, len);
- buf[len] = '\0';
- return len;
- }
- }
-
- *buf++ = '?';
- *buf++ = '?';
- *buf++ = '?';
- *buf++ = '\0';
- return 3;
-}
-
-/*
- * pj_strerror()
- */
-PJ_DEF(pj_str_t) pj_strerror( pj_status_t statcode,
- char *buf, pj_size_t bufsize )
-{
- int len = -1;
- pj_str_t errstr;
-
- if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
- len = pj_snprintf( buf, bufsize, "Unknown error %d", statcode);
-
- } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
- len = pjlib_error(statcode, buf, bufsize);
-
- } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
- len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize);
-
- } else if (statcode < PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE) {
- len = pj_snprintf( buf, bufsize, "User error %d", statcode);
-
- } else {
- len = pj_snprintf( buf, bufsize, "Invalid error %d", statcode);
-
- }
-
- if (len < 1) {
- *buf = '\0';
- len = 0;
- }
-
- errstr.ptr = buf;
- errstr.slen = len;
-
- return errstr;
-}
-
+ { PJ_EEXISTS, "Object already exists" }
+};
+
+/*
+ * pjlib_error()
+ *
+ * Retrieve message string for PJLIB's own error code.
+ */
+static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
+{
+ unsigned i;
+
+ for (i=0; i<sizeof(err_str)/sizeof(err_str[0]); ++i) {
+ if (err_str[i].code == code) {
+ pj_size_t len = strlen(err_str[i].msg);
+ if (len >= size) len = size-1;
+ pj_memcpy(buf, err_str[i].msg, len);
+ buf[len] = '\0';
+ return len;
+ }
+ }
+
+ *buf++ = '?';
+ *buf++ = '?';
+ *buf++ = '?';
+ *buf++ = '\0';
+ return 3;
+}
+
+/*
+ * pj_strerror()
+ */
+PJ_DEF(pj_str_t) pj_strerror( pj_status_t statcode,
+ char *buf, pj_size_t bufsize )
+{
+ int len = -1;
+ pj_str_t errstr;
+
+ if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
+ len = pj_snprintf( buf, bufsize, "Unknown error %d", statcode);
+
+ } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
+ len = pjlib_error(statcode, buf, bufsize);
+
+ } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
+ len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize);
+
+ } else if (statcode < PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE) {
+ len = pj_snprintf( buf, bufsize, "User error %d", statcode);
+
+ } else {
+ len = pj_snprintf( buf, bufsize, "Invalid error %d", statcode);
+
+ }
+
+ if (len < 1) {
+ *buf = '\0';
+ len = 0;
+ }
+
+ errstr.ptr = buf;
+ errstr.slen = len;
+
+ return errstr;
+}
+