summaryrefslogtreecommitdiff
path: root/bk_text.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-01 17:08:59 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-01 17:08:59 +0000
commitaf770784f1153b346a550363406c57b58d4c2552 (patch)
treedcafa0bcf013006b97df6d0d298b4dbf88ea4956 /bk_text.c
parentefe1dfe08841eb96a97d224c4f975cdfb5107c27 (diff)
downloadhalibut-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_text.c')
-rw-r--r--bk_text.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/bk_text.c b/bk_text.c
index df8ae62..a0ebf82 100644
--- a/bk_text.c
+++ b/bk_text.c
@@ -24,6 +24,7 @@ typedef struct {
int include_version_id;
int indent_preambles;
word bullet;
+ char *filename;
} textconfig;
static int text_convert(wchar_t *, char **);
@@ -76,11 +77,15 @@ static textconfig text_configure(paragraph *source) {
ret.include_version_id = TRUE;
ret.indent_preambles = FALSE;
ret.bullet.text = L"-";
+ ret.filename = dupstr("output.txt");
for (; source; source = source->next) {
if (source->type == para_Config) {
if (!ustricmp(source->keyword, L"text-indent")) {
ret.indent = utoi(uadv(source->keyword));
+ } else if (!ustricmp(source->keyword, L"text-filename")) {
+ sfree(ret.filename);
+ ret.filename = utoa_dup(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-indent-code")) {
ret.indent_code = utoi(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-width")) {
@@ -192,14 +197,11 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
conf = text_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.txt'.
+ * Open the output file.
*/
- fp = fopen("output.txt", "w");
+ fp = fopen(conf.filename, "w");
if (!fp) {
- error(err_cantopenw, "output.txt");
+ error(err_cantopenw, conf.filename);
return;
}
@@ -332,6 +334,7 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
*/
fclose(fp);
sfree(conf.asect);
+ sfree(conf.filename);
}
/*