1
/* $Id: exception_symbian.cpp 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 <pj/except.h>
22
#include <pj/assert.h>
27
#if defined(PJ_HAS_EXCEPTION_NAMES) && PJ_HAS_EXCEPTION_NAMES != 0
28
static const char *exception_id_names[PJ_MAX_EXCEPTION_ID];
31
* Start from 1 (not 0)!!!
32
* Exception 0 is reserved for normal path of setjmp()!!!
34
static int last_exception_id = 1;
35
#endif /* PJ_HAS_EXCEPTION_NAMES */
38
#if defined(PJ_HAS_EXCEPTION_NAMES) && PJ_HAS_EXCEPTION_NAMES != 0
39
PJ_DEF(pj_status_t) pj_exception_id_alloc( const char *name,
40
pj_exception_id_t *id)
44
pj_enter_critical_section();
47
* Start from 1 (not 0)!!!
48
* Exception 0 is reserved for normal path of setjmp()!!!
50
for (i=1; i<PJ_MAX_EXCEPTION_ID; ++i) {
51
if (exception_id_names[i] == NULL) {
52
exception_id_names[i] = name;
54
pj_leave_critical_section();
59
pj_leave_critical_section();
63
PJ_DEF(pj_status_t) pj_exception_id_free( pj_exception_id_t id )
66
* Start from 1 (not 0)!!!
67
* Exception 0 is reserved for normal path of setjmp()!!!
69
PJ_ASSERT_RETURN(id>0 && id<PJ_MAX_EXCEPTION_ID, PJ_EINVAL);
71
pj_enter_critical_section();
72
exception_id_names[id] = NULL;
73
pj_leave_critical_section();
79
PJ_DEF(const char*) pj_exception_id_name(pj_exception_id_t id)
82
* Start from 1 (not 0)!!!
83
* Exception 0 is reserved for normal path of setjmp()!!!
85
PJ_ASSERT_RETURN(id>0 && id<PJ_MAX_EXCEPTION_ID, "<Invalid ID>");
87
if (exception_id_names[id] == NULL)
88
return "<Unallocated ID>";
90
return exception_id_names[id];
93
#else /* PJ_HAS_EXCEPTION_NAMES */
94
PJ_DEF(pj_status_t) pj_exception_id_alloc( const char *name,
95
pj_exception_id_t *id)
97
PJ_ASSERT_RETURN(last_exception_id < PJ_MAX_EXCEPTION_ID-1, PJ_ETOOMANY);
99
*id = last_exception_id++;
103
PJ_DEF(pj_status_t) pj_exception_id_free( pj_exception_id_t id )
108
PJ_DEF(const char*) pj_exception_id_name(pj_exception_id_t id)
113
#endif /* PJ_HAS_EXCEPTION_NAMES */