diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:08:59 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:08:59 +0000 |
| commit | af770784f1153b346a550363406c57b58d4c2552 (patch) | |
| tree | dcafa0bcf013006b97df6d0d298b4dbf88ea4956 /bk_man.c | |
| parent | efe1dfe08841eb96a97d224c4f975cdfb5107c27 (diff) | |
| download | halibut-af770784f1153b346a550363406c57b58d4c2552.zip halibut-af770784f1153b346a550363406c57b58d4c2552.tar.gz halibut-af770784f1153b346a550363406c57b58d4c2552.tar.bz2 halibut-af770784f1153b346a550363406c57b58d4c2552.tar.xz | |
Add \cfg / -C directives to allow the user to choose the output file
name (or name schema, in HTML).
[originally from svn r4017]
Diffstat (limited to 'bk_man.c')
| -rw-r--r-- | bk_man.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -16,6 +16,7 @@ typedef struct { wchar_t *th; int headnumbers; int mindepth; + char *filename; } manconfig; static manconfig man_configure(paragraph *source) { @@ -27,6 +28,7 @@ static manconfig man_configure(paragraph *source) { ret.th = NULL; ret.headnumbers = FALSE; ret.mindepth = 0; + ret.filename = dupstr("output.1"); for (; source; source = source->next) { if (source->type == para_Config) { @@ -37,12 +39,16 @@ static manconfig man_configure(paragraph *source) { ep = wp; while (*ep) ep = uadv(ep); + sfree(ret.th); ret.th = mknewa(wchar_t, ep - wp + 1); memcpy(ret.th, wp, (ep - wp + 1) * sizeof(wchar_t)); } else if (!ustricmp(source->keyword, L"man-headnumbers")) { ret.headnumbers = utob(uadv(source->keyword)); } else if (!ustricmp(source->keyword, L"man-mindepth")) { ret.mindepth = utoi(uadv(source->keyword)); + } else if (!ustricmp(source->keyword, L"man-filename")) { + sfree(ret.filename); + ret.filename = utoa_dup(uadv(source->keyword)); } } } @@ -53,6 +59,7 @@ static manconfig man_configure(paragraph *source) { static void man_conf_cleanup(manconfig cf) { sfree(cf.th); + sfree(cf.filename); } #define QUOTE_INITCTRL 1 /* quote initial . and ' on a line */ @@ -70,14 +77,11 @@ void man_backend(paragraph *sourceform, keywordlist *keywords, conf = man_configure(sourceform); /* - * Determine the output file name, and open the output file - * - * FIXME: want configurable output file names here. For the - * moment, we'll just call it `output.1'. + * Open the output file. */ - fp = fopen("output.1", "w"); + fp = fopen(conf.filename, "w"); if (!fp) { - error(err_cantopenw, "output.1"); + error(err_cantopenw, conf.filename); return; } |