- f.open(IO_ReadOnly);
- br = f.readLine(line,256);
- while (br>0)
- {
- QStringList l = QStringList::split("=",line,FALSE);
- QStringList::Iterator it = l.begin();
- line = *it;
- ++it;
- val = *it;
- val = val.stripWhiteSpace();
- if (line == "node_number") {NodeNumber = val.toInt();};
- if (line == "type") {if (val=="explicit") ConType=1; else
- ConType = 2; };
- if (line == "host" ) {ConnectList.append(new ConnectEntry((char*)val.ascii()));};
- if (line == "progdir") { strcpy(progdir,val.ascii());};
- if (line == "homedir") { strcpy(HomeDir,val.ascii());};
- br = f.readLine(line,256);
- }
- f.close();
+
+ if(config_lookup_string(&cfg, "type", &str)){
+ ConType = (strcmp(str, "explicit") == 0) ? 1 : 2;
+ }
+ else {
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "type");
+ }
+
+
+ if(config_lookup_string(&cfg, "host", &str)) {
+ ConnectList.append(new ConnectEntry((char*)str));
+ }
+ else {
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "host");
+ }
+
+ if(config_lookup_string(&cfg, "progdir", &str)){
+ strncpy(progdir, str, 256);
+ }
+ else {
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "progdir");
+ }
+
+ if(config_lookup_string(&cfg, "homedir", &str)){
+ strncpy(HomeDir, str, 255);
+ }
+ else {
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "homedir");
+ }
+
+ config_destroy(&cfg);
+ fclose(file);