diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-13 13:17:48 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-13 13:17:48 +0000 |
| commit | ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3 (patch) | |
| tree | cc37e6ee1698c33a72eaf3d818df40795908aa18 /main.c | |
| parent | e9d2a1681a1ba9fa9cee79e197e6d62c3deae7b7 (diff) | |
| download | halibut-ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3.zip halibut-ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3.tar.gz halibut-ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3.tar.bz2 halibut-ddd7bf5b8a173f375cf3de92a4493c0b80cc2de3.tar.xz | |
Initial work on PS and PDF output. Because these two backends share
an enormous amount of preprocessing and differ only in their final
output form, I've introduced a new type of layer called a
`pre-backend' (bk_paper.c is one). This takes all the information
passed to a normal backend and returns an arbitrary void *, which is
cached by the front end and passed on to any backend(s) which state
a desire for the output of that particular pre-backend. Thus, all
the page layout is done only once, and the PS and PDF backends
process the same data structures into two output files.
Note that these backends are _very_ unfinished; all sorts of vital
things such as section numbers, list markers, and title formatting
are missing, the paragraph justification doesn't quite work, and
advanced stuff like indexes and PDF interactive features haven't
even been started. But this basic framework generates valid output
files and is a good starting point, so I'm checking it in.
[originally from svn r4058]
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 62 |
1 files changed, 49 insertions, 13 deletions
@@ -11,20 +11,29 @@ static void dbg_prtsource(paragraph *sourceform); static void dbg_prtwordlist(int level, word *w); static void dbg_prtkws(keywordlist *kws); +static const struct pre_backend { + void *(*func)(paragraph *, keywordlist *, indexdata *); + int bitfield; +} pre_backends[] = { + {paper_pre_backend, 0x0001} +}; + static const struct backend { char *name; - void (*func)(paragraph *, keywordlist *, indexdata *); + void (*func)(paragraph *, keywordlist *, indexdata *, void *); paragraph *(*filename)(char *filename); - int bitfield; + int bitfield, prebackend_bitfield; } backends[] = { - {"text", text_backend, text_config_filename, 0x0001}, - {"xhtml", xhtml_backend, xhtml_config_filename, 0x0002}, - {"html", xhtml_backend, xhtml_config_filename, 0x0002}, - {"hlp", whlp_backend, whlp_config_filename, 0x0004}, - {"whlp", whlp_backend, whlp_config_filename, 0x0004}, - {"winhelp", whlp_backend, whlp_config_filename, 0x0004}, - {"man", man_backend, man_config_filename, 0x0008}, - {"info", info_backend, info_config_filename, 0x0010}, + {"text", text_backend, text_config_filename, 0x0001, 0}, + {"xhtml", xhtml_backend, xhtml_config_filename, 0x0002, 0}, + {"html", xhtml_backend, xhtml_config_filename, 0x0002, 0}, + {"hlp", whlp_backend, whlp_config_filename, 0x0004, 0}, + {"whlp", whlp_backend, whlp_config_filename, 0x0004, 0}, + {"winhelp", whlp_backend, whlp_config_filename, 0x0004, 0}, + {"man", man_backend, man_config_filename, 0x0008, 0}, + {"info", info_backend, info_config_filename, 0x0010, 0}, + {"ps", ps_backend, ps_config_filename, 0x0020, 0x0001}, + {"pdf", pdf_backend, pdf_config_filename, 0x0040, 0x0001}, }; int main(int argc, char **argv) { @@ -34,9 +43,10 @@ int main(int argc, char **argv) { int errs; int reportcols; int debug; - int backendbits; + int backendbits, prebackbits; int k, b; paragraph *cfg, *cfg_tail; + void *pre_backend_data[16]; /* * Set up initial (default) parameters. @@ -307,13 +317,39 @@ int main(int argc, char **argv) { } /* + * Select and run the pre-backends. + */ + prebackbits = 0; + for (k = 0; k < (int)lenof(backends); k++) + if (backendbits == 0 || (backendbits & backends[k].bitfield)) + prebackbits |= backends[k].prebackend_bitfield; + for (k = 0; k < (int)lenof(pre_backends); k++) + if (prebackbits & pre_backends[k].bitfield) { + assert(k < (int)lenof(pre_backend_data)); + pre_backend_data[k] = + pre_backends[k].func(sourceform, keywords, idx); + } + + /* * Run the selected set of backends. */ for (k = b = 0; k < (int)lenof(backends); k++) if (b != backends[k].bitfield) { b = backends[k].bitfield; - if (backendbits == 0 || (backendbits & b)) - backends[k].func(sourceform, keywords, idx); + if (backendbits == 0 || (backendbits & b)) { + void *pbd = NULL; + int pbb = backends[k].prebackend_bitfield; + int m; + + for (m = 0; m < (int)lenof(pre_backends); m++) + if (pbb & pre_backends[m].bitfield) { + assert(m < (int)lenof(pre_backend_data)); + pbd = pre_backend_data[m]; + break; + } + + backends[k].func(sourceform, keywords, idx, pbd); + } } free_para_list(sourceform); |