Debian Codegraph @

garglk/cheapglk/gi_blorb.h

raw symbols SCIP
1 #ifndef GARGLK_GI_BLORB_H
2 #define GARGLK_GI_BLORB_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 /* gi_blorb.h: Blorb library layer for Glk API.
9 gi_blorb version 1.6.1.
10 Designed by Andrew Plotkin <[email protected]>
11 http://eblong.com/zarf/glk/
12
13 This file is copyright 1998-2017 by Andrew Plotkin. It is
14 distributed under the MIT license; see the "LICENSE" file.
15 */
16
17 /* Error type and error codes */
18 typedef glui32 giblorb_err_t;
19 #define giblorb_err_None (0)
20 #define giblorb_err_CompileTime (1)
21 #define giblorb_err_Alloc (2)
22 #define giblorb_err_Read (3)
23 #define giblorb_err_NotAMap (4)
24 #define giblorb_err_Format (5)
25 #define giblorb_err_NotFound (6)
26
27 /* Methods for loading a chunk */
28 #define giblorb_method_DontLoad (0)
29 #define giblorb_method_Memory (1)
30 #define giblorb_method_FilePos (2)
31
32 /* Four-byte constants */
33
34 #define giblorb_make_id(c1, c2, c3, c4) \
35 (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
36
37 #define giblorb_ID_Exec (giblorb_make_id('E', 'x', 'e', 'c'))
38 #define giblorb_ID_Snd (giblorb_make_id('S', 'n', 'd', ' '))
39 #define giblorb_ID_Pict (giblorb_make_id('P', 'i', 'c', 't'))
40 #define giblorb_ID_Data (giblorb_make_id('D', 'a', 't', 'a'))
41 #define giblorb_ID_Copyright (giblorb_make_id('(', 'c', ')', ' '))
42 #define giblorb_ID_AUTH (giblorb_make_id('A', 'U', 'T', 'H'))
43 #define giblorb_ID_ANNO (giblorb_make_id('A', 'N', 'N', 'O'))
44 #define giblorb_ID_TEXT (giblorb_make_id('T', 'E', 'X', 'T'))
45 #define giblorb_ID_BINA (giblorb_make_id('B', 'I', 'N', 'A'))
46 #define giblorb_ID_JPEG (giblorb_make_id('J', 'P', 'E', 'G'))
47 #define giblorb_ID_PNG (giblorb_make_id('P', 'N', 'G', ' '))
48
49 /* giblorb_map_t: Holds the complete description of an open Blorb
50 file. This type is opaque for normal interpreter use. */
51 typedef struct giblorb_map_struct giblorb_map_t;
52
53 /* giblorb_result_t: Result when you try to load a chunk. */
54 typedef struct giblorb_result_struct {
55 glui32 chunknum; /* The chunk number (for use in
56 giblorb_unload_chunk(), etc.) */
57 union {
58 void *ptr; /* A pointer to the data (if you used
59 giblorb_method_Memory) */
60 glui32 startpos; /* The position in the file (if you
61 used giblorb_method_FilePos) */
62 } data;
63 glui32 length; /* The length of the data */
64 glui32 chunktype; /* The type of the chunk. */
65 } giblorb_result_t;
66
67 typedef struct giblorb_image_info_struct {
68 glui32 chunktype;
69 glui32 width;
70 glui32 height;
71 char *alttext;
72 } giblorb_image_info_t;
73
74 extern giblorb_err_t giblorb_create_map(strid_t file,
75 giblorb_map_t **newmap);
76 extern giblorb_err_t giblorb_destroy_map(giblorb_map_t *map);
77
78 extern giblorb_err_t giblorb_load_chunk_by_type(giblorb_map_t *map,
79 glui32 method, giblorb_result_t *res, glui32 chunktype,
80 glui32 count);
81 extern giblorb_err_t giblorb_load_chunk_by_number(giblorb_map_t *map,
82 glui32 method, giblorb_result_t *res, glui32 chunknum);
83 extern giblorb_err_t giblorb_unload_chunk(giblorb_map_t *map,
84 glui32 chunknum);
85
86 extern giblorb_err_t giblorb_load_resource(giblorb_map_t *map,
87 glui32 method, giblorb_result_t *res, glui32 usage,
88 glui32 resnum);
89 extern giblorb_err_t giblorb_count_resources(giblorb_map_t *map,
90 glui32 usage, glui32 *num, glui32 *min, glui32 *max);
91
92 extern giblorb_err_t giblorb_load_image_info(giblorb_map_t *map,
93 glui32 resnum, giblorb_image_info_t *res);
94
95 /* The following functions are part of the Glk library itself, not
96 the Blorb layer (whose code is in gi_blorb.c). These functions
97 are necessarily implemented in platform-dependent code.
98 */
99 extern giblorb_err_t giblorb_set_resource_map(strid_t file);
100 extern giblorb_map_t *giblorb_get_resource_map(void);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* _GI_BLORB_H */