From 61b283f2e9a8343267ffd0280bacc1369075b763 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 13 Jul 2020 22:08:04 +0200 Subject: weechat: Proper namespacing of symbols Symbol clash in dynamic libraries is a thing. --- weechat/debug.c | 20 +++++++++++--------- weechat/debug.h | 6 +++++- weechat/net.h | 6 ++++++ 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'weechat') diff --git a/weechat/debug.c b/weechat/debug.c index c0353da..dbd1d91 100644 --- a/weechat/debug.c +++ b/weechat/debug.c @@ -5,7 +5,7 @@ #include "debug.h" -static FILE *g_dfile; +static FILE *tomsg_dfile; void debug_init(void) { const char *home = getenv("HOME"); @@ -17,28 +17,30 @@ void debug_init(void) { if (!fname) return; // okay, fine, no debug file sprintf(fname, "%s%s", home, suffix); - g_dfile = fopen(fname, "a"); - if (!g_dfile) { - g_dfile = NULL; + tomsg_dfile = fopen(fname, "a"); + if (!tomsg_dfile) { + tomsg_dfile = NULL; return; // fine! } + free(fname); + // Disable buffering - setvbuf(g_dfile, NULL, _IONBF, 0); + setvbuf(tomsg_dfile, NULL, _IONBF, 0); - fprintf(g_dfile, "--------\n"); + fprintf(tomsg_dfile, "--------\n"); } void debug_deinit(void) { - if (g_dfile) fclose(g_dfile); + if (tomsg_dfile) fclose(tomsg_dfile); } __attribute__((format (printf, 1, 2))) void debugf(const char *restrict format, ...) { - if (!g_dfile) return; + if (!tomsg_dfile) return; va_list ap; va_start(ap, format); - vfprintf(g_dfile, format, ap); + vfprintf(tomsg_dfile, format, ap); va_end(ap); } diff --git a/weechat/debug.h b/weechat/debug.h index 95117a9..d552010 100644 --- a/weechat/debug.h +++ b/weechat/debug.h @@ -1,8 +1,12 @@ #pragma once -void debug_init(void); +#define debug_init tomsg__debug_init +#define debug_deinit tomsg__debug_deinit +#define debugf tomsg__debugf + +void debug_init(void); void debug_deinit(void); __attribute__((format (printf, 1, 2))) diff --git a/weechat/net.h b/weechat/net.h index 7f4e9da..63636e7 100644 --- a/weechat/net.h +++ b/weechat/net.h @@ -4,6 +4,12 @@ #include "global.h" +#define net_set_push_callback tomsg__net_set_push_callback +#define net_set_history_callback tomsg__net_set_history_callback +#define net_sendf tomsg__net_sendf +#define net_handle_recv tomsg__net_handle_recv + + enum net_response_type{ NET_OK, // - NET_NUMBER, // number -- cgit v1.2.3-54-g00ecf