diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-08-23 08:01:06 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-08-23 08:01:06 +0000 |
commit | 75b016927c9deb7c1a1b05628aa2fe56d9c8f255 (patch) | |
tree | ba01dd57ebfad3a846d37dbf84b34cc482f95666 /eglib | |
parent | 73b35c403df78c10e03ded497fcb16fcb23b822e (diff) |
Fix missing eglib functions
Diffstat (limited to 'eglib')
-rw-r--r-- | eglib/gmain.c | 26 | ||||
-rw-r--r-- | eglib/gmain.h | 21 |
2 files changed, 28 insertions, 19 deletions
diff --git a/eglib/gmain.c b/eglib/gmain.c index f658b02a..9a4f0097 100644 --- a/eglib/gmain.c +++ b/eglib/gmain.c @@ -1289,16 +1289,30 @@ gchar *g_strdup(const gchar *str) return s; } -gchar* g_strdup_printf(const gchar *format, ...) +gchar *g_strdup_printf(const gchar *format, ...) { - /* FIXME: Implement this */ - return g_strdup(format); + va_list args; + gchar buffer[1024]; + gint length; + + va_start(args, format); + length = vsnprintf(buffer, sizeof(buffer) - 1, format, args); + va_end(args); + + return strdup(buffer); } -gchar* g_strdelimit(gchar *string, const gchar *delimiters, - gchar new_delimiter) +gchar *g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delim) { - /* FIXME: Implement this */ + register gchar *c; + + if (!string) + return NULL; + + for (c = string; *c; c++) + if (strchr(delimiters, *c)) + *c = new_delim; + return string; } diff --git a/eglib/gmain.h b/eglib/gmain.h index ea445c44..172031ac 100644 --- a/eglib/gmain.h +++ b/eglib/gmain.h @@ -83,12 +83,12 @@ typedef enum { typedef void (*GDestroyNotify) (gpointer data); typedef gboolean (*GIOFunc) (GIOChannel *source, GIOCondition condition, - gpointer data); + gpointer data); GIOError g_io_channel_read(GIOChannel *channel, gchar *buf, gsize count, - gsize *bytes_read); + gsize *bytes_read); GIOError g_io_channel_write(GIOChannel *channel, const gchar *buf, gsize count, - gsize *bytes_written); + gsize *bytes_written); void g_io_channel_close(GIOChannel *channel); @@ -163,7 +163,7 @@ gboolean g_utf8_validate(const gchar *str, gssize max_len, const gchar **end); #define g_main_quit(loop) g_main_loop_quit(loop) #define g_main_unref(loop) g_main_loop_unref(loop) -/* Begin GSList declarations */ +/* GSList declarations */ typedef struct _GSList { void *data; @@ -201,8 +201,6 @@ GSList* g_slist_last(GSList *list); #define g_slist_next(l) ((l)->next) -/* End GSList declarations */ - /* Memory allocation related */ gpointer g_malloc(gulong n_bytes); @@ -215,17 +213,15 @@ void g_free(gpointer mem); gchar *g_strdup(const gchar *str); gchar* g_strdup_printf(const gchar *format, ...); -gchar* g_strdelimit(gchar *string, const gchar *delimiters, - gchar new_delimiter); - +gchar* g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delim); #define g_new(struct_type, n_structs) \ ((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) #define g_new0(struct_type, n_structs) \ ((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) -#define g_try_new(struct_type, n_structs) \ +#define g_try_new(struct_type, n_structs) \ ((struct_type *) g_try_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) -#define g_try_new0(struct_type, n_structs) \ +#define g_try_new0(struct_type, n_structs) \ ((struct_type *) g_try_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) /* GKeyFile */ @@ -257,12 +253,11 @@ gboolean g_key_file_get_boolean(GKeyFile *key_file, const gchar *key, GError **error); - /* GString */ typedef struct { gchar *str; - gsize len; + gsize len; gsize allocated_len; } GString; |