-/* $Id: main.c,v 1.40 2009/07/27 19:43:02 kristaps Exp $ */
+/* $Id: main.c,v 1.44 2009/09/21 13:06:13 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
# endif
#endif
-typedef int (*out_mdoc)(void *, const struct mdoc *);
-typedef int (*out_man)(void *, const struct man *);
+typedef void (*out_mdoc)(void *, const struct mdoc *);
+typedef void (*out_man)(void *, const struct man *);
typedef void (*out_free)(void *);
struct buf {
enum outt {
OUTT_ASCII = 0,
OUTT_TREE,
+ OUTT_HTML,
OUTT_LINT
};
out_man outman;
out_free outfree;
void *outdata;
+ char *outopts;
};
+extern void *html_alloc(char *);
+extern void html_mdoc(void *, const struct mdoc *);
+extern void html_man(void *, const struct man *);
+extern void html_free(void *);
extern void *ascii_alloc(void);
-extern int tree_mdoc(void *, const struct mdoc *);
-extern int tree_man(void *, const struct man *);
-extern int terminal_mdoc(void *, const struct mdoc *);
-extern int terminal_man(void *, const struct man *);
+extern void tree_mdoc(void *, const struct mdoc *);
+extern void tree_man(void *, const struct man *);
+extern void terminal_mdoc(void *, const struct mdoc *);
+extern void terminal_man(void *, const struct man *);
extern void terminal_free(void *);
static int foptions(int *, char *);
curp.outtype = OUTT_ASCII;
/* LINTED */
- while (-1 != (c = getopt(argc, argv, "f:m:VW:T:")))
+ while (-1 != (c = getopt(argc, argv, "f:m:o:T:VW:")))
switch (c) {
case ('f'):
if ( ! foptions(&curp.fflags, optarg))
if ( ! moptions(&curp.inttype, optarg))
return(EXIT_FAILURE);
break;
+ case ('o'):
+ curp.outopts = optarg;
+ break;
case ('T'):
if ( ! toptions(&curp.outtype, optarg))
return(EXIT_FAILURE);
/* NOTE a parser may not have been assigned, yet. */
if ( ! (man || mdoc)) {
- (void)fprintf(stderr, "%s: not a manual", curp->file);
+ (void)fprintf(stderr, "%s: not a manual\n",
+ curp->file);
return(0);
}
if ( ! (curp->outman && curp->outmdoc)) {
switch (curp->outtype) {
+ case (OUTT_HTML):
+ curp->outdata = html_alloc(curp->outopts);
+ curp->outman = html_man;
+ curp->outmdoc = html_mdoc;
+ curp->outfree = html_free;
+ break;
case (OUTT_TREE):
curp->outman = tree_man;
curp->outmdoc = tree_mdoc;
/* Execute the out device, if it exists. */
if (man && curp->outman)
- if ( ! (*curp->outman)(curp->outdata, man))
- return(-1);
+ (*curp->outman)(curp->outdata, man);
if (mdoc && curp->outmdoc)
- if ( ! (*curp->outmdoc)(curp->outdata, mdoc))
- return(-1);
+ (*curp->outmdoc)(curp->outdata, mdoc);
return(1);
}
*tflags = OUTT_LINT;
else if (0 == strcmp(arg, "tree"))
*tflags = OUTT_TREE;
+ else if (0 == strcmp(arg, "html"))
+ *tflags = OUTT_HTML;
else {
warnx("bad argument: -T%s", arg);
return(0);