~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to pith/filter.h

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: filter.h 388 2007-01-24 18:57:42Z hubert@u.washington.edu $
 
3
 *
 
4
 * ========================================================================
 
5
 * Copyright 2006-2007 University of Washington
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * ========================================================================
 
14
 */
 
15
 
 
16
#ifndef PITH_FILTER_INCLUDED
 
17
#define PITH_FILTER_INCLUDED
 
18
 
 
19
 
 
20
#include "../pith/filttype.h"
 
21
#include "../pith/handle.h"
 
22
#include "../pith/store.h"
 
23
 
 
24
 
 
25
/* gf_html2plain flags */
 
26
#define GFHP_STRIPPED           0x01
 
27
#define GFHP_HANDLES            0x02
 
28
#define GFHP_LOCAL_HANDLES      0x04
 
29
#define GFHP_NO_RELATIVE        0x08
 
30
#define GFHP_RELATED_CONTENT    0x10
 
31
 
 
32
 
 
33
/* gf_wrap flags */
 
34
#define GFW_HANDLES             0x01    /* anticpate handle data        */
 
35
#define GFW_ONCOMMA             0x02    /* prefer comma wrap to spaces  */
 
36
#define GFW_UTF8                0x04    /* wrapping utf-8 text          */
 
37
#define GFW_FLOWED              0x08
 
38
#define GFW_FLOW_RESULT         0x10
 
39
#define GFW_DELSP               0x20
 
40
#define GFW_USECOLOR            0x40
 
41
 
 
42
 
 
43
#define TAG_EMBED       '\377'  /* Announces embedded data in text string */
 
44
#define TAG_INVON       'A'     /* Supported character attributes         */
 
45
#define TAG_INVOFF      'a'
 
46
#define TAG_BOLDON      'B'
 
47
#define TAG_BOLDOFF     'b'
 
48
#define TAG_ULINEON     'C'
 
49
#define TAG_ULINEOFF    'c'
 
50
#define TAG_FGCOLOR     'D'     /* Change to this foreground color        */
 
51
#define TAG_BGCOLOR     'd'     /* Change to this background color        */
 
52
#define TAG_ITALICON    'E'
 
53
#define TAG_ITALICOFF   'e'
 
54
#define TAG_STRIKEON    'F'
 
55
#define TAG_STRIKEOFF   'f'
 
56
#define TAG_BIGON       'G'
 
57
#define TAG_BIGOFF      'g'
 
58
#define TAG_SMALLON     'H'
 
59
#define TAG_SMALLOFF    'h'
 
60
#define TAG_HANDLE      'Z'     /* indicate's a handle to an action       */
 
61
#define TAG_HANDLEOFF   'z'     /* indicate's end of handle text          */
 
62
 
 
63
 
 
64
/*
 
65
 * This searchs for lines beginning with From<space> so that we can QP-encode
 
66
 * them.  It also searches for lines consisting of only a dot.  Some mailers
 
67
 * will mangle these lines.  The reason it is ifdef'd is because most people
 
68
 * seem to prefer the >From style escape provided by a lot of mail software
 
69
 * to the QP-encoding.
 
70
 * Froms, dots, bmap, and dmap may be any integer type.  C is the next char.
 
71
 * bmap and dmap should be initialized to 1.
 
72
 * froms is incremented by 1 whenever a line beginning From_ is found.
 
73
 * dots is incremented by 1 whenever a line with only a dot is found.
 
74
 */
 
75
#define Find_Froms(froms,dots,bmap,dmap,c) { int x,y;                   \
 
76
                                switch (c) {                            \
 
77
                                  case '\n': case '\r':                 \
 
78
                                    x = 0x1;                            \
 
79
                                    y = 0x7;                            \
 
80
                                    bmap = 0;                           \
 
81
                                    break;                              \
 
82
                                  case 'F':                             \
 
83
                                    x = 0x3;                            \
 
84
                                    y = 0;                              \
 
85
                                    break;                              \
 
86
                                  case 'r':                             \
 
87
                                    x = 0x7;                            \
 
88
                                    y = 0;                              \
 
89
                                    break;                              \
 
90
                                  case 'o':                             \
 
91
                                    x = 0xf;                            \
 
92
                                    y = 0;                              \
 
93
                                    break;                              \
 
94
                                  case 'm':                             \
 
95
                                    x = 0x1f;                           \
 
96
                                    y = 0;                              \
 
97
                                    break;                              \
 
98
                                  case ' ':                             \
 
99
                                    x = 0x3f;                           \
 
100
                                    y = 0;                              \
 
101
                                    break;                              \
 
102
                                  case '.':                             \
 
103
                                    x = 0;                              \
 
104
                                    y = 0x3;                            \
 
105
                                    break;                              \
 
106
                                  default:                              \
 
107
                                    x = 0;                              \
 
108
                                    y = 0;                              \
 
109
                                    break;                              \
 
110
                                }                                       \
 
111
                                bmap = ((x >> 1) == bmap) ? x : 0;      \
 
112
                                froms += (bmap == 0x3f ? 1 : 0);        \
 
113
                                if(y == 0x7 && dmap != 0x3){            \
 
114
                                    y = 0x1;                            \
 
115
                                    dmap = 0;                           \
 
116
                                }                                       \
 
117
                                dmap = ((y >> 1) == dmap) ? y : 0;      \
 
118
                                dots += (dmap == 0x7 ? 1 : 0);          \
 
119
                             }
 
120
 
 
121
 
 
122
/* exported protoypes */
 
123
int         pc_is_picotext(gf_io_t);
 
124
void        gf_set_readc(gf_io_t *, void *, unsigned long, SourceType);
 
125
void        gf_set_writec(gf_io_t *, void *, unsigned long, SourceType, int);
 
126
void        gf_set_so_readc(gf_io_t *, STORE_S *);
 
127
void        gf_clear_so_readc(STORE_S *);
 
128
void        gf_set_so_writec(gf_io_t *, STORE_S *);
 
129
void        gf_clear_so_writec(STORE_S *);
 
130
int         gf_puts(char *, gf_io_t);
 
131
int         gf_nputs(char *, long, gf_io_t);
 
132
void        gf_filter_init(void);
 
133
void        gf_link_filter(filter_t, void *);
 
134
void        gf_set_terminal(gf_io_t);
 
135
char       *gf_pipe(gf_io_t, gf_io_t);
 
136
long        gf_bytes_piped(void);
 
137
char       *gf_filter(char *, char *, STORE_S *, gf_io_t, FILTLIST_S *, int);
 
138
void        gf_binary_b64(FILTER_S *, int);
 
139
void        gf_b64_binary(FILTER_S *, int);
 
140
void        gf_qp_8bit(FILTER_S *, int);
 
141
void        gf_8bit_qp(FILTER_S *, int);
 
142
void        gf_convert_8bit_charset(FILTER_S *, int);
 
143
void        gf_convert_utf8_charset(FILTER_S *, int);
 
144
void       *gf_convert_utf8_charset_opt(void *, int);
 
145
void        gf_2022_jp_to_euc(FILTER_S *, int);
 
146
void        gf_native8bitjapanese_to_2022_jp(FILTER_S *, int);
 
147
void        gf_euc_to_2022_jp(FILTER_S *, int);
 
148
void        gf_sjis_to_2022_jp(FILTER_S *, int);
 
149
void        gf_utf8(FILTER_S *, int);
 
150
void       *gf_utf8_opt(char *);
 
151
void        gf_rich2plain(FILTER_S *, int);
 
152
void       *gf_rich2plain_opt(int);
 
153
void        gf_enriched2plain(FILTER_S *, int);
 
154
void       *gf_enriched2plain_opt(int);
 
155
void        gf_html2plain(FILTER_S *, int);
 
156
void       *gf_html2plain_opt(char *, int, int *, HANDLE_S **, int);
 
157
void        gf_escape_filter(FILTER_S *, int);
 
158
void        gf_control_filter(FILTER_S *, int);
 
159
void       *gf_control_filter_opt(int *);
 
160
void        gf_tag_filter(FILTER_S *, int);
 
161
void        gf_wrap(FILTER_S *, int);
 
162
void       *gf_wrap_filter_opt(int, int, int *, int, int);
 
163
void        gf_preflow(FILTER_S *, int);
 
164
void        gf_prefix(FILTER_S *, int);
 
165
void       *gf_prefix_opt(char *);
 
166
void        gf_line_test(FILTER_S *, int);
 
167
void       *gf_line_test_opt(linetest_t, void *);
 
168
LT_INS_S  **gf_line_test_new_ins(LT_INS_S **, char *, char *, int);
 
169
void        gf_line_test_free_ins(LT_INS_S **);
 
170
void        gf_nvtnl_local(FILTER_S *, int);
 
171
void        gf_local_nvtnl(FILTER_S *, int);
 
172
 
 
173
 
 
174
#endif /* PITH_FILTER_INCLUDED */