make it use long options
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10939 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c9a4b3af08
commit
4eff9b1b32
|
@ -9,13 +9,14 @@
|
||||||
#define fileno _fileno
|
#define fileno _fileno
|
||||||
#define read _read
|
#define read _read
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <getopt.h>
|
|
||||||
#else
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <histedit.h>
|
#include <histedit.h>
|
||||||
#define HAVE_EDITLINE
|
#define HAVE_EDITLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
static char prompt_str[512] = "";
|
static char prompt_str[512] = "";
|
||||||
static char hostname[512] = "";
|
static char hostname[512] = "";
|
||||||
|
|
||||||
|
@ -218,7 +219,6 @@ int main(int argc, char *argv[])
|
||||||
esl_config_t cfg;
|
esl_config_t cfg;
|
||||||
cli_profile_t *profile = &profiles[0];
|
cli_profile_t *profile = &profiles[0];
|
||||||
int cur = 0;
|
int cur = 0;
|
||||||
int opt;
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
char hfile[512] = "/tmp/fs_cli_history";
|
char hfile[512] = "/tmp/fs_cli_history";
|
||||||
char cfile[512] = "/tmp/fs_cli_config";
|
char cfile[512] = "/tmp/fs_cli_config";
|
||||||
|
@ -234,6 +234,17 @@ int main(int argc, char *argv[])
|
||||||
strncpy(profiles[0].name, "default", sizeof(profiles[0].name));
|
strncpy(profiles[0].name, "default", sizeof(profiles[0].name));
|
||||||
profiles[0].port = 8021;
|
profiles[0].port = 8021;
|
||||||
pcount++;
|
pcount++;
|
||||||
|
|
||||||
|
/* Vars for optargs */
|
||||||
|
int opt;
|
||||||
|
static struct option options[] = {
|
||||||
|
{"help", 0, 0, 'h'},
|
||||||
|
{"host", 1, 0, 'H'},
|
||||||
|
{"port", 1, 0, 'P'},
|
||||||
|
{"password", 1, 0, 'p'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
if (home) {
|
if (home) {
|
||||||
snprintf(hfile, sizeof(hfile), "%s/.fs_cli_history", home);
|
snprintf(hfile, sizeof(hfile), "%s/.fs_cli_history", home);
|
||||||
|
@ -276,7 +287,10 @@ int main(int argc, char *argv[])
|
||||||
esl_config_close_file(&cfg);
|
esl_config_close_file(&cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt (argc, argv, "H:U:P:S:p:h?")) != -1){
|
while (1){
|
||||||
|
int option_index = 0;
|
||||||
|
opt = getopt_long(argc, argv, "H:U:P:S:p:h?", options, &option_index);
|
||||||
|
if (opt == -1) break;
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case 'H':
|
case 'H':
|
||||||
|
@ -293,7 +307,12 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
printf("%s [-H <host>] [-P <port>] [-s <secret>] [-p <port>]\n", argv[0]);
|
printf("Usage: %s [-H <host>] [-P <port>] [-p <secret>] [profile]\n\n", argv[0]);
|
||||||
|
printf(" -?,-h --help Usage Information\n");
|
||||||
|
printf(" -H, --host=hostname Host to connect\n");
|
||||||
|
printf(" -P, --port=port Port to connect\n");
|
||||||
|
printf(" -p, --password=FILENAME Password\n\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
opt = 0;
|
opt = 0;
|
||||||
|
|
Loading…
Reference in New Issue