From fc82ec67a57867817a8056aed8825a8bfbde718f Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 6 Feb 2017 19:02:37 +0000 Subject: Polishing: * support -Ios= * create missing directories * fix output file permissions * error out on comminication failures I now consider this good enough for a first release. Bugs and missing features are still likely, though. --- mandocd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'mandocd.c') diff --git a/mandocd.c b/mandocd.c index 7d76b763..47022606 100644 --- a/mandocd.c +++ b/mandocd.c @@ -1,4 +1,4 @@ -/* $Id: mandocd.c,v 1.2 2017/02/05 22:51:11 schwarze Exp $ */ +/* $Id: mandocd.c,v 1.3 2017/02/06 19:02:37 schwarze Exp $ */ /* * Copyright (c) 2017 Michael Stapelberg * Copyright (c) 2017 Ingo Schwarze @@ -114,6 +114,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 +124,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 +167,7 @@ main(int argc, char *argv[]) mchars_alloc(); parser = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1, - MANDOCLEVEL_BADARG, NULL, NULL); + MANDOCLEVEL_BADARG, NULL, defos); memset(&options, 0, sizeof(options)); switch (outtype) { @@ -266,6 +276,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); } -- cgit v1.2.3