Back to index

texmacs  1.0.7.15
dpxutil.h
Go to the documentation of this file.
00001 /*  $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.11 2009/09/20 14:24:51 matthias Exp $
00002 
00003     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
00004 
00005     Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
00006     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
00007 
00008     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00023 */
00024 
00025 #ifndef _DPXUTIL_H_
00026 #define _DPXUTIL_H_
00027 
00028 #undef  MIN
00029 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
00030 #undef  MAX
00031 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
00032 #undef  ABS
00033 #define ABS(a)    (((a) < 0) ? -(a) : (a))
00034 
00035 #ifndef is_space
00036 #define is_space(c) ((c) == ' '  || (c) == '\t' || (c) == '\f' || \
00037                    (c) == '\r' || (c) == '\n' || (c) == '\0')
00038 #endif
00039 #ifndef is_delim
00040 #define is_delim(c) ((c) == '(' || (c) == '/' || \
00041                      (c) == '<' || (c) == '>' || \
00042                    (c) == '[' || (c) == ']' || \
00043                      (c) == '{' || (c) == '}' || \
00044                      (c) == '%')
00045 #endif
00046 
00047 extern void skip_white_spaces (unsigned char **s, unsigned char *endptr);
00048 extern int  xtoi     (char c);
00049 extern int  getxpair (unsigned char **str);
00050 extern int  putxpair (unsigned char c, char **str);
00051 extern int  sputx    (unsigned char c, char **buf, char *endptr);
00052 
00053 extern unsigned char ostrtouc (unsigned char **inbuf,
00054                             unsigned char *inbufend, unsigned char *valid);
00055 extern unsigned char esctouc  (unsigned char **inbuf,
00056                             unsigned char *inbufend, unsigned char *valid);
00057 
00058 #define HASH_TABLE_SIZE 503
00059 
00060 struct ht_entry {
00061   char  *key;
00062   int    keylen;
00063 
00064   void  *value;
00065 
00066   struct ht_entry *next;
00067 };
00068 
00069 struct ht_table {
00070   long   count;
00071   void (*hval_free_fn) (void *);
00072   struct ht_entry *table[HASH_TABLE_SIZE];
00073 };
00074 
00075 typedef struct ht_table ht_table;
00076 
00077 #define HT_NEW      0
00078 #define HT_REPLACE  1
00079 #define HT_KEEP     2
00080 
00081 extern void  ht_init_table   (struct ht_table *ht,
00082                               void (*hval_free_fn) (void *));
00083 extern void  ht_clear_table  (struct ht_table *ht);
00084 extern long  ht_table_size   (struct ht_table *ht);
00085 extern void *ht_lookup_table (struct ht_table *ht,
00086                               const void *key, int keylen);
00087 extern void  ht_modify_table (struct ht_table *ht,
00088                            const void *key, int keylen,
00089                               void *value, int mode);
00090 #define ht_append_table(ht, key, keylen, value) \
00091           ht_modify_table(ht, key, keylen, value, HT_NEW)
00092 #define ht_insert_table(ht, key, keylen, value) \
00093           ht_modify_table(ht, key, keylen, value, HT_REPLACE)
00094 extern int   ht_remove_table (struct ht_table *ht,
00095                            const void *key, int keylen);
00096 
00097 struct ht_iter {
00098   int    index;
00099   void  *curr;
00100   struct ht_table *hash;
00101 };
00102 
00103 extern int   ht_set_iter    (struct ht_table *ht, struct ht_iter *iter);
00104 extern void  ht_clear_iter  (struct ht_iter *iter);
00105 extern char *ht_iter_getkey (struct ht_iter *iter, int *keylen);
00106 extern void *ht_iter_getval (struct ht_iter *iter);
00107 extern int   ht_iter_next   (struct ht_iter *iter);
00108 
00109 extern char *parse_float_decimal (char **pp, char *endptr);
00110 extern char *parse_c_string      (char **pp, char *endptr);
00111 extern char *parse_c_ident       (char **pp, char *endptr);
00112 
00113 #endif /* _DPXUTIL_H_ */