]>
git.cameronkatri.com Git - mandoc.git/blob - cgi.c
1 /* $Id: cgi.c,v 1.39 2011/12/25 17:49:52 kristaps Exp $ */
3 * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <sys/param.h>
38 #include "apropos_db.h"
65 * A query as passed to the search function.
68 const char *arch
; /* architecture */
69 const char *sec
; /* manual section */
70 const char *expr
; /* unparsed expression string */
71 int manroot
; /* manroot index (or -1)*/
72 int whatis
; /* whether whatis mode */
73 int legacy
; /* whether legacy mode */
83 static int atou(const char *, unsigned *);
84 static void catman(const struct req
*, const char *);
85 static int cmp(const void *, const void *);
86 static void format(const struct req
*, const char *);
87 static void html_print(const char *);
88 static void html_printquery(const struct req
*);
89 static void html_putchar(char);
90 static int http_decode(char *);
91 static void http_parse(struct req
*, char *);
92 static void http_print(const char *);
93 static void http_putchar(char);
94 static void http_printquery(const struct req
*);
95 static int pathstop(DIR *);
96 static void pathgen(DIR *, char *, struct req
*);
97 static void pg_index(const struct req
*, char *);
98 static void pg_search(const struct req
*, char *);
99 static void pg_show(const struct req
*, char *);
100 static void resp_bad(void);
101 static void resp_baddb(void);
102 static void resp_error400(void);
103 static void resp_error404(const char *);
104 static void resp_begin_html(int, const char *);
105 static void resp_begin_http(int, const char *);
106 static void resp_end_html(void);
107 static void resp_index(const struct req
*);
108 static void resp_search(struct res
*, size_t, void *);
109 static void resp_searchform(const struct req
*);
111 static const char *progname
; /* cgi script name */
112 static const char *cache
; /* cache directory */
113 static const char *css
; /* css directory */
114 static const char *host
; /* hostname */
116 static const char * const pages
[PAGE__MAX
] = {
117 "index", /* PAGE_INDEX */
118 "search", /* PAGE_SEARCH */
119 "show", /* PAGE_SHOW */
123 * This is just OpenBSD's strtol(3) suggestion.
124 * I use it instead of strtonum(3) for portability's sake.
127 atou(const char *buf
, unsigned *v
)
133 lval
= strtol(buf
, &ep
, 10);
134 if (buf
[0] == '\0' || *ep
!= '\0')
136 if ((errno
== ERANGE
&& (lval
== LONG_MAX
||
137 lval
== LONG_MIN
)) ||
138 (lval
> INT_MAX
|| lval
< 0))
141 *v
= (unsigned int)lval
;
146 * Print a character, escaping HTML along the way.
147 * This will pass non-ASCII straight to output: be warned!
167 putchar((unsigned char)c
);
172 http_printquery(const struct req
*req
)
176 http_print(req
->q
.expr
? req
->q
.expr
: "");
178 http_print(req
->q
.sec
? req
->q
.sec
: "");
180 http_print(req
->q
.arch
? req
->q
.arch
: "");
185 html_printquery(const struct req
*req
)
188 printf("&expr=");
189 html_print(req
->q
.expr
? req
->q
.expr
: "");
191 html_print(req
->q
.sec
? req
->q
.sec
: "");
192 printf("&arch=");
193 html_print(req
->q
.arch
? req
->q
.arch
: "");
197 http_print(const char *p
)
207 * Call through to html_putchar().
208 * Accepts NULL strings.
211 html_print(const char *p
)
221 * Parse out key-value pairs from an HTTP request variable.
222 * This can be either a cookie or a POST/GET string, although man.cgi
223 * uses only GET for simplicity.
226 http_parse(struct req
*req
, char *p
)
228 char *key
, *val
, *manroot
;
231 memset(&req
->q
, 0, sizeof(struct query
));
241 p
+= (int)strcspn(p
, ";&");
244 if (NULL
!= (val
= strchr(key
, '=')))
247 if ('\0' == *key
|| NULL
== val
|| '\0' == *val
)
250 /* Just abort handling. */
252 if ( ! http_decode(key
))
254 if (NULL
!= val
&& ! http_decode(val
))
257 if (0 == strcmp(key
, "expr"))
259 else if (0 == strcmp(key
, "query"))
261 else if (0 == strcmp(key
, "sec"))
263 else if (0 == strcmp(key
, "sektion"))
265 else if (0 == strcmp(key
, "arch"))
267 else if (0 == strcmp(key
, "manpath"))
269 else if (0 == strcmp(key
, "apropos"))
270 legacy
= 0 == strcmp(val
, "0");
271 else if (0 == strcmp(key
, "op"))
272 req
->q
.whatis
= 0 == strcasecmp(val
, "whatis");
275 /* Test for old man.cgi compatibility mode. */
280 } else if (legacy
> 0) {
286 * Section "0" means no section when in legacy mode.
287 * For some man.cgi scripts, "default" arch is none.
290 if (req
->q
.legacy
&& NULL
!= req
->q
.sec
)
291 if (0 == strcmp(req
->q
.sec
, "0"))
293 if (req
->q
.legacy
&& NULL
!= req
->q
.arch
)
294 if (0 == strcmp(req
->q
.arch
, "default"))
297 /* Default to first manroot. */
299 if (NULL
!= manroot
) {
300 for (i
= 0; i
< (int)req
->psz
; i
++)
301 if (0 == strcmp(req
->p
[i
].name
, manroot
))
303 req
->q
.manroot
= i
< (int)req
->psz
? i
: -1;
311 if (isalnum((unsigned char)c
)) {
312 putchar((unsigned char)c
);
314 } else if (' ' == c
) {
322 * HTTP-decode a string. The standard explanation is that this turns
323 * "%4e+foo" into "n foo" in the regular way. This is done in-place
324 * over the allocated string.
334 for ( ; '\0' != *p
; p
++) {
336 if ('\0' == (hex
[0] = *(p
+ 1)))
338 if ('\0' == (hex
[1] = *(p
+ 2)))
340 if (1 != sscanf(hex
, "%x", &c
))
346 memmove(p
+ 1, p
+ 3, strlen(p
+ 3) + 1);
348 *p
= '+' == *p
? ' ' : *p
;
356 resp_begin_http(int code
, const char *msg
)
360 printf("Status: %d %s\n", code
, msg
);
362 puts("Content-Type: text/html; charset=utf-8\n"
363 "Cache-Control: no-cache\n"
371 resp_begin_html(int code
, const char *msg
)
374 resp_begin_http(code
, msg
);
376 printf("<!DOCTYPE HTML PUBLIC "
377 " \"-//W3C//DTD HTML 4.01//EN\""
378 " \"http://www.w3.org/TR/html4/strict.dtd\">\n"
381 "<META HTTP-EQUIV=\"Content-Type\""
382 " CONTENT=\"text/html; charset=utf-8\">\n"
383 "<LINK REL=\"stylesheet\" HREF=\"%s/man-cgi.css\""
384 " TYPE=\"text/css\" media=\"all\">\n"
385 "<LINK REL=\"stylesheet\" HREF=\"%s/man.css\""
386 " TYPE=\"text/css\" media=\"all\">\n"
387 "<TITLE>System Manpage Reference</TITLE>\n"
390 "<!-- Begin page content. //-->\n", css
, css
);
402 resp_searchform(const struct req
*req
)
406 puts("<!-- Begin search form. //-->");
407 printf("<DIV ID=\"mancgi\">\n"
408 "<FORM ACTION=\"%s/search.html\" METHOD=\"get\">\n"
410 "<LEGEND>Search Parameters</LEGEND>\n"
411 "<INPUT TYPE=\"submit\" NAME=\"op\""
412 " VALUE=\"Whatis\"> or \n"
413 "<INPUT TYPE=\"submit\" NAME=\"op\""
414 " VALUE=\"apropos\"> for manuals satisfying \n"
415 "<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"",
417 html_print(req
->q
.expr
? req
->q
.expr
: "");
418 printf("\">, section "
419 "<INPUT TYPE=\"text\""
420 " SIZE=\"4\" NAME=\"sec\" VALUE=\"");
421 html_print(req
->q
.sec
? req
->q
.sec
: "");
423 "<INPUT TYPE=\"text\""
424 " SIZE=\"8\" NAME=\"arch\" VALUE=\"");
425 html_print(req
->q
.arch
? req
->q
.arch
: "");
428 puts(", <SELECT NAME=\"manpath\">");
429 for (i
= 0; i
< (int)req
->psz
; i
++) {
430 printf("<OPTION %s VALUE=\"",
431 (i
== req
->q
.manroot
) ||
432 (0 == i
&& -1 == req
->q
.manroot
) ?
433 "SELECTED=\"selected\"" : "");
434 html_print(req
->p
[i
].name
);
436 html_print(req
->p
[i
].name
);
442 "<INPUT TYPE=\"reset\" VALUE=\"Reset\">\n"
446 puts("<!-- End search form. //-->");
450 resp_index(const struct req
*req
)
453 resp_begin_html(200, NULL
);
454 resp_searchform(req
);
462 resp_begin_html(400, "Query Malformed");
463 printf("<H1>Malformed Query</H1>\n"
465 "The query your entered was malformed.\n"
466 "Try again from the\n"
467 "<A HREF=\"%s/index.html\">main page</A>.\n"
473 resp_error404(const char *page
)
476 resp_begin_html(404, "Not Found");
477 puts("<H1>Page Not Found</H1>\n"
479 "The page you're looking for, ");
483 "could not be found.\n"
484 "Try searching from the\n"
485 "<A HREF=\"%s/index.html\">main page</A>.\n"
493 resp_begin_html(500, "Internal Server Error");
494 puts("<P>Generic badness happened.</P>");
502 resp_begin_html(500, "Internal Server Error");
503 puts("<P>Your database is broken.</P>");
508 resp_search(struct res
*r
, size_t sz
, void *arg
)
511 const struct req
*req
;
513 req
= (const struct req
*)arg
;
516 assert(req
->q
.manroot
>= 0);
520 * If we have just one result, then jump there now
523 puts("Status: 303 See Other");
524 printf("Location: http://%s%s/show/%d/%u/%u.html?",
525 host
, progname
, req
->q
.manroot
,
526 r
[0].volume
, r
[0].rec
);
527 http_printquery(req
);
529 "Content-Type: text/html; charset=utf-8\n");
533 qsort(r
, sz
, sizeof(struct res
), cmp
);
535 resp_begin_html(200, NULL
);
536 resp_searchform(req
);
538 puts("<DIV CLASS=\"results\">");
542 "No %s results found.\n",
543 req
->q
.whatis
? "whatis" : "apropos");
546 "<A HREF=\"%s/search.html?op=apropos",
548 html_printquery(req
);
549 puts("\">apropos</A>?)");
559 for (i
= 0; i
< (int)sz
; i
++) {
561 "<TD CLASS=\"title\">\n"
562 "<A HREF=\"%s/show/%d/%u/%u.html?",
563 progname
, req
->q
.manroot
,
564 r
[i
].volume
, r
[i
].rec
);
565 html_printquery(req
);
567 html_print(r
[i
].title
);
569 html_print(r
[i
].cat
);
570 if (r
[i
].arch
&& '\0' != *r
[i
].arch
) {
572 html_print(r
[i
].arch
);
576 "<TD CLASS=\"desc\">");
577 html_print(r
[i
].desc
);
589 pg_index(const struct req
*req
, char *path
)
596 catman(const struct req
*req
, const char *file
)
604 if (NULL
== (f
= fopen(file
, "r"))) {
609 resp_begin_html(200, NULL
);
610 resp_searchform(req
);
611 puts("<DIV CLASS=\"catman\">\n"
614 while (NULL
!= (p
= fgetln(f
, &len
))) {
616 for (i
= 0; i
< (int)len
- 1; i
++) {
618 * This means that the catpage is out of state.
619 * Ignore it and keep going (although the
623 if ('\b' == p
[i
] || '\n' == p
[i
])
627 * Print a regular character.
628 * Close out any bold/italic scopes.
629 * If we're in back-space mode, make sure we'll
630 * have something to enter when we backspace.
633 if ('\b' != p
[i
+ 1]) {
641 } else if (i
+ 2 >= (int)len
)
659 * Handle funny behaviour troff-isms.
660 * These grok'd from the original man2html.c.
663 if (('+' == p
[i
] && 'o' == p
[i
+ 2]) ||
664 ('o' == p
[i
] && '+' == p
[i
+ 2]) ||
665 ('|' == p
[i
] && '=' == p
[i
+ 2]) ||
666 ('=' == p
[i
] && '|' == p
[i
+ 2]) ||
667 ('*' == p
[i
] && '=' == p
[i
+ 2]) ||
668 ('=' == p
[i
] && '*' == p
[i
+ 2]) ||
669 ('*' == p
[i
] && '|' == p
[i
+ 2]) ||
670 ('|' == p
[i
] && '*' == p
[i
+ 2])) {
679 } else if (('|' == p
[i
] && '-' == p
[i
+ 2]) ||
680 ('-' == p
[i
] && '|' == p
[i
+ 1]) ||
681 ('+' == p
[i
] && '-' == p
[i
+ 1]) ||
682 ('-' == p
[i
] && '+' == p
[i
+ 1]) ||
683 ('+' == p
[i
] && '|' == p
[i
+ 1]) ||
684 ('|' == p
[i
] && '+' == p
[i
+ 1])) {
708 * Clean up the last character.
709 * We can get to a newline; don't print that.
717 if (i
== (int)len
- 1 && '\n' != p
[i
])
732 format(const struct req
*req
, const char *file
)
740 char opts
[MAXPATHLEN
+ 128];
742 if (-1 == (fd
= open(file
, O_RDONLY
, 0))) {
747 mp
= mparse_alloc(MPARSE_AUTO
, MANDOCLEVEL_FATAL
, NULL
, NULL
);
748 rc
= mparse_readfd(mp
, fd
, file
);
751 if (rc
>= MANDOCLEVEL_FATAL
) {
756 snprintf(opts
, sizeof(opts
), "fragment,"
757 "man=%s/search.html?sec=%%S&expr=%%N,"
758 /*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/,
761 mparse_result(mp
, &mdoc
, &man
);
762 if (NULL
== man
&& NULL
== mdoc
) {
768 resp_begin_html(200, NULL
);
769 resp_searchform(req
);
771 vp
= html_alloc(opts
);
786 pg_show(const struct req
*req
, char *path
)
791 char file
[MAXPATHLEN
];
794 unsigned int vol
, rec
, mr
;
800 /* Parse out mroot, volume, and record from the path. */
802 if (NULL
== path
|| NULL
== (sub
= strchr(path
, '/'))) {
807 if ( ! atou(path
, &mr
)) {
812 if (NULL
== (sub
= strchr(path
, '/'))) {
817 if ( ! atou(path
, &vol
) || ! atou(sub
, &rec
)) {
820 } else if (mr
>= (unsigned int)req
->psz
) {
826 * Begin by chdir()ing into the manroot.
827 * This way we can pick up the database files, which are
828 * relative to the manpath root.
831 if (-1 == chdir(req
->p
[(int)mr
].path
)) {
832 perror(req
->p
[(int)mr
].path
);
837 memset(&ps
, 0, sizeof(struct manpaths
));
838 manpath_manconf(&ps
, "etc/catman.conf");
840 if (vol
>= (unsigned int)ps
.sz
) {
845 sz
= strlcpy(file
, ps
.paths
[vol
], MAXPATHLEN
);
846 assert(sz
< MAXPATHLEN
);
847 strlcat(file
, "/", MAXPATHLEN
);
848 strlcat(file
, MANDOC_IDX
, MAXPATHLEN
);
850 /* Open the index recno(3) database. */
852 idx
= dbopen(file
, O_RDONLY
, 0, DB_RECNO
, NULL
);
862 if (0 != (rc
= (*idx
->get
)(idx
, &key
, &val
, 0))) {
863 rc
< 0 ? resp_baddb() : resp_error400();
865 } else if (0 == val
.size
) {
870 cp
= (char *)val
.data
;
873 if (NULL
== memchr(cp
, '\0', val
.size
- 1))
876 file
[(int)sz
] = '\0';
877 strlcat(file
, "/", MAXPATHLEN
);
878 strlcat(file
, cp
, MAXPATHLEN
);
891 pg_search(const struct req
*req
, char *path
)
896 const char *ep
, *start
;
901 if (req
->q
.manroot
< 0 || 0 == req
->psz
) {
902 resp_search(NULL
, 0, (void *)req
);
906 memset(&opt
, 0, sizeof(struct opts
));
909 opt
.arch
= req
->q
.arch
;
910 opt
.cat
= req
->q
.sec
;
916 * Begin by chdir()ing into the root of the manpath.
917 * This way we can pick up the database files, which are
918 * relative to the manpath root.
921 assert(req
->q
.manroot
< (int)req
->psz
);
922 if (-1 == (chdir(req
->p
[req
->q
.manroot
].path
))) {
923 perror(req
->p
[req
->q
.manroot
].path
);
924 resp_search(NULL
, 0, (void *)req
);
928 memset(&ps
, 0, sizeof(struct manpaths
));
929 manpath_manconf(&ps
, "etc/catman.conf");
932 * Poor man's tokenisation: just break apart by spaces.
933 * Yes, this is half-ass. But it works for now.
936 while (ep
&& isspace((unsigned char)*ep
))
939 while (ep
&& '\0' != *ep
) {
940 cp
= mandoc_realloc(cp
, (sz
+ 1) * sizeof(char *));
942 while ('\0' != *ep
&& ! isspace((unsigned char)*ep
))
944 cp
[sz
] = mandoc_malloc((ep
- start
) + 1);
945 memcpy(cp
[sz
], start
, ep
- start
);
946 cp
[sz
++][ep
- start
] = '\0';
947 while (isspace((unsigned char)*ep
))
952 * Pump down into apropos backend.
953 * The resp_search() function is called with the results.
956 expr
= req
->q
.whatis
?
957 termcomp(sz
, cp
, &tt
) : exprcomp(sz
, cp
, &tt
);
961 (ps
.sz
, ps
.paths
, &opt
,
962 expr
, tt
, (void *)req
, resp_search
);
964 /* ...unless errors occured. */
969 resp_search(NULL
, 0, (void *)req
);
971 for (i
= 0; i
< sz
; i
++)
983 char buf
[MAXPATHLEN
];
986 char *p
, *path
, *subpath
;
988 /* Scan our run-time environment. */
990 if (NULL
== (cache
= getenv("CACHE_DIR")))
991 cache
= "/cache/man.cgi";
993 if (NULL
== (progname
= getenv("SCRIPT_NAME")))
996 if (NULL
== (css
= getenv("CSS_DIR")))
999 if (NULL
== (host
= getenv("HTTP_HOST")))
1003 * First we change directory into the cache directory so that
1004 * subsequent scanning for manpath directories is rooted
1005 * relative to the same position.
1008 if (-1 == chdir(cache
)) {
1011 return(EXIT_FAILURE
);
1012 } else if (NULL
== (cwd
= opendir(cache
))) {
1015 return(EXIT_FAILURE
);
1018 memset(&req
, 0, sizeof(struct req
));
1020 strlcpy(buf
, ".", MAXPATHLEN
);
1021 pathgen(cwd
, buf
, &req
);
1024 /* Next parse out the query string. */
1026 if (NULL
!= (p
= getenv("QUERY_STRING")))
1027 http_parse(&req
, p
);
1030 * Now juggle paths to extract information.
1031 * We want to extract our filetype (the file suffix), the
1032 * initial path component, then the trailing component(s).
1033 * Start with leading subpath component.
1036 subpath
= path
= NULL
;
1037 req
.page
= PAGE__MAX
;
1039 if (NULL
== (path
= getenv("PATH_INFO")) || '\0' == *path
)
1040 req
.page
= PAGE_INDEX
;
1042 if (NULL
!= path
&& '/' == *path
&& '\0' == *++path
)
1043 req
.page
= PAGE_INDEX
;
1045 /* Strip file suffix. */
1047 if (NULL
!= path
&& NULL
!= (p
= strrchr(path
, '.')))
1048 if (NULL
!= p
&& NULL
== strchr(p
, '/'))
1051 /* Resolve subpath component. */
1053 if (NULL
!= path
&& NULL
!= (subpath
= strchr(path
, '/')))
1056 /* Map path into one we recognise. */
1058 if (NULL
!= path
&& '\0' != *path
)
1059 for (i
= 0; i
< (int)PAGE__MAX
; i
++)
1060 if (0 == strcmp(pages
[i
], path
)) {
1061 req
.page
= (enum page
)i
;
1069 pg_index(&req
, subpath
);
1072 pg_search(&req
, subpath
);
1075 pg_show(&req
, subpath
);
1078 resp_error404(path
);
1082 for (i
= 0; i
< (int)req
.psz
; i
++) {
1083 free(req
.p
[i
].path
);
1084 free(req
.p
[i
].name
);
1088 return(EXIT_SUCCESS
);
1092 cmp(const void *p1
, const void *p2
)
1095 return(strcasecmp(((const struct res
*)p1
)->title
,
1096 ((const struct res
*)p2
)->title
));
1100 * Check to see if an "etc" path consists of a catman.conf file. If it
1101 * does, that means that the path contains a tree created by catman(8)
1102 * and should be used for indexing.
1109 while (NULL
!= (d
= readdir(dir
)))
1110 if (DT_REG
== d
->d_type
)
1111 if (0 == strcmp(d
->d_name
, "catman.conf"))
1118 * Scan for indexable paths.
1119 * This adds all paths with "etc/catman.conf" to the buffer.
1122 pathgen(DIR *dir
, char *path
, struct req
*req
)
1130 sz
= strlcat(path
, "/", MAXPATHLEN
);
1131 if (sz
>= MAXPATHLEN
) {
1132 fprintf(stderr
, "%s: Path too long", path
);
1137 * First, scan for the "etc" directory.
1138 * If it's found, then see if it should cause us to stop. This
1139 * happens when a catman.conf is found in the directory.
1143 while (0 == rc
&& NULL
!= (d
= readdir(dir
))) {
1144 if (DT_DIR
!= d
->d_type
|| strcmp(d
->d_name
, "etc"))
1147 path
[(int)sz
] = '\0';
1148 ssz
= strlcat(path
, d
->d_name
, MAXPATHLEN
);
1150 if (ssz
>= MAXPATHLEN
) {
1151 fprintf(stderr
, "%s: Path too long", path
);
1153 } else if (NULL
== (cd
= opendir(path
))) {
1163 /* This also strips the trailing slash. */
1164 path
[(int)--sz
] = '\0';
1165 req
->p
= mandoc_realloc
1167 (req
->psz
+ 1) * sizeof(struct paths
));
1169 * Strip out the leading "./" unless we're just a ".",
1170 * in which case use an empty string as our name.
1172 req
->p
[(int)req
->psz
].path
= mandoc_strdup(path
);
1173 req
->p
[(int)req
->psz
].name
=
1174 cp
= mandoc_strdup(path
+ (1 == sz
? 1 : 2));
1177 * The name is just the path with all the slashes taken
1178 * out of it. Simple but effective.
1180 for ( ; '\0' != *cp
; cp
++)
1187 * If no etc/catman.conf was found, recursively enter child
1188 * directory and continue scanning.
1192 while (NULL
!= (d
= readdir(dir
))) {
1193 if (DT_DIR
!= d
->d_type
|| '.' == d
->d_name
[0])
1196 path
[(int)sz
] = '\0';
1197 ssz
= strlcat(path
, d
->d_name
, MAXPATHLEN
);
1199 if (ssz
>= MAXPATHLEN
) {
1200 fprintf(stderr
, "%s: Path too long", path
);
1202 } else if (NULL
== (cd
= opendir(path
))) {
1207 pathgen(cd
, path
, req
);