From: Moises Silva Date: Wed, 28 Sep 2011 16:27:10 +0000 (-0400) Subject: Merge branch 'master' into smgmaster X-Git-Tag: v1.2.3^2~71^2^2~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff3648ef21906926f13bb64451964fea778bae9e;p=thirdparty%2Ffreeswitch.git Merge branch 'master' into smgmaster Conflicts: build/modules.conf.in libs/esl/fs_cli.c --- ff3648ef21906926f13bb64451964fea778bae9e diff --cc libs/esl/fs_cli.c index 5d0c7eb8c1,22906e710f..6ef6d8953d --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@@ -6,14 -6,16 +6,17 @@@ #include #include #include + #include #define CMD_BUFLEN 1024 +#define PROMPT_PREFIX "netborder-ss7" - static int WARN_STOP = 0; - #ifdef WIN32 + #ifndef WIN32 + #include + #include + #include + #else #define strdup(src) _strdup(src) - #define usleep(time) Sleep(time/1000) #define fileno _fileno #define read _read #include @@@ -847,22 -866,24 +867,43 @@@ static const char *basic_gets(int *cnt } #endif ++<<<<<<< HEAD + +static void print_banner(FILE *stream) +{ + fprintf(stream, + + + "\n" + "*******************************************************\n" + "* Netborder SS7 Gateway *\n" + "* Powered by FreeSWITCH (http://www.freeswitch.org) *\n" + "*******************************************************\n" + "\n" + "Type /help to see a list of commands\n\n\n" + ); +} + ++======= + static const char *banner = + " _____ ____ ____ _ ___ \n" + " | ___/ ___| / ___| | |_ _| \n" + " | |_ \\___ \\ | | | | | | \n" + " | _| ___) | | |___| |___ | | \n" + " |_| |____/ \\____|_____|___| \n" + "\n" + "*******************************************************\n" + "* Anthony Minessale II, Ken Rice, *\n" + "* Michael Jerris, Travis Cross *\n" + "* FreeSWITCH (http://www.freeswitch.org) *\n" + "* Paypal Donations Appreciated: paypal@freeswitch.org *\n" + "* Brought to you by ClueCon http://www.cluecon.com/ *\n" + "*******************************************************\n" + "\n" + "Type /help to see a list of commands\n\n\n"; + + static void print_banner(FILE *stream) { fprintf(stream, "%s%s", output_text_color, banner); } ++>>>>>>> master static void set_fn_keys(cli_profile_t *profile) { @@@ -998,18 -1104,15 +1124,21 @@@ int main(int argc, char *argv[] int count = 0; const char *line = NULL; char cmd_str[1024] = ""; - esl_config_t cfg; cli_profile_t *profile = NULL; - int rv = 0; - #ifndef WIN32 ++<<<<<<< HEAD + char hfile[512] = "/etc/nbess7_cli_history"; + char cfile[512] = "/etc/nbess7_cli.conf"; + char dft_cfile[512] = "/etc/nbess7_cli.conf"; ++======= + char hfile[512] = "/tmp/fs_cli_history"; + char cfile[512] = "/etc/fs_cli.conf"; + char dft_cfile[512] = "/etc/fs_cli.conf"; ++>>>>>>> master #else - char hfile[512] = "fs_cli_history"; - char cfile[512] = "fs_cli.conf"; - char dft_cfile[512] = "fs_cli.conf"; + char hfile[512] = "nbess7_cli_history"; + char cfile[512] = "nbess7_cli.conf"; + char dft_cfile[512] = "nbess7_cli.conf"; #endif char *home = getenv("HOME"); /* Vars for optargs */ @@@ -1051,15 -1152,15 +1178,15 @@@ strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host)); strncpy(internal_profile.pass, "ClueCon", sizeof(internal_profile.pass)); strncpy(internal_profile.name, "internal", sizeof(internal_profile.name)); - internal_profile.port = 8021; + internal_profile.port = 8821; set_fn_keys(&internal_profile); - - + esl_set_string(internal_profile.prompt_color, prompt_color); + esl_set_string(internal_profile.input_text_color, input_text_color); + esl_set_string(internal_profile.output_text_color, output_text_color); if (home) { - snprintf(hfile, sizeof(hfile), "%s/.fs_cli_history", home); - snprintf(cfile, sizeof(cfile), "%s/.fs_cli_conf", home); + snprintf(hfile, sizeof(hfile), "%s/.nbess7_cli_history", home); + snprintf(cfile, sizeof(cfile), "%s/.nbess7_cli_conf", home); } - signal(SIGINT, handle_SIGINT); #ifdef SIGTSTP signal(SIGTSTP, handle_SIGINT); @@@ -1141,62 -1239,7 +1265,66 @@@ printf("\n"); return usage(argv[0]); } ++<<<<<<< HEAD + + if (!(rv = esl_config_open_file(&cfg, cfile))) { + rv = esl_config_open_file(&cfg, dft_cfile); + } + + if (rv) { + char *var, *val; + char cur_cat[128] = ""; + + while (esl_config_next_pair(&cfg, &var, &val)) { + if (strcmp(cur_cat, cfg.category)) { + esl_set_string(cur_cat, cfg.category); + esl_set_string(profiles[pcount].name, cur_cat); + esl_set_string(profiles[pcount].host, "localhost"); + esl_set_string(profiles[pcount].pass, "ClueCon"); + profiles[pcount].port = 8821; + set_fn_keys(&profiles[pcount]); + esl_log(ESL_LOG_DEBUG, "Found Profile [%s]\n", profiles[pcount].name); + pcount++; + } + + if (!strcasecmp(var, "host")) { + esl_set_string(profiles[pcount-1].host, val); + } else if (!strcasecmp(var, "user")) { + esl_set_string(profiles[pcount-1].user, val); + } else if (!strcasecmp(var, "password")) { + esl_set_string(profiles[pcount-1].pass, val); + } else if (!strcasecmp(var, "port")) { + int pt = atoi(val); + if (pt > 0) { + profiles[pcount-1].port = (esl_port_t)pt; + } + } else if (!strcasecmp(var, "debug")) { + int dt = atoi(val); + if (dt > -1 && dt < 8){ + profiles[pcount-1].debug = dt; + } + } else if(!strcasecmp(var, "loglevel")) { + esl_set_string(profiles[pcount-1].loglevel, val); + } else if(!strcasecmp(var, "quiet")) { + profiles[pcount-1].quiet = esl_true(val); + } else if (!strncasecmp(var, "key_F", 5)) { + char *key = var + 5; + + if (key) { + int i = atoi(key); + + if (i > 0 && i < 13) { + profiles[pcount-1].console_fnkeys[i - 1] = strdup(val); + } + } + } + } + esl_config_close_file(&cfg); + } + ++======= + read_config(dft_cfile, cfile); ++>>>>>>> master if (optind < argc) { get_profile(argv[optind], &profile); } @@@ -1231,23 -1268,27 +1353,27 @@@ esl_set_string(profile->loglevel, argv_loglevel); profile->quiet = 0; } - esl_log(ESL_LOG_DEBUG, "Using profile %s [%s]\n", profile->name, profile->host); - + esl_set_string(prompt_color, profile->prompt_color); + esl_set_string(input_text_color, profile->input_text_color); + esl_set_string(output_text_color, profile->output_text_color); if (argv_host) { - if (argv_port && profile->port != 8021) { - snprintf(bare_prompt_str, sizeof(bare_prompt_str), "freeswitch@%s:%u@%s> ", profile->host, profile->port, profile->name); + if (argv_port && profile->port != 8821) { + snprintf(prompt_str, sizeof(prompt_str), PROMPT_PREFIX "@%s:%u@%s> ", profile->host, profile->port, profile->name); } else { - snprintf(bare_prompt_str, sizeof(bare_prompt_str), "freeswitch@%s@%s> ", profile->host, profile->name); + snprintf(prompt_str, sizeof(prompt_str), PROMPT_PREFIX "@%s@%s> ", profile->host, profile->name); } } else { - snprintf(bare_prompt_str, sizeof(bare_prompt_str), "freeswitch@%s> ", profile->name); + snprintf(prompt_str, sizeof(prompt_str), PROMPT_PREFIX "@%s> ", profile->name); } - + bare_prompt_str_len = (int)strlen(bare_prompt_str); + #ifdef WIN32 + snprintf(prompt_str, sizeof(prompt_str), "%s", bare_prompt_str); /* Not supporting this for now */ + #else + snprintf(prompt_str, sizeof(prompt_str), "%s%s%s", prompt_color, bare_prompt_str, input_text_color); + #endif connect: - - CONNECTED = 0; - + connected = 0; while (--loops > 0) { memset(&handle, 0, sizeof(handle)); if (esl_connect(&handle, profile->host, profile->port, profile->user, profile->pass)) { @@@ -1375,20 -1395,15 +1480,22 @@@ wOldColorAttrs = csbiInfo.wAttributes; } #endif - if (!argv_quiet && !profile->quiet) { - snprintf(cmd_str, sizeof(cmd_str), "log %s\n\n", profile->loglevel); + snprintf(cmd_str, sizeof(cmd_str), "log %s\n\n", profile->loglevel); esl_send_recv(&handle, cmd_str); } - print_banner(stdout); ++<<<<<<< HEAD + + esl_log(ESL_LOG_INFO, "Netborder SS7 CLI Ready.\nenter /help for a list of commands.\n"); + printf("%s\n", handle.last_sr_reply); + ++======= + esl_log(ESL_LOG_INFO, "FS CLI Ready.\nenter /help for a list of commands.\n"); + output_printf("%s\n", handle.last_sr_reply); ++>>>>>>> master while (running > 0) { int r; - #ifdef HAVE_EDITLINE line = el_gets(el, &count); #else