From 2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 Mon Sep 17 00:00:00 2001 From: oroborus Date: Sat, 28 Jun 2008 16:38:35 +0000 Subject: - prekopanie adresarovej struktury, prva cast git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/checkFront.c | 136 ------------------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 src/checkFront.c (limited to 'src/checkFront.c') diff --git a/src/checkFront.c b/src/checkFront.c deleted file mode 100644 index f6164f3..0000000 --- a/src/checkFront.c +++ /dev/null @@ -1,136 +0,0 @@ - -#include -#include -#include -#include - -#include "main.h" -#include "list.h" -#include "myTimer.h" -#include "checkFront.h" -#include "idManager.h" -#include "server.h" - -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) -{ - 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; -} - -static void destroyCheck(checkfront_t *p) -{ - assert( p != NULL ); - - free(p->msg); - free(p); -} - -list_t* newCheckFront() -{ - return newList(); -} - -void addMsgInCheckFront(list_t *list, char *msg, int type, int id) -{ - addList(list, newCheck(msg, type, id) ); -} - -void eventMsgInCheckFront(client_t *client) -{ - my_time_t currentTime; - 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_FORNT_TYPE_SIMPLE : - sendClient(client, this->msg); - delListItem(client->listSendMsg, i, destroyCheck); - i--; - break; - - case CHECK_FORNT_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 ) - { - if( isRegisterID(this->id) != -1 ) - { - delID(this->id); - } - - delListItem(client->listSendMsg, i, destroyCheck); - i--; - } - break; - - default : - assert( ! "Zly typ !" ); - break; - } - } -} - -void delMsgInCheckFront(list_t *listCheckFront, int id) -{ - int i; - - for( i = 0 ; i < listCheckFront->count ; i++ ) - { - checkfront_t *this; - - this = (checkfront_t *)listCheckFront->list[i]; - - if( this->id == id ) - { - if( isRegisterID(this->id) != -1 ) - { - delID(this->id); - } - - delListItem(listCheckFront, i, destroyCheck); - return; - } - } -} - -void destroyCheckFront(list_t *p) -{ - assert( p != NULL ); - - destroyListItem(p, destroyCheck); -} - -- cgit v1.2.3