Пример #1
0
// Display a directory's contents
void
dir_page(FILE *of, void *p)
{
	DirDir *d;

	if (!swill_getargs("p(dir)", &d)) {
		fprintf(of, "Missing value");
		return;
	}
	html_head(of, "directory", string("Directory: ") + html(d->get_path()));
	d->dirlist(of);
	html_tail(of);
}
Пример #2
0
// Construct an object based on URL parameters
FunQuery::FunQuery(FILE *of, bool icase, Attributes::size_type cp, bool e, bool r) :
    Query(!e, r, true),
    match_fid(false),
    id_ec(NULL),
    call(NULL),
    current_project(cp)
{
    if (lazy)
        return;

    valid = true;

    // Query name
    char *qname = swill_getvar("n");
    if (qname && *qname)
        name = qname;

    // Match specific file
    int ifid;
    if (swill_getargs("i(fid)", &ifid)) {
        match_fid = true;
        fid = Fileid(ifid);
    }

    // Function call declaration direct match
    if (!swill_getargs("p(call)", &call))
        call = NULL;

    // Identifier EC match
    if (!swill_getargs("p(ec)", &id_ec)) {
        id_ec = NULL;

        // Type of boolean match
        char *m;
        if (!(m = swill_getvar("match"))) {
            fprintf(of, "Missing value: match");
            valid = return_val = false;
            lazy = true;
            return;
        }
        match_type = *m;
    }
    mquery.set_match_type(match_type);

    cfun = !!swill_getvar("cfun");
    macro = !!swill_getvar("macro");
    writable = !!swill_getvar("writable");
    ro = !!swill_getvar("ro");
    pscope = !!swill_getvar("pscope");
    fscope = !!swill_getvar("fscope");
    defined = !!swill_getvar("defined");
    if (!swill_getargs("i(ncallers)|i(ncallerop)", &ncallers, &ncallerop))
        ncallerop = ec_ignore;

    exclude_fnre = !!swill_getvar("xfnre");
    exclude_fure = !!swill_getvar("xfure");
    exclude_fdre = !!swill_getvar("xfdre");
    exclude_fre = !!swill_getvar("xfre");

    // Compile regular expression specs
    if (!compile_re(of, "Function name", "fnre", fnre, match_fnre, str_fnre) ||
            !compile_re(of, "Calling function name", "fure", fure, match_fure, str_fure) ||
            !compile_re(of, "Called function name", "fdre", fdre, match_fdre, str_fdre) ||
            !compile_re(of, "Filename", "fre", fre, match_fre, str_fre, (icase ? REG_ICASE : 0)))
        return;
    specified_order::set_order(mquery.get_sort_order(), mquery.get_reverse());
}
Пример #3
0
/* Builds the html page of the result set of a query 
 * along with the time it took to execute and the query 
 * itself.
 */
void serve_query(FILE *f, sqlite3 *db) {
  const char *query = "\0";
  char response_type[50];
  char *rt = swill_getheader("Http_Choose_Response_Type");
  if (rt)
    strcpy(response_type, rt);
  else
    strcpy(response_type, "text/html");   /* default */
  //swill_fprintf(f, "Response type should be: %s", response_type);
  if (!strcmp(response_type, "text/html"))
    swill_fprintf(f, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
		"<html>"
		"<head>"
		"<style type=\"text/css\">"
		"body{bgcolor=\"#ffffff\";}"
		"span.styled{color:blue;}"
		"table, td{border:1px double;}"
		"p.aligned{text-align:left;}"
		"</style>"
		"</head>"
		"<body>");
  if (swill_getargs("s(query)", &query)) {
    int rc = 0;
    clock_t start_clock,finish_clock;
    double c_time;
    start_clock = clock();
    int j = 0;
    if (!strcmp(response_type, "text/html")) {
      swill_fprintf(f, "<b>For SQL query: ");
      swill_fprintf(f, "<span class=\"styled\">%s</span><br><br>", query);
      swill_fprintf(f, "Result set is:</b><br><br>");
    }
    // j for debugging, execute the query multiple times.
    while (j < 1 && (rc = prep_exec(f, db, query, response_type)) == SQLITE_DONE) {
      j++;
    }
    if (rc == SQLITE_DONE) {
      finish_clock = clock();
      c_time = ((double)finish_clock - 
		(double)start_clock)/CLOCKS_PER_SEC;
      if (!strcmp(response_type, "text/html")) {
        swill_fprintf(f, "<b>\nQUERY SUCCESSFUL! </b><br><br>");
        swill_fprintf(f,"CPU time: <b>%f</b>s.<br><br>", c_time);
      }
    } else {
      if (!strcmp(response_type, "text/html")) {
        swill_fprintf(f, "<br><b>Extended error message:<br><b>%s</b><br><br>", sqlite3_errmsg(db));
        swill_fprintf(f, "Extended error code <b>%i.<br>Please advise </b><a href=\"", sqlite3_extended_errcode(db));
        swill_printurl(f, "pico_ql_error_page.html", "", 0);
        swill_fprintf(f,"\">SQLite error codes</a>.<br><br>");
      }
    }
    if (!strcmp(response_type, "text/html")) {
      swill_fprintf(f, "<p class=\"aligned\">");
      swill_fprintf(f, "<a href=\"");
      swill_printurl(f,"index.html", "", 0);
      swill_fprintf(f,"\">[ Input new Query ]</a>");
      swill_fprintf(f, "<a href=\"");
      swill_printurl(f,"terminateConnection.html", "", 0);
      swill_fprintf(f,"\">[ Terminate Server Connection ]</a>"
		  "</p>"
		  "</body>"
		  "</html>");
    }
  }
  clear_temp_structs();
}