2006-08-17 Aaron Bockover <abockover@novell.com>
[mono.git] / eglib / src / glib.h
index 1c2442c66f4bfb7177911dabc337b9f2f4ed32cc..60aea1688b1936da0fdfa20572578c6a5dabc1cf 100644 (file)
@@ -5,6 +5,22 @@
 #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
  */
@@ -63,7 +72,8 @@ typedef unsigned char  guchar;
  * 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);
@@ -94,11 +104,6 @@ guint    g_str_hash     (gconstpointer v1);
 #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
  */
@@ -110,6 +115,9 @@ gchar       *g_strndup        (const gchar *str, gsize n);
 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
@@ -129,8 +137,52 @@ void         g_string_printf        (GString *string, const gchar *format, ...);
 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
  */