BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJMEDIA Reference

Samples: Print out error message

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

00001 /* $Id: strerror.c 3553 2011-05-05 06:14:19Z nanang $ */
00002 /* 
00003  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
00004  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00019  */
00020 
00030 #include <pjlib.h>
00031 #include <pjlib-util.h>
00032 #include <pjsip.h>
00033 #include <pjmedia.h>
00034 #include <pjnath.h>
00035 #include <pjsip_simple.h>
00036 
00037 /*
00038  * main()
00039  */
00040 int main(int argc, char *argv[])
00041 {
00042     pj_caching_pool cp;
00043     pjmedia_endpt *med_ept;
00044     pjsip_endpoint *sip_ept;
00045     char errmsg[PJ_ERR_MSG_SIZE];
00046     pj_status_t code;
00047 
00048     if (argc != 2) {
00049         puts("Usage: strerror ERRNUM");
00050         return 1;
00051     }
00052 
00053     pj_log_set_level(3);
00054 
00055     pj_init();
00056     pj_caching_pool_init(&cp, NULL, 0);
00057     pjlib_util_init();
00058     pjnath_init();
00059     pjmedia_endpt_create(&cp.factory, NULL, 0, &med_ept);
00060     pjsip_endpt_create(&cp.factory, "localhost", &sip_ept);
00061     pjsip_evsub_init_module(sip_ept);
00062 
00063     code = atoi(argv[1]);
00064     pj_strerror(code, errmsg, sizeof(errmsg));
00065 
00066     printf("Status %d: %s\n", code, errmsg);
00067 
00068     pj_shutdown();
00069     return 0;
00070 }
00071 

 


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