[Openvas-commits] r3505 - in trunk/openvas-libraries: . libopenvascommon

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu May 28 10:11:36 CEST 2009


Author: mattm
Date: 2009-05-28 10:11:35 +0200 (Thu, 28 May 2009)
New Revision: 3505

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/libopenvascommon/nvti.c
   trunk/openvas-libraries/libopenvascommon/nvti.h
Log:
	Add type nvtis for collections of NVT Infos.

	* libopenvascommon/nvti.c (free_nvti_for_hash_table, make_nvtis)
	(free_nvtis, nvtis_size, add_nvti, find_nvti): New functions.

	* libopenvascommon/nvti.h: Update headers.  Add single include guard.

	* ChangeLog: Add log missed yesterday.

Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2009-05-28 07:41:33 UTC (rev 3504)
+++ trunk/openvas-libraries/ChangeLog	2009-05-28 08:11:35 UTC (rev 3505)
@@ -1,3 +1,14 @@
+2009-05-28  Matthew Mundell <mmundell at intevation.de>
+
+	Add type nvtis for collections of NVT Infos.
+
+	* libopenvascommon/nvti.c (free_nvti_for_hash_table, make_nvtis)
+	(free_nvtis, nvtis_size, add_nvti, find_nvti): New functions.
+
+	* libopenvascommon/nvti.h: Update headers.  Add single include guard.
+
+	* ChangeLog: Add log missed yesterday.
+
 2009-05-28  Felix Wolfsteller  <felix.wolfsteller at intevation.de>
 
 	* libopenvascommon/nvti.c (nvti_to_keyfile): Fixed mem leak by freeing
@@ -5,6 +16,10 @@
 
 2009-05-27  Matthew Mundell <mmundell at intevation.de>
 
+	* Makefile (install): Install libopenvascommon/nvti.h.
+
+2009-05-27  Matthew Mundell <mmundell at intevation.de>
+
 	* libopenvascommon/nvti.c: Correct function name.
 
 2009-05-27  Matthew Mundell <mmundell at intevation.de>

Modified: trunk/openvas-libraries/libopenvascommon/nvti.c
===================================================================
--- trunk/openvas-libraries/libopenvascommon/nvti.c	2009-05-28 07:41:33 UTC (rev 3504)
+++ trunk/openvas-libraries/libopenvascommon/nvti.c	2009-05-28 08:11:35 UTC (rev 3505)
@@ -917,3 +917,77 @@
 
   return (0);
 }
+
+
+/* Collections of nvtis. */
+
+/**
+ * @brief Free an NVT Info, for g_hash_table_destroy.
+ *
+ * @param nvti The NVT Info.
+ */
+static void
+free_nvti_for_hash_table (gpointer nvti)
+{
+  nvti_free ((nvti_t*) nvti);
+}
+
+/**
+ * @brief Make a collection of NVT Infos.
+ */
+nvtis_t*
+make_nvtis ()
+{
+  return g_hash_table_new_full (g_str_hash,
+                                g_str_equal,
+                                NULL,
+                                free_nvti_for_hash_table);
+}
+
+/**
+ * @brief Free a collection of NVT Infos.
+ *
+ * @param nvtis The collection of NVT Infos.
+ */
+void
+free_nvtis (nvtis_t* nvtis)
+{
+  if (nvtis) g_hash_table_destroy (nvtis);
+}
+
+/**
+ * @brief Get the size of a collection of NVT Infos.
+ *
+ * @return The number of entries in the collection.
+ */
+guint
+nvtis_size (nvtis_t* nvtis)
+{
+  return g_hash_table_size (nvtis);
+}
+
+/**
+ * @brief Add an NVT Info to a collection of NVT Infos.
+ *
+ * @param nvtis The collection of NVT Infos.
+ */
+void
+add_nvti (nvtis_t* nvtis, nvti_t* nvti)
+{
+  if (nvti)
+    g_hash_table_insert (nvtis, (gpointer) nvti_oid (nvti), (gpointer) nvti);
+}
+
+/**
+ * @brief Add an NVT Info to a collection of NVT Infos.
+ *
+ * @param nvtis The collection of NVT Infos.
+ * @param nvtis The OID of the NVT.
+ *
+ * @return The NVT Info, if found, else NULL.
+ */
+nvti_t*
+find_nvti (nvtis_t* nvtis, const char* oid)
+{
+  return g_hash_table_lookup (nvtis, oid);
+}

Modified: trunk/openvas-libraries/libopenvascommon/nvti.h
===================================================================
--- trunk/openvas-libraries/libopenvascommon/nvti.h	2009-05-28 07:41:33 UTC (rev 3504)
+++ trunk/openvas-libraries/libopenvascommon/nvti.h	2009-05-28 08:11:35 UTC (rev 3505)
@@ -31,6 +31,9 @@
  * This file contains the protos for \ref nvti.c
  */
 
+#ifndef _NVTI_H
+#define _NVTI_H
+
 #include <glib.h>
 
 /**
@@ -119,3 +122,25 @@
 
 nvti_t *nvti_from_keyfile (const gchar *);
 int nvti_to_keyfile (const nvti_t *, const gchar *);
+
+
+/* Collections of NVT Infos. */
+
+/**
+ * @brief A collection of information records corresponding to NVTs.
+ */
+typedef GHashTable nvtis_t;
+
+nvtis_t *make_nvtis ();
+
+void free_nvtis (nvtis_t *);
+
+guint nvtis_size (nvtis_t *);
+
+void add_nvti (nvtis_t *, nvti_t *);
+
+nvti_t *find_nvti (nvtis_t *, const char *);
+
+#define nvtis_find g_hash_table_find
+
+#endif /* not _NVTI_H */



More information about the Openvas-commits mailing list