Debian Codegraph @

texk/xdvipsk/otflib/dpxutil.h

raw
1 /* This is xdvipsk, an eXtended version of dvips(k) by Tomas Rokicki.
2
3 Copyright (C) 2016 by VTeX Ltd (www.vtex.lt),
4 the xdvipsk project team - Sigitas Tolusis and Arunas Povilaitis.
5
6 Program original code copyright (C) 2007-2014 by Jin-Hwan Cho and
7 Shunsaku Hirata, the dvipdfmx project team.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 */
23
24 #ifndef _DPXUTIL_H_
25 #define _DPXUTIL_H_
26
27 #undef MIN
28 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
29 #undef MAX
30 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
31 #undef ABS
32 #define ABS(a) (((a) < 0) ? -(a) : (a))
33
34 #ifndef is_space
35 #define is_space(c) ((c) == ' ' || (c) == '\t' || (c) == '\f' || \
36 (c) == '\r' || (c) == '\n' || (c) == '\0')
37 #endif
38 #ifndef is_delim
39 #define is_delim(c) ((c) == '(' || (c) == '/' || \
40 (c) == '<' || (c) == '>' || \
41 (c) == '[' || (c) == ']' || \
42 (c) == '{' || (c) == '}' || \
43 (c) == '%')
44 #endif
45
46 extern void skip_white_spaces (unsigned char **s, unsigned char *endptr);
47 extern int xtoi (char c);
48 extern int getxpair (unsigned char **str);
49 extern int putxpair (unsigned char c, char **str);
50 extern int sputx (unsigned char c, char **buf, char *endptr);
51
52 extern unsigned char ostrtouc (unsigned char **inbuf,
53 unsigned char *inbufend, unsigned char *valid);
54 extern unsigned char esctouc (unsigned char **inbuf,
55 unsigned char *inbufend, unsigned char *valid);
56
57 #define HASH_TABLE_SIZE 503
58
59 struct ht_entry {
60 char *key;
61 int keylen;
62
63 void *value;
64
65 struct ht_entry *next;
66 };
67
68 typedef void (*hval_free_func) (void *);
69
70 struct ht_table {
71 long count;
72 hval_free_func hval_free_fn;
73 struct ht_entry *table[HASH_TABLE_SIZE];
74 };
75
76 extern void ht_init_table (struct ht_table *ht,
77 hval_free_func hval_free_fn);
78 extern void ht_clear_table (struct ht_table *ht);
79 extern long ht_table_size (struct ht_table *ht);
80 extern void *ht_lookup_table (struct ht_table *ht,
81 const void *key, int keylen);
82 extern void ht_append_table (struct ht_table *ht,
83 const void *key, int keylen, void *value) ;
84 extern int ht_remove_table (struct ht_table *ht,
85 const void *key, int keylen);
86 extern void ht_insert_table (struct ht_table *ht,
87 const void *key, int keylen, void *value);
88
89 struct ht_iter {
90 int index;
91 void *curr;
92 struct ht_table *hash;
93 };
94
95 extern int ht_set_iter (struct ht_table *ht, struct ht_iter *iter);
96 extern void ht_clear_iter (struct ht_iter *iter);
97 extern char *ht_iter_getkey (struct ht_iter *iter, int *keylen);
98 extern void *ht_iter_getval (struct ht_iter *iter);
99 extern int ht_iter_next (struct ht_iter *iter);
100
101 extern char *parse_float_decimal (const char **pp, const char *endptr);
102 extern char *parse_c_string (const char **pp, const char *endptr);
103 extern char *parse_c_ident (const char **pp, const char *endptr);
104
105 #endif /* _DPXUTIL_H_ */