diff --git a/interface.c b/interface.c index 6af4dc0..6f77bac 100644 --- a/interface.c +++ b/interface.c @@ -1191,24 +1191,24 @@ void hexdump (int *in_ptr, int *in_end) { print_end (); } +/* void logprintf (const char *format, ...) { va_list ap; va_start (ap, format); log_message(format, ap); va_end (ap); - /* - int x = 0; - if (!prompt_was) { - x = 1; - print_start (); - } - printf (COLOR_GREY " *** "); - printf (COLOR_NORMAL); - if (x) { - print_end (); - } - */ + //int x = 0; + //if (!prompt_was) { + // x = 1; + // print_start (); + //} + //printf (COLOR_GREY " *** "); + //printf (COLOR_NORMAL); + //if (x) { + // print_end (); + //} } +*/ int color_stack_pos; const char *color_stack[10]; diff --git a/msglog.c b/msglog.c index cbe1828..0799b79 100644 --- a/msglog.c +++ b/msglog.c @@ -14,26 +14,27 @@ #define COLOR_INVERSE "\033[7m" -void log_printf(const char *format, ...) +/** + * Log a message to the telegram-cli message log, by + * just writing it to STDOUT and appending '***' + */ +void log_printf(const char *format, va_list ap) { printf (COLOR_GREY " *** "); - va_list ap; - va_start (ap, format); - vfprintf (stdout, format, ap); - va_end (ap); + vprintf (format, ap); printf (COLOR_NORMAL); } /** * The callback that will log the given msg to the used target */ -void (*log_cb)(const char*, ...) = log_printf; +void (*log_cb)(const char* format, va_list ap) = log_printf; /** * Set a custom logging callback to use instead of the regular * printf to stdout */ -void set_log_cb(void (*cb)(const char*, ...)) +void set_log_cb(void (*cb)(const char*, va_list ap)) { log_cb = cb; } @@ -41,7 +42,7 @@ void set_log_cb(void (*cb)(const char*, ...)) /** * Log a message to the current message log */ -void log_message(const char *format, ...) +void logprintf(const char *format, ...) { va_list ap; va_start (ap, format); diff --git a/msglog.h b/msglog.h index 07d74dc..e574ba2 100644 --- a/msglog.h +++ b/msglog.h @@ -1,13 +1,15 @@ +#include + /** * Set a custom logging callback to use instead of regular printing * to stdout */ -void set_log_cb(void (*cb)(const char*, ...)); +void set_log_cb(void (*cb)(const char*, va_list ap)); /** * Log a message to the current message log */ -void log_message(const char *format, ...); +void logprintf(const char *format, ...); /* void log_debug(const char* format, ...); diff --git a/purple-plugin/telegram-purple.c b/purple-plugin/telegram-purple.c index 4d73b4b..2e417c2 100644 --- a/purple-plugin/telegram-purple.c +++ b/purple-plugin/telegram-purple.c @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include // test @@ -37,6 +40,8 @@ #include "status.h" #include "util.h" #include "prpl.h" +#include "prefs.h" +#include "util.h" // Telegram Includes #include @@ -52,12 +57,14 @@ static PurplePlugin *_telegram_protocol = NULL; * Redirect the msglog of the telegram-cli application to the libpurple * logger */ -void tg_cli_log_cb(const char* format, ...) +void tg_cli_log_cb(const char* format, va_list ap) { - va_list ap; - va_start (ap, format); - purple_debug_info(PLUGIN_ID, format, ap); - va_end (ap); + // emulate libpurple logging function, because we cant pass va_list + // directly + time_t mtime = time(NULL); + const char *mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime)); + printf("(%s) prpl-telegram: ", mdate); + vprintf(format, ap); } /**