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

glib-missing.h File Reference


Detailed Description

Missing functions in the Glib 1.2.

Functions that should be in glib-1.2 but are not. They are all prefixed with "gm_" as in "Glib Missing".

We also include FIXED versions of glib-1.2 routines that are broken and make sure those glib versions are never called directly.

Author:
Raphael Manfredi
Date:
2003

#include "common.h"

Go to the source code of this file.

Defines

#define G_LIST_FOREACH(list, func)
#define G_LIST_FOREACH_WITH_DATA(list, func, user_data)
#define G_LIST_FOREACH_SWAPPED(list, func, user_data)
#define G_SLIST_FOREACH(slist, func)
#define G_SLIST_FOREACH_WITH_DATA(slist, func, user_data)
#define G_SLIST_FOREACH_SWAPPED(slist, func, user_data)
#define GM_SLIST_FOREACH(slist, iter)   for ((iter) = (slist); NULL != (iter); (iter) = g_slist_next(iter))

Functions

gboolean gm_slist_is_looping (const GSList *slist)
 Detects a loop in a singly-linked list.
GSList * gm_slist_insert_after (GSList *list, GSList *lnk, gpointer data)
 Insert `item' after `lnk' in list `list'.
GList * gm_list_insert_after (GList *list, GList *lnk, gpointer data)
 Insert `item' after `lnk' in list `list'.
gchar * gm_string_finalize (GString *gs)
 Frees the GString context but keeps the string data itself and returns it.
size_t gm_vsnprintf (gchar *str, size_t n, gchar const *fmt, va_list args)
 This is the smallest common denominator between the g_vsnprintf() from GLib 1.2 and the one from GLib 2.x.
size_t gm_snprintf (gchar *str, size_t n, gchar const *fmt,...) G_GNUC_PRINTF(3
void gm_savemain (gint argc, gchar **argv, gchar **env)
 Save the original main() arguments.
const gchar * gm_getproctitle (void)
 Return the process title as seen by "ps".
void gm_setproctitle (const gchar *title)
 Change the process title as seen by "ps".
gchar * gm_sanitize_filename (const gchar *filename, gboolean no_spaces, gboolean no_evil)
 Creates a valid and sanitized filename from the supplied string.
void gm_hash_table_insert_const (GHashTable *ht, gconstpointer key, gconstpointer value)
void gm_hash_table_replace_const (GHashTable *ht, gconstpointer key, gconstpointer value)
GSList * gm_hash_table_all_keys (GHashTable *ht)
void gm_hash_table_foreach_key (GHashTable *ht, GFunc func, gpointer user_data)
 Apply function to all the keys of the hash table.


Define Documentation

#define G_LIST_FOREACH list,
func   ) 
 

Value:

G_STMT_START { \
        GList *l_ = (list); \
        while (NULL != l_) { \
            func(l_->data); \
            l_ = g_list_next(l_); \
        } \
    } G_STMT_END

#define G_LIST_FOREACH_SWAPPED list,
func,
user_data   ) 
 

Value:

G_STMT_START { \
        GList *l_ = (list); \
        gpointer user_data_ = (user_data); \
        while (NULL != l_) { \
            func(user_data_, l_->data); \
            l_ = g_list_next(l_); \
        } \
    } G_STMT_END

#define G_LIST_FOREACH_WITH_DATA list,
func,
user_data   ) 
 

Value:

G_STMT_START { \
        GList *l_ = (list); \
        gpointer user_data_ = (user_data); \
        while (NULL != l_) { \
            func(l_->data, user_data_); \
            l_ = g_list_next(l_); \
        } \
    } G_STMT_END

#define G_SLIST_FOREACH slist,
func   ) 
 

Value:

G_STMT_START { \
        GSList *sl_ = (slist); \
        while (NULL != sl_) { \
            func(sl_->data); \
            sl_ = g_slist_next(sl_); \
        } \
    } G_STMT_END

#define G_SLIST_FOREACH_SWAPPED slist,
func,
user_data   ) 
 

Value:

G_STMT_START { \
        GSList *sl_ = (slist); \
        gpointer user_data_ = (user_data); \
        while (NULL != sl_) { \
            func(user_data_, sl_->data); \
            sl_ = g_slist_next(sl_); \
        } \
    } while(0)

#define G_SLIST_FOREACH_WITH_DATA slist,
func,
user_data   ) 
 

Value:

G_STMT_START { \
        GSList *sl_ = (slist); \
        gpointer user_data_ = (user_data); \
        while (NULL != sl_) { \
            func(sl_->data, user_data_); \
            sl_ = g_slist_next(sl_); \
        } \
    } G_STMT_END

#define GM_SLIST_FOREACH slist,
iter   )     for ((iter) = (slist); NULL != (iter); (iter) = g_slist_next(iter))
 


Function Documentation

const gchar* gm_getproctitle void   ) 
 

Return the process title as seen by "ps".

GSList* gm_hash_table_all_keys GHashTable *  ht  ) 
 

Returns:
list of all the hash table keys.

void gm_hash_table_foreach_key GHashTable *  ht,
GFunc  func,
gpointer  user_data
 

Apply function to all the keys of the hash table.

void gm_hash_table_insert_const GHashTable *  ht,
gconstpointer  key,
gconstpointer  value
[inline, static]
 

void gm_hash_table_replace_const GHashTable *  ht,
gconstpointer  key,
gconstpointer  value
[inline, static]
 

GList* gm_list_insert_after GList *  list,
GList *  lnk,
gpointer  data
 

Insert `item' after `lnk' in list `list'.

If `lnk' is NULL, insertion happens at the head.

Returns:
new list head.

gchar* gm_sanitize_filename const gchar *  filename,
gboolean  no_spaces,
gboolean  no_evil
 

Creates a valid and sanitized filename from the supplied string.

For most Unix-like platforms anything goes but for security reasons, shell meta characters are replaced by harmless characters.

Parameters:
filename the suggested filename.
no_spaces if TRUE, spaces are replaced with underscores.
no_evil if TRUE, "evil" characters are replaced with underscores.
Returns:
a newly allocated string or ``filename'' if it was a valid filename already.

void gm_savemain gint  argc,
gchar **  argv,
gchar **  env
 

Save the original main() arguments.

void gm_setproctitle const gchar *  title  ) 
 

Change the process title as seen by "ps".

GSList* gm_slist_insert_after GSList *  list,
GSList *  lnk,
gpointer  data
 

Insert `item' after `lnk' in list `list'.

If `lnk' is NULL, insertion happens at the head.

Returns:
new list head.

gboolean gm_slist_is_looping const GSList *  slist  ) 
 

Detects a loop in a singly-linked list.

Returns:
TRUE if the given slist contains a loop; FALSE otherwise.

size_t gm_snprintf gchar *  str,
size_t  n,
gchar const *  fmt,
  ...
 

gchar* gm_string_finalize GString *  gs  ) 
 

Frees the GString context but keeps the string data itself and returns it.

With Gtk+ 2.x g_string_free(gs, FALSE) would do the job but the variant in Gtk+ 1.2 returns nothing.

Returns:
The string data.

size_t gm_vsnprintf gchar *  dst,
size_t  size,
const gchar *  fmt,
va_list  args
 

This is the smallest common denominator between the g_vsnprintf() from GLib 1.2 and the one from GLib 2.x.

The older version has no defined return value, it could be the resulting string length or the size of the buffer minus one required to hold the resulting string. This version always returns the length of the resulting string unlike the vsnprintf() from ISO C99.

Note:
: The function name might be misleading. You cannot measure the required buffer size with this!
Parameters:
dst The destination buffer to hold the resulting string.
size The size of the destination buffer. It must not exceed INT_MAX.
fmt The printf-format string.
args The variable argument list.
Returns:
The length of the resulting string.


Generated on Sat Jun 30 17:53:26 2007 for gtk-gnutella by  doxygen 1.3.9.1