diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-07-20 16:04:23 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-07-20 16:04:23 +0000 |
commit | 6c38eb3ea1081ee19355b1bab830795b068e3aa5 (patch) | |
tree | 527f29b91b3bd3ff337269fa4b0e47628449c693 /navit | |
parent | 5ba6d30db9ff673f31beba319a9f6227f6b24eb5 (diff) | |
download | navit-6c38eb3ea1081ee19355b1bab830795b068e3aa5.tar.gz |
Add:Core:Option to specify a file for startup commands or set a startup command as command line parameter
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4647 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/attr.h | 1 | ||||
-rw-r--r-- | navit/start_real.c | 27 |
2 files changed, 25 insertions, 3 deletions
diff --git a/navit/attr.h b/navit/attr.h index 6d957f50c..55270e7ef 100644 --- a/navit/attr.h +++ b/navit/attr.h @@ -152,6 +152,7 @@ struct attr { struct vehicleprofile *vehicleprofile; struct roadprofile *roadprofile; struct bookmarks *bookmarks; + struct config *config; struct range { short min, max; } range; diff --git a/navit/start_real.c b/navit/start_real.c index 8e7033e7a..e27041afe 100644 --- a/navit/start_real.c +++ b/navit/start_real.c @@ -44,6 +44,7 @@ #include "linguistics.h" #include "navit_nls.h" #include "atom.h" +#include "command.h" #ifdef HAVE_API_WIN32_CE #include <windows.h> #include <winbase.h> @@ -67,10 +68,10 @@ extern void builtin_init(void); int main_real(int argc, char **argv) { xmlerror *error = NULL; - char *config_file = NULL; + char *config_file = NULL, *command=NULL, *startup_file=NULL; int opt; char *cp; - struct attr navit; + struct attr navit, conf; GList *list = NULL, *li; main_argc=argc; @@ -111,7 +112,7 @@ int main_real(int argc, char **argv) #endif /* _MSC_VER */ if (argc > 1) { /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */ - while((opt = getopt(argc, argv, ":hvc:d:")) != -1) { + while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) { switch(opt) { case 'h': print_usage(); @@ -128,6 +129,12 @@ int main_real(int argc, char **argv) case 'd': printf("TODO Verbose option is set to `%s'\n", optarg); break; + case 'e': + command=optarg; + break; + case 's': + startup_file=optarg; + break; #ifdef HAVE_GETOPT_H case ':': fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); @@ -195,6 +202,20 @@ int main_real(int argc, char **argv) dbg(0, _("No instance has been created, exiting\n")); exit(1); } + conf.type=attr_config; + conf.u.config=config; + if (startup_file) { + FILE *f=fopen(startup_file,"r"); + if (f) { + char buffer[4096]; + while(fgets(buffer, sizeof(buffer), f)) { + command_evaluate(&conf, buffer); + } + } + } + if (command) { + command_evaluate(&conf, command); + } event_main_loop_run(); #ifndef HAVE_API_ANDROID |