From 957f3411170ca1d5f30ee2e2c4e25393195cce75 Mon Sep 17 00:00:00 2001 From: Dusan Durech Date: Tue, 11 Nov 2008 23:39:21 +0100 Subject: modification coding stile :) --- src/base/checkFront.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/base/checkFront.c') diff --git a/src/base/checkFront.c b/src/base/checkFront.c index 53984fb..571cdd3 100644 --- a/src/base/checkFront.c +++ b/src/base/checkFront.c @@ -24,6 +24,7 @@ static checkfront_t *newCheck(char *s, int type, int id) checkfront_t *new; assert(s != NULL); + new = malloc(sizeof(checkfront_t)); memset(new, 0, sizeof(checkfront_t)); new->msg = strdup(s); @@ -31,6 +32,7 @@ static checkfront_t *newCheck(char *s, int type, int id) new->id = id; new->type = type; new->count = 0; + return new; } @@ -50,6 +52,7 @@ void addMsgInCheckFront(list_t * list, char *msg, int type, int id) { if (type == CHECK_FRONT_TYPE_CHECK) incID(id); + addList(list, newCheck(msg, type, id)); } @@ -59,32 +62,33 @@ void eventMsgInCheckFront(client_t * client) int i; currentTime = getMyTime(); + for (i = 0; i < client->listSendMsg->count; i++) { checkfront_t *this; this = (checkfront_t *) client->listSendMsg->list[i]; + switch (this->type) { - case CHECK_FRONT_TYPE_SIMPLE: - sendClient(client, this->msg); - delListItem(client->listSendMsg, i, destroyCheck); - i--; - break; - case CHECK_FRONT_TYPE_CHECK: - if (this->count == 0 - || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL) { + case CHECK_FRONT_TYPE_SIMPLE: sendClient(client, this->msg); - this->time = currentTime; - this->count++; - } - if (this->count > CHECK_FRONT_MAX_COUNT_SEND) { - delID(this->id); delListItem(client->listSendMsg, i, destroyCheck); i--; - } - break; - default: - assert(!_("Bad type of front!")); - break; + break; + case CHECK_FRONT_TYPE_CHECK: + if (this->count == 0 || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL) { + sendClient(client, this->msg); + this->time = currentTime; + this->count++; + } + if (this->count > CHECK_FRONT_MAX_COUNT_SEND) { + delID(this->id); + delListItem(client->listSendMsg, i, destroyCheck); + i--; + } + break; + default: + assert(!_("Bad type of front!")); + break; } } } @@ -97,6 +101,7 @@ void delMsgInCheckFront(list_t * listCheckFront, int id) checkfront_t *this; this = (checkfront_t *) listCheckFront->list[i]; + if (this->id == id) { delID(this->id); delListItem(listCheckFront, i, destroyCheck); -- cgit v1.2.3