diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-12-22 17:37:29 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-12-22 17:37:29 +0000 |
commit | fee81607c448feaa85024f056c54c6a020d10884 (patch) | |
tree | d1d0207137dc4841896dd44df711dd603c0e372e /plugins/!NotAdopted/Skype/msgq.c | |
parent | 10c393c65b72884e874254f276c81adcea9f01b9 (diff) |
not needed anymore
git-svn-id: http://svn.miranda-ng.org/main/trunk@2805 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/Skype/msgq.c')
-rw-r--r-- | plugins/!NotAdopted/Skype/msgq.c | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/plugins/!NotAdopted/Skype/msgq.c b/plugins/!NotAdopted/Skype/msgq.c deleted file mode 100644 index 48790e1c29..0000000000 --- a/plugins/!NotAdopted/Skype/msgq.c +++ /dev/null @@ -1,90 +0,0 @@ -/*
- * Implements a simple message queue for send and receive queue.
- * We could use memlist.c, but it's not efficient
- * enough for this purpose (would always memmove on removing first
- * element), therefore it's implemented as tail queue.
- */
-
-#include "skype.h"
-#include "msgq.h"
-#include "debug.h"
-
-
-void MsgQ_Init(TYP_MSGQ *q)
-{
- TAILQ_INIT(&q->l);
- InitializeCriticalSection (&q->cs);
-}
-
-void MsgQ_Exit(TYP_MSGQ *q)
-{
- struct MsgQueue *ptr;
-
- EnterCriticalSection(&q->cs);
- while (ptr=q->l.tqh_first)
- free(MsgQ_RemoveMsg(q, ptr));
- LeaveCriticalSection(&q->cs);
- DeleteCriticalSection (&q->cs);
-}
-
-BOOL MsgQ_Add(TYP_MSGQ *q, char *msg)
-{
- struct MsgQueue *ptr;
-
- if (!(ptr=(struct MsgQueue*)malloc(sizeof(struct MsgQueue))))
- return FALSE;
- ptr->message = _strdup(msg); // Don't forget to free!
- ptr->tAdded = SkypeTime(NULL);
- SkypeTime(&ptr->tReceived);
- EnterCriticalSection(&q->cs);
- TAILQ_INSERT_TAIL(&q->l, ptr, l);
- //LOG (("MsgQ_Add (%s) @%lu/%ld", msg, ptr->tReceived, ptr->tAdded));
- LeaveCriticalSection(&q->cs);
- return TRUE;
-}
-
-char *MsgQ_RemoveMsg(TYP_MSGQ *q, struct MsgQueue *ptr)
-{
- char *msg;
-
- if (!ptr) return NULL;
- TAILQ_REMOVE(&q->l, ptr, l);
- msg=ptr->message;
- free(ptr);
- return msg;
-}
-
-char *MsgQ_Get(TYP_MSGQ *q)
-{
- char *msg;
-
- EnterCriticalSection(&q->cs);
- msg=MsgQ_RemoveMsg(q, q->l.tqh_first);
- LeaveCriticalSection(&q->cs);
- return msg;
-}
-
-int MsgQ_CollectGarbage(TYP_MSGQ *q, time_t age)
-{
- struct MsgQueue *ptr;
- int i=0;
-
- EnterCriticalSection(&q->cs);
- ptr=q->l.tqh_first;
- while (ptr)
- {
- if (ptr->tAdded && SkypeTime(NULL)-ptr->tAdded>age)
- {
- struct MsgQueue *ptr_;
- LOG(("GarbageCollector throwing out message: %s", ptr->message));
- ptr_=ptr;
- ptr=ptr->l.tqe_next;
- free(MsgQ_RemoveMsg(q, ptr_));
- i++;
- continue;
- }
- ptr=ptr->l.tqe_next;
- }
- LeaveCriticalSection(&q->cs);
- return i;
-}
|