Removed back AppConfiguration class. Postponed its implementation.
[vlp.git] / src / net / lognet.cpp
index fce3aee3f843a0576fb00a0f8fdf271d032c299c..dc2a750ca848f880437cd56765b5206ac5ec7750 100644 (file)
@@ -23,7 +23,6 @@
 #include <unistd.h>
 
 #include <libconfig.h>
-#include "AppConfiguration.h"
 
 #define REMOTE_PATH "REMOTE"
 #define MAXLINKS 30
@@ -199,16 +198,19 @@ void NETMOD::load_config(char *fname)
   if (!file) {
     fprintf(stderr, "Error: Cannot load configuration file %s!\n", fname);
     write_at_console("Cannot load configuration file!");
+    fclose(file);
     exit(3);
   }
-  /* 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)) 
+  if(!config_read(&cfg, file)) 
   {
-    AppConfiguration::error(&cfg);
+    fprintf(stderr, "%s: In file %s, line %d\n",
+        config_error_text(&cfg),
+        config_error_file(&cfg),
+        config_error_line(&cfg));
     config_destroy(&cfg);
+    fclose(file);
     exit(3);/* from original code. */
   }
   
@@ -217,13 +219,18 @@ void NETMOD::load_config(char *fname)
     if (MyNode==-1) {
       write_at_console("Node number must be specified");
       config_destroy(&cfg);
+      fclose(file);
       exit(1);
     };
   }
   else
   {
-    AppConfiguration::error(&cfg);
+    fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+        "Warning",
+        fname,
+        "node_number");
     config_destroy(&cfg);
+    fclose(file);
     exit(1);
   }
 
@@ -240,10 +247,14 @@ void NETMOD::load_config(char *fname)
     to_connect++;
   }
   else {
-    AppConfiguration::error(&cfg);
+    fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+        "Warning",
+        fname,
+        "host");
   }
 
   config_destroy(&cfg);
+  fclose(file);
 
   if (k==0) all_connected=TRUE;
 }