[ekg2-commit] r4069 - trunk/ekg: trunk/ekg/dynstuff_inline.h trunk/ekg/emoticons.c trunk/ekg/events.c trunk/ekg/log.c trunk/ekg/metacontacts.c trunk/ekg/msgqueue.c trunk/ekg/plugins.c trunk/ekg/sessions.c trunk/ekg/stuff.c trunk/ekg/themes.c trunk/ekg/userlist.c
SVN commit
svn w toxygen.net
Wto, 8 Lip 2008, 18:46:28 CEST
Author: darkjames
Date: 2008-07-08 18:46:28 +0200 (Tue, 08 Jul 2008)
New Revision: 4069
Modified:
trunk/ekg/dynstuff_inline.h
trunk/ekg/emoticons.c
trunk/ekg/events.c
trunk/ekg/log.c
trunk/ekg/metacontacts.c
trunk/ekg/msgqueue.c
trunk/ekg/plugins.c
trunk/ekg/sessions.c
trunk/ekg/stuff.c
trunk/ekg/themes.c
trunk/ekg/userlist.c
Log:
new idea howto declare list_t functions
cpp is COOL!
Modified: trunk/ekg/dynstuff_inline.h
===================================================================
--- trunk/ekg/dynstuff_inline.h 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/dynstuff_inline.h 2008-07-08 16:46:28 UTC (rev 4069)
@@ -11,10 +11,10 @@
#if DYNSTUFF_USE_LIST3
-#define __DYNSTUFF_LIST_ADD(lista, typ) \
+#define __DYNSTUFF_LIST_ADD(lista, typ, __notused) \
void lista##_add(typ *new) { list_add3((list_t *) &lista, (list_t) new); }
-#define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ) \
+#define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ, __notused) \
void lista##_add(typ *new) { list_add_beginning3((list_t *) &lista, (list_t) new); }
#define __DYNSTUFF_LIST_ADD_SORTED(lista, typ, comparision) \
@@ -48,7 +48,7 @@
#else
-#define __DYNSTUFF_LIST_ADD(lista, typ) \
+#define __DYNSTUFF_LIST_ADD(lista, typ, __notused) \
void lista##_add(typ *new) { \
new->next = NULL; \
if (!lista) { \
@@ -62,7 +62,7 @@
} \
}
-#define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ) \
+#define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ, __notused) \
void lista##_add(typ *new) { \
new->next = lista; \
lista = new; \
@@ -197,7 +197,7 @@
#if DYNSTUFF_USE_LIST3
-#define __DYNSTUFF_ADD_BEGINNING(prefix, typ) \
+#define __DYNSTUFF_ADD_BEGINNING(prefix, typ, __notused) \
void prefix##_add(typ **lista, typ *new) { list_add_beginning3((list_t *) lista, (list_t) new); }
#define __DYNSTUFF_ADD_SORTED(prefix, typ, comparision) \
@@ -227,7 +227,7 @@
#else
/* XXX, checkit */
-#define __DYNSTUFF_ADD(prefix, typ) \
+#define __DYNSTUFF_ADD(prefix, typ, __notused) \
void prefix##_add(typ **lista, typ *new) { \
typ *tmp = *lista; \
\
@@ -241,7 +241,7 @@
} \
}
-#define __DYNSTUFF_ADD_BEGINNING(prefix, typ) \
+#define __DYNSTUFF_ADD_BEGINNING(prefix, typ, __notused) \
void prefix##_add(typ **lista, typ *new) { \
new->next = *lista; \
*lista = new; \
@@ -372,4 +372,33 @@
#endif
+#define __DYNSTUFF_NOREMOVE(lista, typ, free_func)
+#define __DYNSTUFF_NOUNLINK(lista, typ)
+#define __DYNSTUFF_NOCOUNT(lista, typ)
+#define __DYNSTUFF_NODESTROY(lista, typ, free_func)
+
+#define DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_unlink, list_destroy, list_count) \
+ list_add(lista, type, compare_func) \
+ list_remove(lista, type, free_func) \
+ list_remove2(lista, type, free_func) \
+ list_unlink(lista, type) \
+ list_destroy(lista, type, free_func) \
+ list_count(lista, type)
+
+#define DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, list_count) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, list_count)
+
+#define DYNSTUFF_LIST_DECLARE(lista, type, free_func, list_add, list_remove, list_destroy) \
+ DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, __DYNSTUFF_NOCOUNT)
+
+#define DYNSTUFF_LIST_DECLARE2(lista, type, free_func, list_add, list_remove, list_remove2, list_destroy) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
+
+#define DYNSTUFF_LIST_DECLARE_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_destroy) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
+
+#define DYNSTUFF_LIST_DECLARE_SORTED_NF(lista, type, compare_func, list_add, list_unlink) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT)
+
+
#endif
Modified: trunk/ekg/emoticons.c
===================================================================
--- trunk/ekg/emoticons.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/emoticons.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -41,9 +41,12 @@
emoticon_t *emoticons = NULL;
static LIST_FREE_ITEM(list_emoticon_free, emoticon_t *) { xfree(data->name); xfree(data->value); }
-__DYNSTUFF_LIST_ADD(emoticons, emoticon_t); /* emoticons_add() */
-__DYNSTUFF_LIST_DESTROY(emoticons, emoticon_t, list_emoticon_free); /* emoticons_destroy() */
+DYNSTUFF_LIST_DECLARE(emoticons, emoticon_t, list_emoticon_free,
+ __DYNSTUFF_LIST_ADD, /* emoticons_add() */
+ __DYNSTUFF_NOREMOVE,
+ __DYNSTUFF_LIST_DESTROY) /* emoticons_destroy() */
+
int config_emoticons = 1;
/*
Modified: trunk/ekg/events.c
===================================================================
--- trunk/ekg/events.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/events.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -45,9 +45,10 @@
static LIST_ADD_COMPARE(event_add_compare, event_t *) { return data1->id - data2->id; }
static LIST_FREE_ITEM(list_event_free, struct event *) { xfree(data->name); xfree(data->action); xfree(data->target); }
-__DYNSTUFF_LIST_ADD_SORTED(events, event_t, event_add_compare); /* events_add() */
-__DYNSTUFF_LIST_REMOVE_SAFE(events, event_t, list_event_free); /* events_remove() */
-__DYNSTUFF_LIST_DESTROY(events, event_t, list_event_free); /* events_destroy() */
+DYNSTUFF_LIST_DECLARE_SORTED(events, event_t, event_add_compare, list_event_free,
+ __DYNSTUFF_LIST_ADD_SORTED, /* events_add() */
+ __DYNSTUFF_LIST_REMOVE_SAFE, /* events_remove() */
+ __DYNSTUFF_LIST_DESTROY) /* events_destroy() */
char **events_all = NULL;
Modified: trunk/ekg/log.c
===================================================================
--- trunk/ekg/log.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/log.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -41,10 +41,11 @@
xfree(data->message);
}
-__DYNSTUFF_LIST_ADD(lasts, struct last); /* lasts_add() */
-__DYNSTUFF_LIST_REMOVE_ITER(lasts, struct last, list_last_free); /* lasts_removei() */
-__DYNSTUFF_LIST_DESTROY(lasts, struct last, list_last_free); /* lasts_destroy() */
-__DYNSTUFF_LIST_COUNT(lasts, struct last); /* lasts_count() */
+DYNSTUFF_LIST_DECLARE_WC(lasts, struct last, list_last_free,
+ __DYNSTUFF_LIST_ADD, /* lasts_add() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* lasts_removei() */
+ __DYNSTUFF_LIST_DESTROY, /* lasts_destroy() */
+ __DYNSTUFF_LIST_COUNT) /* lasts_count() */
/*
* last_add()
Modified: trunk/ekg/metacontacts.c
===================================================================
--- trunk/ekg/metacontacts.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/metacontacts.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -48,17 +48,19 @@
static LIST_FREE_ITEM(metacontact_item_free, metacontact_item_t *) { xfree(data->name); xfree(data->s_uid); }
-__DYNSTUFF_ADD_SORTED(metacontact_items, metacontact_item_t, metacontact_add_item_compare); /* metacontact_items_add() */
-__DYNSTUFF_REMOVE_SAFE(metacontact_items, metacontact_item_t, metacontact_item_free); /* metacontact_items_remove() */ /* removei() ? */
-__DYNSTUFF_DESTROY(metacontact_items, metacontact_item_t, metacontact_item_free); /* metacontact_items_destroy() */
+DYNSTUFF_LIST_DECLARE_SORTED(metacontact_items, metacontact_item_t, metacontact_add_item_compare, metacontact_item_free,
+ __DYNSTUFF_ADD_SORTED, /* metacontact_items_add() */
+ __DYNSTUFF_REMOVE_SAFE, /* metacontact_items_remove() */ /* maybe removei() ? */
+ __DYNSTUFF_DESTROY) /* metacontact_items_destroy() */
/* metacontacts: */
static LIST_ADD_COMPARE(metacontact_add_compare, metacontact_t *) { return xstrcasecmp(data1->name, data2->name); }
static LIST_FREE_ITEM(metacontact_list_free, metacontact_t *) { metacontact_items_destroy(&(data->metacontact_items)); xfree(data->name); }
-__DYNSTUFF_LIST_ADD_SORTED(metacontacts, metacontact_t, metacontact_add_compare); /* metacontacts_add() */
-__DYNSTUFF_LIST_REMOVE_SAFE(metacontacts, metacontact_t, metacontact_list_free); /* metacontacts_remove() */ /* removei() ? */
-__DYNSTUFF_LIST_DESTROY(metacontacts, metacontact_t, metacontact_list_free); /* metacontacts_destroy() */
+DYNSTUFF_LIST_DECLARE_SORTED(metacontacts, metacontact_t, metacontact_add_compare, metacontact_list_free,
+ __DYNSTUFF_LIST_ADD_SORTED, /* metacontacts_add() */
+ __DYNSTUFF_LIST_REMOVE_SAFE, /* metacontacts_remove() */ /* maybe removei() ? */
+ __DYNSTUFF_LIST_DESTROY) /* metacontacts_destroy() */
static int metacontact_add_item(metacontact_t *m, const char *session, const char *name, unsigned int prio, int quiet);
static int metacontact_remove_item(metacontact_t *m, const char *session, const char *name, int quiet);
Modified: trunk/ekg/msgqueue.c
===================================================================
--- trunk/ekg/msgqueue.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/msgqueue.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -46,9 +46,10 @@
static LIST_FREE_ITEM(list_msg_queue_free, msg_queue_t *) { xfree(data->session); xfree(data->rcpts); xfree(data->message); xfree(data->seq); }
-__DYNSTUFF_LIST_ADD(msgs_queue, msg_queue_t); /* msgs_queue_add() */
-__DYNSTUFF_LIST_REMOVE_ITER(msgs_queue, msg_queue_t, list_msg_queue_free); /* msgs_queue_removei() */
-__DYNSTUFF_LIST_DESTROY(msgs_queue, msg_queue_t, list_msg_queue_free); /* msgs_queue_destroy() */
+DYNSTUFF_LIST_DECLARE(msgs_queue, msg_queue_t, list_msg_queue_free,
+ __DYNSTUFF_LIST_ADD, /* msgs_queue_add() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* msgs_queue_removei() */
+ __DYNSTUFF_LIST_DESTROY) /* msgs_queue_destroy() */
/*
* msg_queue_add()
Modified: trunk/ekg/plugins.c
===================================================================
--- trunk/ekg/plugins.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/plugins.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -54,11 +54,13 @@
plugin_t *plugins = NULL;
static LIST_ADD_COMPARE(plugin_register_compare, plugin_t *) { return data2->prio - data1->prio; }
-__DYNSTUFF_LIST_ADD_SORTED(plugins, plugin_t, plugin_register_compare); /* plugins_add() */
-__DYNSTUFF_LIST_UNLINK(plugins, plugin_t); /* plugins_unlink() */
+DYNSTUFF_LIST_DECLARE_SORTED_NF(plugins, plugin_t, plugin_register_compare,
+ __DYNSTUFF_LIST_ADD_SORTED, /* plugins_add() */
+ __DYNSTUFF_LIST_UNLINK) /* plugins_unlink() */
+
watch_t *watches = NULL;
-__DYNSTUFF_LIST_ADD_BEGINNING(watches, watch_t); /* watches_add() */
+__DYNSTUFF_LIST_ADD_BEGINNING(watches, watch_t, NULL); /* watches_add() */
idle_t *idles = NULL;
Modified: trunk/ekg/sessions.c
===================================================================
--- trunk/ekg/sessions.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/sessions.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -59,7 +59,7 @@
static LIST_FREE_ITEM(session_param_free_item, session_param_t *) { xfree(data->key); xfree(data->value); }
-__DYNSTUFF_ADD_BEGINNING(session_vars, session_param_t); /* session_vars_add() */
+__DYNSTUFF_ADD_BEGINNING(session_vars, session_param_t, NULL); /* session_vars_add() */
__DYNSTUFF_DESTROY(session_vars, session_param_t, session_param_free_item); /* session_vars_destroy() */
session_t *session_current = NULL;
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/stuff.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -86,10 +86,12 @@
child_t *children = NULL;
static LIST_FREE_ITEM(child_free_item, child_t *) { xfree(data->name); }
-__DYNSTUFF_LIST_ADD(children, child_t); /* children_add() */
-__DYNSTUFF_LIST_REMOVE_ITER(children, child_t, child_free_item); /* children_removei() */
-__DYNSTUFF_LIST_DESTROY(children, child_t, child_free_item); /* children_destroy() */
+DYNSTUFF_LIST_DECLARE(children, child_t, child_free_item,
+ __DYNSTUFF_LIST_ADD, /* children_add() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* children_removei() */
+ __DYNSTUFF_LIST_DESTROY) /* children_destroy() */
+
alias_t *aliases = NULL;
list_t autofinds = NULL;
struct binding *bindings = NULL;
@@ -97,11 +99,13 @@
struct timer *timers = NULL;
static LIST_FREE_ITEM(timer_free_item, struct timer *) { data->function(1, data->data); xfree(data->name); }
-__DYNSTUFF_LIST_ADD(timers, struct timer); /* timers_add() */
-__DYNSTUFF_LIST_REMOVE_SAFE(timers, struct timer, timer_free_item); /* timers_remove() */
-__DYNSTUFF_LIST_REMOVE_ITER(timers, struct timer, timer_free_item); /* timers_removei() */
-__DYNSTUFF_LIST_DESTROY(timers, struct timer, timer_free_item); /* timers_destroy() */
+DYNSTUFF_LIST_DECLARE2(timers, struct timer, timer_free_item,
+ __DYNSTUFF_LIST_ADD, /* timers_add() */
+ __DYNSTUFF_LIST_REMOVE_SAFE, /* timers_remove() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* timers_removei() */
+ __DYNSTUFF_LIST_DESTROY) /* timers_destroy() */
+
struct conference *conferences = NULL;
newconference_t *newconferences = NULL;
@@ -254,9 +258,10 @@
static LIST_FREE_ITEM(list_alias_free, alias_t *) { xfree(data->name); LIST_DESTROY2(data->commands, list_t_free_item); }
-__DYNSTUFF_LIST_ADD(aliases, alias_t); /* aliases_add() */
-__DYNSTUFF_LIST_REMOVE_ITER(aliases, alias_t, list_alias_free); /* aliases_removei() */
-__DYNSTUFF_LIST_DESTROY(aliases, alias_t, list_alias_free); /* aliases_destroy() */
+DYNSTUFF_LIST_DECLARE(aliases, alias_t, list_alias_free,
+ __DYNSTUFF_LIST_ADD, /* aliases_add() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* aliases_removei() */
+ __DYNSTUFF_LIST_DESTROY) /* aliases_destroy() */
/*
* alias_add()
@@ -681,9 +686,10 @@
static LIST_FREE_ITEM(newconference_free_item, newconference_t *) { xfree(data->name); xfree(data->session); userlists_destroy(&(data->participants)); }
-__DYNSTUFF_LIST_ADD(newconferences, newconference_t); /* newconferences_add() */
-__DYNSTUFF_LIST_REMOVE_SAFE(newconferences, newconference_t, newconference_free_item); /* newconferences_remove() */
-__DYNSTUFF_LIST_DESTROY(newconferences, newconference_t, newconference_free_item); /* newconferences_destroy() */
+DYNSTUFF_LIST_DECLARE(newconferences, newconference_t, newconference_free_item,
+ __DYNSTUFF_LIST_ADD, /* newconferences_add() */
+ __DYNSTUFF_LIST_REMOVE_SAFE, /* newconferences_remove() */
+ __DYNSTUFF_LIST_DESTROY) /* newconferences_destroy() */
userlist_t *newconference_member_find(newconference_t *conf, const char *uid) {
userlist_t *ul;
@@ -755,9 +761,10 @@
static LIST_FREE_ITEM(conference_free_item, struct conference *) { xfree(data->name); LIST_DESTROY2(data->recipients, list_t_free_item); }
-__DYNSTUFF_LIST_ADD(conferences, struct conference); /* conferences_add() */
-__DYNSTUFF_LIST_REMOVE_ITER(conferences, struct conference, conference_free_item); /* conferences_removei() */
-__DYNSTUFF_LIST_DESTROY(conferences, struct conference, conference_free_item); /* conferences_destroy() */
+DYNSTUFF_LIST_DECLARE(conferences, struct conference, conference_free_item,
+ __DYNSTUFF_LIST_ADD, /* conferences_add() */
+ __DYNSTUFF_LIST_REMOVE_ITER, /* conferences_removei() */
+ __DYNSTUFF_LIST_DESTROY) /* conferences_destroy() */
/*
* conference_add()
Modified: trunk/ekg/themes.c
===================================================================
--- trunk/ekg/themes.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/themes.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -61,11 +61,11 @@
xfree(data->name);
}
-__DYNSTUFF_ADD_BEGINNING(formats, struct format); /* formats_add() */
-__DYNSTUFF_REMOVE_ITER(formats, struct format, list_format_free); /* formats_removei() */
-__DYNSTUFF_DESTROY(formats, struct format, list_format_free); /* formats_destroy() */
+DYNSTUFF_LIST_DECLARE(formats, struct format, list_format_free,
+ __DYNSTUFF_ADD_BEGINNING, /* formats_add() */
+ __DYNSTUFF_REMOVE_ITER, /* formats_removei() */
+ __DYNSTUFF_DESTROY) /* formats_destroy() */
-
/**
* gim_hash()
*
Modified: trunk/ekg/userlist.c
===================================================================
--- trunk/ekg/userlist.c 2008-07-08 14:55:00 UTC (rev 4068)
+++ trunk/ekg/userlist.c 2008-07-08 16:46:28 UTC (rev 4069)
@@ -85,9 +85,10 @@
static LIST_ADD_COMPARE(group_compare, struct ekg_group *) { return xstrcasecmp(data1->name, data2->name); }
static LIST_FREE_ITEM(group_item_free, struct ekg_group *) { xfree(data->name); }
-__DYNSTUFF_ADD_SORTED(ekg_groups, struct ekg_group, group_compare); /* ekg_groups_add() */
-__DYNSTUFF_REMOVE_ITER(ekg_groups, struct ekg_group, group_item_free); /* ekg_groups_removei() */
-__DYNSTUFF_DESTROY(ekg_groups, struct ekg_group, group_item_free); /* ekg_groups_destroy() */
+DYNSTUFF_LIST_DECLARE_SORTED(ekg_groups, struct ekg_group, group_compare, group_item_free,
+ __DYNSTUFF_ADD_SORTED, /* ekg_groups_add() */
+ __DYNSTUFF_REMOVE_ITER, /* ekg_groups_removei() */
+ __DYNSTUFF_DESTROY) /* ekg_groups_destroy() */
/* resources: */
static LIST_ADD_COMPARE(userlist_resource_compare, ekg_resource_t *) {
@@ -99,9 +100,10 @@
static LIST_FREE_ITEM(list_userlist_resource_free, ekg_resource_t *) { xfree(data->name); xfree(data->descr); }
-__DYNSTUFF_ADD_SORTED(ekg_resources, ekg_resource_t, userlist_resource_compare); /* ekg_resources_add() */
-__DYNSTUFF_REMOVE_SAFE(ekg_resources, ekg_resource_t, list_userlist_resource_free); /* ekg_resources_remove() */
-__DYNSTUFF_DESTROY(ekg_resources, ekg_resource_t, list_userlist_resource_free); /* ekg_resources_destroy() */
+DYNSTUFF_LIST_DECLARE_SORTED(ekg_resources, ekg_resource_t, userlist_resource_compare, list_userlist_resource_free,
+ __DYNSTUFF_ADD_SORTED, /* ekg_resources_add() */
+ __DYNSTUFF_REMOVE_SAFE, /* ekg_resources_remove() */
+ __DYNSTUFF_DESTROY) /* ekg_resources_destroy() */
/*
* userlist_add_entry()
Więcej informacji o liście dyskusyjnej ekg2-commit