Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/html/html2rtf.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1996-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* html to rtf definitions
26
*/
27
28
#ifndef _HTML2RTF_H
29
#define _HTML2RTF_H 1
30
31
#include <ast.h>
32
#include <ctype.h>
33
#include <hash.h>
34
35
#define twips(x) ((x)*2)
36
37
#define FONTSIZE 12 /* default font size */
38
39
#define ENT_SPACE (1<<0) /* translates to trailing space */
40
41
#define STK_HEADING (1<<0) /* element contains <Hn> */
42
#define STK_NOEND (1<<1) /* don't call </x> */
43
#define STK_TAG (1<<8) /* first tag specific bit */
44
45
#define TAG_UNBALANCED (1<<0) /* </x> without <x> ok */
46
#define TAG_IGNORE (1<<1) /* ignore element text */
47
48
typedef struct Attribute_s
49
{
50
char* name; /* attribute name */
51
char* value; /* optional attribute value */
52
} Attribute_t;
53
54
struct Tag_s;
55
56
typedef int (*Call_f)(struct Tag_s*, Attribute_t*);
57
58
typedef struct Entity_s
59
{
60
const char* name; /* entity name */
61
const char* value; /* entity value */
62
unsigned long flags; /* ENT_* flags */
63
} Entity_t;
64
65
typedef struct Tag_s
66
{
67
const char* name; /* html tag name */
68
Call_f start; /* tag start */
69
Call_f end; /* optional tag end */
70
void* data; /* optional data */
71
unsigned long flags; /* TAG_* flags */
72
} Tag_t;
73
74
typedef struct
75
{
76
int tags; /* # tags in rendering */
77
Tag_t* tag[1]; /* rendering tags */
78
} Render_t;
79
80
typedef union Data_u
81
{
82
Sfio_t* io;
83
int number;
84
void* pointer;
85
char* string;
86
} Data_t;
87
88
typedef struct Stack_s
89
{
90
Tag_t* tag; /* active tag */
91
unsigned int line; /* line */
92
unsigned int flags; /* STK_* flags */
93
Data_t data[8]; /* tag specific data */
94
} Stack_t;
95
96
typedef struct State_s
97
{
98
int center; /* center nesting level */
99
int fontsize; /* current font size */
100
int hanging; /* current left hanging indent */
101
int indent; /* current left indent */
102
int pre; /* <PRE> nesting level */
103
int sep; /* output control needs sep */
104
int verbose; /* verbose messages */
105
106
char* project; /* project file name */
107
char* prefix; /* label prefix */
108
109
Sfio_t* in; /* input file pointer */
110
Sfio_t* nul; /* ignored buffer */
111
Sfio_t* out; /* output file pointer */
112
Sfio_t* tmp; /* temporary buffer */
113
114
Stack_t* sp; /* tag stack pointer */
115
Stack_t* sp_max; /* highest sp */
116
Stack_t* sp_min; /* lowest sp */
117
118
Hash_table_t* entities; /* entity dictionary */
119
Hash_table_t* files; /* project file dictionary */
120
Hash_table_t* tags; /* tag dictionary */
121
122
} State_t;
123
124
extern State_t state;
125
126
#endif
127
128