summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-08-08 12:22:55 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-08-08 12:22:55 +0200
commit470032570176e47ab193ed7c31a3297c571394b1 (patch)
tree86e946d62bbdbc830867b8efea23949339d21f65
parent745ced8e14e01f606f5aec79d600bcf5a10b8aff (diff)
New prototype for log_redirect() and log_set_levels()
-rw-r--r--src/log.c11
-rw-r--r--src/log.h21
2 files changed, 27 insertions, 5 deletions
diff --git a/src/log.c b/src/log.c
index 84092cb..10b4599 100644
--- a/src/log.c
+++ b/src/log.c
@@ -49,13 +49,18 @@
static FILE *log_handle=NULL;
static int f_status=0;
+
+/*@
+ @ requires valid_read_string(_format);
+ @*/
static int log_handler(const char *_format, va_list ap) __attribute__((format(printf, 1, 0)));
+
/* static unsigned int log_levels=LOG_LEVEL_DEBUG|LOG_LEVEL_TRACE|LOG_LEVEL_QUIET|LOG_LEVEL_INFO|LOG_LEVEL_VERBOSE|LOG_LEVEL_PROGRESS|LOG_LEVEL_WARNING|LOG_LEVEL_ERROR|LOG_LEVEL_PERROR|LOG_LEVEL_CRITICAL; */
static unsigned int log_levels=LOG_LEVEL_TRACE|LOG_LEVEL_QUIET|LOG_LEVEL_INFO|LOG_LEVEL_VERBOSE|LOG_LEVEL_PROGRESS|LOG_LEVEL_WARNING|LOG_LEVEL_ERROR|LOG_LEVEL_PERROR|LOG_LEVEL_CRITICAL;
-int log_set_levels(const unsigned int levels)
+unsigned int log_set_levels(const unsigned int levels)
{
- const int old_levels=log_levels;
+ const unsigned int old_levels=log_levels;
log_levels=levels;
return old_levels;
}
@@ -160,7 +165,7 @@ int log_close(void)
return f_status;
}
-int log_redirect(unsigned int level, const char *format, ...)
+int log_redirect(const unsigned int level, const char *format, ...)
{
if((log_levels & level)==0)
return 0;
diff --git a/src/log.h b/src/log.h
index 8f8664b..cb91fed 100644
--- a/src/log.h
+++ b/src/log.h
@@ -25,12 +25,29 @@
extern "C" {
#endif
-int log_set_levels(const unsigned int levels);
+unsigned int log_set_levels(const unsigned int levels);
+
+/*@
+ @ requires valid_read_string(default_filename);
+ @ requires \valid(errsv);
+ @ requires separation: \separated(default_filename, errsv);
+ @*/
FILE *log_open(const char*default_filename, const int mode, int *errsv);
+
+/*@
+ @ requires \valid_read(default_filename);
+ @ requires \valid(errsv);
+ @ requires separation: \separated(default_filename, errsv);
+ @*/
FILE *log_open_default(const char*default_filename, const int mode, int *errsv);
+
int log_flush(void);
int log_close(void);
-int log_redirect(unsigned int level, const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+/*@
+ @ requires valid_read_string(format);
+ @*/
+int log_redirect(const unsigned int level, const char *format, ...) __attribute__((format(printf, 2, 3)));
void dump_log(const void *nom_dump,unsigned int lng);
void dump2_log(const void *dump_1, const void *dump_2,const unsigned int lng);