-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.c
50 lines (42 loc) · 949 Bytes
/
queue.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
** bsflite - bs-free AIM client
**
** (C) 2003-2007 by Claudio Leite <leitec at leitec dot org>
**
** NO WARRANTY. Read the file COPYING for more details.
**/
#include "bsf.h"
#ifdef MESSAGE_QUEUE
/* PROTO */
struct MessageQueue *
addToMQueue(struct MessageQueue * head, char *message, char *whom)
{
struct MessageQueue *trav, *lptr;
if (head == NULL) {
head = malloc(sizeof(struct MessageQueue));
lptr = head;
} else {
for (trav = head; trav->next != NULL; trav = trav->next);
trav->next = malloc(sizeof(struct MessageQueue));
lptr = trav->next;
}
lptr->next = NULL;
lptr->message = strdup(message);
lptr->whom = strdup(whom);
lptr->when = (time_t) time(NULL);
return head;
}
/* PROTO */
void
clearMQueue(struct MessageQueue * head)
{
struct MessageQueue *trav, *tptr;
for (trav = head; trav != NULL;) {
tptr = trav;
trav = trav->next;
free(tptr->message);
free(tptr->whom);
free(tptr);
}
}
#endif