[ekg2-commit] r4066 - trunk/ekg: trunk/ekg/commands.c trunk/ekg/configfile.c trunk/ekg/ekg.c trunk/ekg/metacontacts.c trunk/ekg/metacontacts.h trunk/ekg/stuff.c trunk/ekg/stuff.h
SVN commit
svn w toxygen.net
Wto, 8 Lip 2008, 15:44:14 CEST
Author: darkjames
Date: 2008-07-08 15:44:13 +0200 (Tue, 08 Jul 2008)
New Revision: 4066
Modified:
trunk/ekg/commands.c
trunk/ekg/configfile.c
trunk/ekg/ekg.c
trunk/ekg/metacontacts.c
trunk/ekg/metacontacts.h
trunk/ekg/stuff.c
trunk/ekg/stuff.h
Log:
*conferences, metacontacts, aliases
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/commands.c 2008-07-08 13:44:13 UTC (rev 4066)
@@ -2310,7 +2310,7 @@
if ((res = config_read(NULL))) printq("error_reading_config", strerror(errno));
if (res == -1) return -1;
- metacontact_free();
+ metacontacts_destroy();
if ((res = session_read(NULL))) printq("error_reading_config", strerror(errno));
if (res == -1) return -1;
Modified: trunk/ekg/configfile.c
===================================================================
--- trunk/ekg/configfile.c 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/configfile.c 2008-07-08 13:44:13 UTC (rev 4066)
@@ -191,7 +191,7 @@
struct stat st;
if (!in_autoexec && !filename) {
- alias_free();
+ aliases_destroy();
timer_remove_user(-1);
event_free();
variable_set_default();
Modified: trunk/ekg/ekg.c
===================================================================
--- trunk/ekg/ekg.c 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/ekg.c 2008-07-08 13:44:13 UTC (rev 4066)
@@ -1160,9 +1160,9 @@
/* XXX, think about sequence of unloading. */
msgs_queue_destroy();
- conference_free();
- newconference_free();
- metacontact_free();
+ conferences_destroy();
+ newconferences_destroy();
+ metacontacts_destroy();
sessions_free();
{
@@ -1180,7 +1180,7 @@
}
audio_deinitialize();
- alias_free();
+ aliases_destroy();
theme_free();
variables_destroy();
script_variables_free(1);
Modified: trunk/ekg/metacontacts.c
===================================================================
--- trunk/ekg/metacontacts.c 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/metacontacts.c 2008-07-08 13:44:13 UTC (rev 4066)
@@ -32,11 +32,37 @@
#include "userlist.h"
#include "xmalloc.h"
+#include "dynstuff_inline.h"
#include "metacontacts.h"
#include "queries.h"
metacontact_t *metacontacts = NULL;
+/* metacontacts_items: */
+static LIST_ADD_COMPARE(metacontact_add_item_compare, metacontact_item_t *) {
+ if (!data1 || !data1->name || !data1->s_uid || !data2 || !data2->name || !data2->s_uid)
+ return 0;
+
+ if (!xstrcasecmp(data1->s_uid, data2->s_uid))
+ return xstrcasecmp(data1->name, data2->name);
+
+ return xstrcasecmp(session_alias_uid_n(data1->s_uid), session_alias_uid_n(data2->s_uid));
+}
+
+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() */
+
+/* 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() */
+
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);
static int metacontact_remove(const char *name);
@@ -212,18 +238,6 @@
return NULL;
}
-/*
- * metacontact_add_compare()
- *
- * helpfull function when adding to the metacontacts list
- */
-static LIST_ADD_COMPARE(metacontact_add_compare, metacontact_t *) {
- if (!data1 || !data1->name || !data2 || !data2->name)
- return 0;
-
- return xstrcasecmp(data1->name, data2->name);
-}
-
/*
* metacontact_add()
*
@@ -240,25 +254,11 @@
m = xmalloc(sizeof(metacontact_t));
m->name = xstrdup(name);
- return LIST_ADD_SORTED2(&metacontacts, m, metacontact_add_compare);
+ metacontacts_add(m);
+ return m;
}
/*
- * metacontact_add_item_compare()
- *
- * heplfull when adding to items list
- */
-static LIST_ADD_COMPARE(metacontact_add_item_compare, metacontact_item_t *) {
- if (!data1 || !data1->name || !data1->s_uid || !data2 || !data2->name || !data2->s_uid)
- return 0;
-
- if (!xstrcasecmp(data1->s_uid, data2->s_uid))
- return xstrcasecmp(data1->name, data2->name);
-
- return xstrcasecmp(session_alias_uid_n(data1->s_uid), session_alias_uid_n(data2->s_uid));
-}
-
-/*
* metacontact_find_item()
*
* it looks for metacontact item
@@ -318,21 +318,11 @@
i->s_uid = xstrdup(s->uid);
i->prio = prio;
- LIST_ADD_SORTED2(&m->metacontact_items, i, metacontact_add_item_compare);
+ metacontact_items_add(&m->metacontact_items, i);
return 1;
}
-static LIST_FREE_ITEM(metacontact_item_free, metacontact_item_t *) {
- xfree(data->name);
- xfree(data->s_uid);
-}
-
-static LIST_FREE_ITEM(metacontact_list_free, metacontact_t *) {
- LIST_DESTROY2(data->metacontact_items, metacontact_item_free);
- xfree(data->name);
-}
-
/*
* metacotact_remove_item()
*
@@ -360,7 +350,7 @@
return 0;
}
- LIST_REMOVE2(&m->metacontact_items, i, metacontact_item_free);
+ metacontact_items_remove(&m->metacontact_items, i);
return 1;
}
@@ -383,7 +373,7 @@
i = next;
}
- LIST_REMOVE2(&metacontacts, m, metacontact_list_free);
+ metacontacts_remove(m);
return 1;
}
@@ -538,17 +528,6 @@
query_connect_id(NULL, USERLIST_REMOVED, metacontact_userlist_removed_handler, NULL);
}
-/*
- * metacontact_free()
- *
- * it should free all memory user by metacontacts
- */
-void metacontact_free()
-{
-
- LIST_DESTROY2(metacontacts, metacontact_list_free);
-}
-
/*
* metacontact_write()
*
Modified: trunk/ekg/metacontacts.h
===================================================================
--- trunk/ekg/metacontacts.h 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/metacontacts.h 2008-07-08 13:44:13 UTC (rev 4066)
@@ -44,7 +44,7 @@
metacontact_item_t *metacontact_find_prio(metacontact_t *m);
void metacontact_init();
-void metacontact_free();
+void metacontacts_destroy();
int metacontact_write();
int metacontact_read();
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/stuff.c 2008-07-08 13:44:13 UTC (rev 4066)
@@ -252,6 +252,12 @@
}
}
+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() */
+
/*
* alias_add()
*
@@ -315,7 +321,7 @@
a->name = xstrdup(string);
a->commands = NULL;
LIST_ADD2(&(a->commands), list_t_new(xstrdup(cmd)));
- LIST_ADD2(&aliases, a);
+ aliases_add(a);
array = (params) ? array_join(params, (" ")) : xstrdup(("?"));
command_add(NULL, a->name, array, cmd_alias_exec, COMMAND_ISALIAS, NULL);
@@ -341,23 +347,15 @@
alias_t *a;
int removed = 0;
- for (a = aliases; a; ) {
- alias_t *next = a->next;
-
+ for (a = aliases; a; a = a->next) {
if (!name || !xstrcasecmp(a->name, name)) {
- alias_t *tmp;
-
if (name)
printq("aliases_del", name);
command_remove(NULL, a->name);
- xfree(a->name);
- LIST_DESTROY2(a->commands, list_t_free_item);
- if ((tmp = LIST_REMOVE2(&aliases, a, NULL)))
- next = tmp;
+
+ a = aliases_removei(a);
removed = 1;
}
-
- a = next;
}
if (!removed) {
@@ -375,26 +373,6 @@
return 0;
}
-/**
- * alias_free()
- *
- * Free memory allocated by aliases
- */
-
-void alias_free() {
- alias_t *a;
-
- if (!aliases)
- return;
-
- for (a = aliases; a; a = a->next) {
- xfree(a->name);
- LIST_DESTROY2(a->commands, list_t_free_item);
- }
- LIST_DESTROY2(aliases, NULL);
- aliases = NULL;
-}
-
/*
* binding_list()
*
@@ -701,6 +679,12 @@
/* NEW CONFERENCE API HERE, WHEN OLD CONFERENCE API BECOME OBSOLETE CHANGE FUNCTION NAME, ETC.... */
+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() */
+
userlist_t *newconference_member_find(newconference_t *conf, const char *uid) {
userlist_t *ul;
@@ -754,32 +738,27 @@
c->session = xstrdup(s->uid);
c->name = xstrdup(name);
- return LIST_ADD2(&newconferences, c);
+ newconferences_add(c);
+ return c;
}
-static LIST_FREE_ITEM(newconference_free_item, newconference_t *) {
- xfree(data->name);
- xfree(data->session);
- userlists_destroy(&(data->participants));
-}
-
void newconference_destroy(newconference_t *conf, int kill_wnd) {
window_t *w = NULL;
if (!conf) return;
if (kill_wnd) w = window_find_s(session_find(conf->session), conf->name);
- LIST_REMOVE2(&newconferences, conf, newconference_free_item);
-
+ newconferences_remove(conf);
window_kill(w);
}
-void newconference_free() {
- LIST_DESTROY2(newconferences, newconference_free_item);
- newconferences = NULL;
-}
-
/* OLD CONFERENCE API HERE, REQUEST REWRITING/USING NEW-ONE */
+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() */
+
/*
* conference_add()
*
@@ -897,14 +876,11 @@
tabnick_add(name);
- return LIST_ADD2(&conferences, xmemdup(&c, sizeof(c)));
+ cf = xmemdup(&c, sizeof(c));
+ conferences_add(cf);
+ return cf;
}
-static LIST_FREE_ITEM(conference_free_item, struct conference *) {
- xfree(data->name);
- LIST_DESTROY2(data->recipients, list_t_free_item);
-}
-
/*
* conference_remove()
*
@@ -920,21 +896,15 @@
struct conference *c;
int removed = 0;
- for (c = conferences; c; ) {
- struct conference *next = c->next;
-
+ for (c = conferences; c; c = c->next) {
if (!name || !xstrcasecmp(c->name, name)) {
- struct conference *tmp;
-
if (name)
printq("conferences_del", name);
tabnick_remove(c->name);
- if ((tmp = LIST_REMOVE2(&conferences, c, conference_free_item)))
- next = tmp;
+
+ c = conferences_removei(c);
removed = 1;
}
-
- c = next;
}
if (!removed) {
@@ -1143,20 +1113,6 @@
return 0;
}
-/**
- * conference_free()
- *
- * Free memory allocated by conferences.
- */
-
-void conference_free() {
- if (!conferences)
- return;
-
- LIST_DESTROY2(conferences, conference_free_item);
- conferences = NULL;
-}
-
/*
* help_path()
*
Modified: trunk/ekg/stuff.h
===================================================================
--- trunk/ekg/stuff.h 2008-07-08 12:33:03 UTC (rev 4065)
+++ trunk/ekg/stuff.h 2008-07-08 13:44:13 UTC (rev 4066)
@@ -281,7 +281,7 @@
int alias_add(const char *string, int quiet, int append);
int alias_remove(const char *name, int quiet);
-void alias_free();
+void aliases_destroy();
char *base64_encode(const char *buf, size_t len);
char *base64_decode(const char *buf);
@@ -310,7 +310,7 @@
int conference_set_ignore(const char *name, int flag, int quiet);
int conference_rename(const char *oldname, const char *newname, int quiet);
int conference_participant(struct conference *c, const char *uid);
-void conference_free();
+void conferences_destroy();
/* BEGIN OF newconference API HERE */
userlist_t *newconference_member_add(newconference_t *conf, const char *uid, const char *nick);
@@ -319,7 +319,7 @@
newconference_t *newconference_create(session_t *s, const char *name, int create_wnd);
newconference_t *newconference_find(session_t *s, const char *name);
void newconference_destroy(newconference_t *conf, int kill_wnd);
-void newconference_free();
+void newconferences_destroy();
/* END of newconference API */
void ekg_connect();
Więcej informacji o liście dyskusyjnej ekg2-commit