Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Refactor of sample keys and certificates
[src/app-framework-main.git]
/
src
/
verbose.c
diff --git
a/src/verbose.c
b/src/verbose.c
index
a91aeb1
..
e60ba54
100644
(file)
--- a/
src/verbose.c
+++ b/
src/verbose.c
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 201
6
"IoT.bzh"
+ Copyright (C) 201
5-2020
"IoT.bzh"
author: José Bollo <jose.bollo@iot.bzh>
author: José Bollo <jose.bollo@iot.bzh>
@@
-43,14
+43,18
@@
void vverbose(int level, const char *file, int line, const char *fmt, va_list ar
void verbose_set_name(const char *name, int authority)
{
void verbose_set_name(const char *name, int authority)
{
+ closelog();
openlog(name, LOG_PERROR, authority ? LOG_AUTH : LOG_USER);
}
#else
openlog(name, LOG_PERROR, authority ? LOG_AUTH : LOG_USER);
}
#else
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <unistd.h>
+#include <errno.h>
-static c
onst c
har *appname;
+static char *appname;
static int appauthority;
static int appauthority;
@@
-67,7
+71,9
@@
static const char *prefixes[] = {
void vverbose(int level, const char *file, int line, const char *fmt, va_list args)
{
void vverbose(int level, const char *file, int line, const char *fmt, va_list args)
{
+ int saverr = errno;
int tty = isatty(fileno(stderr));
int tty = isatty(fileno(stderr));
+ errno = saverr;
fprintf(stderr, "%s: ", prefixes[LEVEL(level)] + (tty ? 4 : 0));
vfprintf(stderr, fmt, args);
fprintf(stderr, "%s: ", prefixes[LEVEL(level)] + (tty ? 4 : 0));
vfprintf(stderr, fmt, args);
@@
-79,7
+85,8
@@
void vverbose(int level, const char *file, int line, const char *fmt, va_list ar
void verbose_set_name(const char *name, int authority)
{
void verbose_set_name(const char *name, int authority)
{
- appname = name;
+ free(appname);
+ appname = name ? strdup(name) : NULL;
appauthority = authority;
}
appauthority = authority;
}