1 /* @(#) $Id: ./src/os_maild/mail_list.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
18 #include "headers/debug_op.h"
20 #include "mail_list.h"
22 #include "error_messages/error_messages.h"
28 int _memorymaxsize = 0;
31 /* Create the Mail List */
32 void OS_CreateMailList(int maxsize)
36 _memorymaxsize = maxsize;
44 MailNode *OS_CheckLastMail()
49 /* Get the last Mail -- or first node */
50 MailNode *OS_PopLastMail()
65 lastnode = lastnode->prev;
72 void FreeMailMsg(MailMsg *ml)
88 void FreeMail(MailNode *ml)
93 free(ml->mail->subject);
103 /* Add an email to the list -- always to the begining */
104 void OS_AddMailtoList(MailMsg *ml)
106 MailNode *tmp_node = n_node;
111 new_node = (MailNode *)calloc(1,sizeof(MailNode));
115 ErrorExit(MEM_ERROR,ARGV0);
118 /* Always adding to the beginning of the list
119 * The new node will become the first node and
120 * new_node->next will be the previous first node
122 new_node->next = tmp_node;
123 new_node->prev = NULL;
124 tmp_node->prev = new_node;
128 /* Adding the event to the node */
133 /* Need to remove the last node */
134 if(_memoryused > _memorymaxsize)
139 lastnode = lastnode->prev;
150 /* Adding first node */
151 n_node = (MailNode *)calloc(1,sizeof(MailNode));
154 ErrorExit(MEM_ERROR,ARGV0);