=================================================================== RCS file: /cvs/mandoc/mandocd.c,v retrieving revision 1.2 retrieving revision 1.7 diff -u -p -r1.2 -r1.7 --- mandoc/mandocd.c 2017/02/05 22:51:11 1.2 +++ mandoc/mandocd.c 2018/12/13 11:55:46 1.7 @@ -1,4 +1,4 @@ -/* $Id: mandocd.c,v 1.2 2017/02/05 22:51:11 schwarze Exp $ */ +/* $Id: mandocd.c,v 1.7 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2017 Michael Stapelberg * Copyright (c) 2017 Ingo Schwarze @@ -17,6 +17,10 @@ */ #include "config.h" +#if HAVE_CMSG_XPG42 +#define _XPG4_2 +#endif + #include #include @@ -34,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "main.h" #include "manconf.h" @@ -45,7 +50,7 @@ enum outt { static void process(struct mparse *, enum outt, void *); static int read_fds(int, int *); -static void usage(void) __attribute__((noreturn)); +static void usage(void) __attribute__((__noreturn__)); #define NUM_FDS 3 @@ -114,6 +119,7 @@ main(int argc, char *argv[]) struct manoutput options; struct mparse *parser; void *formatter; + const char *defos; const char *errstr; int clientfd; int old_stdin; @@ -123,9 +129,18 @@ main(int argc, char *argv[]) int state, opt; enum outt outtype; + defos = NULL; outtype = OUTT_ASCII; - while ((opt = getopt(argc, argv, "T:")) != -1) { + while ((opt = getopt(argc, argv, "I:T:")) != -1) { switch (opt) { + case 'I': + if (strncmp(optarg, "os=", 3) == 0) + defos = optarg + 3; + else { + warnx("-I %s: Bad argument", optarg); + usage(); + } + break; case 'T': if (strcmp(optarg, "ascii") == 0) outtype = OUTT_ASCII; @@ -157,7 +172,7 @@ main(int argc, char *argv[]) mchars_alloc(); parser = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1, - MANDOCLEVEL_BADARG, NULL, NULL); + MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, defos); memset(&options, 0, sizeof(options)); switch (outtype) { @@ -266,6 +281,6 @@ process(struct mparse *parser, enum outt outtype, void void usage(void) { - fprintf(stderr, "usage: mandocd [-T output] socket_fd\n"); + fprintf(stderr, "usage: mandocd [-I os=name] [-T output] socket_fd\n"); exit(1); }