// begin: Tue Feb 17 19:15:22 PST 2004 // end: Tue Feb 17 19:47:34 PST 2004 #include using namespace std; #define OTL_ODBC_UNIX #include #include /* row of create table score ( "score" bigint not null, dielvl integer not null, maxlvl integer not null, finalhp integer not null, maxhp integer not null, enddate timestamp not null, startdate timestamp not null, uid integer not null, "class" varchar(32) not null, "race" varchar(32) not null, "sex" varchar(32) not null, "alignment" varchar(32) not null, "playername" varchar(32) not null, "quit" varchar(256) not null ); */ int main(int argc, char** argv) { otl_connect db; otl_connect::otl_initialize(); ifstream log; if (argc == 2) { char* logfile=argv[1]; log.open(logfile); if (!log.good()) { cerr << "couldn't open: " << logfile << endl; exit(1); } } try { db.rlogon("UID=nethack;DSN=nethack"); otl_stream o(1, "INSERT INTO score ( score, dielvl, maxlvl, finalhp, maxhp," "enddate, startdate, uid, class, race, sex, alignment," "playername, quit) " "VALUES ( :score, :dielvl, :maxlvl," ":finalhp,:maxhp, :enddate," ":startdate, :uid,:class," ":race, :sex,:alignment," ":playername, :quit )", db); o.set_commit(0); // turn off auto commit Pcre reg("^\S+ (\d+) \d+ (-?\d+) (-?\d+) (-?\d+) (-?\d+) \d+ (\d+)" " (\d+) (\d+) (\w+) (\w+) (\w+) (\w+) (\w+),(.*)$"); int matches(14); char buf[1<<16]; while (log.getline(buf,sizeof(buf))) { if (reg.search(buf) && reg.num_matches == matches) { for (int i=0;i