+void init(pqxx::connection &conn)
+{
+ conn.perform(FetchCurrentTournament(&active_tournament));
+
+ if (active_tournament.id == -1) {
+ std::fprintf(stderr, "No active tournament\n");
+ } else {
+ std::fprintf(stderr, "Current tournament is %d (name: '%s')\n",
+ active_tournament.id, active_tournament.name.c_str());
+ }
+}
+
+void main_loop(pqxx::connection &conn)
+{
+ if (active_tournament.id == -1) {
+ // No active tournament, sleep a second or so and exit
+ sleep(1);
+ return;
+ }
+
+ pqxx::work t(conn, "trx");
+
+ // fetch all songs
+ pqxx::result res( t.exec("SELECT * FROM songs") );
+ for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
+ std::fprintf(stderr, "%s\n", i["title"].c_str());
+ }
+ t.commit();
+
+ sleep(1);
+}
+