diff -r 744f42f0b3a7 configure.ac --- a/configure.ac Tue Nov 09 23:29:34 2010 +0100 +++ b/configure.ac Fri Nov 12 16:51:56 2010 +0900 @@ -654,7 +654,7 @@ AC_CHECK_LIB(glib-2.0, g_hash_table_get_values) if test "x$ac_cv_lib_glib_2_0_g_hash_table_get_values" != x""yes; then - AC_MSG_ERROR(Your version of Glib is too old, you need at least 2.14) + AC_MSG_WARN(Your version of Glib is too old, you should have at least 2.14) fi # diff -r 744f42f0b3a7 include/crm/common/util.h --- a/include/crm/common/util.h Tue Nov 09 23:29:34 2010 +0100 +++ b/include/crm/common/util.h Fri Nov 12 16:51:56 2010 +0900 @@ -298,4 +298,63 @@ extern xmlNode *create_operation_update(xmlNode *parent, lrm_op_t *op, const char *caller_version, int target_rc, const char *origin, int level); extern void free_lrm_op(lrm_op_t *op); +#if HAVE_LIBGLIB_2_0 + +#else + +typedef struct fake_ghi +{ + int offset; + GHashTable *hash; + GList *values; + +} GHashTableIter; + +static inline void g_hash_append_value(gpointer key, gpointer value, gpointer user_data) +{ + GList **values = (GList **)user_data; + *values = g_list_append(*values, value); +} + +static inline GList *g_hash_table_get_values(GHashTable *hash_table) +{ + GList *values = NULL; + g_hash_table_foreach(hash_table, g_hash_append_value, &values); + return values; +} + +static inline void g_hash_table_iter_init(GHashTableIter *iter, GHashTable *hash_table) +{ + iter->offset = 0; + iter->values = NULL; + iter->hash = hash_table; + + /* iter->values = g_hash_table_get_values(hash_table); */ + + /* We could cache the values, but then we need to clean up the list + * later which doesn't fit the glib2 API + * So instead we calculate it in _next() every time its needed + */ +} + + +static inline gboolean g_hash_table_iter_next(GHashTableIter *iter, gpointer *key, gpointer *value) +{ + GList *values = iter->values; + if(iter->values == NULL) { + values = g_hash_table_get_values(iter->hash); + } + + iter->offset++; + *value = g_list_nth_data(values, iter->offset); + + if(iter->values == NULL) { + g_list_free(values); + } + return (*value) != NULL; +} + #endif + +#endif +