# HG changeset patch # User Binki # Date 2009-04-07 22:26:23 # Node ID ad5012647934c3daa954cfdd4e88af6f7aa28339 # Parent dcf2a2b217f14306187e82b69f2bb685137578e2 client: started cleaning client code diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -26,10 +26,11 @@ */ +#include "options.h" +#include "execio.h" + #include /* sprintf, printf */ #include /* malloc, free */ -#include "options.h" -#include "execio.h" #include /* Happy fun XML time */ #include #include @@ -38,45 +39,37 @@ int main(int argc, char *argv[]) { - - - + struct options_common *options; + + cfg_t *cfg; + + cfg_opt_t cfg_opts[] = + { + CFG_STR("username", "guest", CFGF_NONE), + CFG_STR("hostname", "protofusion.org", CFGF_NONE), + CFG_STR("name", "Guest", CFGF_NONE), + CFG_STR("email", "guest@protofusion.org", CFGF_NONE), + CFG_END() + }; -// parseconf(); /* calls the confuse parser from options.c */ -// So I couldn't figure out how to get a function to return multiple variables, so -// I tossed the code from options.c right in here to save me the trouble. Fix if you wish, if possible... :D - - + int i; + + if(options_init(argc, argv, &cfg, cfg_opts, "client", &options)) + { + fprintf(stderr, "error getting configuration\n"); + return 1; + } -/* Conf File Parser */ - cfg_opt_t opts[] = - { - CFG_STR("username", "guest", CFGF_NONE), - CFG_STR("hostname", "protofusion.org", CFGF_NONE), - CFG_STR("name", "Guest", CFGF_NONE), - CFG_STR("email", "guest@protofusion.org", CFGF_NONE), - CFG_END() - }; - cfg_t *cfg; - cfg = cfg_init(opts, CFGF_NONE); - if(cfg_parse(cfg, "distren.conf") == CFG_PARSE_ERROR) - return 1; - /* End Conf File Parser */ +// Please find a better way of doing this :( you can't strcat multiple strings.. meh +// use something like sprintf +//char *username = cfg_getstr(cfg, "username"); +//char *hostname = cfg_getstr(cfg, "hostname"); +//strcat(username, "@"); +//strcat(username, hostname); - - -int x = 1; // hehe for testing - -// Please find a better way of doing this :( you can't strcat multiple strings.. meh -char *username = cfg_getstr(cfg, "username"); -char *hostname = cfg_getstr(cfg, "hostname"); -strcat(username, "@"); -strcat(username, hostname); - - -if( x == 1 ){ +if( i == 1 ){ // Create new account on the server if no username exists // THIS no longer SEGFAULTS!! YAY char buf[10]; @@ -84,7 +77,7 @@ if( x == 1 ){ char *execargv[] = { "ssh", - username, //cfg_getstr(cfg, "username") . "@" . cfg_getstr(cfg, "hostname"), + "username", //cfg_getstr(cfg, "username") . "@" . cfg_getstr(cfg, "hostname"), "-i guest.rsa", //yeaaaah enay better ideas? "sh", "-c", @@ -117,7 +110,7 @@ return 0; } -cfg_free(cfg); +//cfg_free(cfg); };