summaryrefslogtreecommitdiffstats
path: root/eglib
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-01-20 12:37:21 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-01-20 12:37:21 +0000
commit88a2fca09c8a94a11b2a8073fb65f3f3e752d090 (patch)
tree67cbda9d93a0b9434f35aab638ec80e6bd671a90 /eglib
parent3fd70cad862febf8f1a60bd47576cb758d085958 (diff)
Implement stubs of missing eglib functions
Diffstat (limited to 'eglib')
-rw-r--r--eglib/gmain.c188
-rw-r--r--eglib/gmain.h93
2 files changed, 281 insertions, 0 deletions
diff --git a/eglib/gmain.c b/eglib/gmain.c
index bc1af91a..8566265c 100644
--- a/eglib/gmain.c
+++ b/eglib/gmain.c
@@ -3,6 +3,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <malloc.h>
#include <string.h>
#include <limits.h>
@@ -80,6 +81,13 @@ retry:
return (result > 0) ? G_IO_STATUS_NORMAL : G_IO_STATUS_EOF;
}
+GIOError g_io_channel_write(GIOChannel *channel, const gchar *buf, gsize count,
+ gsize *bytes_written)
+{
+ /* Not implemented */
+ return G_IO_STATUS_ERROR;
+}
+
void g_io_channel_close(GIOChannel *channel)
{
if (!channel || channel->closed)
@@ -166,6 +174,12 @@ static GMainContext *g_main_context_default()
return default_context;
}
+gboolean g_source_remove(guint tag)
+{
+ /* Not implemented yet */
+ return FALSE;
+}
+
void g_io_remove_watch(guint id)
{
GMainContext *context = g_main_context_default();
@@ -526,6 +540,44 @@ gint g_timeout_remove(const guint id)
return -1;
}
+guint g_idle_add(GSourceFunc func, gpointer user_data)
+{
+ /* Not implemented */
+ return 0;
+}
+
+/* GError */
+void g_error_free(GError *err)
+{
+ g_free(err->message);
+ g_free(err);
+}
+
+/* Spawning related functions */
+
+gboolean g_spawn_async(const gchar *working_directory,
+ gchar **argv, gchar **envp,
+ GSpawnFlags flags,
+ GSpawnChildSetupFunc child_setup,
+ gpointer user_data,
+ GPid *child_pid,
+ GError **error)
+{
+ /* Not implemented */
+ return FALSE;
+}
+
+void g_spawn_close_pid(GPid pid)
+{
+ return;
+}
+
+guint g_child_watch_add(GPid pid, GChildWatchFunc func, gpointer user_data)
+{
+ /* Not implemented */
+ return 0;
+}
+
/* UTF-8 Validation: approximate copy/paste from glib2. */
#define UNICODE_VALID(c) \
@@ -724,6 +776,18 @@ GSList *g_slist_remove(GSList *list, void *data)
return list;
}
+GSList *g_slist_find(GSList *list, gconstpointer data)
+{
+ GSList *l;
+
+ for (l = list; l != NULL; l = l->next) {
+ if (l->data == data)
+ return l;
+ }
+
+ return NULL;
+}
+
GSList *g_slist_find_custom(GSList *list, const void *data,
GCompareFunc cmp_func)
{
@@ -888,3 +952,127 @@ gchar *g_strdup(const gchar *str)
return s;
}
+gchar *g_strdup_printf(const gchar *format, ...)
+{
+ gchar str[1024];
+ va_list ap;
+
+ memset(str, 0, sizeof(str));
+
+ va_start(ap, format);
+
+ vsnprintf(str, sizeof(str) - 1, format, ap);
+
+ va_end(ap);
+
+ return g_strdup(str);
+}
+
+void g_strfreev(gchar **str_array)
+{
+ int i;
+
+ if (!str_array)
+ return;
+
+ for (i = 0; str_array[i] != NULL; i++)
+ g_free(str_array[i]);
+
+ g_free(str_array);
+}
+
+/* g_shell_* */
+
+gboolean g_shell_parse_argv(const gchar *command_line,
+ gint *argcp,
+ gchar ***argvp,
+ GError **error)
+{
+ /* Not implemented */
+ return FALSE;
+}
+
+/* GKeyFile */
+
+typedef gpointer GHashTable;
+
+typedef struct _GKeyFileGroup GKeyFileGroup;
+
+struct _GKeyFile {
+ GSList *groups;
+
+ GKeyFileGroup *start_group;
+ GKeyFileGroup *current_group;
+
+ /* Holds up to one line of not-yet-parsed data */
+ gchar *parse_buffer;
+
+ /* Used for sizing the output buffer during serialization */
+ gsize approximate_size;
+
+ gchar list_separator;
+
+ GKeyFileFlags flags;
+};
+
+typedef struct _GKeyFileKeyValuePair GKeyFileKeyValuePair;
+
+struct _GKeyFileGroup {
+ /* NULL for above first group (which will be comments) */
+ const gchar *name;
+
+ /* Special comment that is stuck to the top of a group */
+ GKeyFileKeyValuePair *comment;
+
+ GSList *key_value_pairs;
+
+ /* Used in parallel with key_value_pairs for
+ * increased lookup performance
+ */
+ GHashTable *lookup_map;
+};
+
+struct _GKeyFileKeyValuePair {
+ gchar *key; /* NULL for comments */
+ gchar *value;
+};
+
+GKeyFile *g_key_file_new(void)
+{
+ /* Not implemented */
+ return NULL;
+}
+
+void g_key_file_free(GKeyFile *key_file)
+{
+ /* Not implemented fully */
+ g_free(key_file);
+}
+
+gboolean g_key_file_load_from_file(GKeyFile *key_file,
+ const gchar *file,
+ GKeyFileFlags flags,
+ GError **error)
+{
+ /* Not implemented */
+ return FALSE;
+}
+
+gchar *g_key_file_get_string(GKeyFile *key_file,
+ const gchar *group_name,
+ const gchar *key,
+ GError **error)
+{
+ /* Not implemented */
+ return NULL;
+}
+
+gboolean g_key_file_get_boolean(GKeyFile *key_file,
+ const gchar *group_name,
+ const gchar *key,
+ GError **error)
+{
+ /* Not implemented */
+ return FALSE;
+}
+
diff --git a/eglib/gmain.h b/eglib/gmain.h
index c86ab1eb..9c50b050 100644
--- a/eglib/gmain.h
+++ b/eglib/gmain.h
@@ -3,6 +3,8 @@
#include <stdlib.h>
#include <sys/poll.h>
+#include <sys/types.h>
+#include <inttypes.h>
typedef char gchar;
typedef short gshort;
@@ -15,6 +17,8 @@ typedef unsigned short gushort;
typedef unsigned long gulong;
typedef unsigned int guint;
+typedef uint32_t guint32;
+
typedef float gfloat;
typedef double gdouble;
@@ -28,6 +32,8 @@ typedef ssize_t gssize;
#define SSIZE_MAX INT_MAX
#endif
+typedef pid_t GPid;
+
#define MIN_TIMEOUT(a, b) (((a) < (b)) ? (a) : (b))
typedef struct _GIOChannel GIOChannel;
@@ -79,6 +85,10 @@ typedef void (*GDestroyNotify) (gpointer data);
typedef gboolean (*GIOFunc) (GIOChannel *source, GIOCondition condition, gpointer data);
GIOError g_io_channel_read(GIOChannel *channel, gchar *buf, gsize count, gsize *bytes_read);
+GIOError g_io_channel_write(GIOChannel *channel, const gchar *buf, gsize count,
+ gsize *bytes_written);
+
+
void g_io_channel_close(GIOChannel *channel);
GIOChannel *g_io_channel_unix_new(int fd);
@@ -98,6 +108,50 @@ void g_main_loop_quit(GMainLoop *loop);
void g_main_loop_unref(GMainLoop *loop);
guint g_timeout_add(guint interval, GSourceFunc function, gpointer data);
gint g_timeout_remove(const guint id);
+gboolean g_source_remove(guint tag);
+guint g_idle_add(GSourceFunc func, gpointer user_data);
+
+/* GError */
+
+typedef guint32 GQuark;
+
+typedef struct {
+ GQuark domain;
+ gint code;
+ gchar *message;
+} GError;
+
+void g_error_free(GError *err);
+
+/* Spawning related functions */
+
+typedef enum {
+ G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
+ G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
+ /* look for argv[0] in the path i.e. use execvp() */
+ G_SPAWN_SEARCH_PATH = 1 << 2,
+ /* Dump output to /dev/null */
+ G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
+ G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
+ G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
+ G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
+} GSpawnFlags;
+
+typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
+
+gboolean g_spawn_async(const gchar *working_directory,
+ gchar **argv, gchar **envp,
+ GSpawnFlags flags,
+ GSpawnChildSetupFunc child_setup,
+ gpointer user_data,
+ GPid *child_pid,
+ GError **error);
+
+void g_spawn_close_pid(GPid pid);
+
+typedef void (*GChildWatchFunc) (GPid pid, gint status, gpointer data);
+
+guint g_child_watch_add(GPid pid, GChildWatchFunc func, gpointer user_data);
gboolean g_utf8_validate(const gchar *str, gssize max_len, const gchar **end);
@@ -124,6 +178,8 @@ GSList *g_slist_insert_sorted(GSList *list, void *data, GCompareFunc cmp_func);
GSList *g_slist_remove(GSList *list, void *data);
+GSList *g_slist_find(GSList *list, gconstpointer data);
+
GSList *g_slist_find_custom(GSList *list, const void *data,
GCompareFunc cmp_func);
@@ -146,6 +202,8 @@ gpointer g_try_malloc0(gulong n_bytes);
void g_free(gpointer mem);
gchar *g_strdup(const gchar *str);
+gchar *g_strdup_printf(const gchar *format, ...);
+void g_strfreev(gchar **str_array);
#define g_new(struct_type, n_structs) \
((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
@@ -156,4 +214,39 @@ gchar *g_strdup(const gchar *str);
#define g_try_new0(struct_type, n_structs) \
((struct_type *) g_try_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
+/* g_shell_* */
+gboolean g_shell_parse_argv(const gchar *command_line,
+ gint *argcp,
+ gchar ***argvp,
+ GError **error);
+
+/* GKeyFile */
+
+typedef enum {
+ G_KEY_FILE_NONE = 0,
+ G_KEY_FILE_KEEP_COMMENTS = 1 << 0,
+ G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
+} GKeyFileFlags;
+
+typedef struct _GKeyFile GKeyFile;
+
+GKeyFile *g_key_file_new(void);
+
+void g_key_file_free(GKeyFile *key_file);
+
+gboolean g_key_file_load_from_file(GKeyFile *key_file,
+ const gchar *file,
+ GKeyFileFlags flags,
+ GError **error);
+
+gchar *g_key_file_get_string(GKeyFile *key_file,
+ const gchar *group_name,
+ const gchar *key,
+ GError **error);
+
+gboolean g_key_file_get_boolean(GKeyFile *key_file,
+ const gchar *group_name,
+ const gchar *key,
+ GError **error);
+
#endif /* __GMAIN_H */