summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/Makefile.am1
-rw-r--r--src/common/io.c27
-rw-r--r--src/common/io.h43
-rw-r--r--src/common/xml.c34
-rw-r--r--src/common/xml.h3
5 files changed, 108 insertions, 0 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index d074200..b5df3a4 100755
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -7,6 +7,7 @@ libcommon_la_SOURCES = \
endianness.h endianness.c \
environment.h environment.c \
extstr.h extstr.c \
+ io.h io.c \
fnv1a.h fnv1a.c \
leb128.h leb128.c \
macros.h \
diff --git a/src/common/io.c b/src/common/io.c
new file mode 100644
index 0000000..c001449
--- /dev/null
+++ b/src/common/io.c
@@ -0,0 +1,27 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * io.c - entrées sorties fiables
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "io.h"
+
+
+
diff --git a/src/common/io.h b/src/common/io.h
new file mode 100644
index 0000000..e805067
--- /dev/null
+++ b/src/common/io.h
@@ -0,0 +1,43 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * io.h - prototypes pour des entrées sorties fiables
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _COMMON_IO_H
+#define _COMMON_IO_H
+
+
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+#define safe_recv recv
+
+#define safe_send send
+
+
+#define safe_read read
+
+#define safe_write write
+
+
+#endif /* _COMMON_IO_H */
diff --git a/src/common/xml.c b/src/common/xml.c
index 5612247..2d38f96 100644
--- a/src/common/xml.c
+++ b/src/common/xml.c
@@ -30,6 +30,7 @@
#include <string.h>
+#include "cpp.h"
#include "extstr.h"
@@ -868,6 +869,39 @@ bool add_content_to_node(xmlDocPtr xdoc, xmlXPathContextPtr context, const char
/******************************************************************************
* *
+* Paramètres : xdoc = structure XML chargée. *
+* context = contexte à utiliser pour les recherches. *
+* path = chemin d'accès au noeud visé. *
+* value = nombre à inscrire en contenu. *
+* *
+* Description : Ajoute un noeud avec contenu numérique au document. *
+* *
+* Retour : true en cas de succès, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_uint_content_to_node(xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path, unsigned int value)
+{
+ xmlNodePtr node; /* Noeud à modifier */
+ char content[sizeof(STR(UINT_MAX)) + 1];/* Valeur en chaîne */
+
+ if (content == NULL) return true;
+
+ node = ensure_node_exist(xdoc, context, path);
+ if (node == NULL) return false;
+
+ sprintf(content, "%u", value);
+ xmlNodeSetContent(node, BAD_CAST content);
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : node = noeud dont le contenu est à mettre à jour. *
* name = nom de la propriété à créer. *
* value = chaîne de caractère à placer. *
diff --git a/src/common/xml.h b/src/common/xml.h
index c637235..eb7703e 100644
--- a/src/common/xml.h
+++ b/src/common/xml.h
@@ -123,6 +123,9 @@ xmlNodePtr ensure_node_exist(xmlDocPtr, xmlXPathContextPtr, const char *);
/* S'assure qu'un noeud donné est bien présent dans le document. */
bool add_content_to_node(xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
+/* Ajoute un noeud avec contenu numérique au document. */
+bool add_uint_content_to_node(xmlDocPtr, xmlXPathContextPtr, const char *, unsigned int);
+
/* Ajoute une propriété à un noeud existant donné. */
bool _add_string_attribute_to_node(xmlNodePtr, const char *, const char *);