示例#1
0
int
main (int argc, char* argv[])
{
    Node *result;

    READ_OPTIONS_AND_INIT("testvisit", "Run visit function on input for testing.");

    // read from terminal
    if (getStringOption("input.sql") == NULL)
    {
        result = parseStream(stdin);

        DEBUG_LOG("Address of returned node is <%p>", result);
        ERROR_LOG("PARSE RESULT FROM STREAM IS <%s>", beatify(nodeToString(result)));
    }
    // parse input string
    else
    {
        result = parseFromString(getStringOption("input.sql"));

        DEBUG_LOG("Address of returned node is <%p>", result);
        ERROR_LOG("PARSE RESULT FROM STRING IS:\n%s", nodeToString(result));
        ERROR_LOG("PARSE RESULT FROM STRING IS:\n%s", beatify(nodeToString(result)));
    }


    void *state = NULL;
    visitTheNode(result, state);

    return shutdownApplication();
}
示例#2
0
int
main (int argc, char* argv[])
{
    char *result;

    READ_OPTIONS_AND_INIT("testrewriter", "Run all stages on input and output rewritten SQL.");

    START_TIMER("TOTAL");

    // read from terminal
    if (getStringOption("input.sql") == NULL)
    {
        result = rewriteQueryFromStream(stdin);
        ERROR_LOG("REWRITE RESULT FROM STREAM IS <%s>", result);
    }
    // parse input string
    else
    {
        result = rewriteQuery(getStringOption("input.sql"));
        ERROR_LOG("REWRITE RESULT FROM STRING IS:\n%s", result);
    }

    // call executor
    execute(result);

    STOP_TIMER("TOTAL");
    OUT_TIMERS();

    shutdownApplication();
//    freeOptions();
//    destroyMemManager();

    return EXIT_SUCCESS;
}
示例#3
0
QString Expert::getHtmlOutputIndex(const QString &workingDir) const
{
  QString outputDir = getStringOption(m_options,QString::fromAscii("OUTPUT_DIRECTORY"));
  QString htmlOutputDir = getStringOption(m_options,QString::fromAscii("HTML_OUTPUT"));
  //printf("outputDir=%s\n",qPrintable(outputDir));
  //printf("htmlOutputDir=%s\n",qPrintable(htmlOutputDir));
  QString indexFile = workingDir;
  if (QFileInfo(outputDir).isAbsolute()) // override
  {
    indexFile = outputDir;
  }
  else // append
  { 
    indexFile += QString::fromAscii("/")+outputDir;
  }
  if (QFileInfo(htmlOutputDir).isAbsolute()) // override
  {
    indexFile = htmlOutputDir;
  }
  else // append
  {
    indexFile += QString::fromAscii("/")+htmlOutputDir;
  }
  indexFile+=QString::fromAscii("/index.html");
  return indexFile;
}
示例#4
0
int
main (int argc, char* argv[])
{
    Node *result;
    Node *qoModel;
    char *sql;

    READ_OPTIONS_AND_INIT("testtranslate", "Run all stages on input except provenance rewrite and output rewritten SQL code.");

    // read from terminal
    if (getStringOption("input.sql") == NULL)
    {
        result = parseStream(stdin);

        DEBUG_LOG("Address of returned node is <%p>", result);
        ERROR_LOG("PARSE RESULT FROM STREAM IS <%s>", beatify(nodeToString(result)));
    }
    // parse input string
    else
    {
        result = parseFromString(getStringOption("input.sql"));

        DEBUG_LOG("Address of returned node is <%p>", result);
        ERROR_LOG("PARSE RESULT FROM STRING IS:\n%s", beatify(nodeToString(result)));
    }

    qoModel = translateParse(result);
    INFO_LOG("TRANSLATION RESULT FROM STRING IS:\n%s", beatify(nodeToString(qoModel)));
    ERROR_LOG("SIMPLIFIED OPERATOR TREE:\n%s", operatorToOverviewString(qoModel));

    sql = serializeOperatorModel(qoModel);
    ERROR_LOG("SERIALIZED SQL:\n%s", sql);

    return shutdownApplication();
}
示例#5
0
void Step1::init()
{
  Input *option;
  m_projName->setText(getStringOption(m_modelData,STR_PROJECT_NAME));
  m_projNumber->setText(getStringOption(m_modelData,STR_PROJECT_NUMBER));
  option = m_modelData[STR_INPUT];
  if (option->value().toStringList().count()>0)
  {
    m_sourceDir->setText(option->value().toStringList().first());
  }
  m_recursive->setChecked(
      getBoolOption(m_modelData,STR_RECURSIVE) ? Qt::Checked : Qt::Unchecked);
  m_destDir->setText(getStringOption(m_modelData,STR_OUTPUT_DIRECTORY));
}
示例#6
0
int
postgresDatabaseConnectionOpen (void)
{
    StringInfo connStr = makeStringInfo();
//    OptionConnection *op = getOptions()->optionConnection;

    ACQUIRE_MEM_CONTEXT(memContext);

    /* create connection string */
//    if (op->host)
        appendStringInfo(connStr, " host=%s", getStringOption("connection.host"));
//    if (op->db)
        appendStringInfo(connStr, " dbname=%s", getStringOption("connection.db"));
//    if (op->user)
        appendStringInfo(connStr, " user=%s", getStringOption("connection.user"));
    if (optionSet("connection.passwd"))
        appendStringInfo(connStr, " password=%s", getStringOption("connection.passwd"));
//    if (op->port)
        appendStringInfo(connStr, " port=%u", getIntOption("connection.port"));

    /* try to connect to db */
    plugin->conn = PQconnectdb(connStr->data);

    /* check to see that the backend connection was successfully made */
    if (plugin->conn == NULL || PQstatus(plugin->conn) == CONNECTION_BAD)
    {
        char *error = PQerrorMessage(plugin->conn);
        PQfinish(plugin->conn);
        FATAL_LOG("unable to connect to postgres database %s\n\nfailed "
                "because of:\n%s", connStr->data, error);
    }

    plugin->initialized = TRUE;

    // prepare queries
    prepareLookupQueries();

    // initialize cache
    fillOidToDTMap(GET_CACHE()->oidToDT);

    RELEASE_MEM_CONTEXT();
    return EXIT_SUCCESS;
}
示例#7
0
void writePidFile() {
   string pidFile = getStringOption(conf, "PIDFILE", "/var/run/collab/collab.pid");
   FILE *f = fopen(pidFile.c_str(), "w");
   if (f == NULL) {
      //this is a problem
   }
   else {
      pid_t pid = getpid();
      fprintf(f, "%d", pid);
      fclose(f);
   }
}
示例#8
0
void Step1::init()
{
  Input *option;
  m_projName->setText(getStringOption(m_modelData,STR_PROJECT_NAME));
  m_projBrief->setText(getStringOption(m_modelData,STR_PROJECT_BRIEF));
  m_projNumber->setText(getStringOption(m_modelData,STR_PROJECT_NUMBER));
  QString iconName = getStringOption(m_modelData,STR_PROJECT_LOGO);
  if (!iconName.isEmpty())
  {
    QFile Fout(iconName);
    if(!Fout.exists()) 
    {
      m_projIconLab->setText(tr("Sorry, cannot find file(")+iconName+QString::fromAscii(");"));
    }
    else
    {
      QPixmap pm(iconName);
      if (!pm.isNull())
      {
        m_projIconLab->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
      }
      else
      {
        m_projIconLab->setText(tr("Sorry, no preview available (")+iconName+QString::fromAscii(");"));
      }
    }
  }
  else
  {
    m_projIconLab->setText(tr("No Project logo selected."));
  }
  option = m_modelData[STR_INPUT];
  if (option->value().toStringList().count()>0)
  {
    m_sourceDir->setText(option->value().toStringList().first());
  }
  m_recursive->setChecked(
      getBoolOption(m_modelData,STR_RECURSIVE) ? Qt::Checked : Qt::Unchecked);
  m_destDir->setText(getStringOption(m_modelData,STR_OUTPUT_DIRECTORY));
}
示例#9
0
bool Expert::pdfOutputPresent(const QString &workingDir) const
{
  bool generateLatex = getBoolOption(m_options,QString::fromAscii("GENERATE_LATEX"));
  bool pdfLatex = getBoolOption(m_options,QString::fromAscii("USE_PDFLATEX"));
  if (!generateLatex || !pdfLatex) return false;
  QString latexOutput = getStringOption(m_options,QString::fromAscii("LATEX_OUTPUT"));
  QString indexFile;
  if (QFileInfo(latexOutput).isAbsolute())
  {
    indexFile = latexOutput+QString::fromAscii("/refman.pdf");
  }
  else
  {
    indexFile = workingDir+QString::fromAscii("/")+
                latexOutput+QString::fromAscii("/refman.pdf");
  }
  QFileInfo fi(indexFile);
  return fi.exists() && fi.isFile();
}
示例#10
0
/*
 * main function creates a socket, drops privileges
 * then calls a function to accept incoming connections in a loop.
 */
int main(int argc, char **argv, char **envp) {
   Tcp6Service *svc;
   srand(time(NULL));
   if (signal(SIGCHLD, sigchld) == SIG_ERR) {
#ifdef DEBUG      
      err(-1, ERROR_SET_SIGCHLD);
#else
      exit(-1);
#endif
   }
   int opt;
   while ((opt = getopt(argc, argv, "c:")) != -1) {
      switch (opt) {
         case 'c':
            conf = parseConf(optarg);
            break;
         default:
            break;
      }
   }
   short svc_port = getShortOption(conf, "SERVER_PORT", 5042);
   string svc_host = getStringOption(conf, "SERVER_HOST", "");
   try {
      if (svc_host.length() == 0) {
         svc = new Tcp6Service(svc_port);
      }
      else {
         svc = new Tcp6Service(svc_host.c_str(), svc_port);
      }
   } catch (int e) {
      exit(e);
   }
   drop_privs_user(svc_user);
   daemon(1, 0);
   writePidFile();
   loop(svc);
   return 0;
}
示例#11
0
void Camera::setStringByIndex(const Parameter & p, int i)
{
    setString(p, getStringOption(p, i));
}