Hi,
here is a first draft port of the new system to search and display
manual pages online. Kristaps has first presented this system
publicly during BSDCan 2011 in Ottawa.
The attached tarball contains three ports:
* devel/libmutf8-0.2.3
minimal library to validate UTF-8 encoded C strings
* textproc/libhtml-0.3.3
minimal C library for HTML and XHTML documents
* www/mandoc-cgi-0.1.3
search and display manual pages on the web
The first two are pure BUILD_DEPENDS for the latter.
Using the port requires using the very simple base system
patch i include below: It enables building and installing the
mandocdb utility required to build the mandoc database
used by the CGI interface.
Apply the patch like this:
cd /usr/src/usr.bin/mandoc/
cvs up -dP
patch < this.patch
make cleandir
make obj
make depend
make
sudo make install
This doesn't require upgrading any other part of your system.
After that, build all three ports, install mandoc-cgi-0.1.3,
and follow the instructions in:
/usr/local/share/doc/pkg-readmes/mandoc-cgi-0.1.3
For testing, try stuff like this:
* Enter "/var/backups" as the search pattern,
select "Paths" in the "Show only" box,
and you see which tools populate that directory.
* Enter "PAGER" and show only: "Environment Variables",
and you see which utilities respect that variable.
* Enter "EILSEQ" and show only: "Error codes"
and you see which calls produce that obscure error code.
* Enter "Gray" and show only: "Authors"
and you see part of what Jonathan did.
Eventually, the plan is to use this to improve
http://www.openbsd.org/cgi-bin/man.cgi
Obviously, it is not yet compatible enough; but if you don't need
backward compatibility, it's already usable, and i'd like to
get it in to tweak it in the tree.
Some aspects are ugly, but i don't see how to avoid them:
- The www/mandoc-cgi port requires two distribution tarballs.
- The naming is terrible, one is not even versioned, but i will talk
to Kristaps to fix that before the next mandoc-tools release.
- The port downloads and recompiles part of a different
distribution of mandoc(1) than the one we have in base.
However, i consider that better than reacharound from ports
to /usr/src/usr.bin/mandoc, and the code is nearly identical.
- The fixed paths and even more the stripping of /var/www/
in mandoc-cgi.c are ugly hacks, this will be improved later.
- The interface is not yet compatible with man.cgi;
that will be worked on.
Comments?
Ingo
Index: Makefile
===
RCS file: /cvs/src/usr.bin/mandoc/Makefile,v
retrieving revision 1.60
diff -u -p -r1.60 Makefile
--- Makefile18 Sep 2011 15:54:48 - 1.60
+++ Makefile1 Oct 2011 21:26:43 -
@@ -18,7 +18,12 @@ SRCS+= main.c mdoc_term.c chars.c term.c
SRCS+= mdoc_man.c
SRCS+= html.c mdoc_html.c man_html.c out.c eqn_html.c
SRCS+= term_ps.c term_ascii.c tbl_term.c tbl_html.c
+SRCS+= mandocdb.c
PROG= mandoc
+
+LINKS= ${BINDIR}/mandoc ${BINDIR}/mandocdb
+
+MAN= mandoc.1 mandocdb.8
.include
Index: main.c
===
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.78
diff -u -p -r1.78 main.c
--- main.c 17 Sep 2011 14:45:22 - 1.78
+++ main.c 1 Oct 2011 21:26:44 -
@@ -57,6 +57,8 @@ structcurparse {
char outopts[BUFSIZ]; /* buf of output opts */
};
+int mandocdb(int, char**);
+
static int moptions(enum mparset *, char *);
static void mmsg(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
@@ -82,6 +84,9 @@ main(int argc, char *argv[])
progname = argv[0];
else
++progname;
+
+ if (0 == strncmp(progname, "mandocdb", 8))
+ return(mandocdb(argc, argv));
memset(&curp, 0, sizeof(struct curparse));
Index: mandocdb.c
===
RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v
retrieving revision 1.2
diff -u -p -r1.2 mandocdb.c
--- mandocdb.c 17 Sep 2011 13:45:28 - 1.2
+++ mandocdb.c 1 Oct 2011 21:26:45 -
@@ -252,7 +252,7 @@ static const pmdoc_nfmdocs[MDOC_MAX]
static const char *progname;
int
-main(int argc, char *argv[])
+mandocdb(int argc, char *argv[])
{
struct mparse *mp; /* parse sequence */
enum op op; /* current operation */
mandoc-cgi-0.1.3.tgz
Description: application/tar-gz