[ekg2-commit] r3870 - in trunk: ekg plugins/gtk plugins/jabber plugins/ncurses plugins/python plugins/readline: trunk/ekg/commands.c trunk/ekg/configfile.c trunk/ekg/plugins.c trunk/ekg/vars.c trunk/ekg/vars.h trunk/plugins/gtk/completion.c trunk/plugins/jabber/commands.c trunk/plugins/ncurses/completion.c trunk/plugins/python/python-config.c trunk/plugins/readline/readline-completion.c trunk/plugins/readline/ui-readline.c
SVN commit
svn w toxygen.net
Nie, 9 Mar 2008, 00:29:49 CET
Author: peres
Date: 2008-03-09 00:29:48 +0100 (Sun, 09 Mar 2008)
New Revision: 3870
Modified:
trunk/ekg/commands.c
trunk/ekg/configfile.c
trunk/ekg/plugins.c
trunk/ekg/vars.c
trunk/ekg/vars.h
trunk/plugins/gtk/completion.c
trunk/plugins/jabber/commands.c
trunk/plugins/ncurses/completion.c
trunk/plugins/python/python-config.c
trunk/plugins/readline/readline-completion.c
trunk/plugins/readline/ui-readline.c
Log:
vars to list3.
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/ekg/commands.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -1686,7 +1686,6 @@
const char *arg = NULL, *val = NULL;
int unset = 0, show_all = 0, res = 0;
char *value = NULL;
- list_t l;
if (match_arg(params[0], 'a', ("all"), 1)) {
show_all = 1;
@@ -1712,11 +1711,10 @@
}
if ((!arg || !val) && !unset) {
+ variable_t *v;
int displayed = 0;
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
-
+ for (v = variables; v; v = v->next) {
if ((!arg || !xstrcasecmp(arg, v->name)) && (v->display != 2 || xstrcmp(name, ("set")))) {
char *string = *(char**)(v->ptr);
int value = *(int*)(v->ptr);
Modified: trunk/ekg/configfile.c
===================================================================
--- trunk/ekg/configfile.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/ekg/configfile.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -383,16 +383,17 @@
static void config_write_main(FILE *f)
{
list_t l;
- event_t *e;
if (!f)
return;
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
+ {
+ variable_t *v;
- if (!v->plugin)
- config_write_variable(f, v);
+ for (v = variables; v; v = v->next) {
+ if (!v->plugin)
+ config_write_variable(f, v);
+ }
}
for (l = aliases; l; l = l->next) {
@@ -403,10 +404,14 @@
fprintf(f, "alias %s %s\n", a->name, (char *) m->data);
}
- for (e = events; e; e = e->next) {
- fprintf(f, "on %s %d %s %s\n", e->name, e->prio, e->target, e->action);
- }
+ {
+ event_t *e;
+ for (e = events; e; e = e->next) {
+ fprintf(f, "on %s %d %s %s\n", e->name, e->prio, e->target, e->action);
+ }
+ }
+
for (l = bindings; l; l = l->next) {
struct binding *b = l->data;
@@ -503,7 +508,7 @@
for (l = plugins; l; l = l->next) {
plugin_t *p = l->data;
const char *tmp;
- list_t lv;
+ variable_t *v;
if (!(tmp = prepare_pathf("config-%s", p->name)))
return -1;
@@ -513,9 +518,7 @@
fchmod(fileno(f), 0600);
- for (lv = variables; lv; lv = lv->next) {
- variable_t *v = lv->data;
-
+ for (v = variables; v; v = v->next) {
if (p == v->plugin) {
config_write_variable(f, v);
}
@@ -689,8 +692,8 @@
/* now plugins variables */
for (l = plugins; l; l = l->next) {
- list_t lv;
plugin_t *p = l->data;
+ variable_t *v;
snprintf(name, sizeof(name), "config-%s.%d", p->name, (int) getpid());
@@ -699,9 +702,7 @@
chmod(name, 0400);
- for (lv = variables; lv; lv = lv->next) {
- variable_t *v = lv->data;
-
+ for (v = variables; v; v = v->next) {
if (p == v->plugin) {
config_write_variable(f, v);
}
Modified: trunk/ekg/plugins.c
===================================================================
--- trunk/ekg/plugins.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/ekg/plugins.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -512,7 +512,6 @@
*/
list_t l;
- command_t *c;
if (!p)
return -1;
@@ -568,22 +567,30 @@
}
}
- for (l = variables; l; ) {
- variable_t *v = l->data;
+ {
+ variable_t *v;
- l = l->next;
+ for (v = variables; v; ) {
+ variable_t *next = v->next;
- if (v && v->plugin == p)
- variable_remove(v->plugin, v->name);
+ if (v && v->plugin == p)
+ variable_remove(v->plugin, v->name);
+
+ v = next;
+ }
}
- for (c = commands; c; ) {
- command_t *next = c->next;
+ {
+ command_t *c;
- if (c->plugin == p)
- command_freeone(c);
+ for (c = commands; c; ) {
+ command_t *next = c->next;
- c = next;
+ if (c->plugin == p)
+ command_freeone(c);
+
+ c = next;
+ }
}
list_remove(&plugins, p, 0);
Modified: trunk/ekg/vars.c
===================================================================
--- trunk/ekg/vars.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/ekg/vars.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -43,8 +43,8 @@
#include "queries.h"
-static list_t *variables_lock = NULL;
-list_t variables = NULL;
+static variable_t **variables_lock = NULL;
+variable_t *variables = NULL;
char *console_charset;
void changed_session_locks(const char *varname); /* sessions.c */
@@ -202,7 +202,7 @@
* - name.
*/
variable_t *variable_find(const char *name) {
- list_t l;
+ variable_t *v;
int hash;
if (!name)
@@ -210,8 +210,7 @@
hash = variable_hash(name);
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
+ for (v = variables; v; v = v->next) {
if (v->name_hash == hash && !xstrcasecmp(v->name, name))
return v;
}
@@ -282,7 +281,6 @@
variable_t *v;
int hash;
char *__name;
- list_t l;
if (!name)
return NULL;
@@ -294,8 +292,7 @@
hash = variable_hash(__name);
- for (l = variables; l; l = l->next) {
- v = l->data;
+ for (v = variables; v; v = v->next) {
if (v->name_hash != hash || xstrcasecmp(v->name, __name) || v->type != VAR_FOREIGN)
continue;
@@ -333,13 +330,13 @@
/* like commands_lock in command_add() @ commands.c */
if (variables_lock) {
if (*variables_lock == variables) {
- for (; *variables_lock && (variable_add_compare((*variables_lock)->data, v) < 0); variables_lock = &((*variables_lock)->next));
+ for (; *variables_lock && (variable_add_compare(*variables_lock, v) < 0); variables_lock = &((*variables_lock)->next));
} else variables_lock = &((*variables_lock)->next);
- list_add_beginning(variables_lock, v);
+ LIST_ADD_BEGINNING2(variables_lock, v);
return v;
}
- return LIST_ADD_SORTED(&variables, v, variable_add_compare);
+ return LIST_ADD_SORTED2(&variables, v, variable_add_compare);
}
/*
@@ -348,17 +345,15 @@
* usuwa zmienną.
*/
int variable_remove(plugin_t *plugin, const char *name) {
- list_t l;
int hash;
+ variable_t *v;
if (!name)
return -1;
hash = ekg_hash(name);
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
-
+ for (v = variables; v; v = v->next) {
if (!v->name)
continue;
@@ -547,47 +542,43 @@
return 0;
}
-/*
- * variable_free()
- *
- * zwalnia pamięć używaną przez zmienne.
- */
-void variable_free() {
- list_t l;
+LIST_FREE_ITEM(variable_list_freeone, variable_t *) {
+ xfree(data->name);
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
+ switch (data->type) {
+ case VAR_STR:
+ case VAR_FILE:
+ case VAR_THEME:
+ case VAR_DIR:
+ xfree(*((char**) data->ptr));
+ *((char**) data->ptr) = NULL;
+ break;
- xfree(v->name);
+ case VAR_FOREIGN:
+ xfree((char*) data->ptr);
+ break;
- switch (v->type) {
- case VAR_STR:
- case VAR_FILE:
- case VAR_THEME:
- case VAR_DIR:
- xfree(*((char**) v->ptr));
- *((char**) v->ptr) = NULL;
- break;
+ default:
+ break;
+ }
- case VAR_FOREIGN:
- xfree((char*) v->ptr);
- break;
+ if (data->map) {
+ int i;
- default:
- break;
- }
+ for (i = 0; data->map[i].label; i++)
+ xfree(data->map[i].label);
- if (v->map) {
- int i;
-
- for (i = 0; v->map[i].label; i++)
- xfree(v->map[i].label);
-
- xfree(v->map);
- }
+ xfree(data->map);
}
+}
- list_destroy(variables, 1);
+/*
+ * variable_free()
+ *
+ * zwalnia pamięć używaną przez zmienne.
+ */
+void variable_free() {
+ LIST_DESTROY2(variables, variable_list_freeone);
variables = NULL;
}
Modified: trunk/ekg/vars.h
===================================================================
--- trunk/ekg/vars.h 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/ekg/vars.h 2008-03-08 23:29:48 UTC (rev 3870)
@@ -44,7 +44,9 @@
typedef void (variable_check_func_t)(const char *, const char *);
typedef int (variable_display_func_t)(const char *);
-typedef struct {
+typedef struct variable {
+ struct variable *next;
+
char *name; /* nazwa zmiennej */
plugin_t *plugin; /* wstyczka obsługująca zmienną */
int name_hash; /* hash nazwy zmiennej */
@@ -64,7 +66,7 @@
#ifndef EKG2_WIN32_NOFUNCTION
-extern list_t variables;
+extern variable_t *variables;
void variable_init();
void variable_set_default();
Modified: trunk/plugins/gtk/completion.c
===================================================================
--- trunk/plugins/gtk/completion.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/gtk/completion.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -237,10 +237,8 @@
static void variable_generator(const char *text, int len)
{
- list_t l;
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
-
+ variable_t *v;
+ for (v = variables; v; v = v->next) {
if (v->type == VAR_FOREIGN)
continue;
Modified: trunk/plugins/jabber/commands.c
===================================================================
--- trunk/plugins/jabber/commands.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/jabber/commands.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -1521,11 +1521,10 @@
if (config) {
for (l = plugins; l; l = l->next) {
plugin_t *p = l->data;
- list_t n;
+ variable_t *v;
watch_write(j->send_watch, "<plugin xmlns=\"ekg2:plugin\" name=\"%s\" prio=\"%d\">", p->name, p->prio);
back:
- for (n = variables; n; n = n->next) {
- variable_t *v = n->data;
+ for (v = variables; v; v = v->next) {
char *vname, *tname;
if (v->plugin != p) continue;
tname = vname = jabber_escape(v->name);
Modified: trunk/plugins/ncurses/completion.c
===================================================================
--- trunk/plugins/ncurses/completion.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/ncurses/completion.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -237,10 +237,8 @@
static void variable_generator(const char *text, int len)
{
- list_t l;
- for (l = variables; l; l = l->next) {
- variable_t *v = l->data;
-
+ variable_t *v;
+ for (v = variables; v; v = v->next) {
if (v->type == VAR_FOREIGN)
continue;
Modified: trunk/plugins/python/python-config.c
===================================================================
--- trunk/plugins/python/python-config.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/python/python-config.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -72,11 +72,12 @@
int ekg_config_len(ekg_configObj * self)
{
int cnt = 0;
- list_t l;
- for (l = variables; l; l = l->next) {
+ variable_t *v;
+
+ for (v = variables; v; v = v->next) {
cnt++;
- }
- return cnt;
+ }
+ return cnt;
}
/**
@@ -89,13 +90,10 @@
PyObject *ekg_config_get(ekg_configObj * self, PyObject * key)
{
char *name = PyString_AsString(key);
- list_t l;
variable_t *v;
debug("[python] Getting value for '%s' config option\n", name);
- for (l = variables; l; l = l->next) {
- v = l->data;
-
+ for (v = variables; v; v = v->next) {
if (!strcmp(v->name, name)) {
if (v->type == VAR_BOOL || v->type == VAR_INT
|| v->type == VAR_MAP) {
Modified: trunk/plugins/readline/readline-completion.c
===================================================================
--- trunk/plugins/readline/readline-completion.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/readline/readline-completion.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -331,19 +331,15 @@
}
GENERATOR(variable) {
- static list_t el;
+ static variable_t *v;
static int len;
if (!state) {
- el = variables;
+ v = variables;
len = xstrlen(text);
}
- while (el) {
- variable_t *v = el->data;
-
- el = el->next;
-
+ while (v) {
if (v->type == VAR_FOREIGN)
continue;
@@ -354,6 +350,8 @@
if (!xstrncasecmp(text, v->name, len))
return xstrdup(v->name);
}
+
+ v = v->next;
}
return NULL;
Modified: trunk/plugins/readline/ui-readline.c
===================================================================
--- trunk/plugins/readline/ui-readline.c 2008-03-08 23:28:49 UTC (rev 3869)
+++ trunk/plugins/readline/ui-readline.c 2008-03-08 23:29:48 UTC (rev 3870)
@@ -403,7 +403,7 @@
}
/* if no empty line and we save duplicate lines, add it to history */
- if (line && *line && (config_history_savedups || !history_length || xwcscmp(line, history_get(history_length)->line)))
+ if (line && *line && (config_history_savedups || !history_length || xstrcmp(line, history_get(history_length)->line)))
add_history(line);
pager_lines = 0;
Więcej informacji o liście dyskusyjnej ekg2-commit