-
Notifications
You must be signed in to change notification settings - Fork 0
/
sng.h
61 lines (47 loc) · 1.61 KB
/
sng.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
/* sng.h -- interface to the SNG compiler */
typedef struct color_item_t
{
unsigned char r, g, b;
char *name;
struct color_item_t *next;
}
color_item;
/* this modulus should be prime and close to the line count of rgb.txt */
#define COLOR_HASH_MODULUS 751
extern int sngc(FILE *fin, char *file, FILE *fout);
extern int sngd(FILE *fin, char *file, FILE *fout);
extern void fatal(const char *fmt, ... );
extern void *xalloc(unsigned long s);
extern void *xrealloc(void *p, unsigned long s);
extern char *xstrdup(char *s);
extern void initialize_hash(int hashfunc(color_item *),
color_item *hashbuckets[],
int *initflag);
extern int verbose;
extern int idat;
extern int linenum;
extern char *file;
extern FILE *yyin;
extern png_struct *png_ptr;
extern png_info *info_ptr;
#define SUCCEED 0
#define FAIL -1
#define TRUE 1
#define FALSE 0
/* Fake "base64" encoding. This is INCOMPATIBLE with RFC2045 base64 encoding,
* which instead uses the mapping
* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
*
* TODO: Switch to proper encoding?
*/
#define BASE64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"
/*
* Maximum string size -- the size of an IDAT buffer minus the minimum overhead
* of a string chunk (that is, the overhead of a minimal tEXt chunk).
* That overhead: four characters of chunk name, plus zero characters of
* keyword, plus one character of NUL separator.
*/
#define PNG_STRING_MAX_LENGTH (PNG_ZBUF_SIZE - 5)
#define FLOAT_TO_FIXED(d) ((png_fixed_point)((d) * 100000))
#define FIXED_TO_FLOAT(n) ((float)((n) / 100000.0))
/* sng.h ends here */