예제 #1
0
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
    weechat_guile_plugin = plugin;

    guile_stdout = NULL;

    scm_init_guile ();

    guile_module_weechat = scm_c_define_module ("weechat",
                                                &weechat_guile_api_module_init,
                                                NULL);
    scm_c_use_module ("weechat");
    weechat_guile_catch (scm_gc_protect_object, (void *)guile_module_weechat);

    guile_quiet = 1;
    script_init (weechat_guile_plugin,
                 argc,
                 argv,
                 &weechat_guile_command_cb,
                 &weechat_guile_completion_cb,
                 &weechat_guile_infolist_cb,
                 &weechat_guile_signal_debug_dump_cb,
                 &weechat_guile_signal_buffer_closed_cb,
                 &weechat_guile_signal_script_action_cb,
                 &weechat_guile_load_cb);
    guile_quiet = 0;

    script_display_short_list (weechat_guile_plugin,
                               guile_scripts);

    /* init ok */
    return WEECHAT_RC_OK;
}
예제 #2
0
파일: guile.c 프로젝트: ers35/modserver
static int mod_load_servlet(lua_State *l)
{
  const char *path = luaL_checkstring(l, -1);
  SCM module = scm_c_define_module(path, NULL, NULL);
  SCM prev_module = scm_set_current_module(module);
  
  // TODO: don't define these functions every time for each servlet
  scm_c_define_gsubr("get_arg", 2, 0, 0, &api_get_arg);
  scm_c_define_gsubr("get_method", 1, 0, 0, &api_get_method);
  scm_c_define_gsubr("get_header", 2, 0, 0, &api_get_header);
  scm_c_define_gsubr("set_status", 2, 0, 0, &api_set_status);
  scm_c_define_gsubr("set_header", 3, 0, 0, &api_set_header);
  scm_c_define_gsubr("rwrite", 2, 0, 0, &api_rwrite);
  scm_c_define_gsubr("rflush", 1, 0, 0, &api_rflush);
  
  SCM foo = scm_c_primitive_load(path);
  SCM run_symbol = scm_c_lookup("run");
  SCM run_ref = scm_variable_ref(run_symbol);
  scm_set_current_module(prev_module);
  
  lua_newtable(l);
  lua_pushlightuserdata(l, (void*)run_ref);
  lua_pushcclosure(l, servlet_run, 1);
  lua_setfield(l, -2, "run");
  
  return 1;
}
예제 #3
0
/*!
 * \brief Initialise the gschem hooks.
 * \par Function Description

 * Registers gschem's Guile hooks for various events.. Should only be
 * called by main_prog().
 */
void
g_init_hook ()
{
  /* Define the (gschem core hook) module */
  scm_c_define_module ("gschem core hook",
                       init_module_gschem_core_hook,
                       NULL);
}
예제 #4
0
/*!
 * \brief Initialise gschem built-in actions.
 * \par Function Description

 * Registers the Scheme procedures used to access gschem's built-in
 * editing actions implemented in C.  Should only be called by
 * main_prog().
 */
void
g_init_builtins ()
{
  /* Define the (gschem core builtins) module */
  scm_c_define_module ("gschem core builtins",
                       (void (*)(void*)) init_module_gschem_core_builtins,
                       NULL);
}
예제 #5
0
int
weechat_guile_load (const char *filename)
{
    char *filename2, *ptr_base_name, *base_name;
    SCM module;

    if ((weechat_guile_plugin->debug >= 2) || !guile_quiet)
    {
        weechat_printf (NULL,
                        weechat_gettext ("%s: loading script \"%s\""),
                        GUILE_PLUGIN_NAME, filename);
    }

    guile_current_script = NULL;
    guile_registered_script = NULL;
    guile_current_script_filename = filename;

    filename2 = strdup (filename);
    if (!filename2)
        return 0;

    ptr_base_name = basename (filename2);
    base_name = strdup (ptr_base_name);
    module = scm_c_define_module (base_name,
                                  &weechat_guile_module_init_script, filename2);
    free (filename2);

    if (!guile_registered_script)
    {
        weechat_printf (NULL,
                        weechat_gettext ("%s%s: function \"register\" not "
                                         "found (or failed) in file \"%s\""),
                        weechat_prefix ("error"), GUILE_PLUGIN_NAME, filename);
        return 0;
    }

    weechat_guile_catch (scm_gc_protect_object, (void *)module);

    guile_current_script = guile_registered_script;

    /*
     * set input/close callbacks for buffers created by this script
     * (to restore callbacks after upgrade)
     */
    plugin_script_set_buffer_callbacks (weechat_guile_plugin,
                                        guile_scripts,
                                        guile_current_script,
                                        &weechat_guile_api_buffer_input_data_cb,
                                        &weechat_guile_api_buffer_close_cb);

    (void) weechat_hook_signal_send ("guile_script_loaded",
                                     WEECHAT_HOOK_SIGNAL_STRING,
                                     guile_current_script->filename);

    return 1;
}
예제 #6
0
파일: keysym.c 프로젝트: emallson/gram
void
init_gram_keysym (void)
{
  gram_keysym_tag =
    scm_make_smob_type ("keysym", sizeof (struct gram_keysym));
  scm_set_smob_print (gram_keysym_tag, gram_keysym_print);
  scm_set_smob_equalp (gram_keysym_tag, gram_keysym_equalp);

  scm_c_define_module ("gram keysym", init_gram_keysym_fns, NULL);
}
예제 #7
0
/*!
 * \brief Initialise the basic gEDA smob types.
 * \par Function Description
 * Registers the gEDA core smob types and some procedures acting on
 * them.  gEDA only uses a single Guile smob, and uses the flags field
 * to multiplex the several different underlying C structures that may
 * be represented by that smob. Should only be called by
 * edascm_init().
 */
void
edascm_init_smob ()
{
  /* Register gEDA smob type */
  geda_smob_tag = scm_make_smob_type ("geda", 0);
  scm_set_smob_free (geda_smob_tag, smob_free);
  scm_set_smob_print (geda_smob_tag, smob_print);
  scm_set_smob_equalp (geda_smob_tag, smob_equalp);

  /* Define the (geda core smob) module */
  scm_c_define_module ("geda core smob",
                       init_module_geda_core_smob,
                       NULL);
}
예제 #8
0
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
    struct t_plugin_script_init init;

    weechat_guile_plugin = plugin;

    guile_stdout = NULL;

#ifdef HAVE_GUILE_GMP_MEMORY_FUNCTIONS
    /*
     * prevent guile to use its own gmp allocator, because it can conflict
     * with other plugins using GnuTLS like relay, which can crash WeeChat
     * on unload (or exit)
     */
    scm_install_gmp_memory_functions = 0;
#endif /* HAVE_GUILE_GMP_MEMORY_FUNCTIONS */

    scm_init_guile ();

    guile_module_weechat = scm_c_define_module ("weechat",
                                                &weechat_guile_api_module_init,
                                                NULL);
    scm_c_use_module ("weechat");
    weechat_guile_catch (scm_gc_protect_object, (void *)guile_module_weechat);

    init.callback_command = &weechat_guile_command_cb;
    init.callback_completion = &weechat_guile_completion_cb;
    init.callback_hdata = &weechat_guile_hdata_cb;
    init.callback_infolist = &weechat_guile_infolist_cb;
    init.callback_signal_debug_dump = &weechat_guile_signal_debug_dump_cb;
    init.callback_signal_debug_libs = &weechat_guile_signal_debug_libs_cb;
    init.callback_signal_buffer_closed = &weechat_guile_signal_buffer_closed_cb;
    init.callback_signal_script_action = &weechat_guile_signal_script_action_cb;
    init.callback_load_file = &weechat_guile_load_cb;

    guile_quiet = 1;
    plugin_script_init (weechat_guile_plugin, argc, argv, &init);
    guile_quiet = 0;

    plugin_script_display_short_list (weechat_guile_plugin,
                                      guile_scripts);

    /* init OK */
    return WEECHAT_RC_OK;
}
예제 #9
0
/* Start the LazyCat main procedure. */
static void
inner_main (void* closure, int argc, char** argv)
{
  SCM main;
  SCM args;
  SCM module;

  scm_c_define_module ("lazycat prctl", init_prctl_module, NULL);

  module = scm_c_resolve_module ("lazycat daemon lazycatd");
  scm_set_current_module (module);

  scm_c_define_gsubr ("c-set-lazycat-signals", 0, 0, 0, set_lazycat_signals);
  scm_c_export ("c-set-lazycat-signals", NULL);

  main   = scm_c_module_lookup (module, "main");
  args   = scm_program_arguments ();

  scm_call_1 (scm_variable_ref (main), args);
}
예제 #10
0
파일: midi.c 프로젝트: huangjs/cl
void mus_midi_init(void)
{
  scm_c_define_module("snd sndlib", midi_init, NULL);  
}
예제 #11
0
파일: main.c 프로젝트: davidgomes/gnumaku
void
init_gnumaku_module ()
{
    // Create the gnumaku core module and export all procedures
    scm_c_define_module ("gnumaku core", init_gnumaku, NULL);
}