[Openvas-commits] r2590 - in trunk/openvas-client: . nessus
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 26 12:09:25 CET 2009
Author: felix
Date: 2009-02-26 12:09:22 +0100 (Thu, 26 Feb 2009)
New Revision: 2590
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/nessus/plugin_cache.c
Log:
* nessus/plugin_cache.c: Beautified documentation.
* nessus/plugin_cache.c (plugin_cache_get_filename, plugin_cache_write,
plugin_cache_read): plugin_cache_get_filename indeed returns a gchar,
adjusted return type and free it accordingly with g_free.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-02-26 11:02:10 UTC (rev 2589)
+++ trunk/openvas-client/ChangeLog 2009-02-26 11:09:22 UTC (rev 2590)
@@ -1,3 +1,11 @@
+2009-02-26 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+ * nessus/plugin_cache.c: Beautified documentation.
+
+ * nessus/plugin_cache.c (plugin_cache_get_filename, plugin_cache_write,
+ plugin_cache_read): plugin_cache_get_filename indeed returns a gchar,
+ adjusted return type and free it accordingly with g_free.
+
2009-02-25 Felix Wolfsteller <felix.wolfsteller at intevation.de>
* nessus/prefs_dialog/prefs_kb.c: Documentation added, K&R replacements
Modified: trunk/openvas-client/nessus/plugin_cache.c
===================================================================
--- trunk/openvas-client/nessus/plugin_cache.c 2009-02-26 11:02:10 UTC (rev 2589)
+++ trunk/openvas-client/nessus/plugin_cache.c 2009-02-26 11:09:22 UTC (rev 2590)
@@ -28,10 +28,9 @@
/**
* \file
- * Cache for the plugin information read from the server
+ * Cache for the plugin information read from the server.
*
- * File format
- * -----------
+ * @section plugincache-fileformat File format
*
* A plugin cache file consists of a number of lines, each holding a
* number of fields. The fields are separated by vertical bar
@@ -47,6 +46,7 @@
* are the field separators. So decoding can be done by first replacing
* all | with NUL and then %-unescaping each field. Unescaping never
* makes the string longer and thus can be done in place.
+ * An example is given below.
*
* There are several kinds of lines, distinguished by keywords.
* For a healthy cache file they appear in the following order:
@@ -82,13 +82,18 @@
* considered outdated.
*
*
- * Files used
- * ----------
+ * @section plugincache-files-used Files used
*
* A cache file is specific for a given context and is stored in the
* same directory as the openvasrc file for the context. The cache for
* the global context is ~/.openvas_nvt_cache. If an alternate
* openvas file was given on the command line, no caching is done.
+ *
+ * @section plugincache-example Examplary first two lines of a cache file
+ *
+ * OpenVASNVTDescCache|2|fc8902a32651d93ab136e75977f664ec
+ * nvt|1.3.6.1.4.1.25623.1.0.11219|8e58495bf0130d4da02340a505b14041|SYN Scan|scanner|Copyright (C) Renaud Deraison \<deraison at cvs.nessus.org\>|%0aThis plugins performs a supposedly fast SYN port scan%0aIt does so by computing the RTT (round trip time) of the packets%0acoming back and forth between the openvasd host and the target,%0athen it uses that to quicky send SYN packets to the remote host%0a|Performs a TCP SYN scan|Port scanners|$Revision: 1266 $|NOCVE|NOBID|NOXREF|NOSIGNKEYS|NOTAG
+ *
*/
#include <includes.h>
@@ -112,12 +117,12 @@
#define END_KEYWORD "end"
/**
- * Determine the cache file to use for the context.
+ * @brief Determine the cache file to use for the context.
*
* The cache file will be in the same directory as the nessusrc file of
* the context. The return value has to be free'd with efree.
*/
-char *
+gchar *
plugin_cache_get_filename(struct context *context)
{
char *filename = NULL;
@@ -137,7 +142,7 @@
/**
- * Write a string to the cache file
+ * @brief Write a string to the cache file.
*
* The parameter FILE is the stream to be used to write to the cache
* file. S is the NUL-terminated string to be written. The bytes of S
@@ -162,17 +167,17 @@
}
/**
- * Write a record to the cache file
+ * @brief Write a record to the cache file.
*
- * The parameter FILE is be the stream to be used to write to the cache
+ * The parameter FILE is the stream to be used to write to the cache
* file. FORMAT is a string containing one character for each of the
* fields following the format parameter. Two field types are
* supported:
*
- * i The value must be an int. It written in a decimal.
- * s The value must be a NUL-terminated string.
- * The string percent escaped while being written
- * k The value must be a NUL-terminated string.
+ * i (int) The value must be an int. It is written in a decimal.
+ * s (string) The value must be a NUL-terminated string.
+ * The string is percent-escaped while being written.
+ * k (keyword) The value must be a NUL-terminated string.
* The string is copied literally to the file
* and is not percent escaped.
*
@@ -228,7 +233,7 @@
/**
- * Write a plugin to the cache file
+ * @brief Write a plugin to the cache file.
*
* The parameter PLUGIN is the plugin to write and FILE is be the stream
* to be used to write to the cache file. The plugin is written as a
@@ -251,7 +256,7 @@
/**
- * Write a dependency to the cache file
+ * @brief Write a dependency to the cache file.
*
* The parameter DEP is the dependency to write and FILE is be the stream
* to be used to write to the cache file. The dependency is written as a
@@ -273,7 +278,7 @@
/**
- * Write all plugins in the linked list PLUGINS
+ * @brief Write all plugins in the linked list PLUGINS.
*
* The parameter PLUGINS is the first plugin in the list of plugins to
* write and FILE is be the stream to be used to write to the cache
@@ -295,7 +300,7 @@
}
/**
- * Write all dependencies in the linked list DEPS
+ * @brief Write all dependencies in the linked list DEPS.
*
* The parameter DEPS is the first dependency in the list of dependencies to
* write and FILE is be the stream to be used to write to the cache
@@ -317,7 +322,7 @@
}
/**
- * Write the plugins in CONTEXT to a cache
+ * @brief Write the plugins in CONTEXT to a cache.
*
* The parameter CONTEXT is the context whose plugins are to be written.
* The filename for the cache is determined with
@@ -329,12 +334,13 @@
*
* If an error occurs when writing the file, the file is removed to
* avoid incorrect caches lying around.
+ *
* @return Returns 0 on success and != 0 otherwise.
*/
int
plugin_cache_write(struct context * context, const char * server_md5sum)
{
- char *filename;
+ gchar *filename;
FILE *file;
int failure = 0;
@@ -344,7 +350,7 @@
if (!file)
{
show_error(_("Could not open file '%s' for writing plugin cache"), filename);
- efree(&filename);
+ g_free (filename);
return -1;
}
@@ -360,14 +366,14 @@
if (failure)
unlink(filename);
- efree(&filename);
+ g_free (filename);
return failure;
}
/**
- * Read one line from FILE
+ * @brief Read one line from FILE.
*
* The return value is a NUL-terminated string including the trailing
* newline of the line if any. The return value is allocated with
@@ -425,7 +431,7 @@
/**
- * Split LINE at the vertical bars
+ * @brief Split LINE at the vertical bars.
*
* The NUL-terminated string LINE is split into fields at the vertical
* bar characters ('|') by replacing the vertical bars with NUL
@@ -484,9 +490,8 @@
: -1)
/**
- * percent-unquote the NUL-terminated string S.
- *
- * Unquoting is done in place.
+ * @brief Percent-unquote a NUL-terminated string in place.
+ *
* @return Returns 0 on success and != 0 otherwise.
*/
static int
@@ -521,7 +526,7 @@
/**
- * Read a line from the cache file and decode it
+ * @brief Read a line from the cache file and decode it.
*
* The parameter FILE is the stread to the read the cache line from.
* The parameters ITEMS and NITEMS are passed through to split_line and
@@ -583,7 +588,7 @@
/**
- * Read the file header
+ * @brief Read the file header.
*
* The file header is the first line of the file with the md5sum for the
* md5sum originally reported by the server.
@@ -644,7 +649,7 @@
}
/**
- * Read the plugin cache and optionally check the md5sum for the cache
+ * @brief Read the plugin cache and optionally check the md5sum for the cache.
*
* CONTEXT is the context into which the cache should be read.
* SERVER_MD5SUM should be the string with the hex-encoded md5sum
@@ -669,7 +674,7 @@
{
int result = 0;
int end_found = 0;
- char *filename;
+ gchar *filename;
FILE *file;
char *server_md5sum = NULL;
@@ -776,7 +781,7 @@
context_set_plugins_md5sum(context, server_md5sum);
fail:
- efree(&filename);
+ g_free (filename);
efree(&server_md5sum);
if (file != NULL)
fclose(file);
More information about the Openvas-commits
mailing list