Main Page | Data Structures | File List | Data Fields | Globals

util.h

Go to the documentation of this file.
00001 /*
00002  * luau (Lib Update/Auto-Update): Simple Update Library
00003  * Copyright (C) 2003  David Eklund
00004  *
00005  * - This library is free software; you can redistribute it and/or             -
00006  * - modify it under the terms of the GNU Lesser General Public                -
00007  * - License as published by the Free Software Foundation; either              -
00008  * - version 2.1 of the License, or (at your option) any later version.        -
00009  * -                                                                           -
00010  * - This library is distributed in the hope that it will be useful,           -
00011  * - but WITHOUT ANY WARRANTY; without even the implied warranty of            -
00012  * - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         -
00013  * - Lesser General Public License for more details.                           -
00014  * -                                                                           -
00015  * - You should have received a copy of the GNU Lesser General Public          -
00016  * - License along with this library; if not, write to the Free Software       -
00017  * - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -
00018  */
00019  
00026 #ifndef UTIL_H
00027 #define UTIL_H
00028 
00029 #ifdef HAVE_CONFIG_H
00030 #  include <config.h>
00031 #endif
00032 
00033 #ifdef WITH_DMALLOC
00034 #  include <dmalloc.h>
00035 #endif
00036 
00037 #include <stdio.h>
00038 
00039 #include <glib.h>
00040 
00041 #include "gcontainer.h"
00042 
00043 #ifdef WITH_GTHREAD
00044 #  ifdef G_THREADS_ENABLED
00045 #    ifndef G_THREADS_IMPL_NONE
00046 #      define USE_GTHREADS
00047 #    endif
00048 #  endif
00049 #endif /* WITH_GTHREAD */
00050 
00051 #ifndef USE_GTHREADS
00052 #  ifdef G_LOCK
00053 #    undef G_LOCK
00054 #  endif
00055 #  ifdef G_UNLOCK
00056 #    undef G_UNLOCK
00057 #  endif
00058 #  ifdef G_THREADS_ENABLED
00059 #    undef G_THREADS_ENABLED
00060 #  endif
00061 #  define G_LOCK(arg)
00062 #  define G_UNLOCK(arg)
00063 #endif /* !USE_GTHREADS */
00064 
00065 #ifdef WITH_LEAKBUG
00066 #  include <leakbug.h>
00067 #  define LB_REGISTER(ptr, dataSize) lbRegister((ptr), (dataSize), __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00068 #  define g_free(ptr) if (ptr != NULL) { free(ptr); }
00069 #  define g_strdup strdup
00070 #  define g_calloc calloc
00071 #  define g_malloc malloc
00072 #  define g_realloc realloc
00073 #else
00074 #  define LB_REGISTER(ptr, dataSize)
00075 #endif
00076 
00078 #ifdef DEBUG
00079 #  define DBUGOUT(args...) do { printf("luau: %s: %s: ", __FILE__, __func__); printf(args); printf("\n"); } while (0)
00080 #else
00081 #  define DBUGOUT(args...) 
00082 #endif
00083 
00085 #define nnull_g_string_free(ptr, boole)    do {            \
00086         if (ptr != NULL) { g_string_free(ptr, boole); }        \
00087                                                  } while (0)
00088 
00090 #define nnull_g_free(ptr)    do {            \
00091         if (ptr != NULL) { g_free(ptr); }        \
00092                                     } while (0)
00093 
00094 
00095 
00097 #define TEMP_DIR "/tmp"
00098 
00099 /* String utilities */
00101 inline int lutil_streq(const char *str1, const char *str2);
00103 inline int lutil_strcaseeq(const char *str1, const char *str2);
00105 char* lutil_createString(int length);
00107 char* lutil_vstrcreate(const char *src1, ...);
00109 char* lutil_mprintf(const char *template, ...);
00111 char* lutil_strjoin(const char *delim, const GContainer *strings);
00113 GContainer* lutil_gsplit(const char *delim, const char *str);
00114 char* lutil_valistToString(const char *template, va_list args);
00116 gboolean lutil_findString(const GContainer *array, const char *string);
00118 void lutil_printIndented(int indent, int length, const char *string);
00120 gboolean lutil_isCompletelyBlank(const char *input);
00122 void lutil_strToLower(char *str);
00123 void lutil_strToUpper(char *str);
00124 gboolean lutil_containsAlpha(const char *str);
00125 gboolean lutil_containsDigit(const char *str);
00126 
00127 GString* lutil_uncompress(GString *data);
00128 
00129 
00130 /* File utilities */
00132 char* lutil_getTempFilename(void);
00134 gboolean lutil_fileExists(const char *path);
00136 gboolean lutil_isDirectory(const char *path);
00137 
00138 /* Integer utilities */
00140 gint lutil_gintCompare(gpointer p1, gpointer p2);
00142 int lutil_intcmp(int i1, int i2);
00143 char* lutil_sizeToString(int size, int sigfig);
00144 
00145 
00146 #endif

Generated on Mon Apr 12 22:17:11 2004 for luau by doxygen 1.3.2