-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhyp.h
399 lines (338 loc) · 9.32 KB
/
hyp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
/*
* HypView - (c) 2001 - 2006 Philipp Donze
* 2006 - Philipp Donze & Odd Skancke
*
* A replacement hypertext viewer
*
* This file is part of HypView.
*
* HypView is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* HypView is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HypView; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _hyp_h
#define _hyp_h 1
#include <compiler.h> /* for inline macro */
#ifndef _dl_miss_h
typedef short EVNTDATA[4];
#endif
#ifndef __GEMLIB_DEFS
typedef long MFDB;
#endif
#ifndef _diallib_h
typedef long WINDOW_DATA;
#endif
#ifndef DEFS_H
typedef long DOCUMENT;
typedef long TEXT_POS;
typedef long BLOCK;
#endif
/*
* Datei-bedingte Strukturen
*/
typedef struct
{
char magic[4]; /* Magic constant 'HDOC' */
long itable_size; /* Length of index table in bytes */
unsigned short itable_num; /* Number of entries in table */
unsigned char compiler_vers; /* Hypertext compiler version */
unsigned char compiler_os; /* Operating system used for translation */
}HYP_HEADER;
/* Valid values for HYP_HEADER->compiler_os */
enum {UNKNOWN_OS = 0, AMIGA_OS, ATARI_OS, MAC_OS};
typedef struct
{
unsigned char length; /* Length */
unsigned char type; /* Type */
unsigned long seek_offset; /* File seek offset*/
unsigned short comp_diff; /* Difference packed/unpacked in bytes */
unsigned short next; /* Index of successor entry */
unsigned short previous; /* Index of predecessor entry */
unsigned short dir_index; /* Index of directory/parent entry*/
char name; /* First character of 0-terminated entry name */
}INDEX_ENTRY;
/* Valid values for INDEX_ENTRY->type */
enum {
INTERNAL = 0, POPUP, EXTERNAL_REF, PICTURE,
SYSTEM_ARGUMENT, REXX_SCRIPT, REXX_COMMAND, QUIT
};
/* ESC values used in (p)nodes */
#define WINDOWTITLE 35 /* Window title */
#define LINK 36 /* link */
#define ALINK 38 /* alink */
#define EXTERNAL_REFS 48 /* external data block */
#define OBJTABLE 49 /* table with objects */
#define PIC 50 /* picture */
#define LINE 51 /* line */
#define BOX 52 /* box */
#define RBOX 53 /* rounded box */
#define TEXT_ATTRIBUTES 100 /* text/font attribute */
#define LINEY 0x100
/* picture header structure*/
typedef struct
{
unsigned short width; /* width in pixels */
unsigned short height; /* height in pixel */
unsigned char planes; /* number of planes (1..8) */
unsigned char plane_pic; /* available planes bit vector */
unsigned char plane_on_off; /* filled plane bit vector */
unsigned char filler; /* fill byte used to align size of structure */
}HYP_PICTURE;
/* Storage structure for an entry in memory */
typedef struct
{
unsigned short number;
void *start;
unsigned long size;
}LOADED_ENTRY;
/*
* Definitions used by loading routines
*/
enum
{
REF_FILENAME = 0, REF_NODENAME, REF_ALIASNAME, REF_LABELNAME,
REF_DATABASE, REF_OS
};
typedef struct
{
long module_len;
long num_entries;
char start;
}REF_FILE;
typedef struct
{
unsigned short num_index; /* Number of entries in hypertext file */
unsigned char comp_vers; /* Version of compiler used for translation */
unsigned char comp_os; /* Operating system ID */
short st_guide_flags; /* Special ST-Guide flags (encryption, ...) */
short line_width; /* Line width to use for display (@width) */
char *database; /* Description for hypertext database (@database) */
char *hostname; /* Name of host applikation (@hostname) */
char *author; /* Name of authors (@author) */
char *version; /* Hypertext version string (@$VER:) */
INDEX_ENTRY **indextable; /* Pointer to index table */
void **cache; /* Pointer to cache table */
LOADED_ENTRY *entry; /* Currently displayed entry */
char *file; /* Full access path to file */
short index_page; /* Page number of hypertext index */
short default_page; /* Page number of default page (@default) */
short help_page; /* Page number of help page */
REF_FILE *ref; /* Pointer to REF file structure */
}HYP_DOCUMENT;
/* Valid values for HYP_DOCUMENT->st_guide_flags */
#define STG_ENCRYPTED 0x200
struct lineptr
{
short x, y, w, h;
char *txt;
};
typedef struct lineptr LINEPTR;
typedef struct
{
unsigned short number; /* Page number of this entry */
char *start; /* Pointer to start of data */
char *end; /* Pointer to end of data */
long lines, columns; /* Number of lines and columns */
long height;
char *window_title; /* Pointer to window title */
LINEPTR *line_ptr;
}LOADED_NODE;
struct _loaded_picture_;
struct _loaded_picture_
{
unsigned short number;
MFDB mfdb;
};
typedef struct _loaded_picture_ LOADED_PICTURE;
struct pic_adm
{
short type;
unsigned short flags;
char *src;
char osrc[8];
void *data;
GRECT trans;
GRECT orig;
};
struct prepnode
{
HYP_DOCUMENT *hyp;
LOADED_NODE *node;
struct pic_adm *pic_adm;
short pic_count;
short pic_idx;
LINEPTR *line_ptr;
long y, h;
short line;
short min_lines;
short empty;
short empty_lines;
short empty_start;
short limage_add;
short start_idx;
short start_y;
short start_line;
short between;
long y_start;
short last_line;
short last_width;
long last_y;
short width;
};
/* Decode MACRO */
#define DEC_255(ptr) (unsigned short) ((((unsigned char *)ptr)[1] - 1 ) * 255 + ((unsigned char *)ptr)[0] - 1)
static inline short
dec_from_chars(unsigned char *ptr)
{
unsigned short val;
val = (ptr[1] - 1) * 255;
val += ptr[0];
val--;
return val;
}
static inline void
dec_to_chars(unsigned short _val, unsigned char *ptr)
{
ptr[0] = (unsigned char)(_val);
ptr[1] = (unsigned char)((unsigned long)_val / 255) + 1;
ptr[0] += ptr[1];
}
static inline void
long_to_chars(long _val, char *p)
{
union { char c[4]; long l[1]; } val;
val.l[0] = _val;
*p++ = val.c[0];
*p++ = val.c[1];
*p++ = val.c[2];
*p = val.c[3];
}
static inline long
long_from_chars(char *p)
{
union { char c[4]; long l[1]; } val;
val.c[0] = *p++;
val.c[1] = *p++;
val.c[2] = *p++;
val.c[3] = *p;
return val.l[0];
}
/*
* Hyp.c
*/
short HypLoad(DOCUMENT *doc, short handle);
void HypClose(DOCUMENT *doc);
long HypGetNode(DOCUMENT *doc);
long HypFindNode(DOCUMENT *doc, char *chapter);
void HypGotoNode(DOCUMENT *doc, char *chapter,long node_num);
/*
* Load.c
*/
long GetDataSize(HYP_DOCUMENT *doc,long nr);
void *LoadData(HYP_DOCUMENT *doc,long nr, long *data_size);
void GetEntryBytes(HYP_DOCUMENT *doc,long nr,void *src,void *dst,long bytes);
/*
* Tool.c
*/
short find_nr_by_title(HYP_DOCUMENT *hyp_doc,char *title);
char *skip_esc(char *pos);
/*
* Cache.c
*/
long GetCacheSize(long num_elements);
void InitCache(HYP_DOCUMENT *hyp);
void ClearCache(HYP_DOCUMENT *hyp);
void TellCache(HYP_DOCUMENT *hyp, long node_num,void *node);
void *AskCache(HYP_DOCUMENT *hyp, long node_num);
void RemoveNodes(HYP_DOCUMENT *hyp);
/*
* Prepare.c
*/
short PrepareNode(HYP_DOCUMENT *hyp, LOADED_NODE *node);
/*
* Display.c
*/
extern HYP_DOCUMENT *Hyp;
void HypDisplayPage(DOCUMENT *doc);
/*
* Lh5d.c
*/
extern char *lh5_packedMem;
extern long lh5_packedLen;
extern char *lh5_unpackedMem;
extern long lh5_unpackedLen;
void lh5_decode(short reset);
/*
* Click.c
*/
void HypClick(DOCUMENT *doc, EVNTDATA *event);
/*
* Popup.c
*/
typedef struct
{
DOCUMENT *doc;
long lines,cols;
short x,y;
void *entry;
}POPUP_INFO;
void OpenPopup(DOCUMENT *doc, long num, short x, short y);
/*
* Autoloc.c
*/
LINEPTR *HypGetYLine(LOADED_NODE *node, long y);
short HypGetLineY ( LOADED_NODE *node, long line );
long HypGetRealTextLine ( LOADED_NODE *node, short y );
void HypGetTextLine(HYP_DOCUMENT *hyp, long line,char *dst );
long HypAutolocator(DOCUMENT *doc,long line);
/*
* Cursor.c
*/
void HypGetCursorPosition(DOCUMENT *doc,short x, short y, TEXT_POS *pos);
/*
* Block.c
*/
short HypBlockOperations(DOCUMENT *doc, short op, BLOCK *block, void *param);
/*
* Ref.c
*/
typedef struct _result_entry_
{
struct _result_entry_ *next;
short selected;
char str[256];
char path[256];
char dbase_description[256];
char node_name[256];
unsigned short line;
short is_label;
} RESULT_ENTRY;
REF_FILE *ref_load(short handle);
char *ref_find(REF_FILE *ref, short type);
short ref_findnode(REF_FILE *ref, char *string, long *node, short *line);
RESULT_ENTRY *ref_findall(REF_FILE *ref, char *string, short *num_results);
/*
* Ext_Refs.c
*/
short HypCountExtRefs(LOADED_NODE *entry);
void HypExtRefPopup(DOCUMENT *doc, short x, short y);
void HypOpenExtRef(char *name, short new_window);
/*
* Search.c
*/
void search_allref(char *string, short no_message );
/*
* Search_D.c
*/
void HypfindFinsih ( short AppID, short ret );
#endif