Index: gmain.c =================================================================== RCS file: /cvsroot/bluez/utils/eglib/gmain.c,v retrieving revision 1.27 diff -u -3 -p -u -r1.27 gmain.c --- gmain.c 3 May 2007 15:41:42 -0000 1.27 +++ gmain.c 18 May 2007 15:33:39 -0000 @@ -1127,6 +1127,48 @@ void g_slist_free(GSList *list) } } +GSList *g_slist_nth(GSList *list, guint n) +{ + while (n-- > 0 && list) + list = list->next; + + return list; +} + +gpointer g_slist_nth_data(GSList *list, guint n) +{ + while (n-- > 0 && list) + list = list->next; + + return list ? list->data : NULL; +} + +gint g_slist_position(GSList *list, GSList *link) +{ + gint i; + + i = 0; + while (list) { + if (list == link) + return i; + i++; + list = list->next; + } + + return -1; +} + +GSList* g_slist_last(GSList *list) +{ + if (list) + { + while (list->next) + list = list->next; + } + + return list; +} + /* Memory allocation functions */ gpointer g_malloc(gulong n_bytes) Index: gmain.h =================================================================== RCS file: /cvsroot/bluez/utils/eglib/gmain.h,v retrieving revision 1.12 diff -u -3 -p -u -r1.12 gmain.h --- gmain.h 3 May 2007 15:41:43 -0000 1.12 +++ gmain.h 18 May 2007 15:33:39 -0000 @@ -192,6 +192,11 @@ int g_slist_length(GSList *list); void g_slist_foreach(GSList *list, GFunc func, void *user_data); void g_slist_free(GSList *list); +GSList *g_slist_nth(GSList *list, guint n); +gpointer g_slist_nth_data(GSList *list, guint n); +int g_slist_position(GSList *list, GSList *link); +GSList* g_slist_last(GSList *list); + /* End GSList declarations */ /* Memory allocation related */