mandoc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/COPYING +674 -0
- data/README.md +117 -0
- data/ext/mandoc/extconf.rb +59 -0
- data/ext/mandoc/rb_mandoc.c +548 -0
- data/ext/mandoc/rb_mandoc.h +22 -0
- data/lib/mandoc/version.rb +19 -0
- data/lib/mandoc.rb +26 -0
- data/mandoc-1.14.6/LICENSE +55 -0
- data/mandoc-1.14.6/arch.c +54 -0
- data/mandoc-1.14.6/att.c +49 -0
- data/mandoc-1.14.6/catman.c +260 -0
- data/mandoc-1.14.6/cgi.c +1279 -0
- data/mandoc-1.14.6/chars.c +507 -0
- data/mandoc-1.14.6/compat_err.c +103 -0
- data/mandoc-1.14.6/compat_fts.c +696 -0
- data/mandoc-1.14.6/compat_fts.h +106 -0
- data/mandoc-1.14.6/compat_getline.c +59 -0
- data/mandoc-1.14.6/compat_getsubopt.c +87 -0
- data/mandoc-1.14.6/compat_isblank.c +23 -0
- data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
- data/mandoc-1.14.6/compat_mkstemps.c +63 -0
- data/mandoc-1.14.6/compat_ohash.c +330 -0
- data/mandoc-1.14.6/compat_ohash.h +72 -0
- data/mandoc-1.14.6/compat_progname.c +31 -0
- data/mandoc-1.14.6/compat_reallocarray.c +40 -0
- data/mandoc-1.14.6/compat_recallocarray.c +99 -0
- data/mandoc-1.14.6/compat_strcasestr.c +64 -0
- data/mandoc-1.14.6/compat_stringlist.c +135 -0
- data/mandoc-1.14.6/compat_stringlist.h +48 -0
- data/mandoc-1.14.6/compat_strlcat.c +57 -0
- data/mandoc-1.14.6/compat_strlcpy.c +52 -0
- data/mandoc-1.14.6/compat_strndup.c +42 -0
- data/mandoc-1.14.6/compat_strsep.c +70 -0
- data/mandoc-1.14.6/compat_strtonum.c +67 -0
- data/mandoc-1.14.6/compat_vasprintf.c +47 -0
- data/mandoc-1.14.6/config.h +52 -0
- data/mandoc-1.14.6/dba.c +508 -0
- data/mandoc-1.14.6/dba.h +50 -0
- data/mandoc-1.14.6/dba_array.c +190 -0
- data/mandoc-1.14.6/dba_array.h +47 -0
- data/mandoc-1.14.6/dba_read.c +74 -0
- data/mandoc-1.14.6/dba_write.c +127 -0
- data/mandoc-1.14.6/dba_write.h +30 -0
- data/mandoc-1.14.6/dbm.c +480 -0
- data/mandoc-1.14.6/dbm.h +68 -0
- data/mandoc-1.14.6/dbm_map.c +194 -0
- data/mandoc-1.14.6/dbm_map.h +29 -0
- data/mandoc-1.14.6/demandoc.c +260 -0
- data/mandoc-1.14.6/eqn.c +1132 -0
- data/mandoc-1.14.6/eqn.h +72 -0
- data/mandoc-1.14.6/eqn_html.c +246 -0
- data/mandoc-1.14.6/eqn_parse.h +48 -0
- data/mandoc-1.14.6/eqn_term.c +174 -0
- data/mandoc-1.14.6/html.c +1102 -0
- data/mandoc-1.14.6/html.h +142 -0
- data/mandoc-1.14.6/lib.c +35 -0
- data/mandoc-1.14.6/libman.h +42 -0
- data/mandoc-1.14.6/libmandoc.h +85 -0
- data/mandoc-1.14.6/libmdoc.h +87 -0
- data/mandoc-1.14.6/main.c +1375 -0
- data/mandoc-1.14.6/main.h +53 -0
- data/mandoc-1.14.6/man.c +345 -0
- data/mandoc-1.14.6/man.h +21 -0
- data/mandoc-1.14.6/man_html.c +640 -0
- data/mandoc-1.14.6/man_macro.c +470 -0
- data/mandoc-1.14.6/man_term.c +1143 -0
- data/mandoc-1.14.6/man_validate.c +660 -0
- data/mandoc-1.14.6/manconf.h +58 -0
- data/mandoc-1.14.6/mandoc.c +669 -0
- data/mandoc-1.14.6/mandoc.h +329 -0
- data/mandoc-1.14.6/mandoc_aux.c +118 -0
- data/mandoc-1.14.6/mandoc_aux.h +27 -0
- data/mandoc-1.14.6/mandoc_msg.c +375 -0
- data/mandoc-1.14.6/mandoc_ohash.c +65 -0
- data/mandoc-1.14.6/mandoc_ohash.h +23 -0
- data/mandoc-1.14.6/mandoc_parse.h +44 -0
- data/mandoc-1.14.6/mandoc_xr.c +123 -0
- data/mandoc-1.14.6/mandoc_xr.h +31 -0
- data/mandoc-1.14.6/mandocd.c +282 -0
- data/mandoc-1.14.6/mandocdb.c +2448 -0
- data/mandoc-1.14.6/manpath.c +363 -0
- data/mandoc-1.14.6/mansearch.c +851 -0
- data/mandoc-1.14.6/mansearch.h +118 -0
- data/mandoc-1.14.6/mdoc.c +433 -0
- data/mandoc-1.14.6/mdoc.h +158 -0
- data/mandoc-1.14.6/mdoc_argv.c +682 -0
- data/mandoc-1.14.6/mdoc_html.c +1762 -0
- data/mandoc-1.14.6/mdoc_macro.c +1600 -0
- data/mandoc-1.14.6/mdoc_man.c +1850 -0
- data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
- data/mandoc-1.14.6/mdoc_state.c +256 -0
- data/mandoc-1.14.6/mdoc_term.c +1964 -0
- data/mandoc-1.14.6/mdoc_validate.c +3062 -0
- data/mandoc-1.14.6/msec.c +37 -0
- data/mandoc-1.14.6/out.c +544 -0
- data/mandoc-1.14.6/out.h +70 -0
- data/mandoc-1.14.6/preconv.c +179 -0
- data/mandoc-1.14.6/read.c +732 -0
- data/mandoc-1.14.6/roff.c +4390 -0
- data/mandoc-1.14.6/roff.h +561 -0
- data/mandoc-1.14.6/roff_html.c +119 -0
- data/mandoc-1.14.6/roff_int.h +94 -0
- data/mandoc-1.14.6/roff_term.c +266 -0
- data/mandoc-1.14.6/roff_validate.c +151 -0
- data/mandoc-1.14.6/soelim.c +182 -0
- data/mandoc-1.14.6/st.c +82 -0
- data/mandoc-1.14.6/tag.c +327 -0
- data/mandoc-1.14.6/tag.h +35 -0
- data/mandoc-1.14.6/tbl.c +183 -0
- data/mandoc-1.14.6/tbl.h +121 -0
- data/mandoc-1.14.6/tbl_data.c +323 -0
- data/mandoc-1.14.6/tbl_html.c +293 -0
- data/mandoc-1.14.6/tbl_int.h +47 -0
- data/mandoc-1.14.6/tbl_layout.c +376 -0
- data/mandoc-1.14.6/tbl_opts.c +173 -0
- data/mandoc-1.14.6/tbl_parse.h +30 -0
- data/mandoc-1.14.6/tbl_term.c +948 -0
- data/mandoc-1.14.6/term.c +1113 -0
- data/mandoc-1.14.6/term.h +158 -0
- data/mandoc-1.14.6/term_ascii.c +424 -0
- data/mandoc-1.14.6/term_ps.c +1362 -0
- data/mandoc-1.14.6/term_tab.c +130 -0
- data/mandoc-1.14.6/term_tag.c +227 -0
- data/mandoc-1.14.6/term_tag.h +34 -0
- data/mandoc-1.14.6/tree.c +536 -0
- metadata +170 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* $Id: arch.c,v 1.17 2021/05/13 13:33:11 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2017, 2019 Ingo Schwarze <schwarze@openbsd.org>
|
|
4
|
+
*
|
|
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.
|
|
8
|
+
*
|
|
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.
|
|
16
|
+
*/
|
|
17
|
+
#include "config.h"
|
|
18
|
+
|
|
19
|
+
#include <string.h>
|
|
20
|
+
|
|
21
|
+
#include "roff.h"
|
|
22
|
+
|
|
23
|
+
int
|
|
24
|
+
arch_valid(const char *arch, enum mandoc_os os)
|
|
25
|
+
{
|
|
26
|
+
const char *openbsd_arch[] = {
|
|
27
|
+
"alpha", "amd64", "arm64", "armv7", "hppa", "i386",
|
|
28
|
+
"landisk", "loongson", "luna88k", "macppc", "mips64",
|
|
29
|
+
"octeon", "powerpc64", "riscv64", "sparc64", NULL
|
|
30
|
+
};
|
|
31
|
+
const char *netbsd_arch[] = {
|
|
32
|
+
"acorn26", "acorn32", "algor", "alpha", "amiga",
|
|
33
|
+
"arc", "atari",
|
|
34
|
+
"bebox", "cats", "cesfic", "cobalt", "dreamcast",
|
|
35
|
+
"emips", "evbarm", "evbmips", "evbppc", "evbsh3", "evbsh5",
|
|
36
|
+
"hp300", "hpcarm", "hpcmips", "hpcsh", "hppa",
|
|
37
|
+
"i386", "ibmnws", "luna68k",
|
|
38
|
+
"mac68k", "macppc", "mipsco", "mmeye", "mvme68k", "mvmeppc",
|
|
39
|
+
"netwinder", "news68k", "newsmips", "next68k",
|
|
40
|
+
"pc532", "playstation2", "pmax", "pmppc", "prep",
|
|
41
|
+
"sandpoint", "sbmips", "sgimips", "shark",
|
|
42
|
+
"sparc", "sparc64", "sun2", "sun3",
|
|
43
|
+
"vax", "walnut", "x68k", "x86", "x86_64", "xen", NULL
|
|
44
|
+
};
|
|
45
|
+
const char **arches[] = { NULL, netbsd_arch, openbsd_arch };
|
|
46
|
+
const char **arch_p;
|
|
47
|
+
|
|
48
|
+
if ((arch_p = arches[os]) == NULL)
|
|
49
|
+
return 1;
|
|
50
|
+
for (; *arch_p != NULL; arch_p++)
|
|
51
|
+
if (strcmp(*arch_p, arch) == 0)
|
|
52
|
+
return 1;
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
data/mandoc-1.14.6/att.c
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* $Id: att.c,v 1.19 2021/09/04 20:26:43 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
|
|
4
|
+
*
|
|
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.
|
|
8
|
+
*
|
|
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.
|
|
16
|
+
*/
|
|
17
|
+
#include "config.h"
|
|
18
|
+
|
|
19
|
+
#include <sys/types.h>
|
|
20
|
+
#include <string.h>
|
|
21
|
+
|
|
22
|
+
#include "roff.h"
|
|
23
|
+
#include "libmdoc.h"
|
|
24
|
+
|
|
25
|
+
#define LINE(x, y) \
|
|
26
|
+
if (0 == strcmp(p, x)) return(y)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const char *
|
|
30
|
+
mdoc_a2att(const char *p)
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
LINE("v1", "Version\\~1 AT&T UNIX");
|
|
34
|
+
LINE("v2", "Version\\~2 AT&T UNIX");
|
|
35
|
+
LINE("v3", "Version\\~3 AT&T UNIX");
|
|
36
|
+
LINE("v4", "Version\\~4 AT&T UNIX");
|
|
37
|
+
LINE("v5", "Version\\~5 AT&T UNIX");
|
|
38
|
+
LINE("v6", "Version\\~6 AT&T UNIX");
|
|
39
|
+
LINE("v7", "Version\\~7 AT&T UNIX");
|
|
40
|
+
LINE("32v", "Version\\~7 AT&T UNIX/32V");
|
|
41
|
+
LINE("III", "AT&T System\\~III UNIX");
|
|
42
|
+
LINE("V", "AT&T System\\~V UNIX");
|
|
43
|
+
LINE("V.1", "AT&T System\\~V Release\\~1 UNIX");
|
|
44
|
+
LINE("V.2", "AT&T System\\~V Release\\~2 UNIX");
|
|
45
|
+
LINE("V.3", "AT&T System\\~V Release\\~3 UNIX");
|
|
46
|
+
LINE("V.4", "AT&T System\\~V Release\\~4 UNIX");
|
|
47
|
+
|
|
48
|
+
return NULL;
|
|
49
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/* $Id: catman.c,v 1.22 2020/06/14 23:40:31 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
|
|
4
|
+
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
|
|
5
|
+
*
|
|
6
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
7
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
8
|
+
* copyright notice and this permission notice appear in all copies.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
|
11
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
12
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
|
13
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
14
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
15
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
16
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
*/
|
|
18
|
+
#include "config.h"
|
|
19
|
+
|
|
20
|
+
#if NEED_XPG4_2
|
|
21
|
+
#define _XPG4_2
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#include <sys/types.h>
|
|
25
|
+
#include <sys/socket.h>
|
|
26
|
+
#include <sys/stat.h>
|
|
27
|
+
|
|
28
|
+
#if HAVE_ERR
|
|
29
|
+
#include <err.h>
|
|
30
|
+
#endif
|
|
31
|
+
#include <errno.h>
|
|
32
|
+
#include <fcntl.h>
|
|
33
|
+
#if HAVE_FTS
|
|
34
|
+
#include <fts.h>
|
|
35
|
+
#else
|
|
36
|
+
#include "compat_fts.h"
|
|
37
|
+
#endif
|
|
38
|
+
#include <stdio.h>
|
|
39
|
+
#include <stdlib.h>
|
|
40
|
+
#include <string.h>
|
|
41
|
+
#include <time.h>
|
|
42
|
+
#include <unistd.h>
|
|
43
|
+
|
|
44
|
+
int process_manpage(int, int, const char *);
|
|
45
|
+
int process_tree(int, int);
|
|
46
|
+
void run_mandocd(int, const char *, const char *)
|
|
47
|
+
__attribute__((__noreturn__));
|
|
48
|
+
ssize_t sock_fd_write(int, int, int, int);
|
|
49
|
+
void usage(void) __attribute__((__noreturn__));
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
void
|
|
53
|
+
run_mandocd(int sockfd, const char *outtype, const char* defos)
|
|
54
|
+
{
|
|
55
|
+
char sockfdstr[10];
|
|
56
|
+
|
|
57
|
+
if (snprintf(sockfdstr, sizeof(sockfdstr), "%d", sockfd) == -1)
|
|
58
|
+
err(1, "snprintf");
|
|
59
|
+
if (defos == NULL)
|
|
60
|
+
execlp("mandocd", "mandocd", "-T", outtype,
|
|
61
|
+
sockfdstr, (char *)NULL);
|
|
62
|
+
else
|
|
63
|
+
execlp("mandocd", "mandocd", "-T", outtype,
|
|
64
|
+
"-I", defos, sockfdstr, (char *)NULL);
|
|
65
|
+
err(1, "exec");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ssize_t
|
|
69
|
+
sock_fd_write(int fd, int fd0, int fd1, int fd2)
|
|
70
|
+
{
|
|
71
|
+
const struct timespec timeout = { 0, 10000000 }; /* 0.01 s */
|
|
72
|
+
struct msghdr msg;
|
|
73
|
+
struct iovec iov;
|
|
74
|
+
union {
|
|
75
|
+
struct cmsghdr cmsghdr;
|
|
76
|
+
char control[CMSG_SPACE(3 * sizeof(int))];
|
|
77
|
+
} cmsgu;
|
|
78
|
+
struct cmsghdr *cmsg;
|
|
79
|
+
int *walk;
|
|
80
|
+
ssize_t sz;
|
|
81
|
+
unsigned char dummy[1] = {'\0'};
|
|
82
|
+
|
|
83
|
+
iov.iov_base = dummy;
|
|
84
|
+
iov.iov_len = sizeof(dummy);
|
|
85
|
+
|
|
86
|
+
msg.msg_name = NULL;
|
|
87
|
+
msg.msg_namelen = 0;
|
|
88
|
+
msg.msg_iov = &iov;
|
|
89
|
+
msg.msg_iovlen = 1;
|
|
90
|
+
|
|
91
|
+
msg.msg_control = cmsgu.control;
|
|
92
|
+
msg.msg_controllen = sizeof(cmsgu.control);
|
|
93
|
+
|
|
94
|
+
cmsg = CMSG_FIRSTHDR(&msg);
|
|
95
|
+
cmsg->cmsg_len = CMSG_LEN(3 * sizeof(int));
|
|
96
|
+
cmsg->cmsg_level = SOL_SOCKET;
|
|
97
|
+
cmsg->cmsg_type = SCM_RIGHTS;
|
|
98
|
+
|
|
99
|
+
walk = (int *)CMSG_DATA(cmsg);
|
|
100
|
+
*(walk++) = fd0;
|
|
101
|
+
*(walk++) = fd1;
|
|
102
|
+
*(walk++) = fd2;
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* It appears that on some systems, sendmsg(3)
|
|
106
|
+
* may return EAGAIN even in blocking mode.
|
|
107
|
+
* Seen for example on Oracle Solaris 11.2.
|
|
108
|
+
* The sleeping time was chosen by experimentation,
|
|
109
|
+
* to neither cause more than a handful of retries
|
|
110
|
+
* in normal operation nor unnecessary delays.
|
|
111
|
+
*/
|
|
112
|
+
for (;;) {
|
|
113
|
+
if ((sz = sendmsg(fd, &msg, 0)) != -1 ||
|
|
114
|
+
errno != EAGAIN)
|
|
115
|
+
break;
|
|
116
|
+
nanosleep(&timeout, NULL);
|
|
117
|
+
}
|
|
118
|
+
return sz;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
int
|
|
122
|
+
process_manpage(int srv_fd, int dstdir_fd, const char *path)
|
|
123
|
+
{
|
|
124
|
+
int in_fd, out_fd;
|
|
125
|
+
int irc;
|
|
126
|
+
|
|
127
|
+
if ((in_fd = open(path, O_RDONLY)) == -1) {
|
|
128
|
+
warn("open(%s)", path);
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if ((out_fd = openat(dstdir_fd, path,
|
|
133
|
+
O_WRONLY | O_NOFOLLOW | O_CREAT | O_TRUNC,
|
|
134
|
+
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) {
|
|
135
|
+
warn("openat(%s)", path);
|
|
136
|
+
close(in_fd);
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
irc = sock_fd_write(srv_fd, in_fd, out_fd, STDERR_FILENO);
|
|
141
|
+
|
|
142
|
+
close(in_fd);
|
|
143
|
+
close(out_fd);
|
|
144
|
+
|
|
145
|
+
if (irc < 0) {
|
|
146
|
+
warn("sendmsg");
|
|
147
|
+
return -1;
|
|
148
|
+
}
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
int
|
|
153
|
+
process_tree(int srv_fd, int dstdir_fd)
|
|
154
|
+
{
|
|
155
|
+
FTS *ftsp;
|
|
156
|
+
FTSENT *entry;
|
|
157
|
+
const char *argv[2];
|
|
158
|
+
const char *path;
|
|
159
|
+
|
|
160
|
+
argv[0] = ".";
|
|
161
|
+
argv[1] = (char *)NULL;
|
|
162
|
+
|
|
163
|
+
if ((ftsp = fts_open((char * const *)argv,
|
|
164
|
+
FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
|
|
165
|
+
warn("fts_open");
|
|
166
|
+
return -1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
while ((entry = fts_read(ftsp)) != NULL) {
|
|
170
|
+
path = entry->fts_path + 2;
|
|
171
|
+
switch (entry->fts_info) {
|
|
172
|
+
case FTS_F:
|
|
173
|
+
if (process_manpage(srv_fd, dstdir_fd, path) == -1) {
|
|
174
|
+
fts_close(ftsp);
|
|
175
|
+
return -1;
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case FTS_D:
|
|
179
|
+
if (*path != '\0' &&
|
|
180
|
+
mkdirat(dstdir_fd, path, S_IRWXU | S_IRGRP |
|
|
181
|
+
S_IXGRP | S_IROTH | S_IXOTH) == -1 &&
|
|
182
|
+
errno != EEXIST) {
|
|
183
|
+
warn("mkdirat(%s)", path);
|
|
184
|
+
(void)fts_set(ftsp, entry, FTS_SKIP);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case FTS_DP:
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
warnx("%s: not a regular file", path);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fts_close(ftsp);
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
int
|
|
200
|
+
main(int argc, char **argv)
|
|
201
|
+
{
|
|
202
|
+
const char *defos, *outtype;
|
|
203
|
+
int srv_fds[2];
|
|
204
|
+
int dstdir_fd;
|
|
205
|
+
int opt;
|
|
206
|
+
pid_t pid;
|
|
207
|
+
|
|
208
|
+
defos = NULL;
|
|
209
|
+
outtype = "ascii";
|
|
210
|
+
while ((opt = getopt(argc, argv, "I:T:")) != -1) {
|
|
211
|
+
switch (opt) {
|
|
212
|
+
case 'I':
|
|
213
|
+
defos = optarg;
|
|
214
|
+
break;
|
|
215
|
+
case 'T':
|
|
216
|
+
outtype = optarg;
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
usage();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (argc > 0) {
|
|
224
|
+
argc -= optind;
|
|
225
|
+
argv += optind;
|
|
226
|
+
}
|
|
227
|
+
if (argc != 2)
|
|
228
|
+
usage();
|
|
229
|
+
|
|
230
|
+
if (socketpair(AF_LOCAL, SOCK_STREAM, AF_UNSPEC, srv_fds) == -1)
|
|
231
|
+
err(1, "socketpair");
|
|
232
|
+
|
|
233
|
+
pid = fork();
|
|
234
|
+
switch (pid) {
|
|
235
|
+
case -1:
|
|
236
|
+
err(1, "fork");
|
|
237
|
+
case 0:
|
|
238
|
+
close(srv_fds[0]);
|
|
239
|
+
run_mandocd(srv_fds[1], outtype, defos);
|
|
240
|
+
default:
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
close(srv_fds[1]);
|
|
244
|
+
|
|
245
|
+
if ((dstdir_fd = open(argv[1], O_RDONLY | O_DIRECTORY)) == -1)
|
|
246
|
+
err(1, "open(%s)", argv[1]);
|
|
247
|
+
|
|
248
|
+
if (chdir(argv[0]) == -1)
|
|
249
|
+
err(1, "chdir(%s)", argv[0]);
|
|
250
|
+
|
|
251
|
+
return process_tree(srv_fds[0], dstdir_fd) == -1 ? 1 : 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
void
|
|
255
|
+
usage(void)
|
|
256
|
+
{
|
|
257
|
+
fprintf(stderr, "usage: %s [-I os=name] [-T output] "
|
|
258
|
+
"srcdir dstdir\n", BINM_CATMAN);
|
|
259
|
+
exit(1);
|
|
260
|
+
}
|