[Redbutton-devel] SF.net SVN: redbutton: [130] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-07-12 15:33:45
|
Revision: 130 Author: skilvington Date: 2006-07-12 08:33:36 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=130&view=rev Log Message: ----------- tidy up cmd line option parsing Modified Paths: -------------- redbutton-browser/trunk/MHEGEngine.c redbutton-browser/trunk/MHEGEngine.h redbutton-browser/trunk/rb-browser.c Modified: redbutton-browser/trunk/MHEGEngine.c =================================================================== --- redbutton-browser/trunk/MHEGEngine.c 2006-07-04 08:56:19 UTC (rev 129) +++ redbutton-browser/trunk/MHEGEngine.c 2006-07-12 15:33:36 UTC (rev 130) @@ -164,16 +164,16 @@ static MHEGEngine engine; void -MHEGEngine_init(bool remote, char *srg_loc, int verbose, unsigned int timeout, bool fullscreen, char *keymap) +MHEGEngine_init(MHEGEngineOptions *opts) { bzero(&engine, sizeof(MHEGEngine)); - engine.verbose = verbose; - engine.timeout = timeout; + engine.verbose = opts->verbose; + engine.timeout = opts->timeout; - MHEGDisplay_init(&engine.display, fullscreen, keymap); + MHEGDisplay_init(&engine.display, opts->fullscreen, opts->keymap); - MHEGBackend_init(&engine.backend, remote, srg_loc); + MHEGBackend_init(&engine.backend, opts->remote, opts->srg_loc); MHEGApp_init(&engine.active_app); Modified: redbutton-browser/trunk/MHEGEngine.h =================================================================== --- redbutton-browser/trunk/MHEGEngine.h 2006-07-04 08:56:19 UTC (rev 129) +++ redbutton-browser/trunk/MHEGEngine.h 2006-07-12 15:33:36 UTC (rev 130) @@ -76,6 +76,17 @@ #define ContentHook_Stream_MPEG 10 #define ContentHook_Stream_File 11 +/* cmd line options */ +typedef struct +{ + bool remote; /* or local rb-download backend */ + char *srg_loc; /* service gateway location: directory for local; host[:port] for remote */ + int verbose; /* -v flag */ + unsigned int timeout; /* seconds to poll for missing content before generating a ContentRefError */ + bool fullscreen; /* scale to fullscreen? */ + char *keymap; /* keymap config file to use (NULL for default) */ +} MHEGEngineOptions; + /* a list of files we are waiting for, and the objects that want them */ typedef struct { @@ -169,7 +180,7 @@ } MHEGEngine; /* prototypes */ -void MHEGEngine_init(bool, char *, int, unsigned int, bool, char *); +void MHEGEngine_init(MHEGEngineOptions *); int MHEGEngine_run(OctetString *); void MHEGEngine_fini(); Modified: redbutton-browser/trunk/rb-browser.c =================================================================== --- redbutton-browser/trunk/rb-browser.c 2006-07-04 08:56:19 UTC (rev 129) +++ redbutton-browser/trunk/rb-browser.c 2006-07-12 15:33:36 UTC (rev 130) @@ -27,13 +27,8 @@ main(int argc, char *argv[]) { char *prog_name = argv[0]; + MHEGEngineOptions opts; int arg; - bool remote = false; - int v = 0; - bool f = false; - unsigned int timeout = MISSING_CONTENT_TIMEOUT; - char *keymap = NULL; - char *srg_dir; size_t last; int rc; int i; @@ -50,28 +45,37 @@ if(NULL != 0) fatal("%s needs to be compiled with a libc that makes NULL == 0", prog_name); + /* default options */ + bzero(&opts, sizeof(MHEGEngineOptions)); + opts.remote = false; + opts.srg_loc = NULL; /* must be given on cmd line */ + opts.verbose = 0; + opts.fullscreen = false; + opts.timeout = MISSING_CONTENT_TIMEOUT; + opts.keymap = NULL; + while((arg = getopt(argc, argv, "rvfk:t:")) != EOF) { switch(arg) { case 'r': - remote = true; + opts.remote = true; break; case 'v': - v ++; + opts.verbose ++; break; case 'f': - f = true; + opts.fullscreen = true; break; case 'k': - keymap = optarg; + opts.keymap = optarg; break; case 't': - timeout = strtoul(optarg, NULL, 0); + opts.timeout = strtoul(optarg, NULL, 0); break; default: @@ -83,14 +87,17 @@ if(optind != argc - 1) usage(prog_name); - srg_dir = argv[optind]; + opts.srg_loc = argv[optind]; - /* chop off any trailing / chars */ - last = strlen(srg_dir) - 1; - while(last > 0 && srg_dir[last] == '/') - srg_dir[last--] = '\0'; + /* chop off any trailing / chars for local directory name */ + if(!opts.remote) + { + last = strlen(opts.srg_loc) - 1; + while(last > 0 && opts.srg_loc[last] == '/') + opts.srg_loc[last--] = '\0'; + } - MHEGEngine_init(remote, srg_dir, v, timeout, f, keymap); + MHEGEngine_init(&opts); /* search for the boot object */ found = false; @@ -108,7 +115,7 @@ } else { - error("Unable to find boot object in '%s'", srg_dir); + error("Unable to find boot object in service gateway '%s'", opts.srg_loc); rc = EXIT_FAILURE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |