X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/917cc472b6d91e5bac0a2f3cdf26e113a64ecd45..cab8a64b18366a08e39d04444e5378d33fa153ed:/mandocd.c diff --git a/mandocd.c b/mandocd.c index fce28124..9aba9cc1 100644 --- a/mandocd.c +++ b/mandocd.c @@ -1,4 +1,4 @@ -/* $Id: mandocd.c,v 1.1 2017/02/04 12:03:07 schwarze Exp $ */ +/* $Id: mandocd.c,v 1.6 2017/06/24 14:38:32 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 @@ -24,6 +28,7 @@ #include #endif #include +#include #include #include #include @@ -44,7 +49,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 @@ -113,6 +118,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; @@ -122,9 +128,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; @@ -156,7 +171,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) { @@ -265,6 +280,6 @@ process(struct mparse *parser, enum outt outtype, void *formatter) 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); }