[ekg2-commit] r3887 - in trunk: ekg plugins/ncurses plugins/readline: trunk/ekg/commands.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/plugins/ncurses/completion.c trunk/plugins/readline/readline-completion.c
SVN commit
svn w toxygen.net
Pon, 10 Mar 2008, 20:28:18 CET
Author: peres
Date: 2008-03-10 20:28:18 +0100 (Mon, 10 Mar 2008)
New Revision: 3887
Modified:
trunk/ekg/commands.c
trunk/ekg/stuff.c
trunk/ekg/stuff.h
trunk/plugins/ncurses/completion.c
trunk/plugins/readline/readline-completion.c
Log:
Conferences? But I think this was too easy...
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-03-10 19:02:58 UTC (rev 3886)
+++ trunk/ekg/commands.c 2008-03-10 19:28:18 UTC (rev 3887)
@@ -3469,7 +3469,7 @@
static COMMAND(cmd_conference)
{
if (!params[0] || match_arg(params[0], 'l', ("list"), 2) || params[0][0] == '#') {
- list_t l, r;
+ list_t r;
int count = 0;
const char *cname = NULL;
@@ -3478,8 +3478,10 @@
else if (params[0])
cname = params[0];
- for (l = newconferences; l; l = l->next) {
- newconference_t *c = l->data;
+ {
+ newconference_t *c;
+
+ for (c = newconferences; c; c = c->next) {
/* XXX,
* ::: konferencje:
* -- konferencja1/sesja
@@ -3489,41 +3491,45 @@
* albo jak /names w ircu, albo jak?
* XXX
*/
- print("conferences_list", c->name, "");
- count++;
+ print("conferences_list", c->name, "");
+ count++;
+ }
}
- for (l = conferences; l; l = l->next) {
- struct conference *c = l->data;
- string_t recipients;
- const char *recipient;
- int first = 0;
+ {
+ struct conference *c;
- recipients = string_init(NULL);
+ for (c = conferences; c; c = c->next) {
+ string_t recipients;
+ const char *recipient;
+ int first = 0;
- if (cname && xstrcasecmp(cname, c->name))
- continue;
-
- for (r = c->recipients; r; r = r->next) {
- char *uid = r->data;
- userlist_t *u = userlist_find(session, uid);
+ recipients = string_init(NULL);
- if (u && u->nickname)
- recipient = u->nickname;
- else
- recipient = uid;
-
- if (first++)
- string_append_c(recipients, ',');
+ if (cname && xstrcasecmp(cname, c->name))
+ continue;
- string_append(recipients, recipient);
+ for (r = c->recipients; r; r = r->next) {
+ char *uid = r->data;
+ userlist_t *u = userlist_find(session, uid);
- count++;
- }
+ if (u && u->nickname)
+ recipient = u->nickname;
+ else
+ recipient = uid;
- print(c->ignore ? "conferences_list_ignored" : "conferences_list", c->name, recipients->str);
+ if (first++)
+ string_append_c(recipients, ',');
+
+ string_append(recipients, recipient);
- string_free(recipients, 1);
+ count++;
+ }
+
+ print(c->ignore ? "conferences_list_ignored" : "conferences_list", c->name, recipients->str);
+
+ string_free(recipients, 1);
+ }
}
if (!count) {
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-03-10 19:02:58 UTC (rev 3886)
+++ trunk/ekg/stuff.c 2008-03-10 19:28:18 UTC (rev 3887)
@@ -87,8 +87,8 @@
list_t autofinds = NULL;
struct binding *bindings = NULL; /**< list_t struct timer <b>all</b> ekg2 timers */
struct timer *timers = NULL;
-list_t conferences = NULL;
-list_t newconferences = NULL;
+struct conference *conferences = NULL;
+newconference_t *newconferences = NULL;
#ifdef HAVE_ICONV
static list_t ekg_converters = NULL; /**< list for internal use of ekg_convert_string_*() */
#endif
@@ -722,10 +722,9 @@
}
newconference_t *newconference_find(session_t *s, const char *name) {
- list_t l;
- for (l = newconferences; l; l = l->next) {
- newconference_t *c = l->data;
-
+ newconference_t *c;
+
+ for (c = newconferences; c; c = c->next) {
if ((!s || !xstrcmp(s->uid, c->session)) && !xstrcmp(name, c->name)) return c;
}
return NULL;
@@ -747,33 +746,27 @@
c->session = xstrdup(s->uid);
c->name = xstrdup(name);
- return list_add(&newconferences, c);
+ return LIST_ADD2(&newconferences, c);
}
+static LIST_FREE_ITEM(newconference_free_item, newconference_t *) {
+ xfree(data->name);
+ xfree(data->session);
+ userlist_free_u(&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);
- xfree(conf->name);
- xfree(conf->session);
- userlist_free_u(&conf->participants);
- list_remove(&newconferences, conf, 1);
+ LIST_REMOVE2(&newconferences, conf, newconference_free_item);
window_kill(w);
}
void newconference_free() {
- list_t l;
- for (l = newconferences; l; l = l->next) {
- newconference_t *c = l->data;
-
- xfree(c->session);
- xfree(c->name);
- userlist_free_u(&c->participants);
- }
-
- list_destroy(newconferences, 1);
+ LIST_DESTROY2(newconferences, newconference_free_item);
newconferences = NULL;
}
@@ -792,7 +785,7 @@
*/
struct conference *conference_add(session_t *session, const char *name, const char *nicklist, int quiet)
{
- struct conference c;
+ struct conference c, *cf;
char **nicks;
list_t l, sl;
int i, count;
@@ -856,9 +849,7 @@
count = array_count(nicks);
- for (l = conferences; l; l = l->next) {
- struct conference *cf = l->data;
-
+ for (cf = conferences; cf; cf = cf->next) {
if (!xstrcasecmp(name, cf->name)) {
printq("conferences_exist", name);
@@ -898,9 +889,14 @@
tabnick_add(name);
- return list_add(&conferences, xmemdup(&c, sizeof(c)));
+ return LIST_ADD2(&conferences, xmemdup(&c, sizeof(c)));
}
+static LIST_FREE_ITEM(conference_free_item, struct conference *) {
+ xfree(data->name);
+ list_destroy(data->recipients, 1);
+}
+
/*
* conference_remove()
*
@@ -913,23 +909,24 @@
*/
int conference_remove(const char *name, int quiet)
{
- list_t l;
+ struct conference *c;
int removed = 0;
- for (l = conferences; l; ) {
- struct conference *c = l->data;
+ for (c = conferences; c; ) {
+ struct conference *next = c->next;
- l = l->next;
-
if (!name || !xstrcasecmp(c->name, name)) {
+ struct conference *tmp;
+
if (name)
printq("conferences_del", name);
tabnick_remove(c->name);
- xfree(c->name);
- list_destroy(c->recipients, 1);
- list_remove(&conferences, c, 1);
+ if ((tmp = (struct conference *) LIST_REMOVE2(&conferences, c, conference_free_item)))
+ next = tmp;
removed = 1;
}
+
+ c = next;
}
if (!removed) {
@@ -977,11 +974,9 @@
*/
struct conference *conference_find(const char *name)
{
- list_t l;
+ struct conference *c;
- for (l = conferences; l; l = l->next) {
- struct conference *c = l->data;
-
+ for (c = conferences; c; c = c->next) {
if (!xstrcmp(c->name, name))
return c;
}
@@ -1029,10 +1024,9 @@
struct conference *conference_find_by_uids(session_t *s, const char *from, const char **recipients, int count, int quiet)
{
int i;
- list_t l;
+ struct conference *c;
- for (l = conferences; l; l = l->next) {
- struct conference *c = l->data;
+ for (c = conferences; c; c = c->next) {
int matched = 0;
for (i = 0; i < count; i++)
@@ -1148,19 +1142,10 @@
*/
void conference_free() {
- list_t l;
-
if (!conferences)
return;
- for (l = conferences; l; l = l->next) {
- struct conference *c = l->data;
-
- xfree(c->name);
- list_destroy(c->recipients, 1);
- }
-
- list_destroy(conferences, 1);
+ LIST_DESTROY2(conferences, conference_free_item);
conferences = NULL;
}
Modified: trunk/ekg/stuff.h
===================================================================
--- trunk/ekg/stuff.h 2008-03-10 19:02:58 UTC (rev 3886)
+++ trunk/ekg/stuff.h 2008-03-10 19:28:18 UTC (rev 3887)
@@ -132,12 +132,16 @@
};
struct conference {
+ struct conference *next;
+
char *name;
ignore_t ignore;
list_t recipients;
};
-typedef struct {
+typedef struct newconference {
+ struct newconference *next;
+
char *session;
char *name;
list_t participants;
@@ -158,11 +162,11 @@
#ifndef EKG2_WIN32_NOFUNCTION
extern child_t *children;
extern alias_t *aliases;
-extern list_t autofinds;
+extern list_t autofinds; /* char* data */
extern struct binding *bindings;
extern struct timer *timers;
-extern list_t conferences;
-extern list_t newconferences;
+extern struct conference *conferences;
+extern newconference_t *newconferences;
extern list_t buffer_debug;
extern list_t buffer_speech;
extern binding_added_t *bindings_added;
Modified: trunk/plugins/ncurses/completion.c
===================================================================
--- trunk/plugins/ncurses/completion.c 2008-03-10 19:02:58 UTC (rev 3886)
+++ trunk/plugins/ncurses/completion.c 2008-03-10 19:28:18 UTC (rev 3887)
@@ -208,11 +208,9 @@
static void conference_generator(const char *text, int len)
{
- list_t l;
+ struct conference *c;
- for (l = conferences; l; l = l->next) {
- struct conference *c = l->data;
-
+ for (c = conferences; c; c = c->next) {
if (!xstrncasecmp(text, c->name, len))
array_add_check(&completions, xstrdup(c->name), 1);
}
Modified: trunk/plugins/readline/readline-completion.c
===================================================================
--- trunk/plugins/readline/readline-completion.c 2008-03-10 19:02:58 UTC (rev 3886)
+++ trunk/plugins/readline/readline-completion.c 2008-03-10 19:28:18 UTC (rev 3887)
@@ -247,17 +247,16 @@
}
GENERATOR(conference) {
- static list_t el;
+ static struct conference *c;
static int len;
if (!state) {
len = xstrlen(text);
- el = conferences;
+ c = conferences;
}
- while (el) {
- struct conference *c = el->data;
- el = el->next;
+ while (c) {
+ c = c->next;
if (!xstrncasecmp(text, c->name, len))
return xstrdup(c->name);
Więcej informacji o liście dyskusyjnej ekg2-commit