#include <stdlib.h>
#include <string.h>
+/*
+ * Basic data types
+ */
+typedef int gboolean;
+typedef int gint;
+typedef unsigned int gsize;
+typedef unsigned int guint;
+typedef short gshort;
+typedef unsigned short gushort;
+typedef long glong;
+typedef unsigned long gulong;
+typedef void * gpointer;
+typedef const void * gconstpointer;
+typedef char gchar;
+typedef unsigned char guchar;
+
/*
* Macros
*/
#define g_try_malloc(x) malloc(x)
#define g_try_realloc(obj,size) realloc((obj),(size))
#define g_malloc0(x) calloc(1,x)
+#define g_memmove(dest,src,len) memmove (dest, src, len)
+#define g_renew(struct_type, mem, n_structs) realloc (mem, sizeof (struct_type) * n_structs)
+#define g_alloca(size) alloca (size)
+
+gpointer g_memdup (gconstpointer mem, guint byte_size);
/*
- * Basic data types
+ * Misc.
*/
-typedef int gboolean;
-typedef int gint;
-typedef unsigned int gsize;
-typedef unsigned int guint;
-typedef short gshort;
-typedef unsigned short gushort;
-typedef long glong;
-typedef unsigned long gulong;
-typedef void * gpointer;
-typedef const void * gconstpointer;
-typedef char gchar;
-typedef unsigned char guchar;
-
+#define g_atexit(func) ((void) atexit (func))
/*
* Precondition macros
*/
* Hashtables
*/
typedef struct _GHashTable GHashTable;
-typedef void (* GFunc) (gpointer data, gpointer user_data);
+typedef void (*GFunc) (gpointer data, gpointer user_data);
+typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
typedef void (*GDestroyNotify) (gpointer data);
#define g_assert(x) do { if (!(x)) g_error ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); } while (0)
#define g_assert_not_reached() do { g_error ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } while (0)
-/*
- * Singly-linked Lists
- */
-#include <gslist.h>
-
/*
* Strings utility
*/
void g_strfreev (gchar **str_array);
gchar *g_strconcat (const gchar *first, ...);
gchar **g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
+gchar *g_strreverse (gchar *str);
+gboolean g_str_has_prefix (const gchar *str, const gchar *prefix);
+gboolean g_str_has_suffix (const gchar *str, const gchar *suffix);
/*
* String type
void g_string_append_printf (GString *string, const gchar *format, ...);
GString *g_string_append_c (GString *string, gchar c);
GString *g_string_append (GString *string, const gchar *val);
-
+GString *g_string_append_len (GString *string, const gchar *val, gsize len);
#define g_string_sprintfa g_string_append_printf
+
+/*
+ * Lists
+ */
+typedef struct _GSList GSList;
+struct _GSList {
+ gpointer data;
+ GSList *next;
+};
+
+GSList *g_slist_alloc (void);
+GSList *g_slist_append (GSList* list, gpointer data);
+GSList *g_slist_prepend (GSList* list, gpointer data);
+void g_slist_free (GSList* list);
+void g_slist_free_1 (GSList* list);
+GSList *g_slist_copy (GSList* list);
+GSList *g_slist_concat (GSList* list1, GSList* list2);
+void g_slist_foreach (GSList* list, GFunc func, gpointer user_data);
+GSList *g_slist_last (GSList *list);
+GSList *g_slist_find (GSList *list, gconstpointer data);
+GSList *g_slist_remove (GSList *list, gconstpointer data);
+GSList *g_slist_reverse (GSList *list);
+GSList *g_slist_remove_link (GSList *list, GSList *link);
+GSList *g_slist_delete_link (GSList *list, GSList *link);
+GSList *g_slist_insert_sorted (GSList *list, gpointer data, GCompareFunc func);
+guint g_slist_length (GSList *list);
+#define g_slist_next (slist) ((slist) ? (((GSList *) slist)->next) : NULL)
+
+/*
+ * Modules
+ */
+typedef enum {
+ G_MODULE_BIND_LAZY = 0x01,
+ G_MODULE_BIND_LOCAL = 0x02,
+ G_MODULE_BIND_MASK = 0x03
+} GModuleFlags;
+typedef struct _GModule GModule;
+
+GModule *g_module_open (const gchar *file, GModuleFlags flags);
+gboolean g_module_symbol (GModule *module, const gchar *symbol_name,
+ gpointer *symbol);
+const gchar *g_module_error (void);
+gboolean g_module_close (GModule *module);
+gchar * g_module_build_path (const gchar *directory, const gchar *module_name);
/*
* Messages
*/