=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.70 retrieving revision 1.82 diff -u -p -r1.70 -r1.82 --- mandoc/cgi.c 2014/07/13 12:31:23 1.70 +++ mandoc/cgi.c 2014/07/24 20:30:45 1.82 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.70 2014/07/13 12:31:23 schwarze Exp $ */ +/* $Id: cgi.c,v 1.82 2014/07/24 20:30:45 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -53,7 +53,6 @@ struct req { }; static void catman(const struct req *, const char *); -static int cmp(const void *, const void *); static void format(const struct req *, const char *); static void html_print(const char *); static void html_printquery(const struct req *); @@ -64,23 +63,21 @@ static void http_print(const char *); static void http_putchar(char); static void http_printquery(const struct req *); static void pathgen(struct req *); +static void pg_error_badrequest(const char *); +static void pg_error_internal(void); +static void pg_index(const struct req *); +static void pg_noresult(const struct req *, const char *); static void pg_search(const struct req *); -static void pg_show(const struct req *, const char *); +static void pg_searchres(const struct req *, + struct manpage *, size_t); +static void pg_show(struct req *, const char *); static void resp_begin_html(int, const char *); static void resp_begin_http(int, const char *); static void resp_end_html(void); -static void resp_error_badrequest(const char *); -static void resp_error_internal(void); -static void resp_index(const struct req *); -static void resp_noresult(const struct req *, - const char *); -static void resp_search(const struct req *, - struct manpage *, size_t); static void resp_searchform(const struct req *); static void resp_show(const struct req *, const char *); static const char *scriptname; /* CGI script name */ -static const char *httphost; /* hostname used in the URIs */ static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; static const char *const sec_numbers[] = { @@ -251,14 +248,25 @@ http_parse(struct req *req, char *p) if (0 == strcmp(key, "query")) req->q.expr = val; - else if (0 == strcmp(key, "manpath")) + else if (0 == strcmp(key, "manpath")) { +#ifdef COMPAT_OLDURI + if (0 == strncmp(val, "OpenBSD ", 8)) { + val[7] = '-'; + if ('C' == val[8]) + val[8] = 'c'; + } +#endif req->q.manpath = val; - else if (0 == strcmp(key, "apropos")) + } else if (0 == strcmp(key, "apropos")) req->q.equal = !strcmp(val, "0"); - else if (0 == strcmp(key, "sec") || - 0 == strcmp(key, "sektion")) { + else if (0 == strcmp(key, "sec")) { if (strcmp(val, "0")) req->q.sec = val; +#ifdef COMPAT_OLDURI + } else if (0 == strcmp(key, "sektion")) { + if (strcmp(val, "0")) + req->q.sec = val; +#endif } else if (0 == strcmp(key, "arch")) { if (strcmp(val, "default")) req->q.arch = val; @@ -413,7 +421,11 @@ resp_searchform(const struct req *req) /* Write architecture selector. */ - puts("\n" + ""); for (i = 0; i < arch_MAX; i++) { printf("