aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'e-util/e-util.c')
-rw-r--r--e-util/e-util.c244
1 files changed, 244 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 02092041f0..436e11b141 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <locale.h>
#include <stdio.h>
+#include <stdlib.h>
#include "e-util.h"
#if 0
@@ -269,6 +270,30 @@ e_marshal_INT__INT_INT_POINTER (GtkObject * object,
func_data);
}
+typedef gint (*GtkSignal_INT__INT_POINTER_INT_POINTER) (GtkObject * object,
+ gint arg1,
+ gpointer arg2,
+ gint arg3,
+ gpointer arg4,
+ gpointer user_data);
+
+void
+e_marshal_INT__INT_POINTER_INT_POINTER (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data, GtkArg * args)
+{
+ GtkSignal_INT__INT_POINTER_INT_POINTER rfunc;
+ gint *return_val;
+ return_val = GTK_RETLOC_INT (args[3]);
+ rfunc = (GtkSignal_INT__INT_POINTER_INT_POINTER) func;
+ *return_val = (*rfunc) (object,
+ GTK_VALUE_INT (args[0]),
+ GTK_VALUE_POINTER (args[1]),
+ GTK_VALUE_INT (args[2]),
+ GTK_VALUE_POINTER (args[3]),
+ func_data);
+}
+
typedef void (*GtkSignal_NONE__OBJECT_DOUBLE_DOUBLE_BOOL) (GtkObject * object,
GtkObject *arg1,
gdouble arg2,
@@ -361,6 +386,29 @@ e_marshal_NONE__INT_INT_POINTER_POINTER_INT_INT (GtkObject * object,
GTK_VALUE_INT (args[4]), GTK_VALUE_INT (args[5]), func_data);
}
+typedef void (*GtkSignal_NONE__INT_POINTER_INT_POINTER_POINTER_INT_INT) (GtkObject * object,
+ gint arg1,
+ gpointer arg2,
+ gint arg3,
+ gpointer arg4,
+ gpointer arg5,
+ gint arg6,
+ gint arg7,
+ gpointer user_data);
+void
+e_marshal_NONE__INT_POINTER_INT_POINTER_POINTER_INT_INT (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data, GtkArg * args)
+{
+ GtkSignal_NONE__INT_POINTER_INT_POINTER_POINTER_INT_INT rfunc;
+ rfunc = (GtkSignal_NONE__INT_POINTER_INT_POINTER_POINTER_INT_INT) func;
+ (*rfunc) (object,
+ GTK_VALUE_INT (args[0]), GTK_VALUE_POINTER (args[1]), GTK_VALUE_INT (args[2]),
+ GTK_VALUE_POINTER (args[3]),
+ GTK_VALUE_POINTER (args[4]),
+ GTK_VALUE_INT (args[5]), GTK_VALUE_INT (args[6]), func_data);
+}
+
typedef void (*GtkSignal_NONE__INT_INT_POINTER_INT) (GtkObject * object,
gint arg1,
gint arg2,
@@ -378,6 +426,24 @@ e_marshal_NONE__INT_INT_POINTER_INT (GtkObject * object,
GTK_VALUE_POINTER (args[2]), GTK_VALUE_INT (args[3]), func_data);
}
+typedef void (*GtkSignal_NONE__INT_POINTER_INT_POINTER_INT) (GtkObject * object,
+ gint arg1,
+ gpointer arg2,
+ gint arg3,
+ gpointer arg4,
+ gint arg5, gpointer user_data);
+void
+e_marshal_NONE__INT_POINTER_INT_POINTER_INT (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data, GtkArg * args)
+{
+ GtkSignal_NONE__INT_POINTER_INT_POINTER_INT rfunc;
+ rfunc = (GtkSignal_NONE__INT_POINTER_INT_POINTER_INT) func;
+ (*rfunc) (object,
+ GTK_VALUE_INT (args[0]), GTK_VALUE_POINTER (args[1]), GTK_VALUE_INT (args[2]),
+ GTK_VALUE_POINTER (args[3]), GTK_VALUE_INT (args[4]), func_data);
+}
+
typedef gboolean (*GtkSignal_BOOL__INT_INT_POINTER_INT_INT_INT) (GtkObject * object,
gint arg1,
gint arg2,
@@ -404,6 +470,34 @@ e_marshal_BOOL__INT_INT_POINTER_INT_INT_INT (GtkObject * object,
GTK_VALUE_INT (args[5]), func_data);
}
+typedef gboolean (*GtkSignal_BOOL__INT_POINTER_INT_POINTER_INT_INT_INT) (GtkObject * object,
+ gint arg1,
+ gpointer arg2,
+ gint arg3,
+ gpointer arg4,
+ gint arg5,
+ gint arg6,
+ gint arg7,
+ gpointer user_data);
+void
+e_marshal_BOOL__INT_POINTER_INT_POINTER_INT_INT_INT (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data, GtkArg * args)
+{
+ GtkSignal_BOOL__INT_POINTER_INT_POINTER_INT_INT_INT rfunc;
+ gboolean *return_val;
+ return_val = GTK_RETLOC_BOOL (args[6]);
+ rfunc = (GtkSignal_BOOL__INT_POINTER_INT_POINTER_INT_INT_INT) func;
+ *return_val = (*rfunc) (object,
+ GTK_VALUE_INT (args[0]),
+ GTK_VALUE_POINTER (args[1]),
+ GTK_VALUE_INT (args[2]),
+ GTK_VALUE_POINTER (args[3]),
+ GTK_VALUE_INT (args[4]),
+ GTK_VALUE_INT (args[5]),
+ GTK_VALUE_INT (args[6]), func_data);
+}
+
typedef void (*GtkSignal_NONE__INT_INT_POINTER_INT_INT_POINTER_INT_INT) (GtkObject *
object,
gint arg1,
@@ -436,6 +530,38 @@ e_marshal_NONE__INT_INT_POINTER_INT_INT_POINTER_INT_INT (GtkObject * object,
GTK_VALUE_INT (args[6]), GTK_VALUE_INT (args[7]), func_data);
}
+typedef void (*GtkSignal_NONE__INT_POINTER_INT_POINTER_INT_INT_POINTER_INT_INT) (GtkObject *
+ object,
+ gint arg1,
+ gpointer arg2,
+ gint arg3,
+ gpointer arg4,
+ gint arg5,
+ gint arg6,
+ gpointer arg7,
+ gint arg8,
+ gint arg9,
+ gpointer user_data);
+
+void
+e_marshal_NONE__INT_POINTER_INT_POINTER_INT_INT_POINTER_INT_INT (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args)
+{
+ GtkSignal_NONE__INT_POINTER_INT_POINTER_INT_INT_POINTER_INT_INT rfunc;
+ rfunc = (GtkSignal_NONE__INT_POINTER_INT_POINTER_INT_INT_POINTER_INT_INT) func;
+ (*rfunc) (object,
+ GTK_VALUE_INT (args[0]),
+ GTK_VALUE_POINTER (args[1]),
+ GTK_VALUE_INT (args[2]),
+ GTK_VALUE_POINTER (args[3]),
+ GTK_VALUE_INT (args[4]),
+ GTK_VALUE_INT (args[5]),
+ GTK_VALUE_POINTER (args[6]),
+ GTK_VALUE_INT (args[7]), GTK_VALUE_INT (args[8]), func_data);
+}
+
typedef void (*GtkSignal_NONE__POINTER_POINTER_INT) (GtkObject *, gpointer,
gpointer, gint, gpointer);
@@ -449,6 +575,19 @@ e_marshal_NONE__POINTER_POINTER_INT (GtkObject * object, GtkSignalFunc func,
GTK_VALUE_INT (args[2]), func_data);
}
+typedef void (*GtkSignal_NONE__INT_POINTER_INT_POINTER) (GtkObject *, gint, gpointer,
+ gint, gpointer, gpointer);
+
+void
+e_marshal_NONE__INT_POINTER_INT_POINTER (GtkObject * object, GtkSignalFunc func,
+ gpointer func_data, GtkArg * args)
+{
+ GtkSignal_NONE__INT_POINTER_INT_POINTER rfunc;
+ rfunc = (GtkSignal_NONE__INT_POINTER_INT_POINTER) func;
+ (*rfunc) (object, GTK_VALUE_INT (args[0]), GTK_VALUE_POINTER (args[1]),
+ GTK_VALUE_INT (args[2]), GTK_VALUE_POINTER (args[3]), func_data);
+}
+
typedef int (*GtkSignal_INT__POINTER_POINTER) (GtkObject *,
gpointer, gpointer,
gpointer user_data);
@@ -740,3 +879,108 @@ e_create_directory (gchar *directory)
return (return_value);
}
+
+
+/* Perform a binary search for key in base which has nmemb elements
+ of size bytes each. The comparisons are done by (*compare)(). */
+void e_bsearch (const void *key,
+ const void *base,
+ size_t nmemb,
+ size_t size,
+ ESortCompareFunc compare,
+ gpointer closure,
+ size_t *start,
+ size_t *end)
+{
+ size_t l, u, idx;
+ const void *p;
+ int comparison;
+ if (!(start || end))
+ return;
+
+ l = 0;
+ u = nmemb;
+ while (l < u) {
+ idx = (l + u) / 2;
+ p = (void *) (((const char *) base) + (idx * size));
+ comparison = (*compare) (key, p, closure);
+ if (comparison < 0)
+ u = idx;
+ else if (comparison > 0)
+ l = idx + 1;
+ else {
+ size_t lsave, usave;
+ lsave = l;
+ usave = u;
+ if (start) {
+ while (l < u) {
+ idx = (l + u) / 2;
+ p = (void *) (((const char *) base) + (idx * size));
+ comparison = (*compare) (key, p, closure);
+ if (comparison <= 0)
+ u = idx;
+ else
+ l = idx + 1;
+ }
+ *start = l;
+
+ l = lsave;
+ u = usave;
+ }
+ if (end) {
+ while (l < u) {
+ idx = (l + u) / 2;
+ p = (void *) (((const char *) base) + (idx * size));
+ comparison = (*compare) (key, p, closure);
+ if (comparison < 0)
+ u = idx;
+ else
+ l = idx + 1;
+ }
+ *end = l;
+ }
+ return;
+ }
+ }
+
+ if (start)
+ *start = l;
+ if (end)
+ *end = l;
+}
+
+static gpointer closure_closure;
+static ESortCompareFunc compare_closure;
+
+static int
+qsort_callback(const void *data1, const void *data2)
+{
+ return (*compare_closure) (data1, data2, closure_closure);
+}
+
+/* Forget it. We're just going to use qsort. I lost the need for a stable sort. */
+void
+e_sort (void *base,
+ size_t nmemb,
+ size_t size,
+ ESortCompareFunc compare,
+ gpointer closure)
+{
+ closure_closure = closure;
+ compare_closure = compare;
+ qsort(base, nmemb, size, qsort_callback);
+#if 0
+ void *base_copy;
+ int i;
+ base_copy = g_malloc(nmemb * size);
+
+ for (i = 0; i < nmemb; i++) {
+ int position;
+ e_bsearch(base + (i * size), base_copy, i, size, compare, closure, NULL, &position);
+ memmove(base_copy + (position + 1) * size, base_copy + position * size, (i - position) * size);
+ memcpy(base_copy + position * size, base + i * size, size);
+ }
+ memcpy(base, base_copy, nmemb * size);
+ g_free(base_copy);
+#endif
+}