Files
zoitechat/src/common/plugin.h

193 lines
7.2 KiB
C
Raw Normal View History

2026-01-05 23:12:38 -07:00
/* ZoiteChat
* Copyright (C) 1998-2010 Peter Zelezny.
* Copyright (C) 2009-2013 Berke Viktor.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_COMMONPLUGIN_H
#define HEXCHAT_COMMONPLUGIN_H
2011-02-24 04:14:30 +01:00
#ifdef PLUGIN_C
2026-01-05 23:12:38 -07:00
struct _zoitechat_plugin
2011-02-24 04:14:30 +01:00
{
2026-01-05 23:12:38 -07:00
/* Keep these in sync with zoitechat-plugin.h */
2011-02-24 04:14:30 +01:00
/* !!don't change the order, to keep binary compat!! */
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_command) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name,
int pri,
int (*callback) (char *word[], char *word_eol[], void *user_data),
const char *help_text,
void *userdata);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_server) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name,
int pri,
int (*callback) (char *word[], char *word_eol[], void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_print) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name,
int pri,
int (*callback) (char *word[], void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_timer) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
int timeout,
int (*callback) (void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_fd) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
int fd,
int flags,
int (*callback) (int fd, int flags, void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
void *(*zoitechat_unhook) (zoitechat_plugin *ph,
zoitechat_hook *hook);
void (*zoitechat_print) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *text);
2026-01-05 23:12:38 -07:00
void (*zoitechat_printf) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *format, ...);
2026-01-05 23:12:38 -07:00
void (*zoitechat_command) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *command);
2026-01-05 23:12:38 -07:00
void (*zoitechat_commandf) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *format, ...);
2026-01-05 23:12:38 -07:00
int (*zoitechat_nickcmp) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *s1,
const char *s2);
2026-01-05 23:12:38 -07:00
int (*zoitechat_set_context) (zoitechat_plugin *ph,
zoitechat_context *ctx);
zoitechat_context *(*zoitechat_find_context) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *servname,
const char *channel);
2026-01-05 23:12:38 -07:00
zoitechat_context *(*zoitechat_get_context) (zoitechat_plugin *ph);
const char *(*zoitechat_get_info) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *id);
2026-01-05 23:12:38 -07:00
int (*zoitechat_get_prefs) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name,
const char **string,
int *integer);
2026-01-05 23:12:38 -07:00
zoitechat_list * (*zoitechat_list_get) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name);
2026-01-05 23:12:38 -07:00
void (*zoitechat_list_free) (zoitechat_plugin *ph,
zoitechat_list *xlist);
const char * const * (*zoitechat_list_fields) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *name);
2026-01-05 23:12:38 -07:00
int (*zoitechat_list_next) (zoitechat_plugin *ph,
zoitechat_list *xlist);
const char * (*zoitechat_list_str) (zoitechat_plugin *ph,
zoitechat_list *xlist,
2011-02-24 04:14:30 +01:00
const char *name);
2026-01-05 23:12:38 -07:00
int (*zoitechat_list_int) (zoitechat_plugin *ph,
zoitechat_list *xlist,
2011-02-24 04:14:30 +01:00
const char *name);
2026-01-05 23:12:38 -07:00
void * (*zoitechat_plugingui_add) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *filename,
const char *name,
const char *desc,
const char *version,
char *reserved);
2026-01-05 23:12:38 -07:00
void (*zoitechat_plugingui_remove) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
void *handle);
2026-01-05 23:12:38 -07:00
int (*zoitechat_emit_print) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *event_name, ...);
2026-01-05 23:12:38 -07:00
void *(*zoitechat_read_fd) (zoitechat_plugin *ph);
time_t (*zoitechat_list_time) (zoitechat_plugin *ph,
zoitechat_list *xlist,
2011-02-24 04:14:30 +01:00
const char *name);
2026-01-05 23:12:38 -07:00
char *(*zoitechat_gettext) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *msgid);
2026-01-05 23:12:38 -07:00
void (*zoitechat_send_modes) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char **targets,
int ntargets,
int modes_per_line,
char sign,
char mode);
2026-01-05 23:12:38 -07:00
char *(*zoitechat_strip) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
const char *str,
int len,
int flags);
2026-01-05 23:12:38 -07:00
void (*zoitechat_free) (zoitechat_plugin *ph,
2011-02-24 04:14:30 +01:00
void *ptr);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_set_str) (zoitechat_plugin *ph,
2011-12-01 21:24:58 +01:00
const char *var,
const char *value);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_get_str) (zoitechat_plugin *ph,
2011-12-01 21:24:58 +01:00
const char *var,
char *dest);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_set_int) (zoitechat_plugin *ph,
2011-12-01 21:24:58 +01:00
const char *var,
int value);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_get_int) (zoitechat_plugin *ph,
2011-12-01 21:24:58 +01:00
const char *var);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_delete) (zoitechat_plugin *ph,
2012-01-14 00:29:01 +01:00
const char *var);
2026-01-05 23:12:38 -07:00
int (*zoitechat_pluginpref_list) (zoitechat_plugin *ph,
char *dest);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_server_attrs) (zoitechat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], char *word_eol[],
2026-01-05 23:12:38 -07:00
zoitechat_event_attrs *attrs, void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
zoitechat_hook *(*zoitechat_hook_print_attrs) (zoitechat_plugin *ph,
const char *name,
int pri,
2026-01-05 23:12:38 -07:00
int (*callback) (char *word[], zoitechat_event_attrs *attrs,
void *user_data),
void *userdata);
2026-01-05 23:12:38 -07:00
int (*zoitechat_emit_print_attrs) (zoitechat_plugin *ph, zoitechat_event_attrs *attrs,
const char *event_name, ...);
2026-01-05 23:12:38 -07:00
zoitechat_event_attrs *(*zoitechat_event_attrs_create) (zoitechat_plugin *ph);
void (*zoitechat_event_attrs_free) (zoitechat_plugin *ph,
zoitechat_event_attrs *attrs);
2011-02-24 04:14:30 +01:00
/* PRIVATE FIELDS! */
void *handle; /* from dlopen */
char *filename; /* loaded from */
char *name;
char *desc;
char *version;
session *context;
2026-01-05 23:12:38 -07:00
void *deinit_callback; /* pointer to zoitechat_plugin_deinit */
unsigned int fake:1; /* fake plugin. Added by zoitechat_plugingui_add() */
2011-02-24 04:14:30 +01:00
unsigned int free_strings:1; /* free name,desc,version? */
};
#endif
GModule *module_load (char *filename);
2011-02-24 04:14:30 +01:00
char *plugin_load (session *sess, char *filename, char *arg);
int plugin_reload (session *sess, char *name, int by_filename);
2011-02-24 04:14:30 +01:00
void plugin_add (session *sess, char *filename, void *handle, void *init_func, void *deinit_func, char *arg, int fake);
int plugin_kill (char *name, int by_filename);
void plugin_kill_all (void);
void plugin_auto_load (session *sess);
int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]);
int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[],
time_t server_time);
int plugin_emit_print (session *sess, char *word[], time_t server_time);
2011-02-24 04:14:30 +01:00
int plugin_emit_dummy_print (session *sess, char *name);
int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key);
2011-02-24 04:14:30 +01:00
GList* plugin_command_list(GList *tmp_list);
int plugin_show_help (session *sess, char *cmd);
void plugin_command_foreach (session *sess, void *userdata, void (*cb) (session *sess, void *userdata, char *name, char *usage));
session *plugin_find_context (const char *servname, const char *channel, server *current_server);
2011-02-24 04:14:30 +01:00
/* On macOS, G_MODULE_SUFFIX says "so" but meson uses "dylib"
* https://github.com/mesonbuild/meson/issues/1160 */
#if defined(__APPLE__)
# define PLUGIN_SUFFIX "dylib"
#else
# define PLUGIN_SUFFIX G_MODULE_SUFFIX
#endif
2011-02-24 04:14:30 +01:00
#endif