static void irc_init (session *sess) { static int done_init = FALSE; char *buf; if (done_init) return; done_init = TRUE; plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); plugin_add (sess, NULL, NULL, identd_plugin_init, identd_plugin_deinit, NULL, FALSE); #ifdef USE_PLUGIN if (!arg_skip_plugins) plugin_auto_load (sess); /* autoload ~/.xchat *.so */ #endif #ifdef USE_DBUS plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); #endif if (prefs.hex_notify_timeout) notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, notify_checklist, 0); fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); fe_timeout_add (500, hexchat_misc_checks, 0); if (arg_url != NULL) { buf = g_strdup_printf ("server %s", arg_url); g_free (arg_url); /* from GOption */ handle_command (sess, buf, FALSE); g_free (buf); } if (arg_urls != NULL) { guint i; for (i = 0; i < g_strv_length (arg_urls); i++) { buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]); handle_command (sess, buf, FALSE); g_free (buf); } g_strfreev (arg_urls); } if (arg_command != NULL) { handle_command (sess, arg_command, FALSE); g_free (arg_command); } /* load -e <xdir>/startup.txt */ load_perform_file (sess, "startup.txt"); }
static void irc_init (session *sess) { static int done_init = FALSE; if (done_init) return; done_init = TRUE; #ifdef USE_PLUGIN if (!skip_plugins) plugin_auto_load (sess); /* autoload ~/.xchat *.so */ #endif plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); if (prefs.notify_timeout) notify_tag = fe_timeout_add (prefs.notify_timeout * 1000, notify_checklist, 0); fe_timeout_add (prefs.away_timeout * 1000, away_check, 0); fe_timeout_add (500, xchat_misc_checks, 0); if (connect_url != NULL) { char buf[512]; snprintf (buf, sizeof (buf), "server %s", connect_url); handle_command (sess, buf, FALSE); free (connect_url); } }
char * plugin_load (session *sess, char *filename, char *arg) { GModule *handle = module_load (filename); hexchat_init_func *init_func; hexchat_deinit_func *deinit_func; if (handle == NULL) return (char *)g_module_error (); /* find the init routine hexchat_plugin_init */ if (!g_module_symbol (handle, "hexchat_plugin_init", (gpointer *)&init_func)) { g_module_close (handle); return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "hexchat_plugin_deinit", (gpointer *)&deinit_func)) deinit_func = NULL; /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
char * plugin_load (session *sess, char *filename, char *arg) { void *handle; gpointer init_func; // => xchat_init_func gpointer deinit_func; // => xchat_deinit_func /* load the plugin */ handle = g_module_open (filename, 0); if (handle == NULL) return (char *)g_module_error (); /* find the init routine xchat_plugin_init */ if (!g_module_symbol (handle, "xchat_plugin_init", &init_func)) { g_module_close (handle); return _("No xchat_plugin_init symbol; is this really an xchat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "xchat_plugin_deinit", &deinit_func)) deinit_func = NULL; /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
static void irc_init (session *sess) { static int done_init = FALSE; char *buf; if (done_init) return; done_init = TRUE; plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); #ifdef USE_PLUGIN if (!arg_skip_plugins) plugin_auto_load (sess); /* autoload ~/.xchat *.so */ #endif #ifdef USE_DBUS plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); #endif if (prefs.hex_notify_timeout) notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, notify_checklist, 0); fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); fe_timeout_add (500, hexchat_misc_checks, 0); if (arg_url != NULL) { buf = g_strdup_printf ("server %s", arg_url); g_free (arg_url); /* from GOption */ handle_command (sess, buf, FALSE); g_free (buf); } if (arg_command != NULL) { g_free (arg_command); } /* load -e <xdir>/startup.txt */ buf = g_build_filename (get_xdir (), "startup.txt", NULL); load_perform_file (sess, buf); g_free (buf); }
static void irc_init (session *sess) { static int done_init = FALSE; char buf[512]; if (done_init) return; done_init = TRUE; plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); #ifdef USE_PLUGIN if (!arg_skip_plugins) plugin_auto_load (sess); /* autoload ~/.xchat *.so */ #endif #ifdef USE_DBUS plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); #endif if (prefs.notify_timeout) notify_tag = fe_timeout_add (prefs.notify_timeout * 1000, notify_checklist, 0); fe_timeout_add (prefs.away_timeout * 1000, away_check, 0); fe_timeout_add (500, xchat_misc_checks, 0); if (arg_url != NULL) { snprintf (buf, sizeof (buf), "server %s", arg_url); handle_command (sess, buf, FALSE); g_free (arg_url); /* from GOption */ } if (arg_command != NULL) { g_free (arg_command); } /* load -e ~/.xchat2/startup.txt */ snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "startup.txt"); load_perform_file (sess, buf); }
char * plugin_load (session *sess, char *filename, char *arg) { void *handle; char *filepart; hexchat_init_func *init_func; hexchat_deinit_func *deinit_func; char *pluginpath; /* get the filename without path */ filepart = file_part (filename); /* load the plugin */ if (!g_ascii_strcasecmp (filepart, filename)) { /* no path specified, it's just the filename, try to load from config dir */ pluginpath = g_build_filename (get_xdir (), "addons", filename, NULL); handle = g_module_open (pluginpath, 0); g_free (pluginpath); } else { /* try to load with absolute path */ handle = g_module_open (filename, 0); } if (handle == NULL) return (char *)g_module_error (); /* find the init routine hexchat_plugin_init */ if (!g_module_symbol (handle, "hexchat_plugin_init", (gpointer *)&init_func)) { g_module_close (handle); return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "hexchat_plugin_deinit", (gpointer *)&deinit_func)) deinit_func = NULL; /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
char * plugin_load (session *sess, char *filename, char *arg) { void *handle; char *filepart; hexchat_init_func *init_func; hexchat_deinit_func *deinit_func; #ifndef USE_GMODULE char *error; #else char *pluginpath; #endif /* get the filename without path */ filepart = file_part (filename); #ifdef USE_GMODULE /* load the plugin */ if (!g_ascii_strcasecmp (filepart, filename)) { /* no path specified, it's just the filename, try to load from config dir */ pluginpath = g_build_filename (get_xdir (), filename, NULL); handle = g_module_open (pluginpath, 0); g_free (pluginpath); } else { /* try to load with absolute path */ handle = g_module_open (filename, 0); } if (handle == NULL) return (char *)g_module_error (); /* find the init routine hexchat_plugin_init */ if (!g_module_symbol (handle, "hexchat_plugin_init", (gpointer *)&init_func)) { g_module_close (handle); return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "hexchat_plugin_deinit", (gpointer *)&deinit_func)) deinit_func = NULL; #else /* OpenBSD lacks this! */ #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 #endif #ifndef RTLD_NOW #define RTLD_NOW 0 #endif /* load the plugin */ if (filepart && /* xsys draws in libgtk-1.2, causing crashes, so force RTLD_LOCAL */ (strstr (filepart, "local") || strncmp (filepart, "libxsys-1", 9) == 0) ) handle = dlopen (filename, RTLD_NOW); else handle = dlopen (filename, RTLD_GLOBAL | RTLD_NOW); if (handle == NULL) return (char *)dlerror (); dlerror (); /* Clear any existing error */ /* find the init routine hexchat_plugin_init */ init_func = dlsym (handle, "hexchat_plugin_init"); error = (char *)dlerror (); if (error != NULL) { dlclose (handle); return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?"); } /* find the plugin's deinit routine, if any */ deinit_func = dlsym (handle, "hexchat_plugin_deinit"); error = (char *)dlerror (); #endif /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
char * plugin_load (session *sess, char *filename, char *arg) { void *handle; xchat_init_func *init_func; xchat_deinit_func *deinit_func; #ifdef USE_GMODULE /* load the plugin */ handle = g_module_open (filename, 0); if (handle == NULL) return (char *)g_module_error (); /* find the init routine xchat_plugin_init */ if (!g_module_symbol (handle, "xchat_plugin_init", (gpointer *)&init_func)) { g_module_close (handle); return _("No xchat_plugin_init symbol; is this really an xchat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "xchat_plugin_deinit", (gpointer *)&deinit_func)) deinit_func = NULL; #else char *error; char *filepart; /* OpenBSD lacks this! */ #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 #endif #ifndef RTLD_NOW #define RTLD_NOW 0 #endif /* get the filename without path */ filepart = file_part (filename); /* load the plugin */ if (filepart && /* xsys draws in libgtk-1.2, causing crashes, so force RTLD_LOCAL */ (strstr (filepart, "local") || strncmp (filepart, "libxsys-1", 9) == 0) ) handle = dlopen (filename, RTLD_NOW); else handle = dlopen (filename, RTLD_GLOBAL | RTLD_NOW); if (handle == NULL) return (char *)dlerror (); dlerror (); /* Clear any existing error */ /* find the init routine xchat_plugin_init */ init_func = dlsym (handle, "xchat_plugin_init"); error = (char *)dlerror (); if (error != NULL) { dlclose (handle); return _("No xchat_plugin_init symbol; is this really an xchat plugin?"); } /* find the plugin's deinit routine, if any */ deinit_func = dlsym (handle, "xchat_plugin_deinit"); error = (char *)dlerror (); #endif /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
char* plugin_load(session *sess, char *filename, char *arg) { void *handle; xchat_init_func *init_func; xchat_deinit_func *deinit_func; #ifdef USE_GMODULE // load the plugin handle = g_module_open(filename, (GModuleFlags)0); if (handle == nullptr) return (char*)g_module_error(); // find the init routine xchat_plugin_init if (!g_module_symbol((GModule*)handle, "xchat_plugin_init", (gpointer*)&init_func)) { g_module_close((GModule*)handle); return _("No xchat_plugin_init symbol; is this really an xchat plugin?"); } // find the plugin's deinit routine, if any if (!g_module_symbol((GModule*)handle, "xchat_plugin_deinit", (gpointer*)&deinit_func)) deinit_func = nullptr; #else char *error; char *filepart; // OpenBSD lacks this! #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 #endif #ifndef RTLD_NOW #define RTLD_NOW 0 #endif // get the filename without path filepart = file_part(filename); // load the plugin if (filepart && // xsys draws in libgtk-1.2, causing crashes, so force RTLD_LOCAL (strstr(filepart, "local") || strncmp (filepart, "libxsys-1", 9) == 0)) handle = dlopen(filename, RTLD_NOW); else handle = dlopen(filename, RTLD_GLOBAL | RTLD_NOW); if (handle == nullptr) return (char*)dlerror(); dlerror(); // Clear any existing error // find the init routine xchat_plugin_init init_func = (xif)dlsym(handle, "xchat_plugin_init"); error = (char*)dlerror(); if (error != nullptr) { dlclose(handle); return _("No xchat_plugin_init symbol; is this really an xchat plugin?"); } // find the plugin's deinit routine, if any deinit_func = (xdf)dlsym(handle, "xchat_plugin_deinit"); error = (char*)dlerror(); #endif // add it to our linked list plugin_add(sess, filename, handle, (void*)init_func, (void*)deinit_func, arg, FALSE); return nullptr; }