Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

glib-missing.h

Go to the documentation of this file.
00001 /*
00002  * $Id: glib-missing.h,v 1.8 2005/10/21 15:52:42 cbiere Exp $
00003  *
00004  * Copyright (c) 2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00042 #ifndef _glib_missing_h_
00043 #define _glib_missing_h_
00044 
00045 #include <sys/types.h>
00046 #include <glib.h>
00047 
00048 #ifdef USE_GLIB1
00049 typedef gboolean (*GEqualFunc)(gconstpointer a, gconstpointer b);
00050 #endif
00051 
00052 /*
00053  * Public interface.
00054  */
00055 
00056 GSList *gm_slist_insert_after(GSList *list, GSList *lnk, gpointer data);
00057 
00058 GList *gm_list_insert_after(GList *list, GList *lnk, gpointer data);
00059 
00060 #ifdef USE_GLIB1
00061 GList *g_list_delete_link(GList *l, GList *lnk);
00062 GString *g_string_append_len(GString *gs, const gchar *val, gssize len);
00063 #endif
00064 
00065 size_t gm_vsnprintf(gchar *str, size_t n, gchar const *fmt, va_list args);
00066 size_t gm_snprintf(gchar *str, size_t n,
00067     gchar const *fmt, ...) G_GNUC_PRINTF (3, 4);
00068 
00069 void gm_savemain(gint argc, gchar **argv, gchar **env);
00070 void gm_setproctitle(gchar *title);
00071 gchar *gm_sanitize_filename(const gchar *filename,
00072     gboolean no_spaces, gboolean no_evil);
00073 
00074 /*
00075  * The G_*LIST_FOREACH_* macros are supposed to be used with ``func'' being
00076  * a function declared ``static inline'' whereas the protoype MUST match
00077  * ``GFunc''. ``func'' is not assigned to a variable so that the compiler
00078  * can prevent any function call overhead along with ``inline''.
00079  * These macros were rejected by the GLib maintainers so we can safely use
00080  * the G_ prefix.
00081  */
00082 
00083 /* NB: Sub-statement func is evaluated more than once! */
00084 #define G_LIST_FOREACH(list, func, user_data) \
00085     do { \
00086         GList *l_ = (list); \
00087         gpointer user_data_ = (user_data); \
00088         while (NULL != l_) { \
00089             func(l_->data, user_data_); \
00090             l_ = g_list_next(l_); \
00091         } \
00092     } while(0)
00093 
00094 #define G_LIST_FOREACH_SWAPPED(list, func, user_data) \
00095     do { \
00096         GList *l_ = (list); \
00097         gpointer user_data_ = (user_data); \
00098         while (NULL != l_) { \
00099             func(user_data_, l_->data); \
00100             l_ = g_list_next(l_); \
00101         } \
00102     } while(0)
00103 
00104 /* NB: Sub-statement func is evaluated more than once! */
00105 #define G_SLIST_FOREACH(slist, func, user_data) \
00106     do { \
00107         GSList *sl_ = (slist); \
00108         gpointer user_data_ = (user_data); \
00109         while (NULL != sl_) { \
00110             func(sl_->data, user_data_); \
00111             sl_ = g_slist_next(sl_); \
00112         } \
00113     } while(0)
00114 
00115 /* NB: Sub-statement func is evaluated more than once! */
00116 #define G_SLIST_FOREACH_SWAPPED(slist, func, user_data) \
00117     do { \
00118         GSList *sl_ = (slist); \
00119         gpointer user_data_ = (user_data); \
00120         while (NULL != sl_) { \
00121             func(user_data_, sl_->data); \
00122             sl_ = g_slist_next(sl_); \
00123         } \
00124     } while(0)
00125 
00126 /* vi: set ts=4 sw=4: */
00127 #endif  /* _glib_missing_h_ */

Generated on Sun Feb 12 10:49:56 2006 for Gtk-Gnutella by doxygen 1.3.6