Author: abroekhuis
Date: Wed Aug 13 11:30:47 2014
New Revision: 1617704
URL: http://svn.apache.org/r1617704
Log:
CELIX-138: Applied patch.
Modified:
celix/trunk/cmake/cmake_celix/run.sh.in
celix/trunk/launcher/private/src/launcher.c
Modified: celix/trunk/cmake/cmake_celix/run.sh.in
URL:
http://svn.apache.org/viewvc/celix/trunk/cmake/cmake_celix/run.sh.in?rev=1617704&r1=1617703&r2=1617704&view=diff
==============================================================================
--- celix/trunk/cmake/cmake_celix/run.sh.in (original)
+++ celix/trunk/cmake/cmake_celix/run.sh.in Wed Aug 13 11:30:47 2014
@@ -1,2 +1,2 @@
export @LIBRARY_PATH@=@FW_PATH@:@UTILS_PATH@
-@LAUNCHER@
\ No newline at end of file
+@LAUNCHER@ $@
Modified: celix/trunk/launcher/private/src/launcher.c
URL:
http://svn.apache.org/viewvc/celix/trunk/launcher/private/src/launcher.c?rev=1617704&r1=1617703&r2=1617704&view=diff
==============================================================================
--- celix/trunk/launcher/private/src/launcher.c (original)
+++ celix/trunk/launcher/private/src/launcher.c Wed Aug 13 11:30:47 2014
@@ -27,6 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <signal.h>
+#include <libgen.h>
#include <apr_general.h>
#include <apr_strings.h>
@@ -37,6 +38,8 @@
#include "linked_list_iterator.h"
#include "celix_log.h"
+#define DEFAULT_CONFIG_FILE "config.properties"
+
void launcher_shutdown(int signal);
int running = 0;
@@ -44,7 +47,9 @@ int running = 0;
struct framework * framework;
apr_pool_t *memoryPool;
-int main(void) {
+void show_usage(char* prog_name);
+
+int main(int argc, char *argv[]) {
// Set signal handler
apr_status_t rv = APR_SUCCESS;
apr_status_t s = APR_SUCCESS;
@@ -65,7 +70,34 @@ int main(void) {
return CELIX_START_ERROR;
}
- config = properties_load("config.properties");
+ // Perform some minimal command-line option parsing...
+ char* opt = NULL;
+ if (argc > 1) {
+ opt = argv[1];
+ }
+
+ char* config_file = NULL;
+
+ if (opt) {
+ // Check whether the user wants some help...
+ if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
+ show_usage(argv[0]);
+ return 0;
+ } else {
+ config_file = opt;
+ }
+ } else {
+ config_file = DEFAULT_CONFIG_FILE;
+ }
+
+ config = properties_load(config_file);
+ // Make sure we've read it and that nothing went wrong with the file
access...
+ if (errno) {
+ printf("Error: invalid or non-existing configuration file:
\"%s\"!\n", config_file);
+ show_usage(argv[0]);
+ return CELIX_START_ERROR;
+ }
+
autoStart = properties_get(config, "cosgi.auto.start.1");
framework = NULL;
celix_status_t status = CELIX_SUCCESS;
@@ -150,3 +182,7 @@ void launcher_shutdown(int signal) {
// }
// framework_destroy(framework);
}
+
+void show_usage(char* prog_name) {
+ printf("Usage:\n %s [path/to/config.properties]\n\n",
basename(prog_name));
+}