/*
* Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
/**
** This program parses mutt's init.h and generates documentation in
** three different formats:
**
** -> a commented muttrc configuration file
** -> nroff, suitable for inclusion in a manual page
** -> linuxdoc-sgml, suitable for inclusion in the
** SGML-based manual
**
**/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
#ifndef HAVE_STRERROR
#ifndef STDC_HEADERS
extern int sys_nerr;
extern char *sys_errlist[];
#endif
#define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0
#endif /* !HAVE_STRERROR */
extern int optind;
#define BUFFSIZE 2048
enum output_formats_t
{
F_CONF, F_MAN, F_SGML, F_NONE
};
#define D_NL (1 << 0)
#define D_EM (1 << 1)
#define D_BF (1 << 2)
#define D_TAB (1 << 3)
#define D_NP (1 << 4)
#define D_INIT (1 << 5)
#define D_DL (1 << 6)
#define D_DT (1 << 7)
enum
{
SP_START_EM,
SP_START_BF,
SP_END_FT,
SP_NEWLINE,
SP_NEWPAR,
SP_STR,
SP_START_TAB,
SP_END_TAB,
SP_START_DL,
SP_DT,
SP_DD,
SP_END_DL,
SP_REFER
};
enum output_formats_t OutputFormat = F_NONE;
char *Progname;
short Debug = 0;
static char *get_token (char *, size_t, char *);
static char *skip_ws (char *);
static const char *type2human (int);
static int buff2type (const char *);
static int flush_doc (int, FILE *);
static int handle_docline (char *, FILE *, int);
static int print_it (int, char *, FILE *, int);
static void print_confline (const char *, int, const char *, FILE *);
static void handle_confline (char *, FILE *);
static void makedoc (FILE *, FILE *);
static void pretty_default (char *, size_t, const char *, int);
static int sgml_fputc (int, FILE *);
static int sgml_fputs (const char *, FILE *);
int main (int argc, char *argv[])
{
int c;
FILE *f;
if ((Progname = strrchr (argv[0], '/')))
Progname++;
else
Progname = argv[0];
while ((c = getopt (argc, argv, "cmsd")) != EOF)
{
switch (c)
{
case 'c': OutputFormat = F_CONF; break;
ca