summaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 01:00:45 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 01:00:45 +0200
commita04bcf247f4be7e3da4fe3895200f0b9709fc0bb (patch)
tree5e749b81799bb82a751ed632d91b801abe624008 /src/log.c
parentad4999488eadac3a10de99caf50b732af8b771b9 (diff)
downloadfastd-a04bcf247f4be7e3da4fe3895200f0b9709fc0bb.tar
fastd-a04bcf247f4be7e3da4fe3895200f0b9709fc0bb.zip
Merge peer config into peer structure
With this refactoring, the structure fastd_peer_config_t is merged into fastd_peer_t, and fastd_remote_config_t into fastd_remote_t. This also means we now create peers directly when reading their configurations, which significantly simplifies the whole reload process, and prepares for some future optimizations like a key hash table. Note: This commit is too big, but I couldn't come up with a nice way to split it into smaller pieces...
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/log.c b/src/log.c
index 122b322..f6b6d2d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -93,16 +93,18 @@ static size_t snprint_peer_address(char *buffer, size_t size, const fastd_peer_a
/** Creates a string representation of a peer */
static size_t snprint_peer_str(char *buffer, size_t size, const fastd_peer_t *peer) {
- if (peer->config->name) {
- return snprintf_safe(buffer, size, "<%s>", peer->config->name);
- }
- else {
- char buf[65];
- if (conf.protocol->describe_peer(peer, buf, sizeof(buf)))
- return snprintf_safe(buffer, size, "{%s}", buf);
- else
- return snprintf_safe(buffer, size, "(null)");
+ if (peer) {
+ if (peer->name) {
+ return snprintf_safe(buffer, size, "<%s>", peer->name);
+ }
+ else {
+ char buf[65];
+ if (conf.protocol->describe_peer(peer, buf, sizeof(buf)))
+ return snprintf_safe(buffer, size, "{%s}", buf);
+ }
}
+
+ return snprintf_safe(buffer, size, "(null)");
}
/** vsnprintf-like function using different conversion specifiers */
@@ -166,12 +168,7 @@ static int fastd_vsnprintf(char *buffer, size_t size, const char *format, va_lis
break;
case 'P':
- p = va_arg(ap, const fastd_peer_t*);
-
- if (p)
- buffer += snprint_peer_str(buffer, buffer_end-buffer, (const fastd_peer_t*)p);
- else
- buffer += snprintf_safe(buffer, buffer_end-buffer, "(null)");
+ buffer += snprint_peer_str(buffer, buffer_end-buffer, va_arg(ap, const fastd_peer_t*));
break;
case 'I':