Experimental usage.
[vlp.git] / src / net / lognet.cpp
index fce3aee3f843a0576fb00a0f8fdf271d032c299c..96571427e4fc9a4f79177fb1ffa51d8d98668149 100644 (file)
@@ -186,12 +186,8 @@ NETMOD::NETMOD(char *kernel_name)
 
 void NETMOD::load_config(char *fname)
 {
-  config_t cfg;
-  const char *str;
   int on,k=0;
   NETlink *pomlink;
-
-  config_init(&cfg);
   
   
   /* Hack for checking if file exists without using external libs.*/
@@ -204,33 +200,22 @@ void NETMOD::load_config(char *fname)
   /* File exists, so file has been locked. Release it. */
   fclose(file);
   
-  /* Read the file. If there is an error, report it and exit. */
-  if(!config_read_file(&cfg, fname)) 
-  {
-    AppConfiguration::error(&cfg);
-    config_destroy(&cfg);
-    exit(3);/* from original code. */
-  }
+  AppConfiguration config(fname);
   
-  if(config_lookup_int(&cfg, "node_number", &MyNode))
-  {
-    if (MyNode==-1) {
-      write_at_console("Node number must be specified");
-      config_destroy(&cfg);
-      exit(1);
-    };
-  }
-  else
-  {
-    AppConfiguration::error(&cfg);
-    config_destroy(&cfg);
+  MyNode = config.getInt("node_number");
+  if (config.error() == TRUE) {
+    write_at_console("Node number must be specified");
+    config.release();
     exit(1);
   }
 
-  if(config_lookup_string(&cfg, "host", &str)) {
+  char host[255];
+  strcpy(host, config.getString("host"));
+  if(config.error() == FALSE)
+  {
     k++;
     pomlink = new NETlink;
-    strcpy(pomlink->addr, str);
+    strcpy(pomlink->addr, host);
     pomlink->connected = FALSE;
     pomlink->sock = socket(AF_INET, SOCK_STREAM, 0); 
     fcntl(pomlink->sock, F_SETFL,O_NONBLOCK | fcntl(pomlink->sock,F_GETFL,0));
@@ -239,11 +224,7 @@ void NETMOD::load_config(char *fname)
     Links.append(pomlink); 
     to_connect++;
   }
-  else {
-    AppConfiguration::error(&cfg);
-  }
-
-  config_destroy(&cfg);
+  config.release();
 
   if (k==0) all_connected=TRUE;
 }