00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef DTD_UTIL_H_INCLUDED
00026 #define DTD_UTIL_H_INCLUDED
00027 #include "sgmldefs.h"
00028
00029 #include <sys/types.h>
00030 #ifdef _WINDOWS
00031 #include <malloc.h>
00032 #endif
00033
00034 typedef struct
00035 { int allocated;
00036 int size;
00037 ichar *data;
00038 } icharbuf;
00039
00040 typedef struct
00041 { int allocated;
00042 int size;
00043 ochar *data;
00044 } ocharbuf;
00045
00046 int istrlen(const ichar *s);
00047 ichar * istrdup(const ichar *s);
00048 ichar * istrcpy(ichar *d, const ichar *s);
00049 ichar * istrupper(ichar *s);
00050 ichar * istrlower(ichar *s);
00051 int istrprefix(const ichar *pref, const ichar *s);
00052 int istreq(const ichar *s1, const ichar *s2);
00053 int istrcaseeq(const ichar *s1, const ichar *s2);
00054 int istrncaseeq(const ichar *s1, const ichar *s2, int len);
00055 int istrhash(const ichar *t, int tsize);
00056 int istrcasehash(const ichar *t, int tsize);
00057 ichar * istrchr(const ichar *s, int c);
00058 int istrtol(const ichar *s, long *val);
00059 void * sgml_malloc(size_t size);
00060 void * sgml_calloc(size_t n, size_t size);
00061 void sgml_free(void *mem);
00062 void * sgml_realloc(void *old, size_t size);
00063 void sgml_nomem(void);
00064
00065 int check_for_error_socket();
00066
00067 #define add_icharbuf(buf, chr) \
00068 do { if ( buf->size < buf->allocated ) \
00069 buf->data[buf->size++] = chr; \
00070 else \
00071 __add_icharbuf(buf, chr); \
00072 } while(0)
00073 #define add_ocharbuf(buf, chr) \
00074 do { if ( buf->size < buf->allocated ) \
00075 buf->data[buf->size++] = chr; \
00076 else \
00077 __add_ocharbuf(buf, chr); \
00078 } while(0)
00079
00080 icharbuf * new_icharbuf(void);
00081 void free_icharbuf(icharbuf *buf);
00082 void __add_icharbuf(icharbuf *buf, int chr);
00083 void del_icharbuf(icharbuf *buf);
00084 void terminate_icharbuf(icharbuf *buf);
00085 void empty_icharbuf(icharbuf *buf);
00086
00087 int ostrlen(const ochar *s);
00088 ochar * ostrdup(const ochar *s);
00089
00090 ocharbuf * new_ocharbuf(void);
00091 void free_ocharbuf(ocharbuf *buf);
00092 void __add_ocharbuf(ocharbuf *buf, int chr);
00093 void del_ocharbuf(ocharbuf *buf);
00094 void terminate_ocharbuf(ocharbuf *buf);
00095 void empty_ocharbuf(ocharbuf *buf);
00096
00097 const char * str_summary(const char *s, int len);
00098 char * str2ring(const char *in);
00099 char * ringallo(size_t);
00100 ichar * load_sgml_file_to_charp(const char *file, int normalise_rsre,
00101 int *len);
00102
00103 #if defined(USE_STRING_FUNCTIONS) && !defined(UTIL_H_IMPLEMENTATION)
00104
00105 #define istrlen(s1) strlen((char const *)(s1))
00106 #define istreq(s1,s2) (strcmp((char const *)(s1),(char const *)(s2))==0)
00107
00108 #endif
00109
00110 #endif