diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-02-06 19:02:37 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-02-06 19:02:37 +0000 |
commit | fc82ec67a57867817a8056aed8825a8bfbde718f (patch) | |
tree | dba107f5dff80e9b586652471a3ba8924beb3a16 /mandocd.c | |
parent | d4f22904a2c95e6e37afb6ff6303673a185d3595 (diff) | |
download | mandoc-fc82ec67a57867817a8056aed8825a8bfbde718f.tar.gz mandoc-fc82ec67a57867817a8056aed8825a8bfbde718f.tar.zst mandoc-fc82ec67a57867817a8056aed8825a8bfbde718f.zip |
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.
Diffstat (limited to 'mandocd.c')
-rw-r--r-- | mandocd.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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 <stapelberg@debian.org> * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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); } |