1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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., 59 Temple Place, Suite 330, Boston, MA 02111 USA
38 #include "libgeda_priv.h"
40 #ifdef HAVE_LIBDMALLOC
44 /*! \todo Finish function documentation!!!
46 * \par Function Description
49 int vstbl_lookup_str(const vstbl_entry
*table
,
50 int size
, const char *str
)
54 for(i
= 0; i
< size
; i
++) {
55 if(strcmp(table
[i
].m_str
, str
) == 0) {
62 /*! \todo Finish function documentation!!!
64 * \par Function Description
67 int vstbl_get_val(const vstbl_entry
*table
, int index
)
69 return table
[index
].m_val
;
72 /*! \todo Finish function documentation!!!
74 * \par Function Description
77 SCM
g_rc_mode_general(SCM scmmode
,
80 const vstbl_entry
*table
,
87 SCM_ASSERT (scm_is_string (scmmode
), scmmode
,
92 mode
= scm_to_locale_string(scmmode
);
93 scm_dynwind_free(mode
);
95 index
= vstbl_lookup_str(table
, table_size
, mode
);
97 if(index
== table_size
) {
99 "Invalid mode [%s] passed to %s\n",
104 *mode_var
= vstbl_get_val(table
, index
);
113 extern GHashTable
*font_char_to_file
;
115 /*! \brief Reads the gafrc file.
116 * \par Function Description
117 * This is the function which actually reads in the RC file.
118 * First, it looks in a list of previously read RC files. If the file has
119 * already been read, it just says OK. After reading the file, it places
120 * the filename in the list of read files.
122 * \param [in] toplevel The TOPLEVEL object.
123 * \param [in] fname RC file name to read.
124 * \param [in] ok_msg Message to print if file is read ok.
125 * \param [in] err_msg Message to print if file read error occurs
126 * \return 1 on success, 0 otherwise.
128 gint
g_rc_parse_general(TOPLEVEL
*toplevel
,
130 const gchar
*ok_msg
, const gchar
*err_msg
)
132 gint found_rc
= FALSE
;
133 GList
*found_rc_filename_element
;
135 /* First see if fname is in list of previously read RC files. */
136 found_rc_filename_element
= g_list_find_custom(toplevel
->RC_list
,
137 (gconstpointer
) fname
,
138 (GCompareFunc
) strcmp
);
139 if (found_rc_filename_element
!= NULL
) {
140 /* We've already read this one in. */
141 s_log_message(_("RC file [%s] already read in.\n"), fname
);
145 /* Now try to read in contents of RC file. */
146 if (access (fname
, R_OK
) == 0) {
149 /* Everything was OK. Now add this file to list of read RC files. */
150 toplevel
->RC_list
= g_list_append (toplevel
->RC_list
,
152 s_log_message (ok_msg
, fname
);
155 s_log_message (err_msg
, fname
);
162 /*! \brief Read gEDA root path from RC file.
163 * \par Function Description
164 * This function will read the RC file and parse the root path for gEDA.
166 * \return String containing rc root path
168 * \warning Do not free the returned character string.
170 const gchar
* g_rc_parse_path(void)
172 const gchar
*rc_path
;
174 if (g_strcasecmp (GEDARCDIR
, "none") == 0) {
175 /* rc dir not specified at configure time, so search for config in */
176 /* the normal GEDADATA directory */
177 rc_path
= g_getenv ("GEDADATA");
179 /* rc path specified at configure time, always return specified path */
186 /*! \brief Parses a system RC file.
187 * \par Function Description
188 * This function will open and parse a system rc file.
190 * \param [in] toplevel The TOPLEVEL object.
191 * \param [in] rcname System RC file name to parse.
192 * \return 1 on success, 0 on failure.
194 gint
g_rc_parse_system_rc(TOPLEVEL
*toplevel
, const gchar
*rcname
)
196 const gchar
*geda_data
= g_getenv ("GEDADATA");
200 gchar
*ok_msg
, *err_msg
;
202 if (geda_data
== NULL
) {
203 fprintf(stderr
, "You must set the GEDADATA environment variable!\n");
207 tmp
= g_strconcat (g_rc_parse_path (),
211 filename
= f_normalize_filename (tmp
, NULL
);
212 if (filename
== NULL
) {
216 ok_msg
= g_strdup_printf (_("Read system-%s file [%%s]\n"),
218 err_msg
= g_strdup_printf (_("Did not find required system-%s file [%%s]\n"),
220 found_rc
= g_rc_parse_general(toplevel
, filename
, ok_msg
, err_msg
);
230 /*! \brief Parse a RC file in users home directory.
231 * \par Function Description
232 * This function will open and parse a RC file in the users home directory.
234 * \param [in] toplevel The TOPLEVEL object.
235 * \param [in] rcname User's RC file name.
236 * \return 1 on success, 0 on failure.
238 gint
g_rc_parse_home_rc(TOPLEVEL
*toplevel
, const gchar
*rcname
)
240 const gchar
*home
= g_getenv ("HOME");
244 gchar
*ok_msg
, *err_msg
;
250 tmp
= g_build_filename (home
, ".gEDA", rcname
, NULL
);
251 filename
= f_normalize_filename (tmp
, NULL
);
252 if (filename
== NULL
) {
257 ok_msg
= g_strdup_printf (_("Read ~/.gEDA/%s file [%%s]\n"),
259 err_msg
= g_strdup_printf (_("Did not find optional ~/.gEDA/%s file [%%s]\n"),
261 found_rc
= g_rc_parse_general(toplevel
, filename
, ok_msg
, err_msg
);
271 /*! \brief Parse rc file in current working directory.
272 * \par Function Description
273 * This function will open and parse a RC file in the current working directory.
275 * \param [in] toplevel The TOPLEVEL object.
276 * \param [in] rcname Local directory RC file name.
277 * \return 1 on success, 0 on failure.
279 gint
g_rc_parse_local_rc(TOPLEVEL
*toplevel
, const gchar
*rcname
)
286 filename
= f_normalize_filename (rcname
, NULL
);
287 if (filename
== NULL
) {
291 ok_msg
= g_strdup_printf (_("Read local %s file [%%s]\n"),
293 err_msg
= g_strdup_printf (_("Did not find optional local %s file [%%s]\n"),
295 found_rc
= g_rc_parse_general(toplevel
, filename
, ok_msg
, err_msg
);
304 /*! \brief Parse a RC file from a specified location.
305 * \par Function Description
306 * This function will open and parse a RC file from a specified location.
308 * \param [in] toplevel The TOPLEVEL object.
309 * \param [in] rcname Specified location RC file name.
310 * \return 1 on success, 0 on failure.
312 gint
g_rc_parse_specified_rc(TOPLEVEL
*toplevel
, const gchar
*rcname
)
320 if (rcname
== NULL
) {
324 filename
= f_normalize_filename (rcname
, NULL
);
325 if (filename
== NULL
) {
329 rcbasename
= g_path_get_basename (rcname
);
331 ok_msg
= g_strdup_printf (_("Read specified %s file [%%s]\n"),
333 err_msg
= g_strdup_printf (_("Did not find specified %s file [%%s]\n"),
335 found_rc
= g_rc_parse_general(toplevel
, filename
, ok_msg
, err_msg
);
345 /*! \brief General RC file parsing function.
346 * \par Function Description
347 * This function will check for System, HOME and Local RC files matching
348 * the rcname input parameter. If none of those three are found it will
349 * search for the specified_rc_filename. When none are found it will
350 * call exit(-1) to terminate the program.
352 * \param [in] toplevel The TOPLEVEL object.
353 * \param [in] rcname RC file name.
354 * \param [in] specified_rc_filename Specific location RC file name.
355 * \return calls exit(-1) when no RC file matching either rcname or
356 * specified_rc_filename is found.
358 void g_rc_parse(TOPLEVEL
*toplevel
,
359 const gchar
*rcname
, const gchar
*specified_rc_filename
)
364 /* set the GEDADATARC environment variable so that the rc files */
365 /* know where to look for others */
366 rc_path
= f_normalize_filename (g_rc_parse_path (), NULL
);
368 g_setenv ("GEDADATARC", rc_path
, TRUE
);
371 /* visit rc files in order */
372 /* Changed by SDB 1.2.2005 in response to Peter Kaiser's bug report.
373 * Read gafrc files first */
374 found_rc
|= g_rc_parse_system_rc(toplevel
, "gafrc");
375 found_rc
|= g_rc_parse_home_rc(toplevel
, "gafrc");
376 found_rc
|= g_rc_parse_local_rc(toplevel
, "gafrc");
377 /* continue support for individual rc files for each program. */
378 found_rc
|= g_rc_parse_system_rc(toplevel
, rcname
);
379 found_rc
|= g_rc_parse_home_rc(toplevel
, rcname
);
380 found_rc
|= g_rc_parse_local_rc(toplevel
, rcname
);
382 /* New fcn introduced by SDB to consolidate this & make it available
383 * for other programs */
384 found_rc
|= g_rc_parse_specified_rc(toplevel
, specified_rc_filename
);
386 /* Oh well, I couldn't find any rcfile, exit! */
388 /*! \todo these two are basically the
391 s_log_message(_("Could not find any %s file!\n"), rcname
);
397 * \par Function Description
400 * \param [in] name Optional descriptive name for library directory.
401 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
403 SCM
g_rc_component_library(SCM path
, SCM name
)
406 char *namestr
= NULL
;
409 SCM_ASSERT (scm_is_string (path
), path
,
410 SCM_ARG1
, "component-library");
412 scm_dynwind_begin(0);
414 if (name
!= SCM_UNDEFINED
) {
415 SCM_ASSERT (scm_is_string (name
), name
,
416 SCM_ARG2
, "component-library");
417 namestr
= scm_to_locale_string(name
);
418 scm_dynwind_free(namestr
);
421 /* take care of any shell variables */
422 path_chars
= scm_to_locale_string(path
);
423 scm_dynwind_free(path_chars
);
424 string
= s_expand_env_variables(path_chars
);
427 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
429 "Invalid path [%s] passed to component-library\n",
436 if (g_path_is_absolute (string
)) {
437 s_clib_add_directory (string
, namestr
);
439 gchar
*cwd
= g_get_current_dir ();
441 temp
= g_build_filename (cwd
, string
, NULL
);
442 s_clib_add_directory (temp
, namestr
);
453 /*! \brief Guile callback for adding library commands.
454 * \par Function Description
455 * Callback function for the "component-library-command" Guile
456 * function, which can be used in the rc files to add a command to
457 * the component library.
459 * \param [in] listcmd command to get a list of symbols
460 * \param [in] getcmd command to get a symbol from the library
461 * \param [in] name Optional descriptive name for component source.
462 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
464 SCM
g_rc_component_library_command (SCM listcmd
, SCM getcmd
,
467 const CLibSource
*src
;
468 gchar
*lcmdstr
, *gcmdstr
;
469 char *listcmd_c
, *getcmd_c
, *namestr
;
471 SCM_ASSERT (scm_is_string (listcmd
), listcmd
, SCM_ARG1
,
472 "component-library-command");
473 SCM_ASSERT (scm_is_string (getcmd
), getcmd
, SCM_ARG2
,
474 "component-library-command");
475 SCM_ASSERT (scm_is_string (name
), name
, SCM_ARG3
,
476 "component-library-command");
478 scm_dynwind_begin(0);
480 /* take care of any shell variables */
481 /*! \bug this may be a security risk! */
482 listcmd_c
= scm_to_locale_string(listcmd
);
483 scm_dynwind_free(listcmd_c
);
484 lcmdstr
= s_expand_env_variables(listcmd_c
);
485 scm_dynwind_unwind_handler(&g_free
, lcmdstr
, SCM_F_WIND_EXPLICITLY
);
487 /* take care of any shell variables */
488 /*! \bug this may be a security risk! */
489 getcmd_c
= scm_to_locale_string(getcmd
);
490 scm_dynwind_free(getcmd_c
);
491 gcmdstr
= s_expand_env_variables(getcmd_c
);
492 scm_dynwind_unwind_handler(&g_free
, gcmdstr
, SCM_F_WIND_EXPLICITLY
);
494 namestr
= scm_to_locale_string (name
);
495 scm_dynwind_free(namestr
);
497 src
= s_clib_add_command (lcmdstr
, gcmdstr
, namestr
);
501 if (src
!= NULL
) return SCM_BOOL_T
;
506 /*! \brief Guile callback for adding library functions.
507 * \par Function Description
508 * Callback function for the "component-library-funcs" Guile
509 * function, which can be used in the rc files to add a set of Guile
510 * procedures for listing and generating symbols.
512 * \param [in] listfunc A Scheme procedure which takes no arguments
513 * and returns a Scheme list of component names.
514 * \param [in] getfunc A Scheme procedure which takes a component
515 * name as an argument and returns a symbol
516 * encoded in a string in gEDA format, or the \b
517 * \#f if the component name is unknown.
518 * \param [in] name A descriptive name for this component source.
520 * \returns SCM_BOOL_T on success, SCM_BOOL_F otherwise.
522 SCM
g_rc_component_library_funcs (SCM listfunc
, SCM getfunc
, SCM name
)
524 SCM_ASSERT (scm_is_true (scm_procedure_p (listfunc
)), listfunc
, SCM_ARG1
,
525 "component-library-funcs");
526 SCM_ASSERT (scm_is_true (scm_procedure_p (getfunc
)), getfunc
, SCM_ARG2
,
527 "component-library-funcs");
528 SCM_ASSERT (scm_is_string (name
), name
, SCM_ARG1
,
529 "component-library-funcs");
531 if (s_clib_add_scm(listfunc
, getfunc
, name
) != NULL
) {
538 /*! \todo Finish function description!!!
540 * \par Function Description
543 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
545 SCM
g_rc_component_library_search(SCM path
)
552 SCM_ASSERT (scm_is_string (path
), path
,
553 SCM_ARG1
, "component-library-search");
555 scm_dynwind_begin(0);
557 /* take care of any shell variables */
558 path_chars
= scm_to_locale_string(path
);
559 scm_dynwind_free(path_chars
);
560 string
= s_expand_env_variables(path_chars
);
563 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
565 "Invalid path [%s] passed to component-library-search\n",
572 dir
= g_dir_open (string
, 0, NULL
);
575 "Invalid path [%s] passed to component-library-search\n",
582 while ((entry
= g_dir_read_name (dir
))) {
583 /* don't do . and .. and special case font */
584 if ((g_strcasecmp (entry
, ".") != 0) &&
585 (g_strcasecmp (entry
, "..") != 0) &&
586 (g_strcasecmp (entry
, "font") != 0))
588 gchar
*fullpath
= g_build_filename (string
, entry
, NULL
);
590 if (g_file_test (fullpath
, G_FILE_TEST_IS_DIR
)) {
591 if (g_path_is_absolute (fullpath
)) {
592 s_clib_add_directory (fullpath
, NULL
);
594 gchar
*cwd
= g_get_current_dir ();
596 temp
= g_build_filename (cwd
, fullpath
, NULL
);
597 s_clib_add_directory (temp
, NULL
);
612 /*! \todo Finish function description!!!
614 * \par Function Description
617 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
619 SCM
g_rc_source_library(SCM path
)
624 SCM_ASSERT (scm_is_string (path
), path
,
625 SCM_ARG1
, "source-library");
627 scm_dynwind_begin(0);
629 /* take care of any shell variables */
630 path_chars
= scm_to_locale_string(path
);
631 scm_dynwind_free(path_chars
);
632 string
= s_expand_env_variables(path_chars
);
635 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
637 "Invalid path [%s] passed to source-library\n",
644 if (g_path_is_absolute (string
)) {
645 s_slib_add_entry (string
);
647 gchar
*cwd
= g_get_current_dir ();
649 temp
= g_build_filename (cwd
, string
, NULL
);
650 s_slib_add_entry (temp
);
661 /*! \todo Finish function description!!!
663 * \par Function Description
666 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
668 SCM
g_rc_source_library_search(SCM path
)
675 SCM_ASSERT (scm_is_string (path
), path
,
676 SCM_ARG1
, "source-library-search");
678 scm_dynwind_begin(0);
680 /* take care of any shell variables */
681 path_chars
= scm_to_locale_string(path
);
682 scm_dynwind_free(path_chars
);
683 string
= s_expand_env_variables(path_chars
);
686 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
688 "Invalid path [%s] passed to source-library-search\n",
695 dir
= g_dir_open (string
, 0, NULL
);
698 "Invalid path [%s] passed to source-library-search\n",
705 while ((entry
= g_dir_read_name (dir
))) {
706 /* don't do . and .. and special case font */
707 if ((g_strcasecmp (entry
, ".") != 0) &&
708 (g_strcasecmp (entry
, "..") != 0) &&
709 (g_strcasecmp (entry
, "font") != 0))
711 gchar
*fullpath
= g_build_filename (string
, entry
, NULL
);
713 if (g_file_test (fullpath
, G_FILE_TEST_IS_DIR
)) {
714 if (s_slib_uniq (fullpath
)) {
715 if (g_path_is_absolute (fullpath
)) {
716 s_slib_add_entry (fullpath
);
718 gchar
*cwd
= g_get_current_dir ();
720 temp
= g_build_filename (cwd
, fullpath
, NULL
);
721 s_slib_add_entry (temp
);
737 /*! \todo Finish function description!!!
739 * \par Function Description
744 * \return SCM_BOOL_T always.
746 SCM
g_rc_world_size(SCM width
, SCM height
, SCM border
)
747 #define FUNC_NAME "world-size"
749 int i_width
, i_height
, i_border
;
750 int init_right
, init_bottom
;
752 SCM_ASSERT (SCM_NIMP (width
) && SCM_REALP (width
), width
,
753 SCM_ARG1
, FUNC_NAME
);
754 SCM_ASSERT (SCM_NIMP (height
) && SCM_REALP (height
), height
,
755 SCM_ARG2
, FUNC_NAME
);
756 SCM_ASSERT (SCM_NIMP (border
) && SCM_REALP (border
), border
,
757 SCM_ARG3
, FUNC_NAME
);
759 /* yes this is legit, we are casing the resulting double to an int */
760 i_width
= (int) (scm_to_double(width
) * MILS_PER_INCH
);
761 i_height
= (int) (scm_to_double(height
) * MILS_PER_INCH
);
762 i_border
= (int) (scm_to_double(border
) * MILS_PER_INCH
);
764 PAPERSIZEtoWORLD(i_width
, i_height
, i_border
,
765 &init_right
, &init_bottom
);
768 printf("%d %d\n", i_width
, i_height
);
769 printf("%d %d\n", init_right
, init_bottom
);
772 default_init_right
= init_right
;
773 default_init_bottom
= init_bottom
;
779 /*! \todo Finish function description!!!
781 * \par Function Description
784 * \return SCM_BOOL_T always.
786 SCM
g_rc_untitled_name(SCM name
)
788 SCM_ASSERT (scm_is_string (name
), name
,
789 SCM_ARG1
, "untitled-name");
791 g_free(default_untitled_name
);
793 default_untitled_name
= g_strdup_scm_string(name
);
798 /*! \todo Finish function description!!!
800 * \par Function Description
803 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
805 SCM
g_rc_font_directory(SCM path
)
810 SCM_ASSERT (scm_is_string (path
), path
,
811 SCM_ARG1
, "font-directory");
813 scm_dynwind_begin(0);
815 /* take care of any shell variables */
816 path_chars
= scm_to_locale_string(path
);
817 scm_dynwind_free(path_chars
);
818 string
= s_expand_env_variables(path_chars
);
821 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
823 "Invalid path [%s] passed to font-directory\n",
830 g_free(default_font_directory
);
831 default_font_directory
= string
;
837 /*! \todo Finish function description!!!
839 * \par Function Description
842 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
844 SCM
g_rc_scheme_directory(SCM path
)
849 SCM_ASSERT (scm_is_string (path
), path
,
850 SCM_ARG1
, "scheme-directory");
852 scm_dynwind_begin(0);
854 /* take care of any shell variables */
855 path_chars
= scm_to_locale_string(path
);
856 scm_dynwind_free(path_chars
);
857 string
= s_expand_env_variables(path_chars
);
860 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
862 "Invalid path [%s] passed to scheme-directory\n",
869 g_free(default_scheme_directory
);
870 default_scheme_directory
= string
;
876 /*! \todo Finish function description!!!
878 * \par Function Description
881 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
883 SCM
g_rc_bitmap_directory(SCM path
)
888 SCM_ASSERT (scm_is_string (path
), path
,
889 SCM_ARG1
, "bitmap-directory");
891 scm_dynwind_begin(0);
893 /* take care of any shell variables */
894 path_chars
= scm_to_locale_string(path
);
895 scm_dynwind_free(path_chars
);
896 string
= s_expand_env_variables(path_chars
);
899 if (!g_file_test (string
, G_FILE_TEST_IS_DIR
)) {
901 "Invalid path [%s] passed to bitmap-directory\n",
908 g_free(default_bitmap_directory
);
909 default_bitmap_directory
= string
;
915 /*! \todo Finish function description!!!
917 * \par Function Description
919 * \param [in] scmsymname
920 * \return SCM_BOOL_T always.
922 SCM
g_rc_bus_ripper_symname(SCM scmsymname
)
924 SCM_ASSERT (scm_is_string (scmsymname
), scmsymname
,
925 SCM_ARG1
, "bus-ripper-symname");
927 g_free(default_bus_ripper_symname
);
928 default_bus_ripper_symname
= g_strdup_scm_string(scmsymname
);
933 /*! \todo Finish function description!!!
935 * \par Function Description
937 * \param [in] scmsymname
938 * \return SCM_BOOL_T always.
940 SCM
g_rc_postscript_prolog(SCM scmsymname
)
943 SCM_ASSERT (scm_is_string (scmsymname
), scmsymname
,
944 SCM_ARG1
, "postsript-prolog");
946 scm_dynwind_begin(0);
948 g_free(default_postscript_prolog
);
950 /* take care of any shell variables */
951 sym_chars
= scm_to_locale_string(scmsymname
);
952 scm_dynwind_free(sym_chars
);
953 default_postscript_prolog
= s_expand_env_variables(sym_chars
);
959 /*! \todo Finish function description!!!
961 * \par Function Description
963 * \return SCM_BOOL_T always.
965 SCM
g_rc_reset_component_library(void)
972 /*! \todo Finish function description!!!
974 * \par Function Description
976 * \return SCM_BOOL_T always.
978 SCM
g_rc_reset_source_library(void)
986 /*! \todo Finish function description!!!
988 * \par Function Description
990 * \param [in] scmcharstr
991 * \param [in] scmfilename
992 * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
994 SCM
g_rc_map_font_character_to_file(SCM scmcharstr
, SCM scmfilename
)
996 gchar
*charstr
, *filename
;
999 SCM_ASSERT (scm_is_string (scmcharstr
), scmcharstr
,
1000 SCM_ARG1
, "map-font-character-to-file");
1001 SCM_ASSERT (scm_is_string (scmfilename
), scmfilename
,
1002 SCM_ARG2
, "map-font-character-to-file");
1004 scm_dynwind_begin(0);
1006 charstr
= scm_to_locale_string(scmcharstr
);
1007 filename
= scm_to_locale_string(scmfilename
);
1008 scm_dynwind_free(charstr
);
1009 scm_dynwind_free(filename
);
1011 if (charstr
== NULL
|| filename
== NULL
) {
1013 "%s requires two strings as parameters\n",
1014 "map-font-character-to-file"
1020 /* take care of expansion of any shell variables in filename */
1021 filename
= s_expand_env_variables (filename
);
1023 character
= g_utf8_get_char_validated (charstr
, -1);
1025 /* insert the new character declaration in the hash table */
1026 g_hash_table_insert (font_char_to_file
,
1027 GUINT_TO_POINTER ((guint
)character
),
1034 /*! \todo Finish function documentation!!!
1036 * \par Function Description
1039 SCM
g_rc_attribute_promotion(SCM mode
)
1041 static const vstbl_entry mode_table
[] = {
1042 {TRUE
, "enabled" },
1043 {FALSE
, "disabled"},
1046 RETURN_G_RC_MODE("attribute-promotion",
1047 default_attribute_promotion
);
1050 /*! \todo Finish function documentation!!!
1052 * \par Function Description
1055 SCM
g_rc_promote_invisible(SCM mode
)
1057 static const vstbl_entry mode_table
[] = {
1058 {TRUE
, "enabled" },
1059 {FALSE
, "disabled"},
1062 RETURN_G_RC_MODE("promote-invisible",
1063 default_promote_invisible
);
1066 /*! \todo Finish function documentation!!!
1068 * \par Function Description
1071 SCM
g_rc_keep_invisible(SCM mode
)
1073 static const vstbl_entry mode_table
[] = {
1074 {TRUE
, "enabled" },
1075 {FALSE
, "disabled"},
1078 RETURN_G_RC_MODE("keep-invisible",
1079 default_keep_invisible
);
1082 /*! \todo Finish function description!!!
1084 * \par Function Description
1086 * \param [in] attrlist
1087 * \return SCM_BOOL_T always.
1089 SCM
g_rc_always_promote_attributes(SCM attrlist
)
1096 g_list_foreach(default_always_promote_attributes
, (GFunc
)g_free
, NULL
);
1097 g_list_free(default_always_promote_attributes
);
1099 if (scm_is_string (attrlist
)) {
1100 char *attrlist_chars
;
1102 s_log_message(_("WARNING: using a string for 'always-promote-attributes'"
1103 " is deprecated. Use a list of strings instead\n"));
1105 /* convert the space separated strings into a GList */
1106 attrlist_chars
= scm_to_locale_string(attrlist
);
1107 attr2
= g_strsplit(attrlist_chars
, " ", 0);
1108 free(attrlist_chars
);
1109 for (i
=0; attr2
[i
] != NULL
; i
++) {
1110 if (strlen(attr2
[i
]) > 0) {
1111 list
= g_list_prepend(list
, g_strdup(attr2
[i
]));
1117 SCM_ASSERT(scm_list_p(attrlist
), attrlist
, SCM_ARG1
, "always-promote-attributes");
1118 /* convert the scm list into a GList */
1119 for (rest
= attrlist
; !scm_is_null(rest
); rest
= SCM_CDR(rest
)) {
1120 SCM_ASSERT(scm_is_string(SCM_CAR(rest
)), SCM_CAR(rest
), SCM_ARG1
,
1121 "always-promote-attribute: list element is not a string");
1122 attr
= g_strdup_scm_string(SCM_CAR(rest
));
1123 list
= g_list_prepend(list
, attr
);
1127 default_always_promote_attributes
= g_list_reverse(list
);