projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git]
/
src
/
os_maild
/
mail_list.c
diff --git
a/src/os_maild/mail_list.c
b/src/os_maild/mail_list.c
old mode 100755
(executable)
new mode 100644
(file)
index
1e70a9e
..
7e782b2
--- a/
src/os_maild/mail_list.c
+++ b/
src/os_maild/mail_list.c
@@
-1,5
+1,3
@@
-/* @(#) $Id$ */
-
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
@@
-9,7
+7,6
@@
* Foundation
*/
* Foundation
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-17,14
+14,13
@@
#include "headers/debug_op.h"
#include "maild.h"
#include "mail_list.h"
#include "headers/debug_op.h"
#include "maild.h"
#include "mail_list.h"
-
#include "error_messages/error_messages.h"
#include "error_messages/error_messages.h"
-MailNode *n_node;
-MailNode *lastnode;
+static MailNode *n_node;
+static MailNode *lastnode;
-int _memoryused = 0;
-int _memorymaxsize = 0;
+static int _memoryused = 0;
+static int _memorymaxsize = 0;
/* Create the Mail List */
/* Create the Mail List */
@@
-33,134
+29,127
@@
void OS_CreateMailList(int maxsize)
n_node = NULL;
_memorymaxsize = maxsize;
n_node = NULL;
_memorymaxsize = maxsize;
-
_memoryused = 0;
_memoryused = 0;
-
+
return;
}
return;
}
-/* check last mail */
+/* Check last mail */
MailNode *OS_CheckLastMail()
{
MailNode *OS_CheckLastMail()
{
- return(lastnode);
+ return (lastnode);
}
/* Get the last Mail -- or first node */
MailNode *OS_PopLastMail()
{
}
/* Get the last Mail -- or first node */
MailNode *OS_PopLastMail()
{
-
MailNode *oldlast;
oldlast = lastnode;
MailNode *oldlast;
oldlast = lastnode;
-
- if(lastnode == NULL)
- {
+ if (lastnode == NULL) {
n_node = NULL;
n_node = NULL;
- return(NULL);
+ return (NULL);
}
}
-
+
_memoryused--;
_memoryused--;
-
lastnode = lastnode->prev;
/* Remove the last */
lastnode = lastnode->prev;
/* Remove the last */
- return(oldlast);
+ return (oldlast);
}
}
-
void FreeMailMsg(MailMsg *ml)
{
void FreeMailMsg(MailMsg *ml)
{
- if(ml == NULL)
+ if (ml == NULL) {
return;
return;
-
- if(ml->subject)
+ }
+
+ if (ml->subject) {
free(ml->subject);
free(ml->subject);
-
- if(ml->body)
+ }
+
+ if (ml->body) {
free(ml->body);
free(ml->body);
-
- free(ml);
-}
+ }
+ free(ml);
+}
/* Free mail node */
void FreeMail(MailNode *ml)
{
/* Free mail node */
void FreeMail(MailNode *ml)
{
- if(ml == NULL)
+ if (ml == NULL) {
return;
return;
- if(ml->mail->subject)
+ }
+ if (ml->mail->subject) {
free(ml->mail->subject);
free(ml->mail->subject);
-
- if(ml->mail->body)
+ }
+
+ if (ml->mail->body) {
free(ml->mail->body);
free(ml->mail->body);
+ }
- free(ml->mail);
+ free(ml->mail);
free(ml);
}
free(ml);
}
-/* Add an email to the list -- always to the begining */
+/* Add an email to the list -- always to the beginning */
void OS_AddMailtoList(MailMsg *ml)
{
MailNode *tmp_node = n_node;
void OS_AddMailtoList(MailMsg *ml)
{
MailNode *tmp_node = n_node;
-
- if(tmp_node)
- {
+
+ if (tmp_node) {
MailNode *new_node;
MailNode *new_node;
- new_node = (MailNode *)calloc(1,sizeof(MailNode));
-
- if(new_node == NULL)
- {
- ErrorExit(MEM_ERROR,ARGV0);
+ new_node = (MailNode *)calloc(1, sizeof(MailNode));
+
+ if (new_node == NULL) {
+ ErrorExit(MEM_ERROR, ARGV0, errno, strerror(errno));
}
}
- /* Always adding to the beginning of the list
+ /* Always add to the beginning of the list
* The new node will become the first node and
* new_node->next will be the previous first node
*/
new_node->next = tmp_node;
new_node->prev = NULL;
tmp_node->prev = new_node;
* The new node will become the first node and
* new_node->next will be the previous first node
*/
new_node->next = tmp_node;
new_node->prev = NULL;
tmp_node->prev = new_node;
-
+
n_node = new_node;
n_node = new_node;
- /* Adding the event to the node */
+ /* Add the event to the node */
new_node->mail = ml;
_memoryused++;
new_node->mail = ml;
_memoryused++;
-
+
/* Need to remove the last node */
/* Need to remove the last node */
- if(_memoryused > _memorymaxsize)
- {
+ if (_memoryused > _memorymaxsize) {
MailNode *oldlast;
oldlast = lastnode;
lastnode = lastnode->prev;
MailNode *oldlast;
oldlast = lastnode;
lastnode = lastnode->prev;
-
- /* free last node */
+
+ /* Free last node */
FreeMail(oldlast);
FreeMail(oldlast);
-
+
_memoryused--;
}
}
_memoryused--;
}
}
-
- else
- {
- /* Adding first node */
- n_node = (MailNode *)calloc(1,sizeof(MailNode));
- if(n_node == NULL)
- {
- ErrorExit(MEM_ERROR,ARGV0);
+
+ else {
+ /* Add first node */
+ n_node = (MailNode *)calloc(1, sizeof(MailNode));
+ if (n_node == NULL) {
+ ErrorExit(MEM_ERROR, ARGV0, errno, strerror(errno));
}
n_node->prev = NULL;
n_node->next = NULL;
n_node->mail = ml;
}
n_node->prev = NULL;
n_node->next = NULL;
n_node->mail = ml;
-
- lastnode = n_node;
+
+ lastnode = n_node;
}
return;
}
}
return;
}
-/* EOF */