static bool handle(struct req *req) { time_t t; struct tm *tmp; char buf[200]; t = time(NULL); tmp = localtime(&t); strftime(buf, sizeof(buf), "%F %T", tmp); uth_set_char(req->reply, "date", mmatic_strdup(buf, req)); uth_set_char(req->reply, "config variable", uth_char(req->mod->cfg, "variable")); return true; }
static char *get_query(struct req *req) { const char *orig_query; int i; bool inspace = false; xstr *query; query = xstr_create("", req); orig_query = uth_char(req->params, "query"); i = sizeof SQLER_TAG; if (i > xstr_length(uth_xstr(req->params, "query"))) goto end; /* skip whitechars */ for (; orig_query[i]; i++) if (isalpha(orig_query[i])) break; /* replace all whitechars, newlines, etc with single space */ for (; orig_query[i]; i++) { switch (orig_query[i]) { case ' ': if (inspace) continue; xstr_append_char(query, orig_query[i]); inspace = true; break; case '\t': case '\r': case '\n': break; default: xstr_append_char(query, orig_query[i]); inspace = false; } } end: return xstr_string(query); }