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

glib-missing.c 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"
#include "glib-missing.h"
#include "utf8.h"
#include "misc.h"
#include "override.h"

Defines

#define FILENAME_MAXBYTES   256

Functions

 RCSID ("$Id:glib-missing.c, v 1.25 2005/11/02 09:25:23 cbiere Exp $")
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'.

size_t buf_vprintf (gchar *dst, size_t size, const gchar *fmt, va_list args)
 Perform the vsnprintf() operation for the gm_vsnprintf() and gm_snprintf() routines.

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.

size_t gm_snprintf (gchar *dst, size_t size, const gchar *fmt,...)
 This is the smallest common denominator between the g_snprintf() from GLib 1.2 and the one from GLib 2.x.

void gm_savemain (gint argc, gchar **argv, gchar **env)
 Save the original main() arguments.

void gm_setproctitle (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.


Variables

gint orig_argc
gchar ** orig_argv
gchar ** orig_env


Define Documentation

#define FILENAME_MAXBYTES   256
 


Function Documentation

size_t buf_vprintf gchar *  dst,
size_t  size,
const gchar *  fmt,
va_list  args
[inline, static]
 

Perform the vsnprintf() operation for the gm_vsnprintf() and gm_snprintf() routines.

The resulting string will not be larger than (size - 1) and the returned value is always the length of this string. Thus it will not be equal or greater than size either.

Parameters:
dst The destination buffer to hold the resulting string.
size The size of the destination buffer.
fmt The printf-format string.
args The variable argument list.
Returns:
The length of the resulting string.

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.

Maximum bytes in filename i.e., including NUL

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

Save the original main() arguments.

void gm_setproctitle 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.

size_t gm_snprintf gchar *  dst,
size_t  size,
const gchar *  fmt,
... 
 

This is the smallest common denominator between the g_snprintf() 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 snprintf() 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.
Returns:
The length of the resulting string.

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.

RCSID "$Id:glib-missing.  c,
v 1.25 2005/11/02 09:25:23 cbiere Exp $" 
 


Variable Documentation

gint orig_argc [static]
 

gchar** orig_argv [static]
 

gchar** orig_env [static]
 


Generated on Sun Feb 12 10:50:01 2006 for Gtk-Gnutella by doxygen 1.3.6