2
* Copyright (c) Karl Dahlke, 2008
3
* This file is part of the edbrowse project, released under GPL.
9
/* the symbol DOSLIKE is used to conditionally compile those constructs
10
* that are common to DOS and NT, but not typical of Unix. */
18
/* System V or system BSD? */
19
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD)
23
/* seems like everybody needs these header files */
24
#include <sys/types.h>
33
#include <curl/curl.h>
52
/* Some error constants that aren't defined in older versions of libcurl.
53
* I'm not too worried about them, because the catch-all handles so many
54
* things.. Plus, everyone will eventually be using the latest libcurl. */
55
#ifndef CURLE_PEER_FAILED_VERIFICATION
56
#define CURLE_PEER_FAILED_VERIFICATION -1
58
#ifndef CURLE_REMOTE_ACCESS_DENIED
59
#define CURLE_REMOTE_ACCESS_DENIED -2
62
/* WARNING: the following typedef is pseudo-standard in C.
63
* Some systems will define ushort in sys/types.h, others will not.
64
* Unfortunately there is no #define symbol to key on;
65
* no way to conditionally compile the following statement. */
67
typedef unsigned short ushort;
68
typedef unsigned long ulong;
70
/* sys/types.h defines unsigned char as unchar. I prefer uchar.
71
* It is consistent with ushort uint and ulong, and doesn't remind
72
* me of the uncola, a char that isn't really a char. */
73
typedef unsigned char uchar;
75
/* We use uchar for boolean fields. */
80
typedef ushort idNameCode;
82
#define stringEqual !strcmp
84
/* ctype macros, when you're passing a byte,
85
* and you don't want to worry about whether it's char or uchar.
86
* Call the regular routines when c is an int, from fgetc etc. */
87
#define isspaceByte(c) isspace((uchar)c)
88
#define isalphaByte(c) isalpha((uchar)c)
89
#define isalnumByte(c) isalnum((uchar)c)
90
#define islowerByte(c) islower((uchar)c)
91
#define isupperByte(c) isupper((uchar)c)
92
#define isdigitByte(c) isdigit((uchar)c)
93
#define ispunctByte(c) ispunct((uchar)c)
94
#define isprintByte(c) isprint((uchar)c)
96
/* http encoding, content type, content transfer encoding */
97
enum { ENC_PLAIN, ENC_COMPRESS, ENC_GZIP, ENC_URL, ENC_MFD };
98
enum { CT_OTHER, CT_TEXT, CT_HTML, CT_RICH, CT_APPLIC, CT_MULTI, CT_ALT };
99
enum { CE_7BIT, CE_8BIT, CE_QP, CE_64 };
101
/* This program was originally written in perl.
102
* So I got use to perl strings, which admit nulls.
103
* In our case, they will be terminated by newline. */
104
typedef uchar *pst; /* perl string */
106
/* A specific nonascii char denotes an html tag
107
* in the rendered html text.
108
* See the comments in bufsub.c for the rationale. */
109
#define InternalCodeChar '\2'
110
#define InternalCodeCharAlternate '\1'
112
/* How long can a regular expression be? */
114
/* How long can an entered line be? */
115
#define MAXTTYLINE 256
116
/* Longest line that can take the substitute command */
117
#define REPLACELINELEN 50000
118
/* The longest string, in certain contexts. */
119
#define MAXSTRLEN 1024
120
/* How about user login and password? */
121
#define MAXUSERPASS 40
122
/* Number of pop3 mail accounts */
123
#define MAXACCOUNT 100
124
/* Number of mime types */
126
/* number of db tables */
129
/* How many sessions open concurrently */
130
#define MAXSESSION 1000
131
/* Allocation increment for a growing string, that we don't expect
132
* to get too large. This must be a power of 2. */
133
#define ALLOC_GR 0x100
142
/* left and top borders for dialog box, stubs. */
145
#define COLOR_DIALOG_TEXT 0
146
#define G_BFU_FONT_SIZE 0
148
/* the version of edbrowse */
149
extern const char *version;
150
extern const char eol[]; /* internet end of line */
151
extern char EMPTYSTRING[]; /* use this whenever you would use "" */
153
/* Here are the strings you can send out to identify this browser.
154
* Most of the time we will send out the first string, edbrowse-2.15.3.
155
* But sometimes we have to lie.
156
* When you deal with clickbank, for instance, they won't let you in the
157
* door unless you are one of three approved browsers.
158
* I've written to them about this particular flavor of stupidity,
159
* but they obviously don't care. So lie!
160
* Tell them you're Explorer, and walk right in.
161
* Anyways, this array holds up to 10 user agent strings. */
162
extern char *userAgents[10], *currentAgent;
164
struct MACCOUNT { /* pop3 account */
165
char *login, *password, *from, *reply;
166
char *inurl, *outurl;
173
char *suffix, *prot, *program;
178
char *name, *shortname;
179
char *cols[MAXTCOLS];
181
unsigned char key1, key2, key3, key4;
186
/* various globals */
187
extern CURL *curl_handle;
188
extern int debugLevel; /* 0 to 9 */
189
extern int displayLength; /* when printing a line */
190
extern int webTimeout, mailTimeout;
191
extern int browseLine; /* line number, for error reporting */
192
extern bool ismc; /* Is the program running as a mail client? */
193
extern bool cons_utf8; /* does the console expect utf8? */
194
extern bool iuConvert; /* perform iso utf8 conversions automatically */
195
extern char type8859; /* 1 through 15 */
196
extern bool zapMail; /* just get rid of the mail */
197
extern bool js_redirects; /* window.location = new_url */
198
extern uchar browseLocal; /* browsing a local file */
199
extern bool parsePage; /* parsing the html page, and any java therein */
200
extern bool htmlAttrVal_nl; /* allow nl in the attribute of an html tag */
201
extern bool unformatMail; /* suppress formatting */
202
extern bool passMail; /* pass mail across the filters */
203
extern bool errorExit; /* exit on any error, for scripting purposes */
204
extern bool isInteractive;
205
extern volatile bool intFlag; /* set this when interrupt signal is caught */
206
extern bool binaryDetect;
207
extern bool inputReadLine;
208
extern bool listNA; /* list nonascii chars */
209
extern bool inInput; /* reading line from standard in */
210
extern int fileSize; /* when reading/writing files */
211
extern int maxFileSize; /* max size of an editable file */
212
extern int mssock; /* mail server socket */
213
extern int hcode; /* http code, like 404 file not found */
214
extern char herror[]; /* html error */
215
extern char errorMsg[]; /* generated error message */
216
extern char serverLine[]; /* lines to and from the mail server */
217
extern void *jcx; /* javascript context */
218
extern void *jwin; /* javascript window object */
219
extern void *jdoc; /* javascript document object */
220
extern void *jwloc; /* javascript window.location */
221
extern void *jdloc; /* javascript document.location */
222
extern int maxAccount; /* how many email accounts specified */
223
extern int localAccount; /* this is the smtp server for outgoing mail */
224
extern char *mailDir; /* move to this directory when fetching mail */
225
extern struct MACCOUNT accounts[]; /* all the email accounts */
226
extern int maxMime; /* how many mime types specified */
227
extern struct MIMETYPE mimetypes[];
228
extern char *dbarea, *dblogin, *dbpw; /* to log into the database */
229
extern bool fetchBlobColumns;
230
extern char *proxy_host;
231
extern bool caseInsensitive, searchStringsAll;
232
extern bool undoable; /* an undoable operation is taking place */
233
extern bool allowRedirection; /* from http code 301, or http refresh */
234
extern bool sendReferrer; /* in the http header */
235
extern bool allowJS; /* javascript on */
236
extern bool helpMessagesOn; /* no need to type h */
237
extern bool showHiddenFiles; /* during directory scan */
238
extern uchar dirWrite; /* directory write mode, e.g. rename files */
239
extern uchar endMarks; /* do we print ^ $ at the start and end of lines? */
240
extern int context; /* which session (buffer) are we in? */
241
extern uchar linePending[];
242
extern char *changeFileName;
243
extern char *addressFile; /* your address book */
244
extern char *ipbFile; /* file holding ip blacklist */
245
extern char *serverData;
246
extern int serverDataLen;
247
extern char replaceLine[];
248
extern char *currentReferrer;
249
extern char *home; /* home directory */
250
extern char *recycleBin; /* holds deleted files */
251
extern char *configFile, *sigFile;
252
extern char *cookieFile; /* persistent cookies */
253
extern char *spamCan; /* dump spam emails */
254
extern char *edbrowseTempFile;
255
extern char *edbrowseTempPDF;
256
extern char *edbrowseTempHTML;
258
/* Ok, this is kinda simple and stupid.
259
* Every line in every window in every session is a string, without the
260
* newline, and all these strings are managed by an array of pointers.
261
* So your particular buffer may have 3 lines in it,
262
* and these are represented internally by three numbers, 12 29 and 83.
263
* So the text is textLines[12], textLines[29], textLines[83].
264
* Now, if you copy a line of text, I actually copy the string.
265
* This is a waste I suppose, but then I don't have to worry about
266
* what happens if you edit one line and not the other.
267
* They're already separate strings, so we're ok. */
268
extern pst *textLines;
269
extern int textLinesMax, textLinesCount; /* size of textLines array */
271
/* If a file has 30 lines, it is represented by 30 numbers,
272
* indexes into textLines[] above.
273
* Should we use an array of numbers, or a string of numbers
274
* represented by decimal digits?
275
* Both are painful, in different ways.
276
* Consider inserting a block of text, a very common operation.
277
* In a list, we would have to slide all the following numbers down.
278
* Granted, that's better than moving all those lines of text,
279
* but it's still a pain to program, and somewhat inefficient.
280
* If we use strings, we take the original string of numbers,
281
* break it at the insert point, and make a new string
282
* by concatenating these two pieces with the new block.
283
* The same issues arise when deleting text near the top of a file.
284
* This and other considerations push me towards strings.
285
* I currently use 6 characters for a line number,
286
* a seventh for the g// flag.
288
* and 9 and 10 hold the directory suffix.
289
* You know, the slash that we put on the end of a directory,
290
* or the | on the end of a fifo etc.
291
* Thus the following definitions. */
292
#define LNMAX 1000000
295
#define LNFORMAT "%06d "
302
/* Macros to loop through the items in a list. */
303
#define foreach(e,l) for((e)=(l).next; \
304
(e) != (void*)&(l); \
305
(e) = ((struct listHead *)e)->next)
306
#define foreachback(e,l) for((e)=(l).prev; \
307
(e) != (void*)&(l); \
308
(e) = ((struct listHead *)e)->prev)
310
/* an edbrowse window */
312
/* windows stack up as you open new files or follow hyperlinks.
313
* Use the back command to pop the stack.
314
* The back command follows this link, which is 0 if you are at the top. */
315
struct ebWindow *prev;
316
/* This is right out of the source for ed. Current and last line numbers. */
318
/* remember dot and dol for the raw text, when in browse mode */
320
char *fileName; /* name of file or url */
321
char *firstURL; /* before http redirection */
323
char *baseDirName; /* when scanning a directory */
324
char *ft, *fd, *fk; /* title, description, keywords */
326
char lhs[MAXRE], rhs[MAXRE]; /* remembered substitution strings */
327
char *map; /* indexes into textLines[] */
329
/* The labels that you set with the k command, and access via 'x.
330
* Basically, that's 26 line numbers.
331
* Number 0 means the label is not set. */
332
int labels[26], r_labels[26];
333
/* Yeah, these could be bit fields in the structure :1; but who cares. */
334
bool lhs_yes, rhs_yes;
335
bool binMode; /* binary file */
336
bool nlMode; /* newline at the end */
338
/* Two text modes; these are incompatible with binMode */
341
bool browseMode; /* browsing html */
342
bool changeMode; /* something has changed in this file */
343
bool dirMode; /* directory mode */
344
bool firstOpMode; /* first change has been made, undo is possible */
345
bool jsdead; /* javascript is dead, for this window */
346
bool sqlMode; /* accessing a table */
347
char *dw; /* document.write string */
348
int dw_l; /* length of the above */
349
void *tags; /* array of html tags, when browsing */
350
IP32bit *iplist; /* ip addresses referenced by this page */
351
void *jsc; /* js context, if in browse mode, and running javascript */
352
struct DBTABLE *table; /* if in sqlMode */
354
extern struct ebWindow *cw; /* current window */
356
/* An edit session */
358
struct ebWindow *fw, *lw; /* first window, last window */
360
extern struct ebSession sessionList[];
361
extern struct ebSession *cs; /* current session */
364
/* function prototypes */
367
/* Symbolic constants for language independent messages */
368
#include "messages.h"