1 /****************************************************************************
3 * $Id: commands.c,v 1.39 2008/07/03 15:08:34 smorlat Exp $
5 * Copyright (C) 2006-2009 Sandro Santilli <strk@keybit.net>
6 * Copyright (C) 2004 Simon MORLAT <simon.morlat@linphone.org>
8 ****************************************************************************
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ****************************************************************************/
35 #include <linphonecore.h>
36 #include "linphonec.h"
44 /***************************************************************************
46 * Forward declarations
48 ***************************************************************************/
50 extern char *lpc_strip_blanks(char *input);
52 /* Command handlers */
53 static int lpc_cmd_help(LinphoneCore *, char *);
54 static int lpc_cmd_proxy(LinphoneCore *, char *);
55 static int lpc_cmd_call(LinphoneCore *, char *);
56 static int lpc_cmd_answer(LinphoneCore *, char *);
57 static int lpc_cmd_autoanswer(LinphoneCore *, char *);
58 static int lpc_cmd_terminate(LinphoneCore *, char *);
59 static int lpc_cmd_call_logs(LinphoneCore *, char *);
60 static int lpc_cmd_ipv6(LinphoneCore *, char *);
61 static int lpc_cmd_refer(LinphoneCore *, char *);
62 static int lpc_cmd_quit(LinphoneCore *, char *);
63 static int lpc_cmd_nat(LinphoneCore *, char *);
64 static int lpc_cmd_stun(LinphoneCore *, char *);
65 static int lpc_cmd_firewall(LinphoneCore *, char *);
66 static int lpc_cmd_friend(LinphoneCore *, char*);
67 static int lpc_cmd_soundcard(LinphoneCore *, char *);
68 static int lpc_cmd_webcam(LinphoneCore *, char *);
69 static int lpc_cmd_staticpic(LinphoneCore *, char *);
70 static int lpc_cmd_play(LinphoneCore *, char *);
71 static int lpc_cmd_record(LinphoneCore *, char *);
72 static int lpc_cmd_register(LinphoneCore *, char *);
73 static int lpc_cmd_unregister(LinphoneCore *, char *);
74 static int lpc_cmd_duration(LinphoneCore *lc, char *args);
75 static int lpc_cmd_status(LinphoneCore *lc, char *args);
76 static int lpc_cmd_ports(LinphoneCore *lc, char *args);
77 static int lpc_cmd_speak(LinphoneCore *lc, char *args);
78 static int lpc_cmd_codec(LinphoneCore *lc, char *args);
79 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args);
81 /* Command handler helpers */
82 static void linphonec_proxy_add(LinphoneCore *lc);
83 static void linphonec_proxy_display(LinphoneProxyConfig *lc);
84 static void linphonec_proxy_list(LinphoneCore *lc);
85 static void linphonec_proxy_remove(LinphoneCore *lc, int index);
86 static int linphonec_proxy_use(LinphoneCore *lc, int index);
87 static void linphonec_proxy_show(LinphoneCore *lc,int index);
88 static void linphonec_friend_display(LinphoneFriend *fr);
89 static int linphonec_friend_list(LinphoneCore *lc, char *arg);
90 static void linphonec_display_command_help(LPC_COMMAND *cmd);
91 static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
93 static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
95 static int linphonec_friend_delete(LinphoneCore *lc, int num);
96 static int linphonec_friend_delete(LinphoneCore *lc, int num);
97 static void linphonec_codec_list(LinphoneCore *lc);
98 static void linphonec_codec_enable(LinphoneCore *lc, int index);
99 static void linphonec_codec_disable(LinphoneCore *lc, int index);
103 /* Command table management */
104 static LPC_COMMAND *lpc_find_command(const char *name);
106 void linphonec_out(const char *fmt,...);
110 /***************************************************************************
114 ***************************************************************************/
119 LPC_COMMAND commands[] = {
120 { "help", lpc_cmd_help, "Print commands help", NULL },
121 { "call", lpc_cmd_call, "Call a SIP uri",
123 ": initiate a call to the specified destination."
125 { "terminate", lpc_cmd_terminate, "Terminate the current call",
127 { "answer", lpc_cmd_answer, "Answer a call",
128 "Accept an incoming call."
130 { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
131 "'autoanswer' \t: show current autoanswer mode\n"
132 "'autoanswer enable'\t: enable autoanswer mode\n"
133 "'autoanswer disable'\t: disable autoanswer modeĀ \n"},
134 { "proxy", lpc_cmd_proxy, "Manage proxies",
135 "'proxy list' : list all proxy setups.\n"
136 "'proxy add' : add a new proxy setup.\n"
137 "'proxy remove <index>' : remove proxy setup with number index.\n"
138 "'proxy use <index>' : use proxy with number index as default proxy.\n"
139 "'proxy unuse' : don't use a default proxy.\n"
140 "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n"
141 "'proxy show default' : show configuration and status of the default proxy.\n"
143 { "soundcard", lpc_cmd_soundcard, "Manage soundcards",
144 "'soundcard list' : list all sound devices.\n"
145 "'soundcard show' : show current sound devices configuration.\n"
146 "'soundcard use <index>' : select a sound device.\n"
147 "'soundcard use files' : use .wav files instead of soundcard\n"
149 { "webcam", lpc_cmd_webcam, "Manage webcams",
150 "'webcam list' : list all known devices.\n"
151 "'webcam use <index>' : select a video device.\n"
153 { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
154 "'staticpic set' : Set path to picture that should be used.\n"
156 { "ipv6", lpc_cmd_ipv6, "Use IPV6",
157 "'ipv6 status' : show ipv6 usage status.\n"
158 "'ipv6 enable' : enable the use of the ipv6 network.\n"
159 "'ipv6 disable' : do not use ipv6 network."
161 { "refer", lpc_cmd_refer,
162 "Refer the current call to the specified destination.",
163 "'refer <sip-url>' or 'r <sip-url>' "
164 ": refer the current call to the specified destination."
166 { "nat", lpc_cmd_nat, "Set nat address",
167 "'nat' : show nat settings.\n"
168 "'nat <addr>' : set nat address.\n"
170 { "stun", lpc_cmd_stun, "Set stun server address",
171 "'stun' : show stun settings.\n"
172 "'stun <addr>' : set stun server address.\n"
174 { "firewall", lpc_cmd_firewall, "Set firewall policy",
175 "'firewall' : show current firewall policy.\n"
176 "'firewall none' : use direct connection.\n"
177 "'firewall nat' : use nat address given with the 'nat' command.\n"
178 "'firewall stun' : use stun server given with the 'stun' command.\n"
180 { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
181 { "friend", lpc_cmd_friend, "Manage friends",
182 "'friend list [<pattern>]' : list friends.\n"
183 "'friend call <index>' : call a friend.\n"
184 "'friend add <name> <addr>' : add friend, <name> must be quoted to include\n"
185 " spaces, <addr> has \"sip:\" added if it isn't\n"
186 " there. Don't use '<' '>' around <addr>.\n"
187 "'friend delete <index>' : remove friend, 'all' removes all\n"
189 { "play", lpc_cmd_play, "play from a wav file",
190 "This feature is available only in file mode (see 'help soundcard')\n"
191 "'play <wav file>' : play a wav file."
193 { "record", lpc_cmd_record, "record to a wav file",
194 "This feature is available only in file mode (see 'help soundcard')\n"
195 "'record <wav file>' : record into wav file."
197 { "quit", lpc_cmd_quit, "Exit linphonec", NULL },
198 { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"},
199 { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL },
200 { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL },
201 { "status", lpc_cmd_status, "Print various status information",
202 "'status register' \t: print status concerning registration\n"
203 "'status autoanswer'\t: tell whether autoanswer mode is enabled\n"
204 "'status hook' \t: print hook status\n" },
205 { "ports", lpc_cmd_ports, "Network ports configuration",
206 "'ports' \t: prints current used ports.\n"
207 "'ports sip <port number>'\t: Sets the sip port.\n" },
208 { "speak", lpc_cmd_speak, "Speak a sentence using espeak TTS engine",
209 "This feature is available only in file mode. (see 'help soundcard')\n"
210 "'speak <voice name> <sentence>' : speak a text using the specified espeak voice.\n"
211 "Example for english voice: 'speak default Hello my friend !'"
213 { "codec", lpc_cmd_codec, "Codec configuration",
214 "'codec list' : list codecs\n"
215 "'codec enable <index>' : enable available codec\n"
216 "'codec disable <index>' : disable codecs" },
217 { "ec", lpc_cmd_echocancellation, "Echo cancellation",
218 "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
219 "'ec off' : turn echo cancellation (EC) off\n"
220 "'ec show' : show EC status" },
221 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
224 /***************************************************************************
228 ***************************************************************************/
231 * Main command dispatcher.
232 * WARNING: modifies second argument!
234 * Always return 1 currently.
237 linphonec_parse_command_line(LinphoneCore *lc, char *cl)
243 /* Isolate first word and args */
244 while(*ptr && !isspace(*ptr)) ++ptr;
248 /* set args to first nonblank */
250 while(*args && isspace(*args)) ++args;
254 if ( isdigit(*cl) || *cl == '#' || *cl == '*' )
256 while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
258 linphone_core_send_dtmf(lc, *cl);
259 ms_sleep(1); // be nice
263 // discard spurious trailing chars
267 /* Handle other kind of commands */
268 cmd=lpc_find_command(cl);
271 linphonec_out("'%s': Cannot understand this.\n", cl);
275 if ( ! cmd->func(lc, args) )
277 linphonec_out("Syntax error.\n");
278 linphonec_display_command_help(cmd);
285 * Generator function for command completion.
286 * STATE let us know whether to start from scratch;
287 * without any state (STATE==0), then we start at the
291 linphonec_command_generator(const char *text, int state)
293 static int index, len;
303 * Return the next name which partially matches
304 * from the commands list
306 while ((name=commands[index].name))
308 ++index; /* so next call get next command */
310 if (strncmp(name, text, len) == 0)
312 return ortp_strdup(name);
320 /***************************************************************************
324 ***************************************************************************/
327 lpc_cmd_help(LinphoneCore *lc, char *arg)
334 linphonec_out("Commands are:\n");
335 linphonec_out("---------------------------\n");
337 while (commands[i].help)
339 linphonec_out("%10.10s\t%s\n", commands[i].name,
344 linphonec_out("---------------------------\n");
345 linphonec_out("Type 'help <command>' for more details.\n");
350 cmd=lpc_find_command(arg);
353 linphonec_out("No such command.\n");
357 linphonec_display_command_help(cmd);
362 static char callee_name[256]={0};
363 static char caller_name[256]={0};
366 lpc_cmd_call(LinphoneCore *lc, char *args)
368 if ( ! args || ! *args )
373 if ( lc->call != NULL )
375 linphonec_out("Terminate current call first.\n");
379 if ( -1 == linphone_core_invite(lc, args) )
381 linphonec_out("Error from linphone_core_invite.\n");
385 snprintf(callee_name,sizeof(callee_name),"%s",args);
391 const char *linphonec_get_callee(){
395 const char *linphonec_get_caller(){
399 void linphonec_set_caller(const char *caller){
400 snprintf(caller_name,sizeof(caller_name)-1,"%s",caller);
404 lpc_cmd_refer(LinphoneCore *lc, char *args)
407 linphone_core_refer(lc, args);
409 linphonec_out("refer needs an argument\n");
415 lpc_cmd_terminate(LinphoneCore *lc, char *args)
417 if ( -1 == linphone_core_terminate_call(lc, NULL) )
419 linphonec_out("No active call.\n");
425 lpc_cmd_answer(LinphoneCore *lc, char *args)
427 if ( -1 == linphone_core_accept_call(lc, NULL) )
429 linphonec_out("No incoming call.\n");
435 lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
439 if ( linphonec_get_autoanswer() ) {
440 linphonec_out("Auto answer is enabled. Use 'autoanswer disable' to disable.\n");
442 linphonec_out("Auto answer is disabled. Use 'autoanswer enable' to enable.\n");
447 if (strstr(args,"enable")){
448 linphonec_set_autoanswer(TRUE);
449 linphonec_out("Auto answer enabled.\n");
450 }else if (strstr(args,"disable")){
451 linphonec_set_autoanswer(FALSE);
452 linphonec_out("Auto answer disabled.\n");
458 lpc_cmd_quit(LinphoneCore *lc, char *args)
460 linphonec_main_loop_exit();
465 lpc_cmd_nat(LinphoneCore *lc, char *args)
470 if ( args ) args=lpc_strip_blanks(args);
474 linphone_core_set_nat_address(lc, args);
475 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS); */
478 nat = linphone_core_get_nat_address(lc);
479 use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_NAT_ADDRESS;
480 linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
486 lpc_cmd_stun(LinphoneCore *lc, char *args)
491 if ( args ) args=lpc_strip_blanks(args);
495 linphone_core_set_stun_server(lc, args);
496 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN); */
499 stun = linphone_core_get_stun_server(lc);
500 use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_STUN;
501 linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
507 lpc_cmd_firewall(LinphoneCore *lc, char *args)
509 const char* setting=NULL;
511 if ( args ) args=lpc_strip_blanks(args);
515 if (strcmp(args,"none")==0)
517 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_NO_FIREWALL);
519 else if (strcmp(args,"stun")==0)
521 setting = linphone_core_get_stun_server(lc);
524 linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
527 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN);
529 else if (strcmp(args,"nat")==0)
531 setting = linphone_core_get_nat_address(lc);
534 linphonec_out("No nat address is defined, use 'nat <address>' first");
537 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS);
541 switch(linphone_core_get_firewall_policy(lc))
543 case LINPHONE_POLICY_NO_FIREWALL:
544 linphonec_out("No firewall\n");
546 case LINPHONE_POLICY_USE_STUN:
547 linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
549 case LINPHONE_POLICY_USE_NAT_ADDRESS:
550 linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
557 /* Helper function for processing freind names */
559 lpc_friend_name(char **args, char **name)
561 /* Use space as a terminator unless quoted */
562 if (('"' == **args) || ('\'' == **args)){
567 while ((delim != *end) && ('\0' != *end)) end++;
569 fprintf(stderr, "Mismatched quotes\n");
576 *name = strsep(args, " ");
578 if (NULL == *args) { /* Means there was no separator */
579 fprintf(stderr, "Either name or address is missing\n");
582 if (NULL == *name) return 0;
589 lpc_cmd_friend(LinphoneCore *lc, char *args)
593 if ( args ) args=lpc_strip_blanks(args);
595 if ( ! args || ! *args ) return 0;
597 if ( !strncmp(args, "list", 4) )
599 return linphonec_friend_list(lc, args+4);
602 else if ( !strncmp(args, "call", 4) )
605 if ( ! *args ) return 0;
606 friend_num = strtol(args, NULL, 10);
608 if ( errno == ERANGE ) {
609 linphonec_out("Invalid friend number\n");
612 #endif /*_WIN32_WCE*/
613 linphonec_friend_call(lc, friend_num);
616 else if ( !strncmp(args, "delete", 6) )
619 if ( ! *args ) return 0;
620 while (*args == ' ') args++;
621 if ( ! *args ) return 0;
622 if (!strncmp(args, "all", 3))
628 friend_num = strtol(args, NULL, 10);
630 if ( errno == ERANGE ) {
631 linphonec_out("Invalid friend number\n");
634 #endif /*_WIN32_WCE*/
636 linphonec_friend_delete(lc, friend_num);
639 else if ( !strncmp(args, "add", 3) )
648 if ( ! *args ) return 0;
649 while (*args == ' ') args++;
650 if ( ! *args ) return 0;
652 if (!lpc_friend_name(&args, &name)) return 0;
654 while (*args == ' ') args++;
655 if ( ! *args ) return 0;
656 if (isdigit(*args)) {
657 strcpy (addr, "sip:");
658 addr_p = addr + strlen("sip:");
660 addr_orig = strsep(&args, " ");
661 if (1 >= strlen(addr_orig)) {
662 fprintf(stderr, "A single-digit address is not valid\n");
665 strcpy(addr_p, addr_orig);
666 linphonec_friend_add(lc, name, addr);
668 LinphoneFriend *new_friend;
669 new_friend = linphone_friend_new_with_addr(args);
670 linphone_core_add_friend(lc, new_friend);
677 static int lpc_cmd_play(LinphoneCore *lc, char *args){
678 if ( args ) args=lpc_strip_blanks(args);
679 if ( ! args || ! *args ) return 0;
680 linphone_core_set_play_file(lc,args);
684 static int lpc_cmd_record(LinphoneCore *lc, char *args){
685 if ( args ) args=lpc_strip_blanks(args);
686 if ( ! args || ! *args ) return 0;
687 linphone_core_set_record_file(lc,args);
695 lpc_cmd_proxy(LinphoneCore *lc, char *args)
702 if ( ! arg1 ) return 0;
704 /* Isolate first and second arg */
705 while(*ptr && !isspace(*ptr)) ++ptr;
710 while(*arg2 && isspace(*arg2)) ++arg2;
713 if (strcmp(arg1,"add")==0)
716 rl_inhibit_completion=1;
718 linphonec_proxy_add(lc);
720 rl_inhibit_completion=0;
723 else if (strcmp(arg1,"list")==0)
725 linphonec_proxy_list(lc);
727 else if (strcmp(arg1,"remove")==0)
729 linphonec_proxy_remove(lc,atoi(arg2));
731 else if (strcmp(arg1,"use")==0)
736 if ( linphonec_proxy_use(lc, proxynum) )
737 linphonec_out("Default proxy set to %d.\n", proxynum);
741 proxynum=linphone_core_get_default_proxy(lc, NULL);
742 if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
743 else linphonec_out("Current default proxy is %d.\n", proxynum);
745 }else if (strcmp(arg1, "unuse")==0){
746 linphone_core_set_default_proxy(lc, NULL);
747 linphonec_out("Use no proxy.\n");
750 else if (strcmp(arg1, "show")==0)
754 if (strstr(arg2,"default"))
756 proxynum=linphone_core_get_default_proxy(lc, NULL);
757 if ( proxynum < 0 ) {
758 linphonec_out("No default proxy defined\n");
761 linphonec_proxy_show(lc,proxynum);
765 linphonec_proxy_show(lc, atoi(arg2));
768 else return 0; /* syntax error */
773 return 0; /* syntax error */
780 lpc_cmd_call_logs(LinphoneCore *lc, char *args)
782 const MSList *elem=linphone_core_get_call_logs(lc);
783 for (;elem!=NULL;elem=ms_list_next(elem))
785 LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
786 char *str=linphone_call_log_to_str(cl);
787 linphonec_out("%s\n",str);
794 lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
798 return 0; /* syntax error */
801 if (strcmp(arg1,"status")==0)
803 linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
805 else if (strcmp(arg1,"enable")==0)
807 linphone_core_enable_ipv6(lc,TRUE);
808 linphonec_out("ipv6 use enabled.\n");
810 else if (strcmp(arg1,"disable")==0)
812 linphone_core_enable_ipv6(lc,FALSE);
813 linphonec_out("ipv6 use disabled.\n");
817 return 0; /* syntax error */
822 static int devname_to_index(LinphoneCore *lc, const char *devname){
825 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
826 if (strcmp(devname,*p)==0) return i;
831 static const char *index_to_devname(LinphoneCore *lc, int index){
834 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
835 if (i==index) return *p;
840 static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
848 if (!args) return 0; /* syntax error */
850 /* Isolate first and second arg */
851 while(*ptr && !isspace(*ptr)) ++ptr;
856 while(*arg2 && isspace(*arg2)) ++arg2;
859 if (strcmp(arg1, "list")==0)
861 dev=linphone_core_get_sound_devices(lc);
862 for(i=0; dev[i]!=NULL; ++i){
863 linphonec_out("%i: %s\n",i,dev[i]);
868 if (strcmp(arg1, "show")==0)
870 linphonec_out("Ringer device: %s\n",
871 linphone_core_get_ringer_device(lc));
872 linphonec_out("Playback device: %s\n",
873 linphone_core_get_playback_device(lc));
874 linphonec_out("Capture device: %s\n",
875 linphone_core_get_capture_device(lc));
879 if (strcmp(arg1, "use")==0 && arg2)
881 if (strcmp(arg2, "files")==0)
883 linphonec_out("Using wav files instead of soundcard.\n");
884 linphone_core_use_files(lc,TRUE);
888 dev=linphone_core_get_sound_devices(lc);
889 index=atoi(arg2); /* FIXME: handle not-a-number */
890 for(i=0;dev[i]!=NULL;i++)
892 if (i!=index) continue;
894 linphone_core_set_ringer_device(lc,dev[i]);
895 linphone_core_set_playback_device(lc,dev[i]);
896 linphone_core_set_capture_device(lc,dev[i]);
897 linphonec_out("Using sound device %s\n",dev[i]);
900 linphonec_out("No such sound device\n");
903 if (strcmp(arg1, "capture")==0)
905 const char *devname=linphone_core_get_capture_device(lc);
907 linphonec_out("Using capture device #%i (%s)\n",
908 devname_to_index(lc,devname),devname);
910 index=atoi(arg2); /* FIXME: handle not-a-number */
911 devname=index_to_devname(lc,index);
913 linphone_core_set_capture_device(lc,devname);
914 linphonec_out("Using capture sound device %s\n",devname);
917 linphonec_out("No such sound device\n");
921 if (strcmp(arg1, "playback")==0)
923 const char *devname=linphone_core_get_playback_device(lc);
925 linphonec_out("Using playback device #%i (%s)\n",
926 devname_to_index(lc,devname),devname);
928 index=atoi(arg2); /* FIXME: handle not-a-number */
929 devname=index_to_devname(lc,index);
931 linphone_core_set_playback_device(lc,devname);
932 linphonec_out("Using playback sound device %s\n",devname);
935 linphonec_out("No such sound device\n");
939 if (strcmp(arg1, "ring")==0)
941 const char *devname=linphone_core_get_ringer_device(lc);
943 linphonec_out("Using ring device #%i (%s)\n",
944 devname_to_index(lc,devname),devname);
946 index=atoi(arg2); /* FIXME: handle not-a-number */
947 devname=index_to_devname(lc,index);
949 linphone_core_set_ringer_device(lc,devname);
950 linphonec_out("Using ring sound device %s\n",devname);
953 linphonec_out("No such sound device\n");
957 return 0; /* syntax error */
960 static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
968 if (!args) return 0; /* syntax error */
970 /* Isolate first and second arg */
971 while(*ptr && !isspace(*ptr)) ++ptr;
976 while(*arg2 && isspace(*arg2)) ++arg2;
979 if (strcmp(arg1, "list")==0)
981 dev=linphone_core_get_video_devices(lc);
982 for(i=0; dev[i]!=NULL; ++i){
983 linphonec_out("%i: %s\n",i,dev[i]);
988 if (strcmp(arg1, "use")==0 && arg2)
990 dev=linphone_core_get_video_devices(lc);
991 index=atoi(arg2); /* FIXME: handle not-a-number */
992 for(i=0;dev[i]!=NULL;i++)
994 if (i!=index) continue;
996 linphone_core_set_video_device(lc, dev[i]);
997 linphonec_out("Using video device %s\n",dev[i]);
1000 linphonec_out("No such video device\n");
1003 return 0; /* syntax error */
1007 lpc_cmd_staticpic(LinphoneCore *lc, char *args)
1013 if (!args) return 0; /* Syntax error */
1015 /* Isolate first and second arg */
1016 while(*ptr && !isspace(*ptr)) ++ptr;
1021 while(*arg2 && isspace(*arg2)) ++arg2;
1024 if (strcmp(arg1, "set")==0 && arg2) {
1025 return linphone_core_set_static_picture(lc, arg2);
1028 return 0; /* Syntax error */
1033 /***************************************************************************
1035 * Commands helper functions
1037 ***************************************************************************/
1041 linphonec_proxy_add(LinphoneCore *lc)
1043 bool_t enable_register=FALSE;
1044 LinphoneProxyConfig *cfg;
1046 linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
1053 char *input=linphonec_readline("Enter proxy sip address: ");
1057 linphonec_out("Aborted.\n");
1062 clean=lpc_strip_blanks(input);
1068 cfg=linphone_proxy_config_new();
1069 if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
1071 linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
1073 linphone_proxy_config_destroy(cfg);
1081 * SIP Proxy identity
1085 char *input=linphonec_readline("Your identity for this proxy: ");
1089 linphonec_out("Aborted.\n");
1090 linphone_proxy_config_destroy(cfg);
1095 clean=lpc_strip_blanks(input);
1101 linphone_proxy_config_set_identity(cfg, clean);
1102 if ( ! cfg->reg_identity )
1104 linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
1113 * SIP Proxy enable register
1117 char *input=linphonec_readline("Do you want to register on this proxy (yes/no): ");
1121 linphonec_out("Aborted.\n");
1122 linphone_proxy_config_destroy(cfg);
1127 clean=lpc_strip_blanks(input);
1133 if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
1134 else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
1136 linphonec_out("Please answer with 'yes' or 'no'\n");
1140 linphone_proxy_config_enableregister(cfg, enable_register);
1146 * SIP Proxy registration expiration
1148 if ( enable_register==TRUE )
1153 char *input=linphonec_readline("Specify register expiration time"
1154 " in seconds (default is 600): ");
1157 linphonec_out("Aborted.\n");
1158 linphone_proxy_config_destroy(cfg);
1162 expires=strtol(input, (char **)NULL, 10);
1163 if ( expires == LONG_MIN || expires == LONG_MAX )
1165 linphonec_out("Invalid value: %s\n", strerror(errno));
1170 linphone_proxy_config_expires(cfg, expires);
1171 linphonec_out("Expiration: %d seconds\n", cfg->expires);
1183 char *input=linphonec_readline("Specify route if needed: ");
1187 linphonec_out("Aborted.\n");
1188 linphone_proxy_config_destroy(cfg);
1193 clean=lpc_strip_blanks(input);
1196 linphonec_out("No route specified.\n");
1200 linphone_proxy_config_set_route(cfg, clean);
1201 if ( ! cfg->reg_route )
1203 linphonec_out("Invalid route.\n");
1213 * Final confirmation
1220 linphonec_out("--------------------------------------------\n");
1221 linphonec_proxy_display(cfg);
1222 linphonec_out("--------------------------------------------\n");
1223 input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
1227 linphonec_out("Aborted.\n");
1228 linphone_proxy_config_destroy(cfg);
1233 clean=lpc_strip_blanks(input);
1239 if ( ! strcmp(clean, "yes") ) break;
1240 else if ( ! strcmp(clean, "no") )
1242 linphonec_out("Declined.\n");
1243 linphone_proxy_config_destroy(cfg);
1248 linphonec_out("Please answer with 'yes' or 'no'\n");
1254 linphone_core_add_proxy_config(lc,cfg);
1256 /* automatically set the last entered proxy as the default one */
1257 linphone_core_set_default_proxy(lc,cfg);
1259 linphonec_out("Proxy added.\n");
1263 linphonec_proxy_display(LinphoneProxyConfig *cfg)
1265 linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
1267 (cfg->reg_route!=NULL)?cfg->reg_route:"",
1268 (cfg->reg_identity!=NULL)?cfg->reg_identity:"",
1269 (cfg->reg_sendregister)?"yes":"no",
1271 linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
1274 static void linphonec_proxy_show(LinphoneCore *lc, int index)
1278 for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){
1280 LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data;
1281 linphonec_proxy_display(cfg);
1285 linphonec_out("No proxy with index %i\n", index);
1289 linphonec_proxy_list(LinphoneCore *lc)
1291 const MSList *proxies;
1293 int def=linphone_core_get_default_proxy(lc,NULL);
1295 proxies=linphone_core_get_proxy_config_list(lc);
1296 for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
1298 linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
1300 linphonec_out("****** Proxy %i *******\n",n);
1301 linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
1303 if ( ! n ) linphonec_out("No proxies defined\n");
1307 linphonec_proxy_remove(LinphoneCore *lc, int index)
1309 const MSList *proxies;
1310 LinphoneProxyConfig *cfg;
1311 proxies=linphone_core_get_proxy_config_list(lc);
1312 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1314 linphonec_out("No such proxy.\n");
1317 linphone_core_remove_proxy_config(lc,cfg);
1318 linphonec_out("Proxy %s removed.\n", cfg->reg_proxy);
1319 linphone_proxy_config_destroy(cfg);
1323 linphonec_proxy_use(LinphoneCore *lc, int index)
1325 const MSList *proxies;
1326 LinphoneProxyConfig *cfg;
1327 proxies=linphone_core_get_proxy_config_list(lc);
1328 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1330 linphonec_out("No such proxy (try 'proxy list').");
1333 linphone_core_set_default_proxy(lc,cfg);
1338 linphonec_friend_display(LinphoneFriend *fr)
1340 LinphoneAddress *uri=linphone_address_clone(linphone_friend_get_address(fr));
1343 linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
1344 linphone_address_set_display_name(uri,NULL);
1345 str=linphone_address_as_string(uri);
1346 linphonec_out("address: %s\n", str);
1350 linphonec_friend_list(LinphoneCore *lc, char *pat)
1352 const MSList *friend;
1356 pat=lpc_strip_blanks(pat);
1357 if (!*pat) pat = NULL;
1360 friend = linphone_core_get_friend_list(lc);
1361 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1364 const char *name = linphone_address_get_display_name(
1365 linphone_friend_get_address((LinphoneFriend*)friend->data));
1366 if (name && ! strstr(name, pat) ) continue;
1368 linphonec_out("****** Friend %i *******\n",n);
1369 linphonec_friend_display((LinphoneFriend*)friend->data);
1376 linphonec_friend_call(LinphoneCore *lc, unsigned int num)
1378 const MSList *friend = linphone_core_get_friend_list(lc);
1382 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1387 addr = linphone_address_as_string(linphone_friend_get_address((LinphoneFriend*)friend->data));
1388 ret=lpc_cmd_call(lc, addr);
1393 linphonec_out("No such friend %u\n", num);
1399 linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr)
1401 LinphoneFriend *newFriend;
1405 snprintf(url, PATH_MAX, "%s <%s>", name, addr);
1406 newFriend = linphone_friend_new_with_addr(url);
1407 linphone_core_add_friend(lc, newFriend);
1413 linphonec_friend_delete(LinphoneCore *lc, int num)
1415 const MSList *friend = linphone_core_get_friend_list(lc);
1418 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1422 linphone_core_remove_friend(lc, friend->data);
1430 for (i = 0 ; i < n ; i++)
1431 linphonec_friend_delete(lc, 0);
1435 linphonec_out("No such friend %u\n", num);
1440 linphonec_display_command_help(LPC_COMMAND *cmd)
1442 if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
1443 else linphonec_out("%s\n", cmd->help);
1447 static int lpc_cmd_register(LinphoneCore *lc, char *args){
1451 LinphoneProxyConfig *cfg;
1453 if (!args) return 0;
1454 passwd[0]=proxy[0]=identity[0]='\0';
1455 sscanf(args,"%s %s %s",identity,proxy,passwd);
1456 if (proxy[0]=='\0' || identity[0]=='\0'){
1457 linphonec_out("Missing parameters, see help register\n");
1460 if (passwd[0]!='\0'){
1461 LinphoneAddress *from;
1462 LinphoneAuthInfo *info;
1463 if ((from=linphone_address_new(identity))!=NULL){
1465 snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
1466 info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
1467 linphone_core_add_auth_info(lc,info);
1468 linphone_address_destroy(from);
1469 linphone_auth_info_destroy(info);
1472 elem=linphone_core_get_proxy_config_list(lc);
1474 cfg=(LinphoneProxyConfig*)elem->data;
1475 linphone_proxy_config_edit(cfg);
1477 else cfg=linphone_proxy_config_new();
1478 linphone_proxy_config_set_identity(cfg,identity);
1479 linphone_proxy_config_set_server_addr(cfg,proxy);
1480 linphone_proxy_config_enable_register(cfg,TRUE);
1481 if (elem) linphone_proxy_config_done(cfg);
1482 else linphone_core_add_proxy_config(lc,cfg);
1483 linphone_core_set_default_proxy(lc,cfg);
1487 static int lpc_cmd_unregister(LinphoneCore *lc, char *args){
1488 LinphoneProxyConfig *cfg=NULL;
1489 linphone_core_get_default_proxy(lc,&cfg);
1490 if (cfg && linphone_proxy_config_is_registered(cfg)) {
1491 linphone_proxy_config_edit(cfg);
1492 linphone_proxy_config_enable_register(cfg,FALSE);
1493 linphone_proxy_config_done(cfg);
1495 linphonec_out("unregistered\n");
1500 static int lpc_cmd_duration(LinphoneCore *lc, char *args){
1501 LinphoneCallLog *cl;
1502 const MSList *elem=linphone_core_get_call_logs(lc);
1503 for(;elem!=NULL;elem=elem->next){
1504 if (elem->next==NULL){
1505 cl=(LinphoneCallLog*)elem->data;
1506 linphonec_out("%i seconds\n",cl->duration);
1512 static int lpc_cmd_status(LinphoneCore *lc, char *args)
1514 LinphoneProxyConfig *cfg;
1516 if ( ! args ) return 0;
1517 linphone_core_get_default_proxy(lc,&cfg);
1518 if (strstr(args,"register"))
1522 if (linphone_proxy_config_is_registered(cfg)){
1523 linphonec_out("registered, identity=%s duration=%i\n",
1524 linphone_proxy_config_get_identity(cfg),
1525 linphone_proxy_config_get_expires(cfg));
1526 }else if (linphone_proxy_config_register_enabled(cfg)){
1527 linphonec_out("registered=-1\n");
1528 }else linphonec_out("registered=0\n");
1530 else linphonec_out("registered=0\n");
1532 else if (strstr(args,"autoanswer"))
1534 if (cfg && linphone_proxy_config_is_registered(cfg))
1535 linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
1536 else linphonec_out("unregistered\n");
1538 else if (strstr(args,"hook"))
1540 gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL);
1542 if (!cfg || !linphone_proxy_config_is_registered(cfg)){
1543 linphonec_out("unregistered\n");
1548 case GSTATE_CALL_OUT_INVITE:
1549 linphonec_out("hook=dialing\n");
1551 case GSTATE_CALL_IDLE:
1552 linphonec_out("hook=offhook\n");
1554 case GSTATE_CALL_OUT_CONNECTED:
1555 linphonec_out("Call out, hook=%s duration=%i\n", linphonec_get_callee(),
1556 linphone_core_get_current_call_duration(lc));
1558 case GSTATE_CALL_IN_CONNECTED:
1559 linphonec_out("hook=answered duration=%i\n" ,
1560 linphone_core_get_current_call_duration(lc));
1562 case GSTATE_CALL_IN_INVITE:
1563 linphonec_out("Incoming call from %s\n",linphonec_get_caller());
1575 static int lpc_cmd_ports(LinphoneCore *lc, char *args)
1579 linphonec_out("sip port = %i\naudio rtp port = %i\nvideo rtp port = %i\n",
1580 linphone_core_get_sip_port(lc),
1581 linphone_core_get_audio_port(lc),
1582 linphone_core_get_video_port(lc));
1585 if (sscanf(args,"sip %i",&port)==1){
1586 linphonec_out("Setting sip port to %i\n",port);
1587 linphone_core_set_sip_port(lc,port);
1593 static int lpc_cmd_speak(LinphoneCore *lc, char *args){
1601 if (!args) return 0;
1602 memset(voice,0,sizeof(voice));
1603 sscanf(args,"%s63",voice);
1604 sentence=args+strlen(voice);
1605 wavfile=tempnam("/tmp/","linphonec-espeak-");
1606 snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
1609 ms_error("Could not open pipe to espeak !");
1612 fprintf(file,"%s",sentence);
1613 status=pclose(file);
1614 if (WEXITSTATUS(status)==0){
1615 linphone_core_set_play_file(lc,wavfile);
1617 linphonec_out("espeak command failed.");
1620 linphonec_out("Sorry, this command is not implemented in windows version.");
1625 static int lpc_cmd_codec(LinphoneCore *lc, char *args){
1630 if (!args) return 0;
1632 /* Isolate first and second arg */
1633 while(*ptr && !isspace(*ptr)) ++ptr;
1638 while(*arg2 && isspace(*arg2)) ++arg2;
1641 if (strcmp(arg1,"enable")==0)
1643 #ifdef HAVE_READLINE
1644 rl_inhibit_completion=1;
1646 if (!strcmp(arg2,"all")) linphonec_codec_enable(lc,-1);
1647 else linphonec_codec_enable(lc,atoi(arg2));
1648 #ifdef HAVE_READLINE
1649 rl_inhibit_completion=0;
1652 else if (strcmp(arg1,"list")==0)
1654 linphonec_codec_list(lc);
1656 else if (strcmp(arg1,"disable")==0)
1658 if (!strcmp(arg2,"all")) linphonec_codec_disable(lc,-1);
1659 else linphonec_codec_disable(lc,atoi(arg2));
1663 return 0; /* syntax error */
1669 static void linphonec_codec_list(LinphoneCore *lc){
1671 codecs_config_t *config=&lc->codecs_conf;
1674 for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){
1675 pt=(PayloadType*)(node->data);
1676 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
1677 linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
1682 static void linphonec_codec_enable(LinphoneCore *lc, int sel_index){
1684 codecs_config_t *config=&lc->codecs_conf;
1687 for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){
1688 if (index == sel_index || sel_index == -1) {
1689 pt=(PayloadType*)(node->data);
1690 pt->flags|=PAYLOAD_TYPE_ENABLED;
1691 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
1697 static void linphonec_codec_disable(LinphoneCore *lc, int sel_index){
1699 codecs_config_t *config=&lc->codecs_conf;
1702 for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){
1703 if (index == sel_index || sel_index == -1) {
1704 pt=(PayloadType*)(node->data);
1705 pt->flags&=~PAYLOAD_TYPE_ENABLED;
1706 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
1712 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
1717 if (!args) return 0;
1719 /* Isolate first and second arg */
1720 while(*ptr && !isspace(*ptr)) ++ptr;
1725 while(*arg2 && isspace(*arg2)) ++arg2;
1728 if (strcmp(arg1,"on")==0){
1729 int delay, tail_len, frame_size;
1732 linphone_core_enable_echo_cancellation(lc,1);
1735 n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
1738 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1741 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1742 lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
1745 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1746 lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
1747 lp_config_set_int(lc->config,"sound","ec_framesize",frame_size);
1751 else if (strcmp(arg1,"off")==0){
1752 linphone_core_enable_echo_cancellation(lc,0);
1754 else if (strcmp(arg1,"show")==0){
1755 linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
1756 linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
1757 lp_config_get_int(lc->config,"sound","ec_delay",0),
1758 lp_config_get_int(lc->config,"sound","ec_tail_len",0),
1759 lp_config_get_int(lc->config,"sound","ec_framesize",0));
1768 /***************************************************************************
1770 * Command table management funx
1772 ***************************************************************************/
1775 * Find a command given its name
1777 static LPC_COMMAND *
1778 lpc_find_command(const char *name)
1782 for (i=0; commands[i].name; ++i)
1784 if (strcmp(name, commands[i].name) == 0)
1785 return &commands[i];
1788 return (LPC_COMMAND *)NULL;
1792 /****************************************************************************
1794 * $Log: commands.c,v $
1795 * Revision 1.39 2008/07/03 15:08:34 smorlat
1796 * api cleanups, interface in progress.
1798 * Revision 1.38 2008/06/17 20:38:59 smorlat
1799 * added missing file.
1801 * Revision 1.37 2008/04/09 09:26:00 smorlat
1802 * merge various patches
1805 * Revision 1.36 2007/08/01 14:47:53 strk
1806 * * console/commands.c: Clean up commands 'nat', 'stun'
1807 * and 'firewall' to be more intuitive.
1809 * Revision 1.35 2007/06/27 09:01:25 smorlat
1810 * logging improvements.
1812 * Revision 1.34 2007/02/20 10:17:13 smorlat
1813 * linphonec friends patch2
1815 * Revision 1.31 2006/09/22 07:22:47 smorlat
1816 * linphonecore api changes.
1818 * Revision 1.30 2006/09/08 15:32:57 smorlat
1819 * support for using files instead of soundcard (used by linphonec only)
1821 * Revision 1.29 2006/08/28 14:29:07 smorlat
1824 * Revision 1.28 2006/08/21 12:49:59 smorlat
1825 * merged several little patches.
1827 * Revision 1.27 2006/07/17 18:45:00 smorlat
1828 * support for several event queues in ortp.
1829 * glib dependency removed from coreapi/ and console/
1831 * Revision 1.26 2006/04/14 15:16:36 smorlat
1832 * soundcard use did nothing !
1834 * Revision 1.25 2006/04/06 20:09:33 smorlat
1835 * add linphonec command to see and select sound devices.
1837 * Revision 1.24 2006/03/04 11:17:10 smorlat
1838 * mediastreamer2 in progress.
1840 * Revision 1.23 2006/02/20 21:14:01 strk
1841 * Handled syntax errors with 'friend' command
1843 * Revision 1.22 2006/02/20 10:20:29 strk
1844 * Added substring-based filter support for command 'friend list'
1846 * Revision 1.21 2006/02/02 15:39:18 strk
1847 * - Added 'friend list' and 'friend call' commands
1848 * - Allowed for multiple DTFM send in a single line
1849 * - Added status-specific callback (bare version)
1851 * Revision 1.20 2006/01/26 11:54:34 strk
1852 * More robust 'nat' command handler (strip blanks in args)
1854 * Revision 1.19 2006/01/26 09:48:05 strk
1855 * Added limits.h include
1857 * Revision 1.18 2006/01/26 02:18:05 strk
1858 * Added new commands 'nat use' and 'nat unuse'.
1859 * These will required a pending patch to linphonecore.c
1862 * Revision 1.17 2006/01/20 14:12:33 strk
1863 * Added linphonec_init() and linphonec_finish() functions.
1864 * Handled SIGINT and SIGTERM to invoke linphonec_finish().
1865 * Handling of auto-termination (-t) moved to linphonec_finish().
1866 * Reworked main (input read) loop to not rely on 'terminate'
1867 * and 'run' variable (dropped). configfile_name allocated on stack
1868 * using PATH_MAX limit. Changed print_usage signature to allow
1869 * for an exit_status specification.
1871 * Revision 1.16 2006/01/18 09:25:32 strk
1872 * Command completion inhibited in proxy addition and auth request prompts.
1873 * Avoided use of linphonec_readline's internal filename completion.
1875 * Revision 1.15 2006/01/14 13:29:32 strk
1876 * Reworked commands interface to use a table structure,
1877 * used by command line parser and help function.
1878 * Implemented first level of completion (commands).
1879 * Added notification of invalid "answer" and "terminate"
1880 * commands (no incoming call, no active call).
1881 * Forbidden "call" intialization when a call is already active.
1882 * Cleaned up all commands, adding more feedback and error checks.
1884 * Revision 1.14 2006/01/13 13:00:29 strk
1885 * Added linphonec.h. Code layout change (added comments, forward decl,
1886 * globals on top, copyright notices and Logs). Handled out-of-memory
1887 * condition on history management. Removed assumption on sizeof(char).
1888 * Fixed bug in authentication prompt (introduced by linphonec_readline).
1889 * Added support for multiple authentication requests (up to MAX_PENDING_AUTH).
1892 ****************************************************************************/