From e0a3aace3a9624bd9f94b2499f13f37615254bbf Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Sun, 1 Aug 2021 17:01:10 +0100 Subject: [PATCH] restore lost code --- .envrc | 2 +- Makefile | 85 +-- account.c | 1 - buffer.c | 1 - channel.c | 14 +- command.c | 1 - completion.c | 1 - config.c | 1 - connection.c | 23 +- input.c | 1 - message.c | 1 - omemo.c | 1 - pgp.c | 1 - plugin.cpp | 126 ++-- plugin.h | 1 + plugin.hh | 1573 +++++++++++++++++++++++++++++++++++++++++++++- strophe.cpp | 33 + strophe.hh | 28 + tests/plugin.cc | 4 +- tests/strophe.cc | 11 + user.c | 1 - util.c | 1 - 22 files changed, 1754 insertions(+), 157 deletions(-) create mode 100644 strophe.cpp create mode 100644 strophe.hh create mode 100644 tests/strophe.cc diff --git a/.envrc b/.envrc index bb5cd01..11db241 100644 --- a/.envrc +++ b/.envrc @@ -1,6 +1,6 @@ # -*- mode: sh; -*- -export CC=gcc CXX=g++ +export CC=gcc CXX="g++ -fdiagnostics-color=always" # Miscellaneous packages. ENVIRONMENTS=( diff --git a/Makefile b/Makefile index babea2b..0df80b6 100644 --- a/Makefile +++ b/Makefile @@ -28,57 +28,62 @@ LDFLAGS+=$(DBGLDFLAGS) \ -shared -gdwarf-4 \ $(DBGCFLAGS) LDLIBS=-lstrophe \ - -lpthread \ - $(shell xml2-config --libs) \ - $(shell pkg-config --libs librnp-0) \ - $(shell pkg-config --libs libsignal-protocol-c) \ - -lgcrypt \ - -llmdb + -lpthread \ + $(shell xml2-config --libs) \ + $(shell pkg-config --libs librnp-0) \ + $(shell pkg-config --libs libsignal-protocol-c) \ + -lgcrypt \ + -llmdb PREFIX ?= /usr/local LIBDIR ?= $(PREFIX)/lib HDRS=plugin.hh \ - plugin.h \ - account.h \ - buffer.h \ - channel.h \ - command.h \ - completion.h \ - config.h \ - connection.h \ - input.h \ - message.h \ - omemo.h \ - pgp.h \ - user.h \ - util.h \ - xmpp/stanza.h \ + plugin.h \ + strophe.hh \ + account.h \ + buffer.h \ + channel.h \ + command.h \ + completion.h \ + config.h \ + connection.h \ + input.h \ + message.h \ + omemo.h \ + pgp.h \ + user.h \ + util.h \ + xmpp/stanza.h \ SRCS=plugin.cpp \ - account.c \ - buffer.c \ - channel.c \ - command.c \ - completion.c \ - config.c \ - connection.c \ - input.c \ - message.c \ - omemo.c \ - pgp.c \ - user.c \ - util.c \ - xmpp/presence.c \ - xmpp/iq.c \ + strophe.cpp \ + account.c \ + buffer.c \ + channel.c \ + command.c \ + completion.c \ + config.c \ + connection.c \ + input.c \ + message.c \ + omemo.c \ + pgp.c \ + user.c \ + util.c \ + xmpp/presence.c \ + xmpp/iq.c \ DEPS=deps/diff/libdiff.a \ -TSTS=$(patsubst %.cpp,tests/%.cc,$(SRCS)) tests/main.cc +TSTS=$(patsubst %.cpp,tests/%.cc,$(filter %.cpp,$(SRCS))) tests/main.cc OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.c,xmpp/.%.o,$(SRCS)))) JOBS=$(patsubst tests/%.cc,tests/.%.o,$(TSTS)) -all: weechat-xmpp +all: + make depend + make weechat-xmpp && make test + weechat-xmpp: $(DEPS) xmpp.so xmpp.so: $(OBJS) $(DEPS) $(HDRS) @@ -120,7 +125,7 @@ debug: xmpp.so depend: .depend -.depend: $(SRCS) +.depend: $(SRCS) $(HDRS) $(TSTS) $(RM) ./.depend $(CXX) $(CPPFLAGS) -MM $^>>./.depend @@ -147,7 +152,7 @@ else chmod 755 ~/.weechat/plugins/xmpp.so endif -.PHONY: check +.PHONY: all weechat-xmpp test debug depend tidy clean distclean install check check: clang-check --analyze *.c *.cc *.cpp diff --git a/account.c b/account.c index d6a449e..2e6f413 100644 --- a/account.c +++ b/account.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "plugin.h" #include "config.h" diff --git a/buffer.c b/buffer.c index 3d5ed3e..a3447ef 100644 --- a/buffer.c +++ b/buffer.c @@ -4,7 +4,6 @@ #include #include -#include #include "plugin.h" #include "account.h" diff --git a/channel.c b/channel.c index 8577aae..04ccc7c 100644 --- a/channel.c +++ b/channel.c @@ -8,7 +8,6 @@ #include #include #include -#include #include "plugin.h" #include "omemo.h" @@ -901,16 +900,17 @@ struct t_channel_member *channel__add_member(struct t_account *account, user->profile.pgp_id ? user->profile.pgp_id : "", user->profile.pgp_id ? weechat_color("reset") : ""); else - weechat_printf_date_tags(channel->buffer, 0, "xmpp_presence,enter,log4", "%s%s (%s) %s%s%s%s %s%s%s%s%s%s%s%s%s", + weechat_printf_date_tags(channel->buffer, 0, "xmpp_presence,enter,log4", "%s%s (%s) %s%s%s%s%s %s%s%s%s%s%s%s%s%s", weechat_prefix("join"), - jid_resource ? user__as_prefix_raw(account, jid_bare) : "You", - jid_resource ? jid_resource : user__as_prefix_raw(account, jid_bare), + user__as_prefix_raw(account, jid_bare), + jid_resource, user->profile.status ? "is " : "", weechat_color("irc.color.message_join"), - user->profile.status ? user->profile.status : (user->profile.idle ? "idle" : "entered"), - weechat_color("reset"), - user->profile.idle ? "since " : "", + user->profile.status ? user->profile.status : "entered", + user->profile.idle ? " (idle since " : "", user->profile.idle ? user->profile.idle : "", + user->profile.idle ? ")" : "", + weechat_color("reset"), user->profile.status_text ? " [" : "", user->profile.status_text ? user->profile.status_text : "", user->profile.status_text ? "]" : "", diff --git a/command.c b/command.c index 57c7019..7bbbd98 100644 --- a/command.c +++ b/command.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "plugin.h" //#include "oauth.h" diff --git a/completion.c b/completion.c index 9fb976a..00e14e5 100644 --- a/completion.c +++ b/completion.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "plugin.h" #include "config.h" diff --git a/config.c b/config.c index fc89b78..b67c457 100644 --- a/config.c +++ b/config.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "plugin.h" #include "account.h" diff --git a/connection.c b/connection.c index c8dc2c0..69df89a 100644 --- a/connection.c +++ b/connection.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "plugin.h" #include "deps/diff/diff.h" @@ -147,7 +146,16 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void ? from_res : from); user->profile.status_text = status ? strdup(status) : NULL; user->profile.status = show ? strdup(show__text) : NULL; - user->profile.idle = idle ? strdup(idle__since) : NULL; + if (idle) + { + struct tm *since = {0}; + strptime(idle__since, "%FT%T", since); + char timestamp[256] = {0}; + strftime(timestamp, sizeof(timestamp), "%T", since); + user->profile.idle = strdup(idle__since); + } + else + user->profile.idle = NULL; user->is_away = show ? weechat_strcasecmp(show__text, "away") == 0 : 0; user->profile.role = role ? strdup(role) : NULL; user->profile.affiliation = affiliation && strcmp(affiliation, "none") != 0 @@ -176,7 +184,16 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void ? from_res : from); user->profile.status_text = status ? strdup(status) : NULL; user->profile.status = show ? strdup(show__text) : NULL; - user->profile.idle = idle ? strdup(idle__since) : NULL; + if (idle) + { + struct tm *since = {0}; + strptime(idle__since, "%FT%T", since); + char timestamp[256] = {0}; + strftime(timestamp, sizeof(timestamp), "%T", since); + user->profile.idle = strdup(idle__since); + } + else + user->profile.idle = NULL; user->is_away = show ? weechat_strcasecmp(show__text, "away") == 0 : 0; user->profile.role = role ? strdup(role) : NULL; user->profile.affiliation = affiliation && strcmp(affiliation, "none") != 0 diff --git a/input.c b/input.c index dc9fd6f..3f88f8b 100644 --- a/input.c +++ b/input.c @@ -4,7 +4,6 @@ #include #include -#include #include "plugin.h" #include "account.h" diff --git a/message.c b/message.c index 0314d44..9465b3b 100644 --- a/message.c +++ b/message.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "plugin.h" #include "account.h" diff --git a/omemo.c b/omemo.c index 811a508..144bf13 100644 --- a/omemo.c +++ b/omemo.c @@ -12,7 +12,6 @@ #include #include #include -#include struct t_omemo_db { MDB_env *env; diff --git a/pgp.c b/pgp.c index 427bf85..87f00e7 100644 --- a/pgp.c +++ b/pgp.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "plugin.h" #include "pgp.h" diff --git a/plugin.cpp b/plugin.cpp index e6d6d96..453b206 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -3,17 +3,13 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "plugin.hh" +#include "strophe.hh" #define WEECHAT_XMPP_PLUGIN_NAME "xmpp" #define WEECHAT_XMPP_PLUGIN_VERSION "0.2.0" namespace c { extern "C" { -#include -#include -#include -#include - #include "plugin.h" #include "config.h" #include "account.h" @@ -24,101 +20,91 @@ namespace c { #include "completion.h" struct t_weechat_plugin *weechat_xmpp_plugin() { - return weechat_plugin; + return (struct t_weechat_plugin*)weechat::globals::plugin; }; const char *weechat_xmpp_plugin_name() { - return weechat::plugin::instance.name().data(); + return WEECHAT_XMPP_PLUGIN_NAME; }; const char *weechat_xmpp_plugin_version() { - return weechat::plugin::instance.version().data(); + return WEECHAT_XMPP_PLUGIN_VERSION; }; } +} -#define TIMER_INTERVAL_SEC 0.01 - - struct t_hook *weechat_xmpp_process_timer = NULL; - - struct t_gui_bar_item *weechat_xmpp_typing_bar_item = NULL; +namespace weechat { + plugin::plugin() + : std::reference_wrapper( + // try not to think about it too hard + *(weechat_plugin*)nullptr) { + } - bool weechat_plugin_init() - { - if (!config__init()) + bool plugin::init(std::vector) { + if (!c::config__init()) + { + weechat::printf(nullptr, "%s: Error during config init", + globals::plugin->name); return false; + } - config__read(); + c::config__read(); - connection__init(); + c::connection__init(); - command__init(); + c::command__init(); - completion__init(); + c::completion__init(); - weechat_xmpp_process_timer = weechat_hook_timer(TIMER_INTERVAL_SEC * 1000, 0, 0, - &account__timer_cb, - NULL, NULL); + globals::process_timer = + weechat::hook_timer(plugin::timer_interval_sec * 1000, 0, 0, + &c::account__timer_cb, nullptr, nullptr); - if (!weechat_bar_search("typing")) + if (!weechat::bar_search("typing")) { - weechat_bar_new("typing", "off", "400", "window", "${typing}", - "bottom", "horizontal", "vertical", - "1", "1", "default", "default", "default", "default", - "off", "xmpp_typing"); + weechat::bar_new("typing", "off", "400", "window", "${typing}", + "bottom", "horizontal", "vertical", + "1", "1", "default", "default", "default", "default", + "off", "xmpp_typing"); } - weechat_xmpp_typing_bar_item = weechat_bar_item_new("xmpp_typing", - &buffer__typing_bar_cb, - NULL, NULL); + globals::typing_bar_item = + weechat::bar_item_new("xmpp_typing", + (char* (*)(const void*, void*, + t_gui_bar_item*, t_gui_window*, + t_gui_buffer*, t_hashtable*))(&c::buffer__typing_bar_cb), + nullptr, nullptr); - weechat_hook_signal("input_text_changed", &input__text_changed_cb, NULL, NULL); + weechat::hook_signal("input_text_changed", &c::input__text_changed_cb, nullptr, nullptr); return true; } - void weechat_plugin_end() - { - if (weechat_xmpp_typing_bar_item) - weechat_bar_item_remove(weechat_xmpp_typing_bar_item); - - if (weechat_xmpp_process_timer) - weechat_unhook(weechat_xmpp_process_timer); + bool plugin::end() { + if (globals::typing_bar_item) + weechat::bar_item_remove(globals::typing_bar_item); - config__write(); + if (globals::process_timer) + weechat::unhook(globals::process_timer); - account__disconnect_all(); + c::config__write(); - account__free_all(); + c::account__disconnect_all(); - xmpp_shutdown(); - } -} + c::account__free_all(); -namespace weechat { - plugin::plugin() { - } + xmpp::shutdown(); - plugin::plugin(plugin_ptr ptr) - : plugin_ptr(std::move(ptr)) { - this->m_name = WEECHAT_XMPP_PLUGIN_NAME; - this->m_version = WEECHAT_XMPP_PLUGIN_VERSION; + return true; } - plugin::plugin(struct t_weechat_plugin *ptr) - : plugin(std::move(weechat::plugin_ptr( - ptr, [this] (struct t_weechat_plugin *) { } - ))) { + std::string_view plugin::name() const { + return plugin_get_name(*this); } - bool plugin::init(std::vector) { - weechat_printf(nullptr, "%s: It works!", this->name().data()); - return c::weechat_plugin_init(); - } + struct t_weechat_plugin* globals::plugin = nullptr; - bool plugin::end() { - c::weechat_plugin_end(); - return true; - } + hook* globals::process_timer = nullptr; - plugin plugin::instance; + gui_bar_item* globals::typing_bar_item = nullptr; } extern "C" { @@ -129,15 +115,15 @@ extern "C" { WEECHAT_PLUGIN_LICENSE("MPL2"); WEECHAT_PLUGIN_PRIORITY(5500); - int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) + weechat::rc weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) { - weechat::plugin::instance = std::move(weechat::plugin(plugin)); + weechat::globals::plugin = (weechat::weechat_plugin*)plugin; std::vector args(argv, argv+argc); - return weechat::plugin::instance.init(args) ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; + return weechat::plugin::init(args) ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; } - int weechat_plugin_end(struct t_weechat_plugin *) + weechat::rc weechat_plugin_end(struct t_weechat_plugin *) { - return weechat::plugin::instance.end() ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; + return weechat::plugin::end() ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; } } diff --git a/plugin.h b/plugin.h index ac2e6ca..4c6f6d8 100644 --- a/plugin.h +++ b/plugin.h @@ -6,6 +6,7 @@ #define _WEECHAT_XMPP_PLUGIN_H_ #ifndef __cplusplus +#include #define weechat_plugin weechat_xmpp_plugin() #define WEECHAT_XMPP_PLUGIN_NAME weechat_xmpp_plugin_name() #define WEECHAT_XMPP_PLUGIN_VERSION weechat_xmpp_plugin_version() diff --git a/plugin.hh b/plugin.hh index 5f86adb..a05309c 100644 --- a/plugin.hh +++ b/plugin.hh @@ -6,39 +6,1566 @@ #include #include +#include #include #include -#include - -#define weechat_plugin ::weechat::plugin::instance.get() +#include namespace weechat { extern "C" { - //__attribute__((visibility("default"))) - int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]); - int weechat_plugin_end(struct t_weechat_plugin *plugin); +#include + + typedef int rc; + typedef struct t_weechat_plugin weechat_plugin; + typedef struct t_config_option config_option; + typedef struct t_config_section config_section; + typedef struct t_config_file config_file; + typedef struct t_gui_window gui_window; + typedef struct t_gui_buffer gui_buffer; + typedef struct t_gui_bar gui_bar; + typedef struct t_gui_bar_item gui_bar_item; + typedef struct t_gui_bar_window gui_bar_window; + typedef struct t_gui_completion gui_completion; + typedef struct t_gui_nick gui_nick; + typedef struct t_gui_nick_group gui_nick_group; + typedef struct t_infolist infolist; + typedef struct t_infolist_item infolist_item; + typedef struct t_upgrade_file upgrade_file; + typedef struct t_weelist weelist; + typedef struct t_weelist_item weelist_item; + typedef struct t_arraylist arraylist; + typedef struct t_hashtable hashtable; + typedef struct t_hdata hdata; + typedef struct t_hook hook; + } + + namespace globals { + extern weechat_plugin* plugin; + extern hook* process_timer; + extern gui_bar_item* typing_bar_item; } - - typedef std::unique_ptr< - struct t_weechat_plugin, - std::function> plugin_ptr; - class plugin : public plugin_ptr { - public: - plugin(); - plugin(plugin_ptr ptr); - plugin(struct t_weechat_plugin *ptr); + class plugin : public std::reference_wrapper { + public: + plugin(); - inline std::string const& name() const { return this->m_name; } - inline std::string const& version() const { return this->m_version; } + std::string_view name() const; - bool init(std::vector args); - bool end(); + inline operator weechat_plugin* () const { return &this->get(); } - static plugin instance; + static bool init(std::vector args); + static bool end(); - private: - std::string m_name; - std::string m_version; + static constexpr const double timer_interval_sec = 0.01; }; + + inline std::string_view plugin_get_name(weechat_plugin *plugin) { + return globals::plugin->plugin_get_name(globals::plugin); + } + + inline void charset_set(weechat_plugin *plugin, const char *charset) { + return globals::plugin->charset_set(globals::plugin, charset); + } + inline char *iconv_to_internal(const char *charset, const char *string) { + return globals::plugin->iconv_to_internal(charset, string); + } + inline char *iconv_from_internal(const char *charset, const char *string) { + return globals::plugin->iconv_from_internal(charset, string); + } + inline const char *gettext(const char *string) { + return globals::plugin->gettext(string); + } + inline const char *ngettext(const char *single, const char *plural, int count) { + return globals::plugin->ngettext(single, plural, count); + } + inline char *strndup(const char *string, int length) { + return globals::plugin->strndup(string, length); + } + inline void string_tolower(char *string) { + return globals::plugin->string_tolower(string); + } + inline void string_toupper(char *string) { + return globals::plugin->string_toupper(string); + } + inline int strcasecmp(const char *string1, const char *string2) { + return globals::plugin->strcasecmp(string1, string2); + } + inline int strcasecmp_range(const char *string1, const char *string2, + int range) { + return globals::plugin->strcasecmp_range(string1, string2, range); + } + inline int strncasecmp(const char *string1, const char *string2, int max) { + return globals::plugin->strncasecmp(string1, string2, max); + } + inline int strncasecmp_range(const char *string1, const char *string2, + int max, int range) { + return globals::plugin->strncasecmp_range(string1, string2, max, range); + } + inline int strcmp_ignore_chars(const char *string1, const char *string2, + const char *chars_ignored, int case_sensitive) { + return globals::plugin->strcmp_ignore_chars(string1, string2, chars_ignored, case_sensitive); + } + inline const char *strcasestr(const char *string, const char *search) { + return globals::plugin->strcasestr(string, search); + } + inline int strlen_screen(const char *string) { + return globals::plugin->strlen_screen(string); + } + inline int string_match(const char *string, const char *mask, + int case_sensitive) { + return globals::plugin->string_match(string, mask, case_sensitive); + } + inline int string_match_list(const char *string, const char **masks, + int case_sensitive) { + return globals::plugin->string_match_list(string, masks, case_sensitive); + } + inline char *string_replace(const char *string, const char *search, + const char *replace) { + return globals::plugin->string_replace(string, search, replace); + } + inline char *string_expand_home(const char *path) { + return globals::plugin->string_expand_home(path); + } + inline char *string_eval_path_home(const char *path, + struct t_hashtable *pointers, + struct t_hashtable *extra_vars, + struct t_hashtable *options) { + return globals::plugin->string_eval_path_home(path, pointers, extra_vars, options); + } + inline char *string_remove_quotes(const char *string, const char *quotes) { + return globals::plugin->string_remove_quotes(string, quotes); + } + inline char *string_strip(const char *string, int left, int right, + const char *chars) { + return globals::plugin->string_strip(string, left, right, chars); + } + inline char *string_convert_escaped_chars(const char *string) { + return globals::plugin->string_convert_escaped_chars(string); + } + inline char *string_mask_to_regex(const char *mask) { + return globals::plugin->string_mask_to_regex(mask); + } + inline const char *string_regex_flags(const char *regex, int default_flags, + int *flags) { + return globals::plugin->string_regex_flags(regex, default_flags, flags); + } + inline int string_regcomp(void *preg, const char *regex, int default_flags) { + return globals::plugin->string_regcomp(preg, regex, default_flags); + } + inline int string_has_highlight(const char *string, + const char *highlight_words) { + return globals::plugin->string_has_highlight(string, highlight_words); + } + inline int string_has_highlight_regex(const char *string, const char *regex) { + return globals::plugin->string_has_highlight_regex(string, regex); + } + inline char *string_replace_regex(const char *string, void *regex, + const char *replace, + const char reference_char, + char *(*callback)(void *data, + const char *text), + void *callback_data) { + return globals::plugin->string_replace_regex(string, regex, replace, reference_char, callback, callback_data); + } + inline char **string_split(const char *string, const char *separators, + const char *strip_items, int flags, + int num_items_max, int *num_items) { + return globals::plugin->string_split(string, separators, strip_items, flags, num_items_max, num_items); + } + inline char **string_split_shell(const char *string, int *num_items) { + return globals::plugin->string_split_shell(string, num_items); + } + inline void string_free_split(char **split_string) { + return globals::plugin->string_free_split(split_string); + } + inline char *string_build_with_split_string(const char **split_string, + const char *separator) { + return globals::plugin->string_build_with_split_string(split_string, separator); + } + inline char **string_split_command(const char *command, char separator) { + return globals::plugin->string_split_command(command, separator); + } + inline void string_free_split_command(char **split_command) { + return globals::plugin->string_free_split_command(split_command); + } + inline char *string_format_size(unsigned long long size) { + return globals::plugin->string_format_size(size); + } + inline int string_color_code_size(const char *string) { + return globals::plugin->string_color_code_size(string); + } + inline char *string_remove_color(const char *string, const char *replacement) { + return globals::plugin->string_remove_color(string, replacement); + } + inline int string_base_encode(int base, const char *from, int length, + char *to) { + return globals::plugin->string_base_encode(base, from, length, to); + } + inline int string_base_decode(int base, const char *from, char *to) { + return globals::plugin->string_base_decode(base, from, to); + } + inline char *string_hex_dump(const char *data, int data_size, + int bytes_per_line, const char *prefix, + const char *suffix) { + return globals::plugin->string_hex_dump(data, data_size, bytes_per_line, prefix, suffix); + } + inline int string_is_command_char(const char *string) { + return globals::plugin->string_is_command_char(string); + } + inline const char *string_input_for_buffer(const char *string) { + return globals::plugin->string_input_for_buffer(string); + } + inline char *string_eval_expression(const char *expr, + struct t_hashtable *pointers, + struct t_hashtable *extra_vars, + struct t_hashtable *options) { + return globals::plugin->string_eval_expression(expr, pointers, extra_vars, options); + } + inline char **string_dyn_alloc(int size_alloc) { + return globals::plugin->string_dyn_alloc(size_alloc); + } + inline int string_dyn_copy(char **string, const char *new_string) { + return globals::plugin->string_dyn_copy(string, new_string); + } + inline int string_dyn_concat(char **string, const char *add, int bytes) { + return globals::plugin->string_dyn_concat(string, add, bytes); + } + inline char *string_dyn_free(char **string, int free_string) { + return globals::plugin->string_dyn_free(string, free_string); + } + + inline int utf8_has_8bits(const char *string) { + return globals::plugin->utf8_has_8bits(string); + } + inline int utf8_is_valid(const char *string, int length, char **error) { + return globals::plugin->utf8_is_valid(string, length, error); + } + inline void utf8_normalize(char *string, char replacement) { + return globals::plugin->utf8_normalize(string, replacement); + } + inline const char *utf8_prev_char(const char *string_start, + const char *string) { + return globals::plugin->utf8_prev_char(string_start, string); + } + inline const char *utf8_next_char(const char *string) { + return globals::plugin->utf8_next_char(string); + } + inline int utf8_char_int(const char *string) { + return globals::plugin->utf8_char_int(string); + } + inline int utf8_char_size(const char *string) { + return globals::plugin->utf8_char_size(string); + } + inline int utf8_strlen(const char *string) { + return globals::plugin->utf8_strlen(string); + } + inline int utf8_strnlen(const char *string, int bytes) { + return globals::plugin->utf8_strnlen(string, bytes); + } + inline int utf8_strlen_screen(const char *string) { + return globals::plugin->utf8_strlen_screen(string); + } + inline int utf8_charcmp(const char *string1, const char *string2) { + return globals::plugin->utf8_charcmp(string1, string2); + } + inline int utf8_charcasecmp(const char *string1, const char *string2) { + return globals::plugin->utf8_charcasecmp(string1, string2); + } + inline int utf8_char_size_screen(const char *string) { + return globals::plugin->utf8_char_size_screen(string); + } + inline const char *utf8_add_offset(const char *string, int offset) { + return globals::plugin->utf8_add_offset(string, offset); + } + inline int utf8_real_pos(const char *string, int pos) { + return globals::plugin->utf8_real_pos(string, pos); + } + inline int utf8_pos(const char *string, int real_pos) { + return globals::plugin->utf8_pos(string, real_pos); + } + inline char *utf8_strndup(const char *string, int length) { + return globals::plugin->utf8_strndup(string, length); + } + + inline int crypto_hash(const void *data, int data_size, + const char *hash_algo, void *hash, int *hash_size) { + return globals::plugin->crypto_hash(data, data_size, hash_algo, hash, hash_size); + } + inline int crypto_hash_pbkdf2(const void *data, int data_size, + const char *hash_algo, + const void *salt, int salt_size, + int iterations, + void *hash, int *hash_size) { + return globals::plugin->crypto_hash_pbkdf2(data, data_size, hash_algo, salt, salt_size, iterations, hash, hash_size); + } + inline int crypto_hmac(const void *key, int key_size, + const void *message, int message_size, + const char *hash_algo, void *hash, int *hash_size) { + return globals::plugin->crypto_hmac(key, key_size, message, message_size, hash_algo, hash, hash_size); + } + + inline int mkdir_home(const char *directory, int mode) { + return globals::plugin->mkdir_home(directory, mode); + } + inline int mkdir(const char *directory, int mode) { + return globals::plugin->mkdir(directory, mode); + } + inline int mkdir_parents(const char *directory, int mode) { + return globals::plugin->mkdir_parents(directory, mode); + } + inline void exec_on_files(const char *directory, int recurse_subdirs, + int hidden_files, + void (*callback)(void *data, const char *filename), + void *callback_data) { + return globals::plugin->exec_on_files(directory, recurse_subdirs, hidden_files, callback, callback_data); + } + inline char *file_get_content(const char *filename) { + return globals::plugin->file_get_content(filename); + } + + inline int util_timeval_cmp(struct timeval *tv1, struct timeval *tv2) { + return globals::plugin->util_timeval_cmp(tv1, tv2); + } + long long (*util_timeval_diff) (struct timeval *tv1, struct timeval *tv2); + inline void util_timeval_add(struct timeval *tv, long long interval) { + return globals::plugin->util_timeval_add(tv, interval); + } + inline const char *util_get_time_string(const time_t *date) { + return globals::plugin->util_get_time_string(date); + } + inline int util_version_number(const char *version) { + return globals::plugin->util_version_number(version); + } + + inline struct t_weelist *list_new() { + return globals::plugin->list_new(); + } + inline struct t_weelist_item *list_add(struct t_weelist *weelist, + const char *data, + const char *where, + void *user_data) { + return globals::plugin->list_add(weelist, data, where, user_data); + } + inline struct t_weelist_item *list_search(struct t_weelist *weelist, + const char *data) { + return globals::plugin->list_search(weelist, data); + } + inline int list_search_pos(struct t_weelist *weelist, + const char *data) { + return globals::plugin->list_search_pos(weelist, data); + } + inline struct t_weelist_item *list_casesearch(struct t_weelist *weelist, + const char *data) { + return globals::plugin->list_casesearch(weelist, data); + } + inline int list_casesearch_pos(struct t_weelist *weelist, + const char *data) { + return globals::plugin->list_casesearch_pos(weelist, data); + } + inline struct t_weelist_item *list_get(struct t_weelist *weelist, + int position) { + return globals::plugin->list_get(weelist, position); + } + inline void list_set(struct t_weelist_item *item, const char *value) { + return globals::plugin->list_set(item, value); + } + inline struct t_weelist_item *list_next(struct t_weelist_item *item) { + return globals::plugin->list_next(item); + } + inline struct t_weelist_item *list_prev(struct t_weelist_item *item) { + return globals::plugin->list_prev(item); + } + inline const char *list_string(struct t_weelist_item *item) { + return globals::plugin->list_string(item); + } + template + inline T *list_user_data(struct t_weelist_item *item) { + return static_cast( + globals::plugin->list_user_data(item)); + } + inline int list_size(struct t_weelist *weelist) { + return globals::plugin->list_size(weelist); + } + inline void list_remove(struct t_weelist *weelist, + struct t_weelist_item *item) { + return globals::plugin->list_remove(weelist, item); + } + inline void list_remove_all(struct t_weelist *weelist) { + return globals::plugin->list_remove_all(weelist); + } + inline void list_free(struct t_weelist *weelist) { + return globals::plugin->list_free(weelist); + } + + inline struct t_arraylist *arraylist_new(int initial_size, + int sorted, + int allow_duplicates, + int (*callback_cmp)(void *data, + struct t_arraylist *arraylist, + void *pointer1, + void *pointer2), + void *callback_cmp_data, + void (*callback_free)(void *data, + struct t_arraylist *arraylist, + void *pointer), + void *callback_free_data) { + return globals::plugin->arraylist_new(initial_size, sorted, allow_duplicates, callback_cmp, callback_cmp_data, callback_free, callback_free_data); + } + inline int arraylist_size(struct t_arraylist *arraylist) { + return globals::plugin->arraylist_size(arraylist); + } + template + inline T *arraylist_get(struct t_arraylist *arraylist, int index) { + return static_cast( + globals::plugin->arraylist_get(arraylist, index)); + } + template + inline T *arraylist_search(struct t_arraylist *arraylist, void *pointer, + int *index, int *index_insert) { + return static_cast( + globals::plugin->arraylist_search(arraylist, pointer, index, index_insert)); + } + inline int arraylist_insert(struct t_arraylist *arraylist, int index, + void *pointer) { + return globals::plugin->arraylist_insert(arraylist, index, pointer); + } + inline int arraylist_add(struct t_arraylist *arraylist, void *pointer) { + return globals::plugin->arraylist_add(arraylist, pointer); + } + inline int arraylist_remove(struct t_arraylist *arraylist, int index) { + return globals::plugin->arraylist_remove(arraylist, index); + } + inline int arraylist_clear(struct t_arraylist *arraylist) { + return globals::plugin->arraylist_clear(arraylist); + } + inline void arraylist_free(struct t_arraylist *arraylist) { + return globals::plugin->arraylist_free(arraylist); + } + + inline struct t_hashtable *hashtable_new(int size, + const char *type_keys, + const char *type_values, + unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable, + const void *key), + int (*callback_keycmp)(struct t_hashtable *hashtable, + const void *key1, + const void *key2)) { + return globals::plugin->hashtable_new(size, type_keys, type_values, callback_hash_key, callback_keycmp); + } + inline struct t_hashtable_item *hashtable_set_with_size(struct t_hashtable *hashtable, + const void *key, + int key_size, + const void *value, + int value_size) { + return globals::plugin->hashtable_set_with_size(hashtable, key, key_size, value, value_size); + } + inline struct t_hashtable_item *hashtable_set(struct t_hashtable *hashtable, + const void *key, + const void *value) { + return globals::plugin->hashtable_set(hashtable, key, value); + } + template + inline T *hashtable_get(struct t_hashtable *hashtable, const void *key) { + return static_cast( + globals::plugin->hashtable_get(hashtable, key)); + } + inline int hashtable_has_key(struct t_hashtable *hashtable, const void *key) { + return globals::plugin->hashtable_has_key(hashtable, key); + } + inline void hashtable_map(struct t_hashtable *hashtable, + void (*callback_map) (void *data, + struct t_hashtable *hashtable, + const void *key, + const void *value), + void *callback_map_data) { + return globals::plugin->hashtable_map(hashtable, callback_map, callback_map_data); + } + inline void hashtable_map_string(struct t_hashtable *hashtable, + void (*callback_map) (void *data, + struct t_hashtable *hashtable, + const char *key, + const char *value), + void *callback_map_data) { + return globals::plugin->hashtable_map_string(hashtable, callback_map, callback_map_data); + } + inline struct t_hashtable *hashtable_dup(struct t_hashtable *hashtable) { + return globals::plugin->hashtable_dup(hashtable); + } + inline int hashtable_get_integer(struct t_hashtable *hashtable, + const char *property) { + return globals::plugin->hashtable_get_integer(hashtable, property); + } + inline const char *hashtable_get_string(struct t_hashtable *hashtable, + const char *property) { + return globals::plugin->hashtable_get_string(hashtable, property); + } + inline void hashtable_set_pointer(struct t_hashtable *hashtable, + const char *property, + void *pointer) { + return globals::plugin->hashtable_set_pointer(hashtable, property, pointer); + } + inline int hashtable_add_to_infolist(struct t_hashtable *hashtable, + struct t_infolist_item *infolist_item, + const char *prefix) { + return globals::plugin->hashtable_add_to_infolist(hashtable, infolist_item, prefix); + } + inline int hashtable_add_from_infolist(struct t_hashtable *hashtable, + struct t_infolist *infolist, + const char *prefix) { + return globals::plugin->hashtable_add_from_infolist(hashtable, infolist, prefix); + } + inline void hashtable_remove(struct t_hashtable *hashtable, const void *key) { + return globals::plugin->hashtable_remove(hashtable, key); + } + inline void hashtable_remove_all(struct t_hashtable *hashtable) { + return globals::plugin->hashtable_remove_all(hashtable); + } + inline void hashtable_free(struct t_hashtable *hashtable) { + return globals::plugin->hashtable_free(hashtable); + } + + inline struct t_config_file *config_new(weechat_plugin *plugin, + const char *name, + int (*callback_reload)(const void *pointer, + void *data, + struct t_config_file *config_file), + const void *callback_reload_pointer, + void *callback_reload_data) { + return globals::plugin->config_new(globals::plugin, name, callback_reload, callback_reload_pointer, callback_reload_data); + } + inline struct t_config_section *config_new_section(struct t_config_file *config_file, + const char *name, + int user_can_add_options, + int user_can_delete_options, + int (*callback_read)(const void *pointer, + void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const void *callback_read_pointer, + void *callback_read_data, + int (*callback_write)(const void *pointer, + void *data, + struct t_config_file *config_file, + const char *section_name), + const void *callback_write_pointer, + void *callback_write_data, + int (*callback_write_default)(const void *pointer, + void *data, + struct t_config_file *config_file, + const char *section_name), + const void *callback_write_default_pointer, + void *callback_write_default_data, + int (*callback_create_option)(const void *pointer, + void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const void *callback_create_option_pointer, + void *callback_create_option_data, + int (*callback_delete_option)(const void *pointer, + void *data, + struct t_config_file *config_file, + struct t_config_section *section, + struct t_config_option *option), + const void *callback_delete_option_pointer, + void *callback_delete_option_data) { + return globals::plugin->config_new_section(config_file, name, user_can_add_options, user_can_delete_options, callback_read, callback_read_pointer, callback_read_data, callback_write, callback_write_pointer, callback_write_data, callback_write_default, callback_write_default_pointer, callback_write_default_data, callback_create_option, callback_create_option_pointer, callback_create_option_data, callback_delete_option, callback_delete_option_pointer, callback_delete_option_data); + } + inline struct t_config_section *config_search_section(struct t_config_file *config_file, + const char *section_name) { + return globals::plugin->config_search_section(config_file, section_name); + } + inline struct t_config_option *config_new_option(struct t_config_file *config_file, + struct t_config_section *section, + const char *name, + const char *type, + const char *description, + const char *string_values, + int min, + int max, + const char *default_value, + const char *value, + int null_value_allowed, + int (*callback_check_value)(const void *pointer, + void *data, + struct t_config_option *option, + const char *value), + const void *callback_check_value_pointer, + void *callback_check_value_data, + void (*callback_change)(const void *pointer, + void *data, + struct t_config_option *option), + const void *callback_change_pointer, + void *callback_change_data, + void (*callback_delete)(const void *pointer, + void *data, + struct t_config_option *option), + const void *callback_delete_pointer, + void *callback_delete_data) { + return globals::plugin->config_new_option(config_file, section, name, type, description, string_values, min, max, default_value, value, null_value_allowed, callback_check_value, callback_check_value_pointer, callback_check_value_data, callback_change, callback_change_pointer, callback_change_data, callback_delete, callback_delete_pointer, callback_delete_data); + } + inline struct t_config_option *config_search_option(struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name) { + return globals::plugin->config_search_option(config_file, section, option_name); + } + inline void config_search_section_option(struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + struct t_config_section **section_found, + struct t_config_option **option_found) { + return globals::plugin->config_search_section_option(config_file, section, option_name, section_found, option_found); + } + inline void config_search_with_string(const char *option_name, + struct t_config_file **config_file, + struct t_config_section **section, + struct t_config_option **option, + char **pos_option_name) { + return globals::plugin->config_search_with_string(option_name, config_file, section, option, pos_option_name); + } + inline int config_string_to_boolean(const char *text) { + return globals::plugin->config_string_to_boolean(text); + } + inline int config_option_reset(struct t_config_option *option, + int run_callback) { + return globals::plugin->config_option_reset(option, run_callback); + } + inline int config_option_set(struct t_config_option *option, + const char *value, int run_callback) { + return globals::plugin->config_option_set(option, value, run_callback); + } + inline int config_option_set_null(struct t_config_option *option, + int run_callback) { + return globals::plugin->config_option_set_null(option, run_callback); + } + inline int config_option_unset(struct t_config_option *option) { + return globals::plugin->config_option_unset(option); + } + inline void config_option_rename(struct t_config_option *option, + const char *new_name) { + return globals::plugin->config_option_rename(option, new_name); + } + inline const char *config_option_get_string(struct t_config_option *option, + const char *property) { + return globals::plugin->config_option_get_string(option, property); + } + template + inline T *config_option_get_pointer(struct t_config_option *option, + const char *property) { + return static_cast( + globals::plugin->config_option_get_pointer(option, property)); + } + inline int config_option_is_null(struct t_config_option *option) { + return globals::plugin->config_option_is_null(option); + } + inline int config_option_default_is_null(struct t_config_option *option) { + return globals::plugin->config_option_default_is_null(option); + } + inline int config_boolean(struct t_config_option *option) { + return globals::plugin->config_boolean(option); + } + inline int config_boolean_default(struct t_config_option *option) { + return globals::plugin->config_boolean_default(option); + } + inline int config_integer(struct t_config_option *option) { + return globals::plugin->config_integer(option); + } + inline int config_integer_default(struct t_config_option *option) { + return globals::plugin->config_integer_default(option); + } + inline const char *config_string(struct t_config_option *option) { + return globals::plugin->config_string(option); + } + inline const char *config_string_default(struct t_config_option *option) { + return globals::plugin->config_string_default(option); + } + inline const char *config_color(struct t_config_option *option) { + return globals::plugin->config_color(option); + } + inline const char *config_color_default(struct t_config_option *option) { + return globals::plugin->config_color_default(option); + } + inline int config_write_option(struct t_config_file *config_file, + struct t_config_option *option) { + return globals::plugin->config_write_option(config_file, option); + } + template + inline int config_write_line(struct t_config_file *config_file, + const char *option_name, + const char *value, Args... args) { + return globals::plugin->config_write_line(config_file, option_name, value, args...); + } + inline int config_write(struct t_config_file *config_file) { + return globals::plugin->config_write(config_file); + } + inline int config_read(struct t_config_file *config_file) { + return globals::plugin->config_read(config_file); + } + inline int config_reload(struct t_config_file *config_file) { + return globals::plugin->config_reload(config_file); + } + inline void config_option_free(struct t_config_option *option) { + return globals::plugin->config_option_free(option); + } + inline void config_section_free_options(struct t_config_section *section) { + return globals::plugin->config_section_free_options(section); + } + inline void config_section_free(struct t_config_section *section) { + return globals::plugin->config_section_free(section); + } + inline void config_free(struct t_config_file *config_file) { + return globals::plugin->config_free(config_file); + } + inline struct t_config_option *config_get(const char *option_name) { + return globals::plugin->config_get(option_name); + } + inline const char *config_get_plugin(weechat_plugin *plugin, + const char *option_name) { + return globals::plugin->config_get_plugin(globals::plugin, option_name); + } + inline int config_is_set_plugin(weechat_plugin *plugin, + const char *option_name) { + return globals::plugin->config_is_set_plugin(globals::plugin, option_name); + } + inline int config_set_plugin(weechat_plugin *plugin, + const char *option_name, const char *value) { + return globals::plugin->config_set_plugin(globals::plugin, option_name, value); + } + inline void config_set_desc_plugin(weechat_plugin *plugin, + const char *option_name, + const char *description) { + return globals::plugin->config_set_desc_plugin(globals::plugin, option_name, description); + } + inline int config_unset_plugin(weechat_plugin *plugin, + const char *option_name) { + return globals::plugin->config_unset_plugin(globals::plugin, option_name); + } + + inline int key_bind(const char *context, struct t_hashtable *keys) { + return globals::plugin->key_bind(context, keys); + } + inline int key_unbind(const char *context, const char *key) { + return globals::plugin->key_unbind(context, key); + } + + inline const char *prefix(const char *prefix) { + return globals::plugin->prefix(prefix); + } + inline const char *color(const char *color_name) { + return globals::plugin->color(color_name); + } + template + inline void printf(struct t_gui_buffer *buffer, const char *message, Args... args) { + return globals::plugin->printf_date_tags( + buffer, 0, NULL, message, args...); + } + template + inline void printf_date_tags(struct t_gui_buffer *buffer, time_t date, + const char *tags, const char *message, Args... args) { + return globals::plugin->printf_date_tags(buffer, date, tags, message, args...); + } + template + inline void printf_y(struct t_gui_buffer *buffer, int y, + const char *message, Args... args) { + return globals::plugin->printf_y(buffer, y, message, args...); + } + template + inline void log_printf(const char *message, Args... args) { + return globals::plugin->log_printf(message, args...); + } + + inline struct t_hook *hook_command(weechat_plugin *plugin, + const char *command, + const char *description, + const char *args, + const char *args_description, + const char *completion, + int (*callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + int argc, char **argv, + char **argv_eol), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_command(globals::plugin, command, description, args, args_description, completion, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_command_run(weechat_plugin *plugin, + const char *command, + int (*callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *command), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_command_run(globals::plugin, command, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_timer(weechat_plugin *plugin, + long interval, + int align_second, + int max_calls, + int (*callback)(const void *pointer, + void *data, + int remaining_calls), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_timer(globals::plugin, interval, align_second, max_calls, callback, callback_pointer, callback_data); + } + inline hook* hook_timer(long interval, + int align_second, + int max_calls, + int (*callback)(const void *pointer, + void *data, + int remaining_calls), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_timer(globals::plugin, + interval, align_second, max_calls, + callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_fd(weechat_plugin *plugin, + int fd, + int flag_read, + int flag_write, + int flag_exception, + int (*callback)(const void *pointer, + void *data, + int fd), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_fd(globals::plugin, fd, flag_read, flag_write, flag_exception, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_process(weechat_plugin *plugin, + const char *command, + int timeout, + int (*callback)(const void *pointer, + void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_process(globals::plugin, command, timeout, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_process_hashtable(weechat_plugin *plugin, + const char *command, + struct t_hashtable *options, + int timeout, + int (*callback)(const void *pointer, + void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_process_hashtable(globals::plugin, command, options, timeout, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_connect(weechat_plugin *plugin, + const char *proxy, + const char *address, + int port, + int ipv6, + int retry, + void *gnutls_sess, void *gnutls_cb, + int gnutls_dhkey_size, + const char *gnutls_priorities, + const char *local_hostname, + int (*callback)(const void *pointer, + void *data, + int status, + int gnutls_rc, + int sock, + const char *error, + const char *ip_address), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_connect(globals::plugin, proxy, address, port, ipv6, retry, gnutls_sess, gnutls_cb, gnutls_dhkey_size, gnutls_priorities, local_hostname, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_line(weechat_plugin *plugin, + const char *buffer_type, + const char *buffer_name, + const char *tags, + struct t_hashtable *(*callback)(const void *pointer, + void *data, + struct t_hashtable *line), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_line(globals::plugin, buffer_type, buffer_name, tags, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_print(weechat_plugin *plugin, + struct t_gui_buffer *buffer, + const char *tags, + const char *message, + int strip_colors, + int (*callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + time_t date, + int tags_count, + const char **tags, + int displayed, + int highlight, + const char *prefix, + const char *message), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_print(globals::plugin, buffer, tags, message, strip_colors, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_signal(const char *signal, + int (*callback)(const void *pointer, + void *data, + const char *signal, + const char *type_data, + void *signal_data), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_signal(globals::plugin, signal, callback, callback_pointer, callback_data); + } + inline int hook_signal_send(const char *signal, const char *type_data, + void *signal_data) { + return globals::plugin->hook_signal_send(signal, type_data, signal_data); + } + inline struct t_hook *hook_hsignal(weechat_plugin *plugin, + const char *signal, + int (*callback)(const void *pointer, + void *data, + const char *signal, + struct t_hashtable *hashtable), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_hsignal(globals::plugin, signal, callback, callback_pointer, callback_data); + } + inline int hook_hsignal_send(const char *signal, + struct t_hashtable *hashtable) { + return globals::plugin->hook_hsignal_send(signal, hashtable); + } + inline struct t_hook *hook_config(weechat_plugin *plugin, + const char *option, + int (*callback)(const void *pointer, + void *data, + const char *option, + const char *value), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_config(globals::plugin, option, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_completion(weechat_plugin *plugin, + const char *completion_item, + const char *description, + int (*callback)(const void *pointer, + void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_completion(globals::plugin, completion_item, description, callback, callback_pointer, callback_data); + } + inline const char *hook_completion_get_string(struct t_gui_completion *completion, + const char *property) { + return globals::plugin->hook_completion_get_string(completion, property); + } + inline void hook_completion_list_add(struct t_gui_completion *completion, + const char *word, + int nick_completion, + const char *where) { + return globals::plugin->hook_completion_list_add(completion, word, nick_completion, where); + } + inline struct t_hook *hook_modifier(weechat_plugin *plugin, + const char *modifier, + char *(*callback)(const void *pointer, + void *data, + const char *modifier, + const char *modifier_data, + const char *string), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_modifier(globals::plugin, modifier, callback, callback_pointer, callback_data); + } + inline char *hook_modifier_exec(weechat_plugin *plugin, + const char *modifier, + const char *modifier_data, + const char *string) { + return globals::plugin->hook_modifier_exec(globals::plugin, modifier, modifier_data, string); + } + inline struct t_hook *hook_info(weechat_plugin *plugin, + const char *info_name, + const char *description, + const char *args_description, + char *(*callback)(const void *pointer, + void *data, + const char *info_name, + const char *arguments), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_info(globals::plugin, info_name, description, args_description, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_info_hashtable(weechat_plugin *plugin, + const char *info_name, + const char *description, + const char *args_description, + const char *output_description, + struct t_hashtable *(*callback)(const void *pointer, + void *data, + const char *info_name, + struct t_hashtable *hashtable), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_info_hashtable(globals::plugin, info_name, description, args_description, output_description, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_infolist(weechat_plugin *plugin, + const char *infolist_name, + const char *description, + const char *pointer_description, + const char *args_description, + struct t_infolist *(*callback)(const void *cb_pointer, + void *data, + const char *infolist_name, + void *obj_pointer, + const char *arguments), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_infolist(globals::plugin, infolist_name, description, pointer_description, args_description, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_hdata(weechat_plugin *plugin, + const char *hdata_name, + const char *description, + struct t_hdata *(*callback)(const void *pointer, + void *data, + const char *hdata_name), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_hdata(globals::plugin, hdata_name, description, callback, callback_pointer, callback_data); + } + inline struct t_hook *hook_focus(weechat_plugin *plugin, + const char *area, + struct t_hashtable *(*callback)(const void *pointer, + void *data, + struct t_hashtable *info), + const void *callback_pointer, + void *callback_data) { + return globals::plugin->hook_focus(globals::plugin, area, callback, callback_pointer, callback_data); + } + inline void hook_set(struct t_hook *hook, const char *property, + const char *value) { + return globals::plugin->hook_set(hook, property, value); + } + inline void unhook(struct t_hook *hook) { + return globals::plugin->unhook(hook); + } + inline void unhook_all(weechat_plugin *plugin, + const char *subplugin) { + return globals::plugin->unhook_all(globals::plugin, subplugin); + } + + inline struct t_gui_buffer *buffer_new(weechat_plugin *plugin, + const char *name, + int (*input_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const void *input_callback_pointer, + void *input_callback_data, + int (*close_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer), + const void *close_callback_pointer, + void *close_callback_data) { + return globals::plugin->buffer_new(globals::plugin, name, input_callback, input_callback_pointer, input_callback_data, close_callback, close_callback_pointer, close_callback_data); + } + inline struct t_gui_buffer *buffer_search(const char *plugin, const char *name) { + return globals::plugin->buffer_search(plugin, name); + } + inline struct t_gui_buffer *buffer_search_main() { + return globals::plugin->buffer_search_main(); + } + inline void buffer_clear(struct t_gui_buffer *buffer) { + return globals::plugin->buffer_clear(buffer); + } + inline void buffer_close(struct t_gui_buffer *buffer) { + return globals::plugin->buffer_close(buffer); + } + inline void buffer_merge(struct t_gui_buffer *buffer, + struct t_gui_buffer *target_buffer) { + return globals::plugin->buffer_merge(buffer, target_buffer); + } + inline void buffer_unmerge(struct t_gui_buffer *buffer, int number) { + return globals::plugin->buffer_unmerge(buffer, number); + } + inline int buffer_get_integer(struct t_gui_buffer *buffer, + const char *property) { + return globals::plugin->buffer_get_integer(buffer, property); + } + inline const char *buffer_get_string(struct t_gui_buffer *buffer, + const char *property) { + return globals::plugin->buffer_get_string(buffer, property); + } + template + inline T *buffer_get_pointer(struct t_gui_buffer *buffer, + const char *property) { + return static_cast( + globals::plugin->buffer_get_pointer(buffer, property)); + } + inline void buffer_set(struct t_gui_buffer *buffer, const char *property, + const char *value) { + return globals::plugin->buffer_set(buffer, property, value); + } + inline void buffer_set_pointer(struct t_gui_buffer *buffer, + const char *property, void *pointer) { + return globals::plugin->buffer_set_pointer(buffer, property, pointer); + } + inline char *buffer_string_replace_local_var(struct t_gui_buffer *buffer, + const char *string) { + return globals::plugin->buffer_string_replace_local_var(buffer, string); + } + inline int buffer_match_list(struct t_gui_buffer *buffer, const char *string) { + return globals::plugin->buffer_match_list(buffer, string); + } + + inline struct t_gui_window *window_search_with_buffer(struct t_gui_buffer *buffer) { + return globals::plugin->window_search_with_buffer(buffer); + } + inline int window_get_integer(struct t_gui_window *window, + const char *property) { + return globals::plugin->window_get_integer(window, property); + } + inline const char *window_get_string(struct t_gui_window *window, + const char *property) { + return globals::plugin->window_get_string(window, property); + } + template + inline T *window_get_pointer(struct t_gui_window *window, + const char *property) { + return static_cast( + globals::plugin->window_get_pointer(window, property)); + } + inline struct t_gui_window *current_window() { + return static_cast( + globals::plugin->window_get_pointer(nullptr, "current")); + } + inline void window_set_title(const char *title) { + return globals::plugin->window_set_title(title); + } + + inline struct t_gui_nick_group *nicklist_add_group(struct t_gui_buffer *buffer, + struct t_gui_nick_group *parent_group, + const char *name, + const char *color, + int visible) { + return globals::plugin->nicklist_add_group(buffer, parent_group, name, color, visible); + } + inline struct t_gui_nick_group *nicklist_search_group(struct t_gui_buffer *buffer, + struct t_gui_nick_group *from_group, + const char *name) { + return globals::plugin->nicklist_search_group(buffer, from_group, name); + } + inline struct t_gui_nick *nicklist_add_nick(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + const char *name, + const char *color, + const char *prefix, + const char *prefix_color, + int visible) { + return globals::plugin->nicklist_add_nick(buffer, group, name, color, prefix, prefix_color, visible); + } + inline struct t_gui_nick *nicklist_search_nick(struct t_gui_buffer *buffer, + struct t_gui_nick_group *from_group, + const char *name) { + return globals::plugin->nicklist_search_nick(buffer, from_group, name); + } + inline void nicklist_remove_group(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group) { + return globals::plugin->nicklist_remove_group(buffer, group); + } + inline void nicklist_remove_nick(struct t_gui_buffer *buffer, + struct t_gui_nick *nick) { + return globals::plugin->nicklist_remove_nick(buffer, nick); + } + inline void nicklist_remove_all(struct t_gui_buffer *buffer) { + return globals::plugin->nicklist_remove_all(buffer); + } + inline void nicklist_get_next_item(struct t_gui_buffer *buffer, + struct t_gui_nick_group **group, + struct t_gui_nick **nick) { + return globals::plugin->nicklist_get_next_item(buffer, group, nick); + } + inline int nicklist_group_get_integer(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + const char *property) { + return globals::plugin->nicklist_group_get_integer(buffer, group, property); + } + inline const char *nicklist_group_get_string(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + const char *property) { + return globals::plugin->nicklist_group_get_string(buffer, group, property); + } + template + inline T *nicklist_group_get_pointer(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + const char *property) { + return static_cast( + globals::plugin->nicklist_group_get_pointer(buffer, group, property)); + } + inline void nicklist_group_set(struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + const char *property, const char *value) { + return globals::plugin->nicklist_group_set(buffer, group, property, value); + } + inline int nicklist_nick_get_integer(struct t_gui_buffer *buffer, + struct t_gui_nick *nick, + const char *property) { + return globals::plugin->nicklist_nick_get_integer(buffer, nick, property); + } + inline const char *nicklist_nick_get_string(struct t_gui_buffer *buffer, + struct t_gui_nick *nick, + const char *property) { + return globals::plugin->nicklist_nick_get_string(buffer, nick, property); + } + template + inline T *nicklist_nick_get_pointer(struct t_gui_buffer *buffer, + struct t_gui_nick *nick, + const char *property) { + return static_cast( + globals::plugin->nicklist_nick_get_pointer(buffer, nick, property)); + } + inline void nicklist_nick_set(struct t_gui_buffer *buffer, + struct t_gui_nick *nick, + const char *property, const char *value) { + return globals::plugin->nicklist_nick_set(buffer, nick, property, value); + } + + inline struct t_gui_bar_item *bar_item_search(const char *name) { + return globals::plugin->bar_item_search(name); + } + inline struct t_gui_bar_item *bar_item_new(const char *name, + char *(*build_callback)(const void *pointer, + void *data, + struct t_gui_bar_item *item, + struct t_gui_window *window, + struct t_gui_buffer *buffer, + struct t_hashtable *extra_info), + const void *build_callback_pointer, + void *build_callback_data) { + return globals::plugin->bar_item_new(globals::plugin, name, build_callback, build_callback_pointer, build_callback_data); + } + inline void bar_item_update(const char *name) { + return globals::plugin->bar_item_update(name); + } + inline void bar_item_remove(struct t_gui_bar_item *item) { + return globals::plugin->bar_item_remove(item); + } + inline struct t_gui_bar *bar_search(const char *name) { + return globals::plugin->bar_search(name); + } + inline struct t_gui_bar *bar_new(const char *name, + const char *hidden, + const char *priority, + const char *type, + const char *condition, + const char *position, + const char *filling_top_bottom, + const char *filling_left_right, + const char *size, + const char *size_max, + const char *color_fg, + const char *color_delim, + const char *color_bg, + const char *color_bg_inactive, + const char *separator, + const char *items) { + return globals::plugin->bar_new(name, hidden, priority, type, condition, position, filling_top_bottom, filling_left_right, size, size_max, color_fg, color_delim, color_bg, color_bg_inactive, separator, items); + } + inline int bar_set(struct t_gui_bar *bar, const char *property, + const char *value) { + return globals::plugin->bar_set(bar, property, value); + } + inline void bar_update(const char *name) { + return globals::plugin->bar_update(name); + } + inline void bar_remove(struct t_gui_bar *bar) { + return globals::plugin->bar_remove(bar); + } + + inline int command(weechat_plugin *plugin, + struct t_gui_buffer *buffer, const char *command) { + return globals::plugin->command(globals::plugin, buffer, command); + } + inline int command_options(weechat_plugin *plugin, + struct t_gui_buffer *buffer, const char *command, + struct t_hashtable *options) { + return globals::plugin->command_options(globals::plugin, buffer, command, options); + } + + inline struct t_gui_completion *completion_new(weechat_plugin *plugin, + struct t_gui_buffer *buffer) { + return globals::plugin->completion_new(globals::plugin, buffer); + } + inline int completion_search(struct t_gui_completion *completion, + const char *data, int position, int direction) { + return globals::plugin->completion_search(completion, data, position, direction); + } + inline const char *completion_get_string(struct t_gui_completion *completion, + const char *property) { + return globals::plugin->completion_get_string(completion, property); + } + inline void completion_list_add(struct t_gui_completion *completion, + const char *word, + int nick_completion, + const char *where) { + return globals::plugin->completion_list_add(completion, word, nick_completion, where); + } + inline void completion_free(struct t_gui_completion *completion) { + return globals::plugin->completion_free(completion); + } + + inline int network_pass_proxy(const char *proxy, int sock, + const char *address, int port) { + return globals::plugin->network_pass_proxy(proxy, sock, address, port); + } + inline int network_connect_to(const char *proxy, + struct sockaddr *address, + socklen_t address_length) { + return globals::plugin->network_connect_to(proxy, address, address_length); + } + + inline char *info_get(weechat_plugin *plugin, const char *info_name, + const char *arguments) { + return globals::plugin->info_get(globals::plugin, info_name, arguments); + } + inline struct t_hashtable *info_get_hashtable(weechat_plugin *plugin, + const char *info_name, + struct t_hashtable *hashtable) { + return globals::plugin->info_get_hashtable(globals::plugin, info_name, hashtable); + } + + inline struct t_infolist *infolist_new(weechat_plugin *plugin) { + return globals::plugin->infolist_new(globals::plugin); + } + inline struct t_infolist_item *infolist_new_item(struct t_infolist *infolist) { + return globals::plugin->infolist_new_item(infolist); + } + inline struct t_infolist_var *infolist_new_var_integer(struct t_infolist_item *item, + const char *name, + int value) { + return globals::plugin->infolist_new_var_integer(item, name, value); + } + inline struct t_infolist_var *infolist_new_var_string(struct t_infolist_item *item, + const char *name, + const char *value) { + return globals::plugin->infolist_new_var_string(item, name, value); + } + inline struct t_infolist_var *infolist_new_var_pointer(struct t_infolist_item *item, + const char *name, + void *pointer) { + return globals::plugin->infolist_new_var_pointer(item, name, pointer); + } + inline struct t_infolist_var *infolist_new_var_buffer(struct t_infolist_item *item, + const char *name, + void *pointer, + int size) { + return globals::plugin->infolist_new_var_buffer(item, name, pointer, size); + } + inline struct t_infolist_var *infolist_new_var_time(struct t_infolist_item *item, + const char *name, + time_t time) { + return globals::plugin->infolist_new_var_time(item, name, time); + } + inline struct t_infolist_var *infolist_search_var(struct t_infolist *infolist, + const char *name) { + return globals::plugin->infolist_search_var(infolist, name); + } + inline struct t_infolist *infolist_get(weechat_plugin *plugin, + const char *infolist_name, + void *pointer, + const char *arguments) { + return globals::plugin->infolist_get(globals::plugin, infolist_name, pointer, arguments); + } + inline int infolist_next(struct t_infolist *infolist) { + return globals::plugin->infolist_next(infolist); + } + inline int infolist_prev(struct t_infolist *infolist) { + return globals::plugin->infolist_prev(infolist); + } + inline void infolist_reset_item_cursor(struct t_infolist *infolist) { + return globals::plugin->infolist_reset_item_cursor(infolist); + } + inline const char *infolist_fields(struct t_infolist *infolist) { + return globals::plugin->infolist_fields(infolist); + } + inline int infolist_integer(struct t_infolist *infolist, const char *var) { + return globals::plugin->infolist_integer(infolist, var); + } + inline const char *infolist_string(struct t_infolist *infolist, const char *var) { + return globals::plugin->infolist_string(infolist, var); + } + template + inline T *infolist_pointer(struct t_infolist *infolist, const char *var) { + return static_cast( + globals::plugin->infolist_pointer(infolist, var)); + } + template + inline T *infolist_buffer(struct t_infolist *infolist, const char *var, + int *size) { + return static_cast( + globals::plugin->infolist_buffer(infolist, var, size)); + } + inline time_t infolist_time(struct t_infolist *infolist, const char *var) { + return globals::plugin->infolist_time(infolist, var); + } + inline void infolist_free(struct t_infolist *infolist) { + return globals::plugin->infolist_free(infolist); + } + + inline struct t_hdata *hdata_new(weechat_plugin *plugin, + const char *hdata_name, const char *var_prev, + const char *var_next, + int create_allowed, int delete_allowed, + int (*callback_update)(void *data, + struct t_hdata *hdata, + void *pointer, + struct t_hashtable *hashtable), + void *callback_update_data) { + return globals::plugin->hdata_new(globals::plugin, hdata_name, var_prev, var_next, create_allowed, delete_allowed, callback_update, callback_update_data); + } + inline void hdata_new_var(struct t_hdata *hdata, const char *name, int offset, + int type, int update_allowed, const char *array_size, + const char *hdata_name) { + return globals::plugin->hdata_new_var(hdata, name, offset, type, update_allowed, array_size, hdata_name); + } + inline void hdata_new_list(struct t_hdata *hdata, const char *name, + void *pointer, int flags) { + return globals::plugin->hdata_new_list(hdata, name, pointer, flags); + } + inline struct t_hdata *hdata_get(weechat_plugin *plugin, + const char *hdata_name) { + return globals::plugin->hdata_get(globals::plugin, hdata_name); + } + inline int hdata_get_var_offset(struct t_hdata *hdata, const char *name) { + return globals::plugin->hdata_get_var_offset(hdata, name); + } + inline int hdata_get_var_type(struct t_hdata *hdata, const char *name) { + return globals::plugin->hdata_get_var_type(hdata, name); + } + inline const char *hdata_get_var_type_string(struct t_hdata *hdata, + const char *name) { + return globals::plugin->hdata_get_var_type_string(hdata, name); + } + inline int hdata_get_var_array_size(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_get_var_array_size(hdata, pointer, name); + } + inline const char *hdata_get_var_array_size_string(struct t_hdata *hdata, + void *pointer, + const char *name) { + return globals::plugin->hdata_get_var_array_size_string(hdata, pointer, name); + } + inline const char *hdata_get_var_hdata(struct t_hdata *hdata, + const char *name) { + return globals::plugin->hdata_get_var_hdata(hdata, name); + } + template + inline T *hdata_get_var(struct t_hdata *hdata, void *pointer, + const char *name) { + return static_cast( + globals::plugin->hdata_get_var(hdata, pointer, name)); + } + template + inline T *hdata_get_var_at_offset(struct t_hdata *hdata, void *pointer, + int offset) { + return static_cast( + globals::plugin->hdata_get_var_at_offset(hdata, pointer, offset)); + } + template + inline T *hdata_get_list(struct t_hdata *hdata, const char *name) { + return static_cast( + globals::plugin->hdata_get_list(hdata, name)); + } + inline int hdata_check_pointer(struct t_hdata *hdata, void *list, + void *pointer) { + return globals::plugin->hdata_check_pointer(hdata, list, pointer); + } + template + inline T *hdata_move(struct t_hdata *hdata, void *pointer, int count) { + return static_cast( + globals::plugin->hdata_move(hdata, pointer, count)); + } + template + inline T *hdata_search(struct t_hdata *hdata, void *pointer, + const char *search, int move) { + return static_cast( + globals::plugin->hdata_search(hdata, pointer, search, move)); + } + inline char hdata_char(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_char(hdata, pointer, name); + } + inline int hdata_integer(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_integer(hdata, pointer, name); + } + inline long hdata_long(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_long(hdata, pointer, name); + } + inline const char *hdata_string(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_string(hdata, pointer, name); + } + template + inline T *hdata_pointer(struct t_hdata *hdata, void *pointer, + const char *name) { + return static_cast( + globals::plugin->hdata_pointer(hdata, pointer, name)); + } + inline time_t hdata_time(struct t_hdata *hdata, void *pointer, + const char *name) { + return globals::plugin->hdata_time(hdata, pointer, name); + } + inline struct t_hashtable *hdata_hashtable(struct t_hdata *hdata, + void *pointer, const char *name) { + return globals::plugin->hdata_hashtable(hdata, pointer, name); + } + inline int hdata_compare(struct t_hdata *hdata, + void *pointer1, void *pointer2, const char *name, + int case_sensitive) { + return globals::plugin->hdata_compare(hdata, pointer1, pointer2, name, case_sensitive); + } + inline int hdata_set(struct t_hdata *hdata, void *pointer, const char *name, + const char *value) { + return globals::plugin->hdata_set(hdata, pointer, name, value); + } + inline int hdata_update(struct t_hdata *hdata, void *pointer, + struct t_hashtable *hashtable) { + return globals::plugin->hdata_update(hdata, pointer, hashtable); + } + inline const char *hdata_get_string(struct t_hdata *hdata, + const char *property) { + return globals::plugin->hdata_get_string(hdata, property); + } + + inline struct t_upgrade_file *upgrade_new(const char *filename, + int (*callback_read)(const void *pointer, + void *data, + struct t_upgrade_file *upgrade_file, + int object_id, + struct t_infolist *infolist), + const void *callback_read_pointer, + void *callback_read_data) { + return globals::plugin->upgrade_new(filename, callback_read, callback_read_pointer, callback_read_data); + } + inline int upgrade_write_object(struct t_upgrade_file *upgrade_file, + int object_id, + struct t_infolist *infolist) { + return globals::plugin->upgrade_write_object(upgrade_file, object_id, infolist); + } + inline int upgrade_read(struct t_upgrade_file *upgrade_file) { + return globals::plugin->upgrade_read(upgrade_file); + } + inline void upgrade_close(struct t_upgrade_file *upgrade_file) { + return globals::plugin->upgrade_close(upgrade_file); + } } diff --git a/strophe.cpp b/strophe.cpp new file mode 100644 index 0000000..e9db828 --- /dev/null +++ b/strophe.cpp @@ -0,0 +1,33 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, version 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "strophe.hh" + +xmpp_log_t* logger = nullptr; + +namespace xmpp { + context::context() + : context(xmpp_ctx_new(nullptr, logger)) { + } + + context::context(xmpp_ctx_ptr ptr) + : xmpp_ctx_ptr(std::move(ptr)) { + } + + context::context(xmpp_ctx_t *ptr) + : context(std::move(xmpp_ctx_ptr( + ptr, [this] (xmpp_ctx_t *ctx) { + xmpp_ctx_free(ctx); + } + ))) { + } + + context::~context() { + this->reset(nullptr); + } + + void shutdown() { + xmpp_shutdown(); + } +} diff --git a/strophe.hh b/strophe.hh new file mode 100644 index 0000000..c3ec0ca --- /dev/null +++ b/strophe.hh @@ -0,0 +1,28 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, version 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include +#include + +extern "C" { +#include +} + +namespace xmpp { + typedef std::unique_ptr< + xmpp_ctx_t, + std::function> xmpp_ctx_ptr; + + class context : public xmpp_ctx_ptr { + public: + context(); + context(xmpp_ctx_ptr ptr); + context(xmpp_ctx_t *ptr); + ~context(); + }; + + void shutdown(); +} diff --git a/tests/plugin.cc b/tests/plugin.cc index 45e9a1a..9485760 100644 --- a/tests/plugin.cc +++ b/tests/plugin.cc @@ -13,6 +13,6 @@ TEST_CASE("placeholder") CHECK(argc != 1); } - weechat::plugin c; - CHECK(&c.name() == NULL); + //weechat::plugin c; + //CHECK(&c.name() == NULL); } diff --git a/tests/strophe.cc b/tests/strophe.cc new file mode 100644 index 0000000..fe40fed --- /dev/null +++ b/tests/strophe.cc @@ -0,0 +1,11 @@ +#include +#include + +#include "../strophe.hh" + +TEST_CASE("create context") +{ + xmpp::context ctx; + + CHECK(ctx.get()); +} diff --git a/user.c b/user.c index 5190f69..3401553 100644 --- a/user.c +++ b/user.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "plugin.h" #include "account.h" diff --git a/util.c b/util.c index 382ee05..a3e37e0 100644 --- a/util.c +++ b/util.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "plugin.h" #include "util.h"