示例#1
0
void
weechat_perl_reload_name (const char *name)
{
    struct t_plugin_script *ptr_script;
    char *filename;

    ptr_script = plugin_script_search (weechat_perl_plugin, perl_scripts, name);
    if (ptr_script)
    {
        filename = strdup (ptr_script->filename);
        if (filename)
        {
            weechat_perl_unload (ptr_script);
            if (!perl_quiet)
            {
                weechat_printf (NULL,
                                weechat_gettext ("%s: script \"%s\" unloaded"),
                                PERL_PLUGIN_NAME, name);
            }
            weechat_perl_load (filename);
            free (filename);
        }
    }
    else
    {
        weechat_printf (NULL,
                        weechat_gettext ("%s%s: script \"%s\" not loaded"),
                        weechat_prefix ("error"), PERL_PLUGIN_NAME, name);
    }
}
示例#2
0
void
weechat_perl_unload_all ()
{
    while (perl_scripts)
    {
        weechat_perl_unload (perl_scripts);
    }
}
示例#3
0
int
weechat_perl_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input,
                   int exec_commands, const char *code)
{
    void *func_argv[1], *result;

    if (!perl_script_eval)
    {
        perl_quiet = 1;
        perl_script_eval = weechat_perl_load (WEECHAT_SCRIPT_EVAL_NAME,
                                              PERL_EVAL_SCRIPT);
        perl_quiet = 0;
        if (!perl_script_eval)
            return 0;
    }

    weechat_perl_output_flush ();

    perl_eval_mode = 1;
    perl_eval_send_input = send_to_buffer_as_input;
    perl_eval_exec_commands = exec_commands;
    perl_eval_buffer = buffer;

    func_argv[0] = (char *)code;
    result = weechat_perl_exec (perl_script_eval,
                                WEECHAT_SCRIPT_EXEC_IGNORE,
                                "script_perl_eval",
                                "s", func_argv);
    /* result is ignored */
    if (result)
        free (result);

    weechat_perl_output_flush ();

    perl_eval_mode = 0;
    perl_eval_send_input = 0;
    perl_eval_exec_commands = 0;
    perl_eval_buffer = NULL;

    if (!weechat_config_boolean (perl_config_look_eval_keep_context))
    {
        perl_quiet = 1;
        weechat_perl_unload (perl_script_eval);
        perl_quiet = 0;
        perl_script_eval = NULL;
    }

    return 1;
}
示例#4
0
int
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
    /* unload all scripts */
    perl_quiet = 1;
    if (perl_script_eval)
    {
        weechat_perl_unload (perl_script_eval);
        perl_script_eval = NULL;
    }
    plugin_script_end (plugin, &perl_data);
    perl_quiet = 0;

#ifndef MULTIPLICITY
    /* free perl interpreter */
    if (perl_main)
    {
        perl_destruct (perl_main);
        perl_free (perl_main);
        perl_main = NULL;
    }
#endif /* MULTIPLICITY */

#if defined(PERL_SYS_TERM) && !defined(__FreeBSD__) && !defined(WIN32) && !defined(__CYGWIN__) && !(defined(__APPLE__) && defined(__MACH__))
    /*
     * we call this function on all OS, but NOT on FreeBSD or Cygwin,
     * because it crashes with no reason (bug in Perl?)
     */
    if (perl_quit_or_upgrade)
        PERL_SYS_TERM ();
#endif

    /* free some data */
    if (perl_action_install_list)
        free (perl_action_install_list);
    if (perl_action_remove_list)
        free (perl_action_remove_list);
    if (perl_action_autoload_list)
        free (perl_action_autoload_list);
    weechat_string_dyn_free (perl_buffer_output, 1);

    return WEECHAT_RC_OK;
}