Esempio n. 1
0
run_t *get_runs(runner_t *runner, sqlite3 **sqconn) {
    char *sqlite3_query =
        "SELECT runs.* FROM runners "
        "INNER JOIN runs ON runners.uid = runs.uid "
        "GROUP BY runners.uid";

    run_t *run = NULL;
    sqlite3_stmt *res;
    const char *tail;
    int perr = sqlite3_prepare_v2(*sqconn, sqlite3_query, 1000, &res, &tail);
    if(perr != SQLITE_OK) {
        fprintf(stderr, "Failed to prepare run join statement.");
        return NULL;
    }

    /* Go through all the runs, building a linked
     * list of them for display. */
    run_t *run_head = run;
    while( sqlite3_step(res) == SQLITE_ROW ) {
        DEBUG(printf("Found run at %s: ", sqlite3_column_text(res, QUERY_ROW_LOCATION)));
        run_head->next = build_run(sqlite3_column_int(res, QUERY_ROW_UID),
                                (char*)sqlite3_column_text(res, QUERY_ROW_LOCATION),
                                sqlite3_column_double(res, QUERY_ROW_TIME),
                                sqlite3_column_double(res, QUERY_ROW_DISTANCE),
                                sqlite3_column_double(res, QUERY_ROW_TEMPERATURE));
        if(run_head->next != NULL)
            run_head = run_head->next;
    }
    sqlite3_finalize(res);
    return run;
}
Esempio n. 2
0
void RunBSP(const char* name)
{
  // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503
  // make sure we don't attempt to region compile a map with the camera outside the region
  if (region_active && !Region_cameraValid())
  {
    globalErrorStream() << "The camera must be in the region to start a region compile.\n";
    return;
  }

  SaveMap();

  if(Map_Unnamed(g_map))
  {
    globalOutputStream() << "build cancelled\n";
    return;
  }

  if (g_SnapShots_Enabled && !Map_Unnamed(g_map) && Map_Modified(g_map))
  {
    Map_Snapshot();
  }

  if (region_active)
  {
    const char* mapname = Map_Name(g_map);
    StringOutputStream name(256);
    name << StringRange(mapname, path_get_filename_base_end(mapname)) << ".reg";
    Map_SaveRegion(name.c_str());
  }

  Pointfile_Delete();

  bsp_init();

  if (g_WatchBSP_Enabled)
  {
    ArrayCommandListener listener;
    build_run(name, listener);
    // grab the file name for engine running
    const char* fullname = Map_Name(g_map);
    StringOutputStream bspname(64);
    bspname << StringRange(path_get_filename_start(fullname), path_get_filename_base_end(fullname));
    BuildMonitor_Run( listener.array(), bspname.c_str() );
  }
  else
  {
    char junkpath[PATH_MAX];
    strcpy(junkpath, SettingsPath_get());
    strcat(junkpath, "junk.txt");

    char batpath[PATH_MAX];
#if defined(POSIX)
    strcpy(batpath, SettingsPath_get());
    strcat(batpath, "qe3bsp.sh");
#elif defined(WIN32)
    strcpy(batpath, SettingsPath_get());
    strcat(batpath, "qe3bsp.bat");
#else
#error "unsupported platform"
#endif
    bool written = false;
    {
      TextFileOutputStream batchFile(batpath);
      if(!batchFile.failed())
      {
#if defined (POSIX)
        batchFile << "#!/bin/sh \n\n";
#endif
        BatchCommandListener listener(batchFile, junkpath);
        build_run(name, listener);
        written = true;
      }
    }
    if(written)
    {
#if defined (POSIX)
      chmod (batpath, 0744);
#endif
      globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";
      globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n";
      Q_Exec(batpath, NULL, NULL, true);
    }
  }

  bsp_shutdown();
}