/* $Id$ */ #include #include #include #include #include int valid(char *s) { int i; for (i = 32; *s; i--, s++) if (!isascii(*s) || !isxdigit(*s)) return 0; return !i; } int main() { char *answer = "Alles OK"; char *s, *p; if (!(s = getenv("QUERY_STRING"))) errx(1, "not a CGI context"); printf("Content-type: text/html\r\n\r\n"); if ((s = strstr(s, "key="))) { s += 4; p = strchr(s, '&'); if (p) *p = '\0'; if (valid(s)) answer = s; } printf("%s", answer); return 0; }