You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2013/06/25 00:04:47 UTC
svn commit: r1496233 - in /qpid/trunk/qpid/extras/dispatch/router:
CMakeLists.txt src/main.c
Author: tross
Date: Mon Jun 24 22:04:47 2013
New Revision: 1496233
URL: http://svn.apache.org/r1496233
Log:
QPID-4913 - Added configuration file option in command line parser.
Also added a cmake option to specify the default path to the configuration file.
Modified:
qpid/trunk/qpid/extras/dispatch/router/CMakeLists.txt
qpid/trunk/qpid/extras/dispatch/router/src/main.c
Modified: qpid/trunk/qpid/extras/dispatch/router/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/router/CMakeLists.txt?rev=1496233&r1=1496232&r2=1496233&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/router/CMakeLists.txt (original)
+++ qpid/trunk/qpid/extras/dispatch/router/CMakeLists.txt Mon Jun 24 22:04:47 2013
@@ -17,6 +17,13 @@
## under the License.
##
+
+set(DEFAULT_CONFIG_PATH "/etc/qpid-dispatch.conf" CACHE string "Default Config File Path")
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
##
## Build the router application
##
Modified: qpid/trunk/qpid/extras/dispatch/router/src/main.c
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/router/src/main.c?rev=1496233&r1=1496232&r2=1496233&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/router/src/main.c (original)
+++ qpid/trunk/qpid/extras/dispatch/router/src/main.c Mon Jun 24 22:04:47 2013
@@ -22,10 +22,13 @@
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
+#include <getopt.h>
+#include "config.h"
static int exit_with_sigint = 0;
static dx_dispatch_t *dispatch;
+
/**
* The thread_start_handler is invoked once for each server thread at thread startup.
*/
@@ -84,9 +87,39 @@ static void startup(void *context)
int main(int argc, char **argv)
{
+ const char *config_path = DEFAULT_CONFIG_PATH;
+
+ static struct option long_options[] = {
+ {"config", required_argument, 0, 'c'},
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while (1) {
+ int c = getopt_long(argc, argv, "c:h", long_options, 0);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'c' :
+ config_path = optarg;
+ break;
+
+ case 'h' :
+ printf("Usage: %s [OPTION]\n\n", argv[0]);
+ printf(" -c, --config=PATH (%s)\n", DEFAULT_CONFIG_PATH);
+ printf(" Load configuration from file at PATH\n");
+ printf(" -h, --help Print this help\n");
+ exit(0);
+
+ case '?' :
+ exit(1);
+ }
+ }
+
dx_log_set_mask(LOG_INFO | LOG_TRACE | LOG_ERROR);
- dispatch = dx_dispatch("../etc/qpid-dispatch.conf");
+ dispatch = dx_dispatch(config_path);
dx_server_set_signal_handler(dispatch, server_signal_handler, 0);
dx_server_set_start_handler(dispatch, thread_start_handler, 0);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org