/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1996-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* troff to html definitions25*/2627#ifndef _MM2HTML_H28#define _MM2HTML_H 12930#include <ast.h>31#include <ccode.h>32#include <ctype.h>33#include <debug.h>34#include <hash.h>3536#define ARGS 51237#define STKS 51238#define MAXNAME 10243940#define COND_BLOCK (1<<0)41#define COND_EL (1<<1)42#define COND_IE (1<<2)43#define COND_IF (1<<3)44#define COND_KEPT (1<<4)45#define COND_SKIP (1<<5)4647#define TAG_BREAK (1<<0)48#define TAG_COPY (1<<1)49#define TAG_DO (1<<2)50#define TAG_PASS (1<<3)51#define TAG_RAW (1<<4)52#define TAG_STATIC (1<<5)53#define TAG_STATIC_BODY (1<<6)54#define TAG_TRACE_GET (1<<7)55#define TAG_TRACE_SET (1<<8)56#define TAG_TRIGGER (1<<9)5758typedef struct Arg_s59{60int argc; /* number of args */61char* argv[ARGS]; /* arg values */62Sfio_t* sp; /* arg string stream */63} Arg_t;6465struct Tag_s;6667typedef void (*Call_f)(struct Tag_s*, Arg_t*);6869typedef struct Tag_s70{71char* name; /* mm tag name */72Call_f call; /* tag implementation */73unsigned long flags; /* TAG_* flags */74char* body; /* macro body */75char* file; /* definition file */76int line; /* definition line */77int size; /* body size (0 if static) */78} Tag_t;7980typedef struct Dir_s81{82struct Dir_s* next; /* next in list */83char* name; /* directory name */84} Dir_t;8586typedef struct Num_s87{88char* name; /* register name */89char value[64]; /* representation value */90long number; /* numeric value */91int flags; /* TAG_* flags (yes) */92int increment; /* auto increment amount */93char format; /* {0,1,a,A,i,I} */94char internal; /* internal readonly */95} Num_t;9697typedef struct98{99char* path; /* last path on stream */100Sfio_t* sp; /* io stream */101} Stream_t;102103typedef struct Pushin_s104{105unsigned char* in; /* previous state.in */106char* file; /* previous error_info.file */107int line; /* previous error_info.line */108Arg_t* mac; /* previous state.mac */109Arg_t* tag; /* previous state.tag */110Arg_t top; /* new state.tag */111Sfio_t* ip; /* input file stream */112unsigned char* buf; /* input buffer */113unsigned char* end; /* end of input buffer */114Sfio_t* loop; /* loop body stream */115} Pushin_t;116117typedef struct Trap_s118{119struct Trap_s* next; /* next in list */120char name[1]; /* trap name */121} Trap_t;122123typedef struct Value_s124{125int current; /* current value */126int previous; /* previous value */127} Value_t;128129typedef struct Var_s130{131char* name; /* variable name */132char* value; /* variable value */133} Var_t;134135typedef struct Env_s136{137int generation; /* environment generation */138139int c2; /* no-br tag control character */140int cc; /* tag control character */141int ce; /* center state */142int dl; /* output line length */143int dn; /* output line count */144int nf; /* output fill state */145int ss; /* sub/super script state */146147Value_t ft; /* font index */148Value_t in; /* left indent */149Value_t ll; /* line length */150Value_t po; /* page offset */151Value_t ps; /* font size */152Value_t ti; /* temporary indent */153Value_t vs; /* vertical spacing */154155char* name; /* environment name */156157} Env_t;158159typedef struct Divert_s160{161struct Divert_s*next; /* next in list */162Env_t environment; /* diversion environment */163Env_t* env; /* previous state.env */164Sfio_t* sp; /* diversion stream */165Tag_t* tag; /* diversion tag */166} Divert_t;167168typedef struct List_s169{170int dl; /* dl code emitted */171int in; /* data indent */172int ti; /* label indent */173} List_t;174175typedef struct State_s176{177int generation; /* evnironment generation */178Env_t* env; /* current environment */179Env_t* env_stack[STKS];/* environment stack */180Env_t** env_sp; /* environment stack pointer */181unsigned char tag_stack[STKS];/* tag nest stack */182unsigned char* tag_top; /* tag nest stack pointer */183184List_t* list; /* current list state */185List_t list_stack[STKS];/* current list stack */186187unsigned long test; /* test mask */188189int groff; /* groff extensions */190int groff_init; /* groff extensions init */191int dl; /* diversion line length */192int dn; /* diversion line count */193int ec; /* escape character */194int footer; /* footer title emitted */195int head; /* document has head */196int eo; /* ec disabled */197int link; /* current \h...\h'0' code */198int ln; /* output line count */199int n; /* last output line length */200int nl; /* output line position */201int noline; /* '\n' is not line terminator */202int pass; /* pass state */203int pc; /* title page number character */204int silent; /* minimal error messages */205int t; /* distance to next trap */206int verbose; /* verbose messages */207208time_t date; /* global date */209210char* address; /* author address */211char* author; /* document author */212char* background; /* background image */213char* company; /* author company */214char* corporation; /* author corporation */215char* font[6]; /* font index to name map */216char* input; /* first input file */217char* location; /* author location */218char* logo; /* logo/banner image */219char* mailto; /* mail contact */220char* organization; /* author organization */221char* package; /* title prefix */222char* phone; /* author phone */223char* title; /* document title */224char* toolbar; /* junk before </BODY> */225226Arg_t* mac; /* current macro args */227Arg_t* tag; /* current tag args */228Arg_t top; /* top tag arg data */229230Dir_t* dirs; /* include dir list */231Dir_t* hot; /* hot text list */232Dir_t* macros; /* macro packages */233234Divert_t* divert; /* diversion stack */235236Hash_table_t* symbols; /* symbol dictionary */237238Sfio_t* arg; /* arg buffer */239Sfio_t* nul; /* ignored buffer */240Sfio_t* out; /* output file pointer */241Sfio_t* ref; /* reference buffer */242Sfio_t* req; /* request buffer */243Sfio_t* tmp; /* temporary buffer */244245unsigned char* in; /* input buffer pointer */246247unsigned char ta[ARGS]; /* .ta stops */248249Pushin_t in_stack[STKS]; /* input stream stack */250Pushin_t* in_top; /* input stream stack top */251Sfio_t* out_stack[STKS];/* output stream stack */252Sfio_t** out_top; /* output stream stack top */253254Tag_t* define; /* defining this macro */255Tag_t* end; /* end collection with this tag */256257struct258{259int level; /* conditional nesting level */260int flags[STKS]; /* COND_* flags */261} cond;262263struct264{265char trap[MAXNAME+4];/* inline trap invocation */266int center; /* remaining center lines */267int count; /* remaining input lines */268int dc; /* check list indent */269int dd; /* end of list item */270int dl; /* start of list */271int dt; /* start of list item */272int interrupt; /* text interrupted by \c */273int right; /* right justify `center' */274int text; /* output text line count */275} it;276277struct278{279char* file; /* original file */280int line; /* original line */281} original;282283Trap_t* fini; /* fini trap list */284Trap_t* trap; /* normal trap list */285286} State_t;287288extern State_t state;289290#endif291292293