main.c revision 698f87a48e2e945bfe5493ce168e0d0ae1cedd5c
/* $Id: main.c,v 1.167 2012/11/19 17:22:26 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mandoc.h"
#include "main.h"
#include "mdoc.h"
#include "man.h"
# if !defined(lint)
# define __attribute__(x)
# endif
#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
typedef void (*out_free)(void *);
enum outt {
OUTT_ASCII = 0, /* -Tascii */
OUTT_LOCALE, /* -Tlocale */
OUTT_UTF8, /* -Tutf8 */
OUTT_TREE, /* -Ttree */
OUTT_MAN, /* -Tman */
OUTT_HTML, /* -Thtml */
OUTT_XHTML, /* -Txhtml */
OUTT_LINT, /* -Tlint */
OUTT_PS, /* -Tps */
OUTT_PDF /* -Tpdf */
};
struct curparse {
int wstop; /* stop after a file with a warning */
void *outdata; /* data for output */
};
const char *, int, int, const char *);
const char *, enum mandoclevel *);
static const char *progname;
int
{
int c;
enum mandoclevel rc;
char *defos;
else
++progname;
type = MPARSE_AUTO;
/* LINTED */
switch (c) {
case ('I'):
optarg);
return((int)MANDOCLEVEL_BADARG);
}
if (defos) {
optarg);
return((int)MANDOCLEVEL_BADARG);
}
break;
case ('m'):
return((int)MANDOCLEVEL_BADARG);
break;
case ('O'):
break;
case ('T'):
return((int)MANDOCLEVEL_BADARG);
break;
case ('W'):
return((int)MANDOCLEVEL_BADARG);
break;
case ('V'):
version();
/* NOTREACHED */
default:
usage();
/* NOTREACHED */
}
/*
* Conditionally start up the lookaside buffer before parsing.
*/
rc = MANDOCLEVEL_OK;
while (*argv) {
break;
++argv;
}
return((int)rc);
}
static void
version(void)
{
exit((int)MANDOCLEVEL_OK);
}
static void
usage(void)
{
"[-V] "
"[-Ios=name] "
"[-mformat] "
"[-Ooption] "
"[-Toutput] "
"[-Wlevel]\n"
"\t [file ...]\n",
progname);
exit((int)MANDOCLEVEL_BADARG);
}
static void
{
enum mandoclevel rc;
/* Begin by parsing the file itself. */
/* Stop immediately if the parse has failed. */
if (MANDOCLEVEL_FATAL <= rc)
goto cleanup;
/*
* With -Wstop and warnings or errors of at least the requested
* level, do not produce output.
*/
goto cleanup;
/* If unset, allocate output dev now (if applicable). */
case (OUTT_XHTML):
break;
case (OUTT_HTML):
break;
case (OUTT_UTF8):
break;
case (OUTT_LOCALE):
break;
case (OUTT_ASCII):
break;
case (OUTT_PDF):
break;
case (OUTT_PS):
break;
default:
break;
}
case (OUTT_HTML):
/* FALLTHROUGH */
case (OUTT_XHTML):
break;
case (OUTT_TREE):
break;
case (OUTT_MAN):
break;
case (OUTT_PDF):
/* FALLTHROUGH */
case (OUTT_ASCII):
/* FALLTHROUGH */
case (OUTT_UTF8):
/* FALLTHROUGH */
case (OUTT_LOCALE):
/* FALLTHROUGH */
case (OUTT_PS):
break;
default:
break;
}
}
/* Execute the out device, if it exists. */
}
static int
{
*tflags = MPARSE_MDOC;
*tflags = MPARSE_AUTO;
*tflags = MPARSE_MAN;
else {
return(0);
}
return(1);
}
static int
{
else {
return(0);
}
return(1);
}
static int
{
char *v, *o;
const char *toks[6];
toks[0] = "stop";
while (*arg) {
o = arg;
case (0):
break;
case (1):
/* FALLTHROUGH */
case (2):
break;
case (3):
break;
case (4):
break;
default:
return(0);
}
}
return(1);
}
static void
{
mparse_strerror(t));
if (msg)
}