3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
17 #include "headers/debug_op.h"
19 #include "mail_list.h"
21 #include "error_messages/error_messages.h"
27 int _memorymaxsize = 0;
30 /* Create the Mail List */
31 void OS_CreateMailList(int maxsize)
35 _memorymaxsize = maxsize;
43 MailNode *OS_CheckLastMail()
48 /* Get the last Mail -- or first node */
49 MailNode *OS_PopLastMail()
64 lastnode = lastnode->prev;
71 void FreeMailMsg(MailMsg *ml)
87 void FreeMail(MailNode *ml)
92 free(ml->mail->subject);
102 /* Add an email to the list -- always to the begining */
103 void OS_AddMailtoList(MailMsg *ml)
105 MailNode *tmp_node = n_node;
110 new_node = (MailNode *)calloc(1,sizeof(MailNode));
114 ErrorExit(MEM_ERROR,ARGV0);
117 /* Always adding to the beginning of the list
118 * The new node will become the first node and
119 * new_node->next will be the previous first node
121 new_node->next = tmp_node;
122 new_node->prev = NULL;
123 tmp_node->prev = new_node;
127 /* Adding the event to the node */
132 /* Need to remove the last node */
133 if(_memoryused > _memorymaxsize)
138 lastnode = lastnode->prev;
149 /* Adding first node */
150 n_node = (MailNode *)calloc(1,sizeof(MailNode));
153 ErrorExit(MEM_ERROR,ARGV0);