[ekg2-commit] r3857 - trunk/ekg: trunk/ekg/commands.c trunk/ekg/configfile.c trunk/ekg/dynstuff.h trunk/ekg/log.c trunk/ekg/log.h trunk/ekg/plugins.h
SVN commit
svn w toxygen.net
Sob, 8 Mar 2008, 14:51:54 CET
Author: peres
Date: 2008-03-08 14:51:54 +0100 (Sat, 08 Mar 2008)
New Revision: 3857
Modified:
trunk/ekg/commands.c
trunk/ekg/configfile.c
trunk/ekg/dynstuff.h
trunk/ekg/log.c
trunk/ekg/log.h
trunk/ekg/plugins.h
Log:
Rest of events + last.
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/commands.c 2008-03-08 13:51:54 UTC (rev 3857)
@@ -3709,7 +3709,7 @@
static COMMAND(cmd_last)
{
- list_t l;
+ struct last *ll;
const char *uid = NULL;
int show_sent = 0, last_n = 0, count = 0, i = 0, show_all = 0;
char **arr = NULL;
@@ -3724,7 +3724,7 @@
return -1;
}
- if ((uid && !last_count(uid)) || !list_count(lasts)) {
+ if ((uid && !last_count(uid)) || !LIST_COUNT2(lasts)) {
if (uid)
printq("last_list_empty_nick", format_user(session, uid));
else
@@ -3781,7 +3781,7 @@
array_free(arr);
- if (!((uid) ? (count = last_count(uid)) : (count = list_count(lasts)))) {
+ if (!((uid) ? (count = last_count(uid)) : (count = LIST_COUNT2(lasts)))) {
if (uid) {
printq("last_list_empty_nick", format_user(session, uid));
return -1;
@@ -3796,8 +3796,7 @@
printq("last_begin");
- for (l = lasts; l; l = l->next) {
- struct last *ll = l->data;
+ for (ll = lasts; ll; ll = ll->next) {
struct tm *tm, *st;
char buf[100], buf2[100], *time_str = NULL;
const char *form;
Modified: trunk/ekg/configfile.c
===================================================================
--- trunk/ekg/configfile.c 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/configfile.c 2008-03-08 13:51:54 UTC (rev 3857)
@@ -383,6 +383,7 @@
static void config_write_main(FILE *f)
{
list_t l;
+ event_t *e;
if (!f)
return;
@@ -402,9 +403,7 @@
fprintf(f, "alias %s %s\n", a->name, (char *) m->data);
}
- for (l = events; l; l = l->next) {
- event_t *e = l->data;
-
+ for (e = events; e; e = e->next) {
fprintf(f, "on %s %d %s %s\n", e->name, e->prio, e->target, e->action);
}
Modified: trunk/ekg/dynstuff.h
===================================================================
--- trunk/ekg/dynstuff.h 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/dynstuff.h 2008-03-08 13:51:54 UTC (rev 3857)
@@ -76,7 +76,9 @@
#define LIST_ADD_SORTED(list, data, comp) list_add_sorted(list, data, (void *) comp)
#define LIST_ADD_SORTED2(list, data, comp) list_add_sorted3((list_t *) list, (list_t) data, (void *) comp)
#define LIST_ADD_BEGINNING2(list, data) list_add_beginning3((list_t *) list, (list_t) data)
+#define LIST_ADD2(list, data) list_add3((list_t *) list, (list_t) data)
+#define LIST_COUNT2(list) list_count((list_t) list)
#define LIST_RESORT(list, comp) list_resort(list, (void *) comp)
#define LIST_RESORT2(list, comp) list_resort3((list_t *) list, (void *) comp)
Modified: trunk/ekg/log.c
===================================================================
--- trunk/ekg/log.c 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/log.c 2008-03-08 13:51:54 UTC (rev 3857)
@@ -30,7 +30,7 @@
#include "log.h"
#include "xmalloc.h"
-list_t lasts = NULL;
+struct last *lasts = NULL;
int config_last_size = 10;
int config_last = 0;
@@ -38,7 +38,6 @@
static LIST_FREE_ITEM(list_last_free, struct last *) {
xfree(data->uid);
xfree(data->message);
- xfree(data);
}
/*
@@ -53,7 +52,6 @@
* - msg - treść wiadomości.
*/
void last_add(int type, const char *uid, time_t t, time_t st, const char *msg) {
- list_t l;
struct last *ll;
int count = 0;
@@ -64,16 +62,14 @@
if (config_last & 2)
count = last_count(uid);
else
- count = list_count(lasts);
+ count = LIST_COUNT2(lasts);
/* usuwamy ostatnią wiadomość, w razie potrzeby... */
if (count >= config_last_size) {
time_t tmp_time = 0;
/* najpierw ją znajdziemy... */
- for (l = lasts; l; l = l->next) {
- ll = l->data;
-
+ for (ll = lasts; ll; ll = ll->next) {
if (config_last & 2 && xstrcasecmp(ll->uid, uid))
continue;
@@ -85,16 +81,15 @@
}
/* ...by teraz usunąć */
- for (l = lasts; l; l = l->next) {
- ll = l->data;
-
+ for (ll = lasts; ll; ll = ll->next) {
if (ll->time == tmp_time && !xstrcasecmp(ll->uid, uid)) {
- LIST_REMOVE(&lasts, ll, list_last_free);
+ LIST_REMOVE2(&lasts, ll, list_last_free);
break;
}
}
}
+
ll = xmalloc(sizeof(struct last));
ll->type = type;
ll->uid = xstrdup(uid);
@@ -102,7 +97,7 @@
ll->sent_time = st;
ll->message = xstrdup(msg);
- list_add(&lasts, ll);
+ LIST_ADD2(&lasts, ll);
}
/*
@@ -113,15 +108,15 @@
* - uin - numerek osoby.
*/
void last_del(const char *uid) {
- list_t l;
+ struct last *ll;
- for (l = lasts; l; ) {
- struct last *ll = l->data;
+ for (ll = lasts; ll; ) {
+ struct last *next = ll->next;
- l = l->next;
-
if (!xstrcasecmp(uid, ll->uid))
- LIST_REMOVE(&lasts, ll, list_last_free);
+ LIST_REMOVE2(&lasts, ll, list_last_free);
+
+ ll = next;
}
}
@@ -131,7 +126,7 @@
* zwalnia miejsce po last.
*/
void last_free() {
- LIST_DESTROY(lasts, list_last_free);
+ LIST_DESTROY2(lasts, list_last_free);
lasts = NULL;
}
@@ -144,11 +139,9 @@
*/
int last_count(const char *uid) {
int count = 0;
- list_t l;
+ struct last *ll;
- for (l = lasts; l; l = l->next) {
- struct last *ll = l->data;
-
+ for (ll = lasts; ll; ll = ll->next) {
if (!xstrcasecmp(uid, ll->uid))
count++;
}
Modified: trunk/ekg/log.h
===================================================================
--- trunk/ekg/log.h 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/log.h 2008-03-08 13:51:54 UTC (rev 3857)
@@ -30,6 +30,7 @@
#include "dynstuff.h"
struct last {
+ struct last *next;
unsigned int type : 1; /* 0 - przychodząca, 1 - wychodząca */
char *uid; /* od kogo, lub do kogo przy wysyłanych */
time_t time; /* czas */
@@ -38,7 +39,7 @@
};
#ifndef EKG2_WIN32_NOFUNCTION
-extern list_t lasts;
+extern struct last *lasts;
void last_add(int type, const char *uid, time_t t, time_t st, const char *msg);
void last_del(const char *uid);
Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h 2008-03-08 13:40:19 UTC (rev 3856)
+++ trunk/ekg/plugins.h 2008-03-08 13:51:54 UTC (rev 3857)
@@ -26,7 +26,7 @@
#include "dynstuff.h"
#include "sessions.h"
-#define EKG_ABI_VER 3854
+#define EKG_ABI_VER 3856
#define EXPORT __attribute__ ((visibility("default")))
Więcej informacji o liście dyskusyjnej ekg2-commit