util.h

00001 /*  $Id: util.h,v 1.2 2005/03/03 17:23:07 kifer Exp $
00002 
00003     Part of SWI-Prolog
00004 
00005     Author:        Jan Wielemaker
00006     E-mail:        jan@swi.psy.uva.nl
00007     WWW:           http://www.swi-prolog.org
00008     Copyright (C): 1985-2002, University of Amsterdam
00009 
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2.1 of the License, or (at your option) any later version.
00014 
00015     This library 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 GNU
00018     Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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               /* get size_t */
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 /*DTD_UTIL_H_INCLUDED*/

Generated on Wed Jul 26 13:30:46 2006 for XSB by  doxygen 1.4.5