Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=xbdmenu.git;a=commitdiff;h=c25293f602a8e718c979c048b69efabaa49b8e08
commit c25293f602a8e718c979c048b69efabaa49b8e08 Author: James Buren <[email protected]> Date: Thu Mar 12 10:45:57 2009 -0500 env.c * add substance to the env_init and env_end functions diff --git a/env.c b/env.c index b0beafd..7709be1 100644 --- a/env.c +++ b/env.c @@ -1,11 +1,62 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> #include "mem.h" +#include "str.h" #include "env.h" +#define MENUFILE "/menu" +#define THEMEFILE "/theme" + extern void env_init(const int argc,const char **argv) { + unsigned int i; + env = zmalloci(sizeof(struct env_t)); + for(i=1;i< (unsigned int) argc;++i) + { + const char *arg = argv[i]; + if(!strcmp(arg,"-v")) + { + printf("xbdmenu version %s\n",VERSION); + exit(EXIT_SUCCESS); + } + else if(!strcmp(arg,"-m")) + { + const char *val = argv[i+1]; + if(val==NULL) + { + printf("No argument passed for \"-m\" flag.\n"); + exit(EXIT_FAILURE); + } + env->menudir = zstrdup(val); + env->menufile = strcmb(val,MENUFILE); + } + else if(!strcmp(arg,"-t")) + { + const char *val = argv[i+1]; + if(val==NULL) + { + printf("No argument passed for \"-t\" flag.\n"); + exit(EXIT_FAILURE); + } + env->themedir = zstrdup(val); + env->themefile = strcmb(val,THEMEFILE); + } + } } extern void env_end(void) { - + if(env) + { + if(env->menudir) + zfree(env->menudir); + if(env->menufile) + zfree(env->menufile); + if(env->themedir) + zfree(env->themedir); + if(env->themefile) + zfree(env->themefile); + zfree(env); + } } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
