BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJMEDIA Reference

Samples: Print out error message

This file is pjsip-apps/src/samples/strerror.c

1 /* $Id: strerror.c 3553 2011-05-05 06:14:19Z nanang $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
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.
10  *
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.
15  *
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
19  */
20 
30 #include <pjlib.h>
31 #include <pjlib-util.h>
32 #include <pjsip.h>
33 #include <pjmedia.h>
34 #include <pjnath.h>
35 #include <pjsip_simple.h>
36 
37 /*
38  * main()
39  */
40 int main(int argc, char *argv[])
41 {
42  pj_caching_pool cp;
43  pjmedia_endpt *med_ept;
44  pjsip_endpoint *sip_ept;
45  char errmsg[PJ_ERR_MSG_SIZE];
46  pj_status_t code;
47 
48  if (argc != 2) {
49  puts("Usage: strerror ERRNUM");
50  return 1;
51  }
52 
54 
55  pj_init();
56  pj_caching_pool_init(&cp, NULL, 0);
58  pjnath_init();
59  pjmedia_endpt_create(&cp.factory, NULL, 0, &med_ept);
60  pjsip_endpt_create(&cp.factory, "localhost", &sip_ept);
61  pjsip_evsub_init_module(sip_ept);
62 
63  code = atoi(argv[1]);
64  pj_strerror(code, errmsg, sizeof(errmsg));
65 
66  printf("Status %d: %s\n", code, errmsg);
67 
68  pj_shutdown();
69  return 0;
70 }
71 
PJMEDIA main header file.
pj_status_t pjnath_init(void)
struct pjmedia_endpt pjmedia_endpt
Definition: types.h:187
int pj_status_t
pj_pool_factory factory
pj_status_t pjmedia_endpt_create(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt)
Definition: endpoint.h:105
void pj_caching_pool_init(pj_caching_pool *ch_pool, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
PJ_BEGIN_DECL pj_status_t pjlib_util_init(void)
pj_str_t pj_strerror(pj_status_t statcode, char *buf, pj_size_t bufsize)
#define PJ_ERR_MSG_SIZE
void pj_shutdown(void)
pj_status_t pj_init(void)
void pj_log_set_level(int level)

 


PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.