Exemplo n.º 1
0
bool validDatabase(const QString& db) {
  PIOGroup *g = PIOOpenVoidGrp(const_cast<char*>(db.latin1()), const_cast<char*>("r"));
  if (g) {
    PIOCloseVoidGrp(&g);
    return true;
  }
  return false;
}
Exemplo n.º 2
0
bool validDatabase(const QString& db) {
  if (getenv("PGUSER") == NULL || getenv("DBROOT") == NULL) {
    qDebug("DMC is missing environment variables");
    /* DMC will lock up if these environment variables are not set */
    return false;
  }

  PIOGroup *g = PIOOpenVoidGrp(const_cast<char*>(db.latin1()), const_cast<char*>("r"));
  if (g) {
    PIOCloseVoidGrp(&g);
    // the call PIOOpenVoidGrp open the database, 
    // the PIOCloseVoidGrp call do not close it
    // once one db is opened, 
    // any subsequent open call will fail unless it is the same database
    // lets close it
    int rtc;
    rtc = PIOQuitDB();
    if(rtc != 0) { 
      // closing failed, dont care
    }
    return true;
  }
  return false;
}