| 1 |
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. |
| 2 |
|
| 3 |
Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata, |
| 4 |
the dvipdfmx project team. |
| 5 |
|
| 6 |
Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]> |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef _DPXUTIL_H_ |
| 24 |
#define _DPXUTIL_H_ |
| 25 |
|
| 26 |
#include <time.h> |
| 27 |
|
| 28 |
#undef MIN |
| 29 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| 30 |
#undef MAX |
| 31 |
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| 32 |
#undef ABS |
| 33 |
#define ABS(a) (((a) < 0) ? -(a) : (a)) |
| 34 |
|
| 35 |
extern double min4(double v1, double v2, double v3, double v4); |
| 36 |
extern double max4(double v1, double v2, double v3, double v4); |
| 37 |
|
| 38 |
extern int dpx_util_read_length (double *vp, double mag, |
| 39 |
const char **curptr, const char *endptr); |
| 40 |
|
| 41 |
#define INVALID_EPOCH_VALUE ((time_t)-1) |
| 42 |
extern time_t dpx_util_get_unique_time_if_given (void); |
| 43 |
extern int dpx_util_format_asn_date (char *date_string, int need_timezone); |
| 44 |
|
| 45 |
#ifndef is_space |
| 46 |
#define is_space(c) ((c) == ' ' || (c) == '\t' || (c) == '\f' || \ |
| 47 |
(c) == '\r' || (c) == '\n' || (c) == '\0') |
| 48 |
#endif |
| 49 |
#ifndef is_delim |
| 50 |
#define is_delim(c) ((c) == '(' || (c) == ')' || \ |
| 51 |
(c) == '/' || \ |
| 52 |
(c) == '<' || (c) == '>' || \ |
| 53 |
(c) == '[' || (c) == ']' || \ |
| 54 |
(c) == '{' || (c) == '}' || \ |
| 55 |
(c) == '%') |
| 56 |
#endif |
| 57 |
|
| 58 |
extern void skip_white_spaces (unsigned char **s, unsigned char *endptr); |
| 59 |
extern int xtoi (char c); |
| 60 |
|
| 61 |
typedef struct stack_elem |
| 62 |
{ |
| 63 |
void *data; |
| 64 |
struct stack_elem *prev; |
| 65 |
} stack_elem; |
| 66 |
|
| 67 |
typedef struct dpx_stack |
| 68 |
{ |
| 69 |
int size; |
| 70 |
stack_elem *top; |
| 71 |
stack_elem *bottom; |
| 72 |
} dpx_stack; |
| 73 |
|
| 74 |
extern void dpx_stack_init (dpx_stack *st); |
| 75 |
extern void *dpx_stack_pop (dpx_stack *st); |
| 76 |
extern void dpx_stack_push (dpx_stack *st, void *data); |
| 77 |
extern int dpx_stack_depth (dpx_stack *st); |
| 78 |
extern void *dpx_stack_top (dpx_stack *st); |
| 79 |
extern void *dpx_stack_at (dpx_stack *st, int pos); |
| 80 |
extern void dpx_stack_roll (dpx_stack *st, int n, int j); |
| 81 |
|
| 82 |
|
| 83 |
#define HASH_TABLE_SIZE 503 |
| 84 |
|
| 85 |
struct ht_entry { |
| 86 |
char *key; |
| 87 |
int keylen; |
| 88 |
|
| 89 |
void *value; |
| 90 |
|
| 91 |
struct ht_entry *next; |
| 92 |
}; |
| 93 |
|
| 94 |
typedef void (*hval_free_func) (void *); |
| 95 |
|
| 96 |
struct ht_table { |
| 97 |
int count; |
| 98 |
hval_free_func hval_free_fn; |
| 99 |
struct ht_entry *table[HASH_TABLE_SIZE]; |
| 100 |
}; |
| 101 |
|
| 102 |
extern void ht_init_table (struct ht_table *ht, |
| 103 |
hval_free_func hval_free_fn); |
| 104 |
extern void ht_clear_table (struct ht_table *ht); |
| 105 |
extern int ht_table_size (struct ht_table *ht); |
| 106 |
extern void *ht_lookup_table (struct ht_table *ht, |
| 107 |
const void *key, int keylen); |
| 108 |
extern void ht_append_table (struct ht_table *ht, |
| 109 |
const void *key, int keylen, void *value) ; |
| 110 |
extern int ht_remove_table (struct ht_table *ht, |
| 111 |
const void *key, int keylen); |
| 112 |
extern void ht_insert_table (struct ht_table *ht, |
| 113 |
const void *key, int keylen, void *value); |
| 114 |
|
| 115 |
struct ht_iter { |
| 116 |
int index; |
| 117 |
void *curr; |
| 118 |
struct ht_table *hash; |
| 119 |
}; |
| 120 |
|
| 121 |
extern int ht_set_iter (struct ht_table *ht, struct ht_iter *iter); |
| 122 |
extern void ht_clear_iter (struct ht_iter *iter); |
| 123 |
extern char *ht_iter_getkey (struct ht_iter *iter, int *keylen); |
| 124 |
extern void *ht_iter_getval (struct ht_iter *iter); |
| 125 |
extern int ht_iter_next (struct ht_iter *iter); |
| 126 |
|
| 127 |
extern char *parse_float_decimal (const char **pp, const char *endptr); |
| 128 |
extern char *parse_c_string (const char **pp, const char *endptr); |
| 129 |
extern char *parse_c_ident (const char **pp, const char *endptr); |
| 130 |
|
| 131 |
#endif /* _DPXUTIL_H_ */ |