From 44a729e38eb5f1fb37a7e5f58ef5ded27ba53377 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 3 Feb 2009 19:37:58 +0000 Subject: [PATCH] allow you to specify -htdocs dir at runtime. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11614 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch.c | 55 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/switch.c b/src/switch.c index 54ae45db6c..4d519cf731 100644 --- a/src/switch.c +++ b/src/switch.c @@ -281,29 +281,30 @@ int main(int argc, char *argv[]) usageDesc = "these are the optional arguments you can pass to freeswitch\n" #ifdef WIN32 - "\t-service [name] -- start freeswitch as a service, cannot be used if loaded as a console app\n" - "\t-install [name] -- install freeswitch as a service, with optional service name\n" - "\t-uninstall -- remove freeswitch as a service\n" + "\t-service [name] -- start freeswitch as a service, cannot be used if loaded as a console app\n" + "\t-install [name] -- install freeswitch as a service, with optional service name\n" + "\t-uninstall -- remove freeswitch as a service\n" #else - "\t-nf -- no forking\n" - "\t-u [user] -- specify user to switch to\n" - "\t-g [group] -- specify group to switch to\n" + "\t-nf -- no forking\n" + "\t-u [user] -- specify user to switch to\n" + "\t-g [group] -- specify group to switch to\n" #endif - "\t-help -- this message\n" + "\t-help -- this message\n" #ifdef HAVE_SETRLIMIT - "\t-core -- dump cores\n" + "\t-core -- dump cores\n" #endif - "\t-hp -- enable high priority settings\n" - "\t-vg -- run under valgrind\n" - "\t-nosql -- disable internal sql scoreboard\n" - "\t-stop -- stop freeswitch\n" - "\t-nc -- do not output to a console and background\n" - "\t-c -- output to a console and stay in the foreground\n" - "\t-conf [confdir] -- specify an alternate config dir\n" - "\t-log [logdir] -- specify an alternate log dir\n" - "\t-db [dbdir] -- specify an alternate db dir\n" - "\t-mod [moddir] -- specify an alternate mod dir\n" - "\t-scripts [scriptsdir] -- specify an alternate scripts dir\n"; + "\t-hp -- enable high priority settings\n" + "\t-vg -- run under valgrind\n" + "\t-nosql -- disable internal sql scoreboard\n" + "\t-stop -- stop freeswitch\n" + "\t-nc -- do not output to a console and background\n" + "\t-c -- output to a console and stay in the foreground\n" + "\t-conf [confdir] -- specify an alternate config dir\n" + "\t-log [logdir] -- specify an alternate log dir\n" + "\t-db [dbdir] -- specify an alternate db dir\n" + "\t-mod [moddir] -- specify an alternate mod dir\n" + "\t-htdocs [htdocsdir] -- specify an alternate htdocs dir\n" + "\t-scripts [scriptsdir] -- specify an alternate scripts dir\n"; for (x = 1; x < argc; x++) { known_opt = 0; @@ -550,6 +551,22 @@ int main(int argc, char *argv[]) known_opt++; } + if (argv[x] && !strcmp(argv[x], "-htdocs")) { + x++; + if (argv[x] && strlen(argv[x])) { + SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(strlen(argv[x]) + 1); + if (!SWITCH_GLOBAL_dirs.htdocs_dir) { + fprintf(stderr, "Allocation error\n"); + return 255; + } + strcpy(SWITCH_GLOBAL_dirs.htdocs_dir, argv[x]); + } else { + fprintf(stderr, "When using -htdocs you must specify a htdocs directory\n"); + return 255; + } + known_opt++; + } + if (!known_opt || (argv[x] && (!strcmp(argv[x], "-help") || !strcmp(argv[x], "-h") || !strcmp(argv[x], "-?")))) { printf("%s\n", usageDesc); exit(0);