Changeset - ad5012647934
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-04-07 22:26:23
ohnobinki@ohnopublishing.net
client: started cleaning client code
1 file changed with 31 insertions and 38 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -26,10 +26,11 @@
 
 */
 

	
 

	
 
#include "options.h"
 
#include "execio.h"
 

	
 
#include <stdio.h> /* sprintf, printf */
 
#include <stdlib.h> /* malloc, free */
 
#include "options.h"
 
#include "execio.h"
 
#include <libxml/tree.h> /* Happy fun XML time */
 
#include <libxml/xmlwriter.h>
 
#include <confuse.h>
 
@@ -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);
 
};
 

	
 

	
0 comments (0 inline, 0 general)