libgeda: Remove some exit() calls and assertions.
[geda-gaf/peter-b.git] / libgeda / src / g_register.c
blob21a16d0c0a089d7416601083bc4285d50d2e2ca3
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
22 #include <missing.h>
24 #include <stdio.h>
25 #include <sys/stat.h>
26 #ifdef HAVE_STDLIB_H
27 #include <stdlib.h>
28 #endif
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
33 #include "libgeda_priv.h"
35 #ifdef HAVE_LIBDMALLOC
36 #include <dmalloc.h>
37 #endif
39 /*! \brief */
40 struct gsubr_t {
41 char* name;
42 int req;
43 int opt;
44 int rst;
45 SCM (*fnc)();
48 /*! \brief */
49 static struct gsubr_t libgeda_funcs[] = {
50 { "eval-protected", 1, 1, 0, g_scm_eval_protected },
51 { "eval-string-protected", 1, 0, 0, g_scm_eval_string_protected },
53 { "component-library", 1, 1, 0, g_rc_component_library },
54 { "component-library-command", 3, 0, 0, g_rc_component_library_command },
55 { "component-library-funcs", 3, 0, 0, g_rc_component_library_funcs },
56 { "component-library-search", 1, 0, 0, g_rc_component_library_search },
57 { "source-library", 1, 0, 0, g_rc_source_library },
58 { "source-library-search", 1, 0, 0, g_rc_source_library_search },
60 { "world-size", 3, 0, 0, g_rc_world_size },
62 { "reset-component-library", 0, 0, 0, g_rc_reset_component_library },
63 { "reset-source-library", 0, 0, 0, g_rc_reset_source_library },
65 { "untitled-name", 1, 0, 0, g_rc_untitled_name },
66 { "scheme-directory", 1, 0, 0, g_rc_scheme_directory },
67 { "bitmap-directory", 1, 0, 0, g_rc_bitmap_directory },
68 { "bus-ripper-symname", 1, 0, 0, g_rc_bus_ripper_symname },
69 { "postscript-prolog", 1, 0, 0, g_rc_postscript_prolog },
70 { "attribute-promotion", 1, 0, 0, g_rc_attribute_promotion },
71 { "promote-invisible", 1, 0, 0, g_rc_promote_invisible },
72 { "keep-invisible", 1, 0, 0, g_rc_keep_invisible },
73 { "always-promote-attributes",1, 0, 0, g_rc_always_promote_attributes },
74 { "print-color-map", 0, 1, 0, g_rc_print_color_map },
75 { NULL, 0, 0, 0, NULL } };
77 /*! \brief Register all libgeda functions with scheme.
78 * \par Function Description
79 * Creates g_subr_t objects to make g_rc_* functions that are defined
80 * in g_rc.c visible to Scheme.
82 void g_register_libgeda_funcs (void)
84 struct gsubr_t *tmp = libgeda_funcs;
86 while (tmp->name != NULL) {
87 scm_c_define_gsubr (tmp->name, tmp->req, tmp->opt, tmp->rst, tmp->fnc);
88 tmp++;
93 /*! \brief Register some libgeda directories with Scheme.
94 * \par Function Description
95 * Ensures that the default gEDA Scheme directory is added to the
96 * Guile load path.
98 void
99 g_register_libgeda_dirs (void)
101 char *scheme_dir;
103 scheme_dir = g_build_filename (s_path_sys_data (), "scheme", NULL);
104 g_rc_scheme_directory (scm_from_utf8_string (scheme_dir));
105 g_free (scheme_dir);