projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 2.7
[ossec-hids.git]
/
src
/
os_xml
/
os_xml_writer.c
diff --git
a/src/os_xml/os_xml_writer.c
b/src/os_xml/os_xml_writer.c
index
939ca24
..
0e460e4
100755
(executable)
--- a/
src/os_xml/os_xml_writer.c
+++ b/
src/os_xml/os_xml_writer.c
@@
-1,11
+1,12
@@
-/* @(#) $Id: os_xml_writer.c,v 1.5 2009/06/24 17:06:32 dcid Exp $ */
+/* @(#) $Id: ./src/os_xml/os_xml_writer.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
* Foundation
*/
@@
-33,7
+34,7
@@
/* Internal functions */
int _oswcomment(FILE *fp_in, FILE *fp_out);
/* Internal functions */
int _oswcomment(FILE *fp_in, FILE *fp_out);
-int _WReadElem(FILE *fp_in, FILE *fp_out, int position, int parent,
+int _WReadElem(FILE *fp_in, FILE *fp_out, int position, int parent,
char **node, char *value, int node_pos);
char **node, char *value, int node_pos);
@@
-55,8
+56,8
@@
int _xml_wfgetc(FILE *fp_in, FILE *fp_out)
if(c == '\n') /* add new line */
_line++;
if(c == '\n') /* add new line */
_line++;
-
- return(c);
+
+ return(c);
}
#define FWGETC(fp_in, fp_out) _xml_wfgetc(fp_in, fp_out)
}
#define FWGETC(fp_in, fp_out) _xml_wfgetc(fp_in, fp_out)
@@
-111,10
+112,10
@@
int OS_WriteXML(char *infile, char *outfile, char **nodes, char *attr,
{
int r = 0;
int rwidth = 0;
{
int r = 0;
int rwidth = 0;
-
+
fseek(fp_out, 0, SEEK_END);
fprintf(fp_out, "\n");
fseek(fp_out, 0, SEEK_END);
fprintf(fp_out, "\n");
-
+
/* Printing each node. */
while(nodes[r])
{
/* Printing each node. */
while(nodes[r])
{
@@
-125,13
+126,13
@@
int OS_WriteXML(char *infile, char *outfile, char **nodes, char *attr,
if(nodes[r])
fprintf(fp_out, "\n");
}
if(nodes[r])
fprintf(fp_out, "\n");
}
-
+
/* Printing val. */
r--;
rwidth -=6;
fprintf(fp_out, "%s</%s>\n", newval, nodes[r]);
r--;
/* Printing val. */
r--;
rwidth -=6;
fprintf(fp_out, "%s</%s>\n", newval, nodes[r]);
r--;
-
+
/* Closing each node. */
while(r >= 0)
/* Closing each node. */
while(r >= 0)
@@
-141,7
+142,7
@@
int OS_WriteXML(char *infile, char *outfile, char **nodes, char *attr,
rwidth -= 3;
}
}
rwidth -= 3;
}
}
-
+
fclose(fp_in);
fclose(fp_out);
return(0);
fclose(fp_in);
fclose(fp_out);
return(0);
@@
-201,7
+202,7
@@
int _oswcomment(FILE *fp_in, FILE *fp_out)
-int _WReadElem(FILE *fp_in, FILE *fp_out,
+int _WReadElem(FILE *fp_in, FILE *fp_out,
int position, int parent, char **nodes, char *val, int node_pos)
{
int c;
int position, int parent, char **nodes, char *val, int node_pos)
{
int c;
@@
-239,8
+240,8
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
continue;
}
}
continue;
}
}
-
-
+
+
/* Real checking */
if(location == -1)
{
/* Real checking */
if(location == -1)
{
@@
-262,7
+263,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
continue;
}
}
continue;
}
}
-
+
/* Looking for the closure */
else if((location == 0) && ((c == _R_CONFE) || (c == ' ')))
/* Looking for the closure */
else if((location == 0) && ((c == _R_CONFE) || (c == ' ')))
@@
-277,7
+278,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
_ge = '/';
elem[count -1] = '\0';
}
_ge = '/';
elem[count -1] = '\0';
}
-
+
/* If we may have more attributes */
if(c == ' ')
/* If we may have more attributes */
if(c == ' ')
@@
-298,11
+299,11
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
{
count = 0;
location = -1;
{
count = 0;
location = -1;
-
+
memset(elem,'\0',XML_MAXSIZE);
memset(closedelem,'\0',XML_MAXSIZE);
memset(cont,'\0',XML_MAXSIZE);
memset(elem,'\0',XML_MAXSIZE);
memset(closedelem,'\0',XML_MAXSIZE);
memset(cont,'\0',XML_MAXSIZE);
-
+
if(parent > 0)
{
return(ret_code);
if(parent > 0)
{
return(ret_code);
@@
-313,7
+314,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
{
count = 0;
location = 1;
{
count = 0;
location = 1;
- }
+ }
/* Checking position of the node */
/* Checking position of the node */
@@
-323,7
+324,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
}
/* Checking if the element name matches */
}
/* Checking if the element name matches */
- if(node_pos == position &&
+ if(node_pos == position &&
nodes[node_pos] && strcmp(elem, nodes[node_pos]) == 0)
{
node_pos++;
nodes[node_pos] && strcmp(elem, nodes[node_pos]) == 0)
{
node_pos++;
@@
-345,7
+346,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
}
}
}
}
}
}
-
+
else if((location == 2) &&(c == _R_CONFE))
{
closedelem[count]='\0';
else if((location == 2) &&(c == _R_CONFE))
{
closedelem[count]='\0';
@@
-357,7
+358,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
memset(elem,'\0',XML_MAXSIZE);
memset(closedelem,'\0',XML_MAXSIZE);
memset(cont,'\0',XML_MAXSIZE);
memset(elem,'\0',XML_MAXSIZE);
memset(closedelem,'\0',XML_MAXSIZE);
memset(cont,'\0',XML_MAXSIZE);
-
+
count = 0;
location = -1;
if(parent > 0)
count = 0;
location = -1;
if(parent > 0)
@@
-395,7
+396,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
{
ret_code = 1;
}
{
ret_code = 1;
}
-
+
count = 0;
}
}
count = 0;
}
}
@@
-415,7
+416,7
@@
int _WReadElem(FILE *fp_in, FILE *fp_out,
}
}
}
}
}
}
-
+
if(location == -1)
{
return(ret_code);
if(location == -1)
{
return(ret_code);