예제 #1
0
파일: main.c 프로젝트: pmyadlowsky/qmx
static int mixmaster(jack_nframes_t nframes, void *arg) {
	sample_t *outs[QMX_CHANNELS], *ch;
	size_t n, i;
	if (use_jack && need_init_guile) {
		scm_init_guile();
		need_init_guile = 0;
		}
	for (n = 0; n < QMX_CHANNELS; n++) {
		// zero the mix buffers
		if (use_jack)
			ch = outs[n] = jack_port_get_buffer(jack_cauldron[n], nframes);
		else ch = outs[n] = fixed_cauldron + n * nframes;
		for (i = 0; i < nframes; i++) ch[i] = 0.0;
		}
	// mix from sources
	alsa_mix(nframes, outs);
	audio_files_mix(nframes, outs);
	feeds_mix(nframes, outs);
	if (use_jack) jack_ports_mix(nframes, outs);
	unit_gens_mix(nframes, outs);
	// process mix; e.g. fade
	run_filter(fader, nframes, outs, outs, 0);
	// deliver mix
	buffer_out(nframes, outs);
	record(nframes, outs);
	return 0;
	}
예제 #2
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;
}
예제 #3
0
static void scm_conv_check(void)
{
    scm_init_guile();
    static struct {
        int version;
        char const *str;
        char const *num;
        sa_family_t exp_family;
    } tests[] = {
        { 4, "1.0.0.0", "(%d . 16777216)", AF_INET },
        { 4, "127.0.0.1", "(%d . 2130706433)", AF_INET },
        { 4, "128.10.5.255", "(%d . 2148140543)", AF_INET },
        { 6, "ff02::1", "(%d . 338963523518870617245727861364146307073)", AF_INET6 },
        { 6, "1:2:3:4::", "(%d . 5192455318486707403025865779445760)", AF_INET6 },
    };

    for (unsigned t = 0; t < NB_ELEMS(tests); t++) {
        struct ip_addr addr;
        ip_addr_ctor_from_str(&addr, tests[t].str, strlen(tests[t].str), tests[t].version);
        SCM ip = scm_from_ip_addr(&addr);
        SCM str = scm_simple_format(SCM_BOOL_F, scm_from_latin1_string("~a"), scm_cons(ip, SCM_EOL));
        char buf[256];
        size_t len = scm_to_locale_stringbuf(str, buf, sizeof(buf));
        assert(len < sizeof(buf));
        buf[len] = '\0';
        char expected[256];
        snprintf(expected, sizeof(expected), tests[t].num, tests[t].exp_family);

        printf("%s -> '%s' (expected '%s')\n", tests[t].str, buf, expected);
        assert(0 == strcmp(expected, buf));
    }
}
예제 #4
0
파일: plugin.c 프로젝트: UIKit0/gnumeric
G_MODULE_EXPORT void
go_plugin_init (GOPlugin *p, GOCmdContext *cc)
{
	char *name, *dir;

	*ret_error = NULL;

	 scm_init_guile ();

	/* Initialize just in case. */
	eval_pos = NULL;

	init_value_type ();

	scm_c_define_gsubr ("gnumeric-funcall", 2, 0, 0, scm_gnumeric_funcall);
	scm_c_define_gsubr ("register-function", 5, 0, 0, scm_register_function);

	dir = gnm_sys_data_dir ("guile");
	name = g_strconcat (dir, "gnumeric_startup.scm", NULL);
	scm_apply (scm_c_eval_string ("(lambda (filename)"
				  "  (if (access? filename R_OK)"
				  "    (load filename)"
				  "    (display (string-append \"could not read Guile plug-in init file\" filename \"\n\"))))"),
		  scm_cons (scm_makfrom0str (name), SCM_EOL),
		  SCM_EOL);
	g_free (name);
	g_free (dir);
	/* Don't try to deactivate the plugin */
	gnm_plugin_use_ref (PLUGIN);
}
예제 #5
0
파일: scheme.c 프로젝트: bluemoon/Godel
PyObject *VM_init(VM *self, PyObject *args, PyObject *kwds){
  // For the enviroment setup
  scm_init_guile();
  self->root = scm_current_module();
  self->SMOB_Tag = scm_make_smob_type("PythonSMOB", 0);
  self->callbacks = PyDict_New();
  
  return 0;
}
예제 #6
0
파일: main.c 프로젝트: spk121/burro-engine
int
main (int argc, char *argv[])
{
    extern void scm_c_set_default_vm_engine_x (int x);
    scm_c_set_default_vm_engine_x (1);
    scm_init_guile ();

    return g_application_run (G_APPLICATION (burro_app_new ()), argc, argv);
}
int main( ){

	SCM func;
	scm_init_guile();
	scm_c_primitive_load( "helloworld.scm" );
	func = scm_variable_ref( scm_c_lookup( "hello_world" ) );
	scm_call_0( func );

	return 0;
}
int main(int argc, char **argv)
{

     /* initialize Guile */
     scm_init_guile();

     /* Register the new C-Guile functions */
		scm_c_define_gsubr("hello-world", 0, 0, 0, (SCM (*)()) scm_hello_world); 

     /* Load the library of Guile functions */
     scm_c_primitive_load("scheme-calling-c.scm");

     return 0;
}
예제 #9
0
bool init_guile(const char *script) {
  int i;

  static const funcmap_t functions[] = {
    {"it-quit", 0, 0, 0, it_quit_wrapper},
    {"it-switch-mode", 0, 0, 0, it_switch_mode_wrapper},
    {"it-toggle-fullscreen", 0, 0, 0, it_toggle_fullscreen_wrapper},
    {"it-toggle-bar", 0, 0, 0, it_toggle_bar_wrapper},
    {"t-reload-all", 0, 0, 0, t_reload_all_wrapper},
    {"it-reload-image", 0, 0, 0, it_reload_image_wrapper},
    {"it-remove-image", 0, 0, 0, it_remove_image_wrapper},
    {"i-navigate", 1, 0, 0, i_navigate_wrapper},
    {"i-alternate", 0, 0, 0, i_alternate_wrapper},
    {"it-first", 0, 0, 0, it_first_wrapper},
    {"it-n-or-last", 1, 0, 0, it_n_or_last_wrapper},
    {"i-navigate-frame", 1, 0, 0, i_navigate_frame_wrapper},
    {"i-toggle-animation", 0, 0, 0, i_toggle_animation_wrapper},
    {"it-scroll-move", 2, 0, 0, it_scroll_move_wrapper},
    {"it-scroll-screen", 1, 0, 0, it_scroll_screen_wrapper},
    {"i-scroll-to-edge", 1, 0, 0, i_scroll_to_edge_wrapper},
    {"i-zoom", 1, 0, 0, i_zoom_wrapper},
    {"i-set-zoom", 1, 0, 0, i_set_zoom_wrapper},
    {"i-fit-to-win", 1, 0, 0, i_fit_to_win_wrapper},
    {"i-fit-to-img", 0, 0, 0, i_fit_to_img_wrapper},
    {"i-rotate", 1, 0, 0, i_rotate_wrapper},
    {"i-flip", 1, 0, 0, i_flip_wrapper},
    {"i-toggle-antialias", 0, 0, 0, i_toggle_antialias_wrapper},
    {"it-toggle-alpha", 0, 0, 0, it_toggle_alpha_wrapper},
    {"p-set-bar-left", 1, 0, 0, p_set_bar_left_wrapper},
    {"p-set-bar-right", 1, 0, 0, p_set_bar_right_wrapper},
    {"it-add-image", 1, 0, 0, it_add_image_wrapper},
    {"p-get-file-index", 0, 0, 0, p_get_file_index_wrapper},
    {"p-get-file-count", 0, 0, 0, p_get_file_count_wrapper},
    {"it-redraw", 0, 0, 0, it_redraw_wrapper},
  };

  scm_init_guile();
  for (i = 0; i < ARRLEN(functions); i++) {
    scm_c_define_gsubr(functions[i].name,
                       functions[i].req,
                       functions[i].opt,
                       functions[i].rst,
                       functions[i].func);
  }
  
  scm_c_primitive_load(script);
  return true;
}
예제 #10
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;
}
예제 #11
0
int main (int argc, char **argv)
{
  scm_init_guile();
  register_functions(NULL);

  //init script, loads the entire script
  scm_c_primitive_load("init.scm");

  //main script, please write update function, and draw function
  scm_c_primitive_load("main.scm");

  if(SDL_Init(SDL_INIT_VIDEO) != 0) {
    printf("it didn't work :(");
    return 1;
  }
  printf("it worked\n");
  SDL_Quit();
  
  return 0;
}
예제 #12
0
void
xscm_init_guile (void)
{
    scm_init_guile ();
}
/*
  Create a minimal web browser that has Emacsy integrated into it.
 */
int main(int argc, char* argv[])
{
  int err;
  // Initialize GNU Guile.
  scm_init_guile();
  // Initialize Emacsy.
  err = emacsy_initialize();
  if (err) 
    return err;

  // Register the primitive procedures that control the browser.
  init_primitives();  

  // You can evaluate S-expressions here.
  scm_c_eval_string("(use-modules (system repl error-handling))"
                    "(define (safe-load filename)              "
                    "  (call-with-error-handling               "
                    "    (lambda () (load filename))))         ");

  // But to make the application easy to mold, it's best to load the
  // Scheme code from a file.
  const char *startup_script = "emacsy-webkit-gtk-w-buffers.scm";
  if (access(startup_script, R_OK) != -1) {
    printf("Loading '%s'.\n", startup_script);

    // We could load the file like this:
    //scm_c_primitive_load(".emacy-webkit-gtk.scm");

    // But this will drop us into a REPL if anything goes wrong.
    scm_call_1(scm_c_private_ref("guile-user", "safe-load"),
               scm_from_locale_string(startup_script));
  } else {
    printf("Did not find '%s'.\n", startup_script);
  }

  // Initialize GTK+.
  gtk_init(&argc, &argv);

  // Create an 800x600 window that will contain the browser instance.
  GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600);
  //gtk_window_set_size(GTK_WINDOW(main_window), 800, 600);
  
  GdkGeometry geom_struct;
  geom_struct.max_width = 800;
  geom_struct.max_height = 600;
  gtk_window_set_geometry_hints(GTK_WINDOW(main_window),
                                NULL,
                                &geom_struct,
                                GDK_HINT_MAX_SIZE);
  /* you might need to use GTK_STATE_ACTIVE or GTK_STATE_PRELIGHT */
  GdkColor black = {0, 0x0, 0x0, 0x0};
  GdkColor white = {0, 0xFFFF, 0xFFFF, 0xFFFF};
  gtk_widget_modify_bg(GTK_WINDOW(main_window), GTK_STATE_NORMAL, &black);
  gtk_widget_modify_fg(GTK_WINDOW(main_window), GTK_STATE_NORMAL, &white);

  // Create a browser instance
  /* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); */
  /* webkit_web_view_set_highlight_text_matches(web_view, TRUE); */
  web_view = NULL;

  // Create a scrollable area, and put the browser instance into it
  scrolled_window = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  scm_c_eval_string("(new-tab)");
  //gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(web_view));

  // Set up callbacks so that if either the main window or the browser
  // instance is closed, the program will exit.
  g_signal_connect(main_window, "destroy", G_CALLBACK(destroy_window), NULL);
  //g_signal_connect(web_view, "close-web-view", G_CALLBACK(close_window), main_window);


  // This label will be where we display Emacsy's echo-area.
  label = gtk_label_new("label");
  gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);
  gtk_label_set_use_underline(GTK_LABEL(label), FALSE);
  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
  gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE);
  gtk_label_set_max_width_chars(GTK_LABEL(label), 160);

  modeline = gtk_label_new("modeline");
  gtk_misc_set_alignment(GTK_MISC(modeline), 0.0f, 0.0f);
  gtk_label_set_use_underline(GTK_LABEL(modeline), FALSE);
  gtk_label_set_line_wrap(GTK_LABEL(modeline), TRUE);
  gtk_label_set_single_line_mode(GTK_LABEL(modeline), TRUE);
  gtk_label_set_max_width_chars(GTK_LABEL(modeline), 160);


  // While idle, process events in Emacsy and upate the echo-area.
  g_idle_add((GSourceFunc) process_and_update_emacsy, NULL);

  // Handle key press and release events.
  g_signal_connect(main_window, "key_press_event", G_CALLBACK(key_press), NULL);
  g_signal_connect(main_window, "key_release_event", G_CALLBACK(key_press), NULL);
    
  GtkWidget *vbox;
  vbox = gtk_vbox_new(FALSE, 1);
  gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
  gtk_box_pack_start(GTK_BOX(vbox), modeline, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

  // Put the scrollable area into the main window.
  gtk_container_add(GTK_CONTAINER(main_window), vbox);


  // Load a web page into the browser instance.
  webkit_web_view_load_uri(web_view, 
                           "http://shanecelis.github.io/2013/06/15/the-garden/");

  // Make sure that when the browser area becomes visible, it will get mouse
  // and keyboard events.
  gtk_widget_grab_focus(GTK_WIDGET(web_view));

  // Make sure the main window and all its contents are visible.
  gtk_widget_show_all(main_window);
  gtk_window_set_resizable(GTK_WINDOW(main_window), FALSE);

  // Run the main GTK+ event loop.
  gtk_main();

  return 0;
}
예제 #14
0
파일: export.c 프로젝트: SayCV/geda-gaf
static void
cmd_export_impl (void *data, int argc, char **argv)
{
  int i;
  GError *err = NULL;
  gchar *tmp;
  const gchar *out_suffix;
  struct ExportFormat *exporter = NULL;
  GArray *render_color_map = NULL;
  gchar *original_cwd = g_get_current_dir ();

  gtk_init_check (&argc, &argv);
  scm_init_guile ();
  libgeda_init ();
  scm_dynwind_begin (0);
  toplevel = s_toplevel_new ();
  edascm_dynwind_toplevel (toplevel);

  /* Now load rc files, if necessary */
  if (getenv ("GAF_INHIBIT_RCFILES") == NULL) {
    g_rc_parse (toplevel, "gaf export", NULL, NULL);
  }
  i_vars_libgeda_set (toplevel); /* Ugh */

  /* Parse configuration files */
  export_config ();

  /* Parse command-line arguments */
  export_command_line (argc, argv);

  /* If no format was specified, try and guess from output
   * filename. */
  if (settings.format == NULL) {
    out_suffix = strrchr (settings.outfile, '.');
    if (out_suffix != NULL) {
      out_suffix++; /* Skip '.' */
    } else {
      fprintf (stderr,
               _("ERROR: Cannot infer output format from filename '%s'.\n"),
               settings.outfile);
      exit (1);
    }
  }

  /* Try and find an exporter function */
  tmp = g_utf8_strdown ((settings.format == NULL) ? out_suffix : settings.format, -1);
  for (i = 0; formats[i].name != NULL; i++) {
    if (strcmp (tmp, formats[i].alias) == 0) {
      exporter = &formats[i];
      break;
    }
  }
  if (exporter == NULL) {
    if (settings.format == NULL) {
      fprintf (stderr,
               _("ERROR: Cannot find supported format for filename '%s'.\n"),
               settings.outfile);
      exit (1);
    } else {
      fprintf (stderr,
               _("ERROR: Unsupported output format '%s'.\n"),
               settings.format);
      fprintf (stderr, see_help_msg);
      exit (1);
    }
  }
  g_free (tmp);

  /* If more than one schematic/symbol file was specified, check that
   * exporter supports multipage output. */
  if ((settings.infilec > 1) && !(exporter->flags & OUTPUT_MULTIPAGE)) {
    fprintf (stderr,
             _("ERROR: Selected output format does not support multipage output\n"));
    exit (1);
  }

  /* Load schematic files */
  while (optind < argc) {
    PAGE *page;
    tmp = argv[optind++];

    page = s_page_new (toplevel, tmp);
    if (!f_open (toplevel, page, tmp, &err)) {
      fprintf (stderr,
               _("ERROR: Failed to load '%s': %s\n"), tmp,
               err->message);
      exit (1);
    }
    if (g_chdir (original_cwd) != 0) {
      fprintf (stderr,
               _("ERROR: Failed to change directory to '%s': %s\n"),
               original_cwd, g_strerror (errno));
      exit (1);
    }
  }

  /* Create renderer */
  renderer = eda_renderer_new (NULL, NULL);
  if (settings.font != NULL) {
    g_object_set (renderer, "font-name", settings.font, NULL);
  }

  /* Make sure libgeda knows how to calculate the bounds of text
   * taking into account font etc. */
  o_text_set_rendered_bounds_func (toplevel,
                                   export_text_rendered_bounds,
                                   renderer);

  /* Create color map */
  render_color_map =
    g_array_sized_new (FALSE, FALSE, sizeof(GedaColor), MAX_COLORS);
  render_color_map =
    g_array_append_vals (render_color_map, print_colors, MAX_COLORS);
  if (!settings.color) {
    /* Create a black and white color map.  All non-background colors
     * are black. */
    GedaColor white = {~0, ~0, ~0, ~0, TRUE};
    GedaColor black = {0, 0, 0, ~0, TRUE};
    for (i = 0; i < MAX_COLORS; i++) {
      GedaColor *c = &g_array_index (render_color_map, GedaColor, i);
      if (!c->enabled) continue;

      if (c->a == 0) {
        c->enabled = FALSE;
        continue;
      }

      if (i == OUTPUT_BACKGROUND_COLOR) {
        *c = white;
      } else {
        *c = black;
      }
    }
  }
  eda_renderer_set_color_map (renderer, render_color_map);

  /* Render */
  exporter->func ();

  scm_dynwind_end ();
  exit (0);
}
예제 #15
0
파일: app.c 프로젝트: pasoev/guile-words
/* Initialise Guile and load the Scheme file containing procedures */
void init(void){
  scm_init_guile();
  scm_c_primitive_load ("../scm/words.scm");
}
예제 #16
0
int main()
{
	scm_init_guile();
	scm_shell(0, NULL);
}
예제 #17
0
파일: main.c 프로젝트: pmyadlowsky/qmx
int main(int argc, char **argv) {
	struct pollfd polls[MAX_POLL_ITEMS];
	int opt, background, fdin, nfds, watch_alsa;
	int con_in, msg_in;
	background = 0;
	watch_alsa = 0;
	client_name = DEFAULT_CLIENT_NAME;
	server_name = DEFAULT_SERVER_NAME;
	msg_port = DEFAULT_MSG_PORT;
	sampling_rate = DEFAULT_SAMPLING_RATE;
	period_frames = DEFAULT_PERIOD_SIZE;
	while ((opt = getopt(argc, argv, "adn:p:P:r:s:")) != -1) {
		switch (opt) {
			case 'a': watch_alsa = 1; break;
			case 'd': background = 1; break;
			case 'j': use_jack = 1; break;
			case 'n': client_name = optarg; break;
			case 'P': msg_port = atoi(optarg); break;
			case 'p': period_frames = atoi(optarg); break;
			case 'r': sampling_rate = atoi(optarg); break;
			case 's': server_name = optarg; break;
			default:
				fprintf(stderr, "invalid option: %c", opt);
				exit(1);
			}
		}
	if (background) {
		set_handler(SIGCHLD, sigsnag);
		if (fork() > 0) _exit(0);
		}
	set_handler(SIGINT, sigsnag);
	set_handler(SIGTERM, sigsnag);
	set_handler(SIGABRT, sigsnag);
	set_handler(SIGHUP, sigsnag);
	set_handler(SIGQUIT, sigsnag);
	scm_init_guile();
	init_env();
	if (use_jack) start_jack(NULL);
	else {
		size_t memsize = QMX_CHANNELS * period_frames * sizeof(sample_t);
		fixed_cauldron = (sample_t *)malloc(memsize);
		int ret = mlock(fixed_cauldron, memsize);
		if (ret == 0) log_msg("MIXMEM locked: %lu\n", memsize);
		else log_msg("MIXMEM not locked: %s\n", strerror(errno));
		}
	start_outbuffer();
	scm_c_define("jack-sampling-rate", scm_from_int(sampling_rate));
	while (optind < argc) {
		log_msg("load %s\n", argv[optind]);
		scm_c_primitive_load(argv[optind]);
		optind++;
		}
	fdin = fileno(stdin);
	nfds = 0;
	con_in = -1;
	if (!background) {
		con_in = nfds;
		polls[nfds].fd = fdin;
		polls[nfds].events = POLLIN;
		nfds++;
		}
	msg_in = -1;
	if (msg_socket() >= 0) {
		msg_in = nfds;
		polls[nfds].fd = msg_socket();
		polls[nfds].events = POLLIN;
		nfds++;
		}
	if (isatty(fdin)) rl_callback_handler_install(prompt, line_handler);
	running = 1;
	if (!use_jack) spawn_detached_thread(mix_thread_abs, NULL);
	while (running) {
		if (watch_alsa) check_card_event();
		if (poll(polls, nfds, POLL_TIMEOUT) < 1) continue;
		if ((con_in >= 0) && (polls[con_in].revents & POLLIN))
			process_line(fdin);
		if ((msg_in >= 0) && (polls[msg_in].revents & POLLIN))
			msg_process();
		}
	if (isatty(fdin)) rl_callback_handler_remove();
	shutdown_env();
	log_msg("bye!\n");
	cleanup();
	return 0;
	}
예제 #18
0
파일: guile.c 프로젝트: ers35/modserver
static int mod_init(lua_State *l)
{
  scm_init_guile();
  return 0;
}
예제 #19
0
int main(int argc, char **argv)
{
  int ret;

  scm_init_guile();
  cl_init_const();

  ret = test_scm_is_handle();
  printf("test that a handle is a handle: %d\n", ret);
  if (!ret)
    return 1;

  ret = test_scm_is_not_handle();
  printf("test that a bool is not handle: %d\n", ret);
  if (!ret)
    return 1;

  ret = test_equalp_handle();
  printf("test that a handle equals itself: %d\n", ret);
  if (!ret)
    return 1;

  ret = test_not_equalp_handle();
  printf("test that a handle does not equal another handle: %d\n", ret);
  if (!ret)
    return 1;

  ret = test_not_free_handle();
  printf("test that an unfreed handle has non-NULL SMOB data: %d\n", ret);
  if (!ret)
    return 1;

  ret = test_free_handle();
  printf("test that a freed handle has NULL SMOB data: %d\n", ret);
  if (!ret)
    return 1;

  printf("test that double frees of handles don't segfault\n");
  test_double_free_handle();

  printf("test that frees of a handle with string-based postfields doesn't segfault\n");
  test_free_handle_string_postfields();

#if SCM_MAJOR_VERSION != 1
  printf("test that frees of a handle with bytevector-based postfields doesn't segfault\n");
  test_free_handle_bytevector_postfields();
#endif

#define TEST_SLIST(x) \
  extern SCM x; \
  printf ("test that frees of a handle with a " #x " slist doesn't segfault\n"); \
  test_free_handle_slist_option(x); \
  printf ("test that frees of a handle with an empty " #x " slist don't segfault\n"); \
  test_free_handle_empty_slist_option(x)

  TEST_SLIST(cl_CURLOPT_HTTPHEADER);
  TEST_SLIST(cl_CURLOPT_HTTP200ALIASES);
  TEST_SLIST(cl_CURLOPT_MAIL_RCPT);
  TEST_SLIST(cl_CURLOPT_QUOTE);
  TEST_SLIST(cl_CURLOPT_POSTQUOTE);
  TEST_SLIST(cl_CURLOPT_PREQUOTE);
  TEST_SLIST(cl_CURLOPT_RESOLVE);
  TEST_SLIST(cl_CURLOPT_TELNETOPTIONS);

  ret = test_cl_is_handle_p__handle ();
  if (!ret)
    return 1;

  ret = test_cl_is_handle_p__true ();
  if (!ret)
    return 1;

  ret = test_can_convert_to_slist__slist ();
  if (!ret)
    return 1;

  ret = test_can_convert_to_slist__empty_list ();
  if (!ret)
    return 1;

  ret = test_can_convert_to_slist__list_of_integers ();
  if (!ret)
    return 1;

  ret = test_scm_convert_to_slist__slist ();
  if (!ret)
    return 1;

  ret = test_scm_convert_to_slist__empty_list ();
  if (!ret)
    return 1;

  ret = test_scm_convert_to_slist__list_of_integers ();
  if (!ret)
    return 1;

  return 0;
}
예제 #20
0
int main() {
    printf("Variante %d: %s\n", VARIANTE, VARIANTE_STRING);

#ifdef USE_GUILE
    scm_init_guile();
    /* register "executer" function in scheme */
    scm_c_define_gsubr("executer", 1, 0, 0, executer_wrapper);
#endif

    while (1) {
        //struct cmdline *l;
        char *line=0;
        //int i, j;
        char *prompt = "ensishell>";

        /* Readline use some internal memory structure that
           can not be cleaned at the end of the program. Thus
           one memory leak per command seems unavoidable yet */
        line = readline(prompt);
        if (line == 0 || ! strncmp(line,"exit", 4)) {
            terminate(line);
        }

        if(!strncmp(line,"jobs",4)) {
            print_bg(liste_children_bg);
        }

#ifdef USE_GNU_READLINE
        add_history(line);
#endif


#ifdef USE_GUILE
        /* The line is a scheme command */
        if (line[0] == '(') {
            char catchligne[strlen(line) + 256];
            sprintf(catchligne, "(catch #t (lambda () %s) (lambda (key . parameters) (display \"mauvaise expression/bug en scheme\n\")))", line);
            scm_eval_string(scm_from_locale_string(catchligne));
            free(line);
            continue;
        }
#endif
        update_bg(&liste_children_bg);
        executer(line);

        /* parsecmd free line and set it up to 0 */
        //l = parsecmd( & line);

        ///* If input stream closed, normal termination */
        //if (!l) {

        //    terminate(0);
        //}



        //if (l->err) {
        //    /* Syntax error, read another command */
        //    printf("error: %s\n", l->err);
        //    continue;
        //}

        //if (l->in) printf("in: %s\n", l->in);
        //if (l->out) printf("out: %s\n", l->out);
        //if (l->bg) printf("background (&)\n");

        ///* Display each command of the pipe */
        //for (i=0; l->seq[i]!=0; i++) {
        //    char **cmd = l->seq[i];
        //    printf("seq[%d]: ", i);
        //    for (j=0; cmd[j]!=0; j++) {
        //        printf("'%s' ", cmd[j]);
        //    }
        //    printf("\n");
        //}
    }

}