-/* $Id: private.h,v 1.22 2008/12/02 13:20:24 kristaps Exp $ */
+/* $Id: private.h,v 1.37 2008/12/10 12:05:33 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
#ifndef PRIVATE_H
#define PRIVATE_H
-/* Input buffer (input read into buffer, then filled when empty). */
+#include <stdio.h>
+#include <time.h>
+
+#include "libmdocml.h"
+
struct md_rbuf {
int fd; /* Open descriptor. */
char *name; /* Name of file. */
char *buf; /* Buffer. */
size_t bufsz; /* Size of buffer. */
size_t line; /* Current line number. */
+#define MD_LINE (BUFSIZ)
+ char linebuf[MD_LINE];
};
-/* Output buffer (output buffered until full, then flushed). */
struct md_mbuf {
int fd; /* Open descriptor. */
char *name; /* Name of file. */
size_t pos; /* Position in buffer. */
};
+#define ROFFTok_Sp_A 0
+#define ROFFTok_Sp_B 1
+#define ROFFTok_Sp_F 2
+#define ROFFTok_Sp_N 3
+#define ROFFTok_Sp_R 4
+#define ROFFTok_Sp_T 5
+#define ROFFTok_Sp_V 6
+#define ROFFTok_Space 7
+#define ROFFTok_Null 8
+#define ROFFTok_Hyphen 9
+#define ROFFTok_Em 10
+#define ROFFTok_En 11
+#define ROFFTok_Ge 12
+#define ROFFTok_Le 13
+#define ROFFTok_Rquote 14
+#define ROFFTok_Lquote 15
+#define ROFFTok_Uparrow 16
+#define ROFFTok_Acute 17
+#define ROFFTok_Grave 18
+#define ROFFTok_Pi 19
+#define ROFFTok_Ne 20
+#define ROFFTok_Lt 21
+#define ROFFTok_Gt 22
+#define ROFFTok_Plusmin 23
+#define ROFFTok_Infty 24
+#define ROFFTok_Bar 25
+#define ROFFTok_Nan 26
+#define ROFFTok_Quote 27
+#define ROFFTok_Sp_0 28
+#define ROFFTok_Slash 29
+#define ROFFTok_MAX 30
+
#define ROFF___ 0
#define ROFF_Dd 1
#define ROFF_Dt 2
#define ROFF_Words 59
#define ROFF_ARGMAX 60
+#define ROFF_MAXLINEARG 32
+
extern const char *const *toknames;
extern const char *const *tokargnames;
-enum roffmsg { ROFF_WARN, ROFF_ERROR };
+enum roffmsg {
+ ROFF_WARN,
+ ROFF_ERROR,
+};
+
+enum roffmsec {
+ ROFF_MSEC_1,
+ ROFF_MSEC_2,
+ ROFF_MSEC_3,
+ ROFF_MSEC_3p,
+ ROFF_MSEC_4,
+ ROFF_MSEC_5,
+ ROFF_MSEC_6,
+ ROFF_MSEC_7,
+ ROFF_MSEC_8,
+ ROFF_MSEC_9,
+ ROFF_MSEC_UNASS,
+ ROFF_MSEC_DRAFT,
+ ROFF_MSEC_PAPER,
+ ROFF_MSEC_MAX,
+};
+
+enum roffatt {
+ ROFF_ATT_V1,
+ ROFF_ATT_V2,
+ ROFF_ATT_V3,
+ ROFF_ATT_V6,
+ ROFF_ATT_V7,
+ ROFF_ATT_32V,
+ ROFF_ATT_V_1,
+ ROFF_ATT_V_4,
+ ROFF_ATT_MAX,
+};
+
+enum roffvol {
+ ROFF_VOL_NONE,
+ ROFF_VOL_AMD,
+ ROFF_VOL_IND,
+ ROFF_VOL_KM,
+ ROFF_VOL_LOCAL,
+ ROFF_VOL_PRM,
+ ROFF_VOL_PS1,
+ ROFF_VOL_SMM,
+ ROFF_VOL_URM,
+ ROFF_VOL_USD,
+#define ROFF_ARCH_START ROFF_ARCH_ALPHA
+ ROFF_ARCH_ALPHA,
+ ROFF_ARCH_AMD64,
+ ROFF_ARCH_AMIGA,
+ ROFF_ARCH_ARC,
+ ROFF_ARCH_ARMISH,
+ ROFF_ARCH_AVIION,
+ ROFF_ARCH_HP300,
+ ROFF_ARCH_HPPA,
+ ROFF_ARCH_HPPA64,
+ ROFF_ARCH_I386,
+ ROFF_ARCH_LANDISK,
+ ROFF_ARCH_LUNA88K,
+ ROFF_ARCH_MAC68K,
+ ROFF_ARCH_MACPPC,
+ ROFF_ARCH_MVME68K,
+ ROFF_ARCH_MVME88K,
+ ROFF_ARCH_MVMEPPC,
+ ROFF_ARCH_PMAX,
+ ROFF_ARCH_SGI,
+ ROFF_ARCH_SPARC,
+ ROFF_ARCH_SPARC64,
+ ROFF_ARCH_SUN3,
+ ROFF_ARCH_VAX,
+ ROFF_ARCH_ZAURUS,
+ ROFF_VOL_MAX,
+};
+
+#define ROFFSec_NMASK (0x07)
+
+#define ROFFSec_NAME (1 << 0)
+#define ROFFSec_SYNOP (1 << 1)
+#define ROFFSec_DESC (1 << 2)
+#define ROFFSec_RETVAL (1 << 3)
+#define ROFFSec_ENV (1 << 4)
+#define ROFFSec_FILES (1 << 5)
+#define ROFFSec_EX (1 << 6)
+#define ROFFSec_DIAG (1 << 7)
+#define ROFFSec_ERRS (1 << 8)
+#define ROFFSec_SEEALSO (1 << 9)
+#define ROFFSec_STAND (1 << 10)
+#define ROFFSec_HIST (1 << 11)
+#define ROFFSec_AUTH (1 << 12)
+#define ROFFSec_CAVEATS (1 << 13)
+#define ROFFSec_BUGS (1 << 14)
+#define ROFFSec_OTHER (1 << 15)
struct roffcb {
- void (*roffmsg)(void *, enum roffmsg,
- const char *, const char *, char *);
- int (*roffhead)(void *);
- int (*rofftail)(void *);
- int (*roffin)(void *, int, int *, char **);
- int (*roffdata)(void *, int, char *);
+ int (*roffmsg)(void *, enum roffmsg,
+ const char *, const char *, const char *);
+ int (*roffhead)(void *, const struct tm *, const char *,
+ const char *, enum roffmsec, enum roffvol);
+ int (*rofftail)(void *, const struct tm *, const char *,
+ const char *, enum roffmsec, enum roffvol);
+ int (*roffdata)(void *, int, const char *, const char *);
+ int (*roffin)(void *, int, int *, const char **);
int (*roffout)(void *, int);
- int (*roffblkin)(void *, int, int *, char **);
+ int (*roffblkin)(void *, int, int *, const char **);
int (*roffblkout)(void *, int);
- int (*roffspecial)(void *, int, int *, char **, char **);
+ int (*roffblkheadin)(void *, int, int *, const char **);
+ int (*roffblkheadout)(void *, int);
+ int (*roffblkbodyin)(void *, int, int *, const char **);
+ int (*roffblkbodyout)(void *, int);
+ int (*roffspecial)(void *, int, const char *,
+ const int *, const char **, const char **);
};
+struct rofftree;
+
__BEGIN_DECLS
typedef void (*(*md_init)(const struct md_args *,
struct md_mbuf *, const struct md_rbuf *));
typedef int (*md_line)(void *, char *);
typedef int (*md_exit)(void *, int);
-
-void *md_init_html4_strict(const struct md_args *,
+void *md_init_html(const struct md_args *,
struct md_mbuf *, const struct md_rbuf *);
-int md_line_html4_strict(void *, char *);
-int md_exit_html4_strict(void *, int);
-
+int md_line_html(void *, char *);
+int md_exit_html(void *, int);
void *md_init_xml(const struct md_args *,
struct md_mbuf *, const struct md_rbuf *);
int md_line_xml(void *, char *);
int md_exit_xml(void *, int);
-
int md_buf_puts(struct md_mbuf *, const char *, size_t);
int md_buf_putchar(struct md_mbuf *, char);
int md_buf_putstring(struct md_mbuf *, const char *);
-
-struct rofftree;
-
struct rofftree *roff_alloc(const struct roffcb *, void *);
int roff_engine(struct rofftree *, char *);
int roff_free(struct rofftree *, int);
+int rofftok_scan(const char *, int *);
+char *roff_literal(int, const int *,
+ const char **, const char **);
+char *roff_fmtstring(int);
+char *roff_msecname(enum roffmsec);
+enum roffmsec roff_msec(const char *);
+int roff_sec(const char **);
+enum roffatt roff_att(const char *);
+enum roffvol roff_vol(const char *);
+char *roff_volname(enum roffvol);
__END_DECLS