From: martin-s Date: Wed, 20 Jul 2011 16:04:23 +0000 (+0000) Subject: Add:Core:Option to specify a file for startup commands or set a startup command as... X-Git-Tag: navit-0.5.0.5194svn~548 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59310d46bbadbcf229513d8ad8fa8ee3cb6e26dd;p=profile%2Fivi%2Fnavit.git Add:Core:Option to specify a file for startup commands or set a startup command as command line parameter git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4647 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/attr.h b/navit/navit/attr.h index 6d957f5..55270e7 100644 --- a/navit/navit/attr.h +++ b/navit/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/navit/start_real.c b/navit/navit/start_real.c index 8e7033e..e27041a 100644 --- a/navit/navit/start_real.c +++ b/navit/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 #include @@ -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