viel spass mit'n x.org source :-D
das is für so ne "riesen" aufgabe wie n config file parsen gleich der beste start (joke)
PHP-Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char ** argv) {
ifstream file("config.cfg");
string buf, key;
int n;
while(file.good()) {
getline(file, buf, '\n');
n=buf.find("key1=");
if(n != string::npos) {
n += 5; //strlen von "key1="
key=buf.substr(n,buf.length());
break;
} else {
continue;
}
}
if(key.length() > 0) {
cout << "found '" << key << "'" << endl;
} else {
cout << "key1 not found " << endl;
}
file.close();
}
Code:
var1=test
key1=servername
key2=.....
....
Lesezeichen