Lines Matching +full:wp +full:- +full:content

3  * Copyright (c) 2014-2019, 2021, 2022 Ingo Schwarze <schwarze@usta.de>
112 "1 - General Commands",
113 "2 - System Calls",
114 "3 - Library Functions",
115 "3p - Perl Library",
116 "4 - Device Drivers",
117 "5 - File Formats",
118 "6 - Games",
119 "7 - Miscellaneous Information",
120 "8 - System Manager\'s Manual",
121 "9 - Kernel Developer\'s Manual"
145 * This will pass non-ASCII straight to output: be warned!
202 * Parse the QUERY_STRING for key-value pairs
211 req->isquery = 1;
212 req->q.manpath = NULL;
213 req->q.arch = NULL;
214 req->q.sec = NULL;
215 req->q.query = NULL;
216 req->q.equal = 1;
240 /* Handle key-value pairs. */
243 set_query_attr(&req->q.query, &val);
246 req->q.equal = !strcmp(val, "0");
251 val[7] = '-';
256 set_query_attr(&req->q.manpath, &val);
266 set_query_attr(&req->q.sec, &val);
272 set_query_attr(&req->q.arch, &val);
292 * HTTP-decode a string. The standard explanation is that this turns
293 * "%4e+foo" into "n foo" in the regular way. This is done in-place
332 strchr("-._~", *p) == NULL)
346 printf("Content-Type: text/html; charset=utf-8\r\n"
347 "Cache-Control: no-cache\r\n"
348 "Content-Security-Policy: default-src 'none'; "
349 "style-src 'self' 'unsafe-inline'\r\n"
350 "Pragma: no-cache\r\n"
363 if ((fd = open(filename, O_RDONLY)) == -1)
386 " <meta charset=\"UTF-8\"/>\n"
388 " content=\"width=device-width, initial-scale=1.0\">\n"
397 namesz = cp == NULL ? strlen(name) : cp - name;
402 } else if (name - file > 1) {
403 for (cp = name - 2; cp >= file; cp--) {
407 secsz = name - cp - 1;
414 fputs(" - ", stdout);
449 if (req->q.query != NULL)
450 html_print(req->q.query);
466 puts(" <select name=\"sec\" aria-label=\"Manual section\">");
469 if (NULL != req->q.sec &&
470 0 == strcmp(sec_numbers[i], req->q.sec))
478 printf( " <select name=\"arch\" aria-label=\"CPU architecture\">\n"
480 if (NULL == req->q.arch)
485 if (NULL != req->q.arch &&
486 0 == strcmp(arch_names[i], req->q.arch))
494 if (req->psz > 1) {
496 " aria-label=\"Manual path\">");
497 for (i = 0; i < (int)req->psz; i++) {
499 if (strcmp(req->q.manpath, req->p[i]) == 0)
502 html_print(req->p[i]);
518 '-' == *frag || '.' == *frag ||
531 for (i = 0; i < req->psz; i++)
532 if ( ! strcmp(manpath, req->p[i]))
569 "<p role=\"doc-notice\" aria-label=\"Usage\">\n"
572 " aria-label=\"man dot CGI, section 8\">man.cgi(8)</a>\n"
575 " aria-label=\"apropos, section 1\">apropos(1)</a>\n"
593 puts("<p role=\"doc-notice\" aria-label=\"No result\">");
607 "<p role=\"doc-notice\" aria-label=\"Bad Request\">");
621 puts("<main><p role=\"doc-notice\">Internal Server Error</p></main>");
632 if (strcmp(req->q.manpath, req->p[0]))
633 printf("%s/", req->q.manpath);
634 if (req->q.arch != NULL)
635 printf("%s/", req->q.arch);
637 if (req->q.sec != NULL) {
639 http_encode(req->q.sec);
641 printf("\r\nContent-Type: text/html; charset=utf-8\r\n\r\n");
658 r[i].file, req->q.manpath);
663 if (req->isquery && sz == 1) {
672 if (strcmp(req->q.manpath, req->p[0]))
673 printf("%s/", req->q.manpath);
675 "Content-Type: text/html; charset=utf-8\r\n\r\n",
686 if (req->q.equal || sz == 1) {
694 prio = sec_prios[sec[0] - '1'];
697 if (req->q.arch == NULL) {
704 archend - arch) ? 2 : 1;
726 req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY);
738 if (strcmp(req->q.manpath, req->p[0]))
739 printf("%s/", req->q.manpath);
752 if (req->q.equal || sz == 1) {
771 puts("<p role=\"doc-notice\">\n"
783 while ((len = getline(&p, &sz, f)) != -1) {
785 for (i = 0; i < len - 1; i++) {
798 * If we're in back-space mode, make sure we'll
828 * Handle funny behaviour troff-isms.
848 } else if (('|' == p[i] && '-' == p[i + 2]) ||
849 ('-' == p[i] && '|' == p[i + 1]) ||
850 ('+' == p[i] && '-' == p[i + 1]) ||
851 ('-' == p[i] && '+' == p[i + 1]) ||
886 if (i == len - 1 && p[i] != '\n')
909 if (-1 == (fd = open(file, O_RDONLY))) {
910 puts("<p role=\"doc-notice\">\n"
918 MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath);
926 usepath = strcmp(req->q.manpath, req->p[0]);
929 usepath ? req->q.manpath : "", usepath ? "/" : "");
932 if (meta->macroset == MACROSET_MDOC)
968 manpath = mandoc_strndup(fullpath, file - fullpath);
984 if (chdir(manpath) == -1) {
1013 char *query, *rp, *wp;
1023 if (chdir(req->q.manpath) == -1) {
1024 warn("chdir %s", req->q.manpath);
1029 search.arch = req->q.arch;
1030 search.sec = req->q.sec;
1032 search.argmode = req->q.equal ? ARG_NAME : ARG_EXPR;
1040 * Break apart at spaces with backslash-escaping.
1045 rp = query = mandoc_strdup(req->q.query);
1052 argv[argc++] = wp = rp;
1055 *wp = '\0';
1061 if (wp != rp)
1062 *wp = *rp;
1065 wp++;
1072 if (req->isquery && req->q.equal && argc == 1)
1103 * pledge() calls in multiple low-level resp_*() functions.
1106 if (pledge("stdio rpath", NULL) == -1) {
1119 if (setitimer(ITIMER_VIRTUAL, &itimer, NULL) == -1) {
1131 if (chdir(MAN_DIR) == -1) {
1151 *req.q.query == '\0' || access(path, F_OK) == -1)
1199 req->isquery = 0;
1200 req->q.equal = 1;
1201 req->q.manpath = NULL;
1202 req->q.arch = NULL;
1213 req->q.query = mandoc_strndup(name, sec - name - 1);
1214 req->q.sec = mandoc_strdup(sec);
1216 req->q.query = mandoc_strdup(name);
1217 req->q.sec = NULL;
1226 req->q.manpath = mandoc_strndup(path, end - path);
1227 if (validate_manpath(req, req->q.manpath)) {
1232 free(req->q.manpath);
1233 req->q.manpath = NULL;
1240 free(req->q.sec);
1241 req->q.sec = mandoc_strndup(path, end - path);
1254 req->q.arch = mandoc_strndup(path, end - path);
1255 if (validate_arch(req->q.arch) == 0) {
1282 while ((len = getline(&dp, &dpsz, fp)) != -1) {
1283 if (dp[len - 1] == '\n')
1284 dp[--len] = '\0';
1285 req->p = mandoc_realloc(req->p,
1286 (req->psz + 1) * sizeof(char *));
1299 req->p[req->psz++] = dp;
1305 if (req->p == NULL) {