diff options
author | Robert Pösel <robyer@seznam.cz> | 2013-10-29 08:47:48 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2013-10-29 08:47:48 +0000 |
commit | 50421b7809c47bd95c59b4a5627e2f89c8bccfa5 (patch) | |
tree | 323784b1c0bb7c86e5df509aab310fa1404680ef /protocols/SkypeClassic/src/msgq.h | |
parent | 8604516498f9135ac1c4379488228d84e69a89ab (diff) |
SkypeClassic: Folders structure and project cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6668 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeClassic/src/msgq.h')
-rw-r--r-- | protocols/SkypeClassic/src/msgq.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/protocols/SkypeClassic/src/msgq.h b/protocols/SkypeClassic/src/msgq.h new file mode 100644 index 0000000000..4eb666944b --- /dev/null +++ b/protocols/SkypeClassic/src/msgq.h @@ -0,0 +1,64 @@ +#include <time.h>
+
+// ----------------------------------------------------------------------
+// Stolen from *nix sys/queue.h
+// ----------------------------------------------------------------------
+/*
+ * Tail queue definitions.
+ */
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_INIT(head) { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+}
+
+#define TAILQ_INSERT_TAIL(head, elm, field) { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+}
+
+#define TAILQ_REMOVE(head, elm, field) { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+}
+// ----------------------------------------------------------------------
+
+struct MsgQueue {
+ TAILQ_ENTRY(MsgQueue) l;
+ char *message;
+ time_t tAdded;
+ time_t tReceived;
+};
+typedef struct
+{
+ TAILQ_HEAD(tag_msgq, MsgQueue) l;
+ CRITICAL_SECTION cs;
+} TYP_MSGQ;
+
+void MsgQ_Init(TYP_MSGQ *q);
+void MsgQ_Exit(TYP_MSGQ *q);
+BOOL MsgQ_Add(TYP_MSGQ *q, char *msg);
+char *MsgQ_RemoveMsg(TYP_MSGQ *q, struct MsgQueue *ptr);
+char *MsgQ_Get(TYP_MSGQ *q);
+int MsgQ_CollectGarbage(TYP_MSGQ *q, time_t age);
|