summaryrefslogtreecommitdiff
path: root/src/base/checkFront.c
diff options
context:
space:
mode:
authorxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
committerxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
commitc8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch)
tree6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/base/checkFront.c
parentcb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff)
Changed style of the code to the K&R standard
Diffstat (limited to 'src/base/checkFront.c')
-rw-r--r--src/base/checkFront.c153
1 files changed, 72 insertions, 81 deletions
diff --git a/src/base/checkFront.c b/src/base/checkFront.c
index dfe11eb..53984fb 100644
--- a/src/base/checkFront.c
+++ b/src/base/checkFront.c
@@ -11,111 +11,102 @@
#include "idManager.h"
#include "server.h"
-typedef struct struct_checkfront_t
-{
- char *msg;
- my_time_t time;
- int id;
- int count;
- int type;
+typedef struct struct_checkfront_t {
+ char *msg;
+ my_time_t time;
+ int id;
+ int count;
+ int type;
} checkfront_t;
-static checkfront_t *
-newCheck(char *s, int type, int id)
+static checkfront_t *newCheck(char *s, int type, int id)
{
- checkfront_t *new;
+ checkfront_t *new;
- assert(s != NULL);
- new = malloc(sizeof(checkfront_t));
- memset(new, 0, sizeof(checkfront_t));
- new->msg = strdup(s);
- new->time = getMyTime();
- new->id = id;
- new->type = type;
- new->count = 0;
- return new;
+ assert(s != NULL);
+ new = malloc(sizeof(checkfront_t));
+ memset(new, 0, sizeof(checkfront_t));
+ new->msg = strdup(s);
+ new->time = getMyTime();
+ new->id = id;
+ new->type = type;
+ new->count = 0;
+ return new;
}
-static void
-destroyCheck(checkfront_t * p)
+static void destroyCheck(checkfront_t * p)
{
- assert(p != NULL);
- free(p->msg);
- free(p);
+ assert(p != NULL);
+ free(p->msg);
+ free(p);
}
-list_t *
-newCheckFront()
+list_t *newCheckFront()
{
- return newList();
+ return newList();
}
-void
-addMsgInCheckFront(list_t * list, char *msg, int type, int id)
+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));
+ if (type == CHECK_FRONT_TYPE_CHECK)
+ incID(id);
+ addList(list, newCheck(msg, type, id));
}
-void
-eventMsgInCheckFront(client_t * client)
+void eventMsgInCheckFront(client_t * client)
{
- my_time_t currentTime;
- int i;
+ my_time_t currentTime;
+ int i;
- currentTime = getMyTime();
- for (i = 0; i < client->listSendMsg->count; i++) {
- checkfront_t *this;
+ 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) {
- 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;
- }
- }
+ 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) {
+ 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;
+ }
+ }
}
-void
-delMsgInCheckFront(list_t * listCheckFront, int id)
+void delMsgInCheckFront(list_t * listCheckFront, int id)
{
- int i;
+ int i;
- for (i = 0; i < listCheckFront->count; i++) {
- checkfront_t *this;
+ for (i = 0; i < listCheckFront->count; i++) {
+ checkfront_t *this;
- this = (checkfront_t *) listCheckFront->list[i];
- if (this->id == id) {
- delID(this->id);
- delListItem(listCheckFront, i, destroyCheck);
- return;
- }
- }
+ this = (checkfront_t *) listCheckFront->list[i];
+ if (this->id == id) {
+ delID(this->id);
+ delListItem(listCheckFront, i, destroyCheck);
+ return;
+ }
+ }
}
-void
-destroyCheckFront(list_t * p)
+void destroyCheckFront(list_t * p)
{
- assert(p != NULL);
- destroyListItem(p, destroyCheck);
+ assert(p != NULL);
+ destroyListItem(p, destroyCheck);
}