libgeda

g_rc.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * libgeda - gEDA's library
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00027 #include <config.h>
00028 #include <missing.h>
00029 
00030 #include <errno.h>
00031 #include <stdio.h>
00032 #include <sys/stat.h>
00033 #include <ctype.h>
00034 #ifdef HAVE_STRING_H
00035 #include <string.h>
00036 #endif
00037 #ifdef HAVE_STDLIB_H
00038 #include <stdlib.h>
00039 #endif
00040 #ifdef HAVE_UNISTD_H
00041 #include <unistd.h>
00042 #endif
00043 
00044 #include "libgeda_priv.h"
00045 
00046 #ifdef HAVE_LIBDMALLOC
00047 #include <dmalloc.h>
00048 #endif
00049 
00055 int vstbl_lookup_str(const vstbl_entry *table,
00056                 int size, const char *str)
00057 {
00058   int i;
00059 
00060   for(i = 0; i < size; i++) {
00061     if(strcmp(table[i].m_str, str) == 0) {
00062       break;
00063     }
00064   }
00065   return i;
00066 }
00067 
00073 int vstbl_get_val(const vstbl_entry *table, int index)
00074 {
00075   return table[index].m_val;
00076 }
00077 
00083 SCM g_rc_mode_general(SCM scmmode, 
00084                       const char *rc_name,
00085                       int *mode_var,
00086                       const vstbl_entry *table,
00087                       int table_size)
00088 {
00089   SCM ret;
00090   int index;
00091   char *mode;
00092 
00093   SCM_ASSERT (scm_is_string (scmmode), scmmode,
00094               SCM_ARG1, rc_name);
00095   
00096   mode = scm_to_utf8_string (scmmode);
00097   
00098   index = vstbl_lookup_str(table, table_size, mode);
00099   /* no match? */
00100   if(index == table_size) {
00101     fprintf(stderr,
00102             "Invalid mode [%s] passed to %s\n",
00103             mode,
00104             rc_name);
00105     ret = SCM_BOOL_F;
00106   } else {
00107     *mode_var = vstbl_get_val(table, index);
00108     ret = SCM_BOOL_T;
00109   }
00110 
00111   free (mode);
00112 
00113   return ret;
00114 }
00115 
00127 gboolean
00128 g_rc_parse_system (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
00129 {
00130   gchar *sysname = NULL;
00131   gboolean status;
00132 
00133   /* Default to gafrc */
00134   rcname = (rcname != NULL) ? rcname : "gafrc";
00135 
00136   sysname = g_strdup_printf ("system-%s", rcname);
00137   status = g_rc_parse_local (toplevel, sysname, s_path_sys_config (), err);
00138   g_free (sysname);
00139   return status;
00140 }
00141 
00153 gboolean
00154 g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
00155 {
00156   /* Default to gafrc */
00157   rcname = (rcname != NULL) ? rcname : "gafrc";
00158 
00159   return g_rc_parse_local (toplevel, rcname, s_path_user_config (), err);
00160 }
00161 
00178 gboolean
00179 g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path,
00180                   GError **err)
00181 {
00182   gchar *dir = NULL;
00183   gchar *rcfile = NULL;
00184   gboolean status;
00185   g_return_val_if_fail ((toplevel != NULL), FALSE);
00186 
00187   /* Default to gafrc */
00188   rcname = (rcname != NULL) ? rcname : "gafrc";
00189   /* Default to cwd */
00190   path = (path != NULL) ? path : ".";
00191 
00192   /* If path isn't a directory, get the dirname. */
00193   if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
00194     dir = g_strdup (path);
00195   } else {
00196     dir = g_path_get_dirname (path);
00197   }
00198 
00199   rcfile = g_build_filename (dir, rcname, NULL);
00200   status = g_rc_parse_file (toplevel, rcfile, err);
00201 
00202   g_free (dir);
00203   g_free (rcfile);
00204   return status;
00205 }
00206 
00221 static gboolean
00222 g_rc_try_mark_read (TOPLEVEL *toplevel, gchar *filename, GError **err)
00223 {
00224   GList *found = NULL;
00225   g_return_val_if_fail ((toplevel != NULL), FALSE);
00226   g_return_val_if_fail ((filename != NULL), FALSE);
00227 
00228   /* Test if marked read already */
00229   found = g_list_find_custom (toplevel->RC_list, filename,
00230                               (GCompareFunc) strcmp);
00231   if (found != NULL) {
00232     g_set_error (err, EDA_ERROR, EDA_ERROR_RC_TWICE,
00233                  _("Config file already loaded"));
00234     return FALSE;
00235   }
00236 
00237   toplevel->RC_list = g_list_append (toplevel->RC_list, filename);
00238   /* N.b. don't free name_norm here; it's stored in the TOPLEVEL. */
00239   return TRUE;
00240 }
00241 
00251 gboolean
00252 g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
00253 {
00254   gchar *name_norm = NULL;
00255   GError *tmp_err = NULL;
00256   g_return_val_if_fail ((toplevel != NULL), FALSE);
00257   g_return_val_if_fail ((rcfile != NULL), FALSE);
00258 
00259   /* Normalise filename */
00260   name_norm = f_normalize_filename (rcfile, &tmp_err);
00261   if (name_norm == NULL) goto parse_file_error;
00262 
00263   /* Attempt to load the rc file, if it hasn't been loaded already.
00264    * If g_rc_try_mark_read() succeeds, it stores name_norm in
00265    * toplevel, so we *don't* free it. */
00266   if (g_rc_try_mark_read (toplevel, name_norm, &tmp_err)
00267       && g_read_file (toplevel, name_norm, &tmp_err)) {
00268     s_log_message (_("Parsed config from [%s]\n"), name_norm);
00269     return TRUE;
00270   }
00271 
00272  parse_file_error:
00273   /* Copy tmp_err into err, with a prefixed message. */
00276   if (err == NULL) {
00277     g_error_free (tmp_err);
00278   } else {
00279     gchar *orig_msg = tmp_err->message;
00280     tmp_err->message =
00281       g_strdup_printf (_("Unable to parse config from [%s]: %s"),
00282                        (name_norm != NULL) ? name_norm : rcfile, orig_msg);
00283     g_free (orig_msg);
00284     *err = tmp_err;
00285   }
00286   g_free (name_norm);
00287   return FALSE;
00288 }
00289 
00290 static void
00291 g_rc_parse__process_error (GError **err, const gchar *pname)
00292 {
00293   char *pbase;
00294 
00295   /* Take no chances; if err was not set for some reason, bail out. */
00296   if (*err == NULL) {
00297     const gchar *msgl =
00298       _("ERROR: An unknown error occurred while parsing configuration files.");
00299     s_log_message ("%s\n", msgl);
00300     fprintf(stderr, "%s\n", msgl);
00301 
00302   } else {
00303     /* Config files are allowed to be missing or skipped; check for
00304      * this. */
00305     if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT) ||
00306         g_error_matches (*err, EDA_ERROR, EDA_ERROR_RC_TWICE)) {
00307       return;
00308     }
00309 
00310     s_log_message (_("ERROR: %s\n"), (*err)->message);
00311     fprintf (stderr, _("ERROR: %s\n"), (*err)->message);
00312   }
00313 
00314   /* g_path_get_basename() allocates memory, but we don't care
00315    * because we're about to exit. */
00316   pbase = g_path_get_basename (pname);
00317   fprintf (stderr, _("ERROR: The %s log may contain more information.\n"),
00318            pbase);
00319   exit (1);
00320 }
00321 
00340 void
00341 g_rc_parse (TOPLEVEL *toplevel, const gchar *pname,
00342             const gchar *rcname, const gchar *rcfile)
00343 {
00344   g_rc_parse_handler (toplevel, rcname, rcfile,
00345                       (ConfigParseErrorFunc) g_rc_parse__process_error,
00346                       (void *) pname);
00347 }
00348 
00368 void
00369 g_rc_parse_handler (TOPLEVEL *toplevel,
00370                     const gchar *rcname, const gchar *rcfile,
00371                     ConfigParseErrorFunc handler, void *user_data)
00372 {
00373   GError *err = NULL;
00374 
00375 #ifdef HANDLER_DISPATCH
00376 #  error HANDLER_DISPATCH already defined
00377 #endif
00378 #define HANDLER_DISPATCH \
00379   do { if (err == NULL) break;  handler (&err, user_data);        \
00380        g_error_free (err); err = NULL; } while (0)
00381 
00382   /* Load configuration files in order. */
00383   /* First gafrc files. */
00384   g_rc_parse_system (toplevel, NULL, &err); HANDLER_DISPATCH;
00385   g_rc_parse_user (toplevel, NULL, &err); HANDLER_DISPATCH;
00386   g_rc_parse_local (toplevel, NULL, NULL, &err); HANDLER_DISPATCH;
00387   /* Next application-specific rcname. */
00388   if (rcname != NULL) {
00389     g_rc_parse_system (toplevel, rcname, &err); HANDLER_DISPATCH;
00390     g_rc_parse_user (toplevel, rcname, &err); HANDLER_DISPATCH;
00391     g_rc_parse_local (toplevel, rcname, NULL, &err); HANDLER_DISPATCH;
00392   }
00393   /* Finally, optional additional config file. */
00394   if (rcfile != NULL) {
00395     g_rc_parse_file (toplevel, rcfile, &err); HANDLER_DISPATCH;
00396   }
00397 
00398 #undef HANDLER_DISPATCH
00399 }
00400 
00408 SCM g_rc_component_library(SCM path, SCM name)
00409 {
00410   gchar *string;
00411   char *temp;
00412   char *namestr = NULL;
00413 
00414   SCM_ASSERT (scm_is_string (path), path,
00415               SCM_ARG1, "component-library");
00416 
00417   scm_dynwind_begin (0);
00418   if (name != SCM_UNDEFINED) {
00419     SCM_ASSERT (scm_is_string (name), name,
00420         SCM_ARG2, "component-library");
00421     namestr = scm_to_utf8_string (name);
00422     scm_dynwind_free(namestr);
00423   }
00424 
00425   /* take care of any shell variables */
00426   temp = scm_to_utf8_string (path);
00427   string = s_expand_env_variables (temp);
00428   scm_dynwind_unwind_handler (g_free, string, SCM_F_WIND_EXPLICITLY);
00429   free (temp);
00430 
00431   /* invalid path? */
00432   if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
00433     fprintf(stderr,
00434             "Invalid path [%s] passed to component-library\n",
00435             string);
00436     scm_dynwind_end();
00437     return SCM_BOOL_F;
00438   }
00439 
00440   if (g_path_is_absolute (string)) {
00441     s_clib_add_directory (string, namestr);
00442   } else {
00443     gchar *cwd = g_get_current_dir ();
00444     gchar *temp;
00445     temp = g_build_filename (cwd, string, NULL);
00446     s_clib_add_directory (temp, namestr);
00447     g_free(temp);
00448     g_free(cwd);
00449   }
00450 
00451   scm_dynwind_end();
00452   return SCM_BOOL_T;
00453 }
00454 
00466 SCM g_rc_component_library_command (SCM listcmd, SCM getcmd, 
00467                                     SCM name)
00468 {
00469   const CLibSource *src;
00470   gchar *lcmdstr, *gcmdstr;
00471   char *tmp_str, *namestr;
00472 
00473   SCM_ASSERT (scm_is_string (listcmd), listcmd, SCM_ARG1, 
00474               "component-library-command");
00475   SCM_ASSERT (scm_is_string (getcmd), getcmd, SCM_ARG2, 
00476               "component-library-command");
00477   SCM_ASSERT (scm_is_string (name), name, SCM_ARG3, 
00478               "component-library-command");
00479 
00480   scm_dynwind_begin(0);
00481 
00482   /* take care of any shell variables */
00484   tmp_str = scm_to_utf8_string (listcmd);
00485   lcmdstr = s_expand_env_variables (tmp_str);
00486   scm_dynwind_unwind_handler (g_free, lcmdstr, SCM_F_WIND_EXPLICITLY);
00487   free (tmp_str); /* this should stay as free (allocated from guile) */
00488 
00489   /* take care of any shell variables */
00491   tmp_str = scm_to_utf8_string (getcmd);
00492   gcmdstr = s_expand_env_variables (tmp_str);
00493   scm_dynwind_unwind_handler (g_free, gcmdstr, SCM_F_WIND_EXPLICITLY);
00494   free (tmp_str); /* this should stay as free (allocated from guile) */
00495 
00496   namestr = scm_to_utf8_string (name);
00497 
00498   src = s_clib_add_command (lcmdstr, gcmdstr, namestr);
00499 
00500   free (namestr); /* this should stay as free (allocated from guile) */
00501 
00502   scm_dynwind_end();
00503 
00504   if (src != NULL) return SCM_BOOL_T;
00505 
00506   return SCM_BOOL_F;
00507 }
00508 
00525 SCM g_rc_component_library_funcs (SCM listfunc, SCM getfunc, SCM name)
00526 {
00527   char *namestr;
00528   SCM result = SCM_BOOL_F;
00529 
00530   SCM_ASSERT (scm_is_true (scm_procedure_p (listfunc)), listfunc, SCM_ARG1,
00531           "component-library-funcs");
00532   SCM_ASSERT (scm_is_true (scm_procedure_p (getfunc)), getfunc, SCM_ARG2,
00533           "component-library-funcs");
00534   SCM_ASSERT (scm_is_string (name), name, SCM_ARG3, 
00535           "component-library-funcs");
00536 
00537   namestr = scm_to_utf8_string (name);
00538 
00539   if (s_clib_add_scm (listfunc, getfunc, namestr) != NULL) {
00540     result = SCM_BOOL_T;
00541   }
00542 
00543   free (namestr);
00544   return result;
00545 }
00546 
00554 SCM g_rc_source_library(SCM path)
00555 {
00556   gchar *string;
00557   char *temp;
00558   
00559   SCM_ASSERT (scm_is_string (path), path,
00560               SCM_ARG1, "source-library");
00561 
00562   /* take care of any shell variables */
00563   temp = scm_to_utf8_string (path);
00564   string = s_expand_env_variables (temp);
00565   free (temp);
00566   
00567   /* invalid path? */
00568   if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
00569     fprintf (stderr,
00570              "Invalid path [%s] passed to source-library\n",
00571              string);
00572     g_free(string);
00573     return SCM_BOOL_F;
00574   }
00575 
00576   if (g_path_is_absolute (string)) {
00577     s_slib_add_entry (string);
00578   } else {
00579     gchar *cwd = g_get_current_dir ();
00580     gchar *temp;
00581     temp = g_build_filename (cwd, string, NULL);
00582     s_slib_add_entry (temp);
00583     g_free(temp);
00584     g_free(cwd);
00585   }
00586   
00587   g_free(string);
00588   
00589   return SCM_BOOL_T;
00590 }
00591 
00599 SCM g_rc_source_library_search(SCM path)
00600 {
00601   gchar *string;
00602   char *temp;
00603   GDir *dir;
00604   const gchar *entry;
00605   
00606   SCM_ASSERT (scm_is_string (path), path,
00607               SCM_ARG1, "source-library-search");
00608 
00609   /* take care of any shell variables */
00610   temp = scm_to_utf8_string (path);
00611   string = s_expand_env_variables (temp);
00612   free (temp);
00613 
00614   /* invalid path? */
00615   if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
00616     fprintf (stderr,
00617              "Invalid path [%s] passed to source-library-search\n",
00618              string);
00619     g_free(string);
00620     return SCM_BOOL_F;
00621   }
00622 
00623   dir = g_dir_open (string, 0, NULL);
00624   if (dir == NULL) {
00625     fprintf (stderr,
00626              "Invalid path [%s] passed to source-library-search\n",
00627              string);
00628     g_free(string);
00629     return SCM_BOOL_F;
00630   }
00631 
00632   while ((entry = g_dir_read_name (dir))) {
00633     /* don't do . and .. and special case font */
00634     if ((g_strcasecmp (entry, ".")    != 0) && 
00635         (g_strcasecmp (entry, "..")   != 0) &&
00636         (g_strcasecmp (entry, "font") != 0))
00637     {
00638       gchar *fullpath = g_build_filename (string, entry, NULL);
00639 
00640       if (g_file_test (fullpath, G_FILE_TEST_IS_DIR)) {
00641         if (s_slib_uniq (fullpath)) {
00642           if (g_path_is_absolute (fullpath)) {
00643             s_slib_add_entry (fullpath);
00644           } else {
00645             gchar *cwd = g_get_current_dir ();
00646             gchar *temp;
00647             temp = g_build_filename (cwd, fullpath, NULL);
00648             s_slib_add_entry (temp);
00649             g_free(temp);
00650             g_free(cwd);
00651           }
00652         }
00653       }
00654       g_free(fullpath);
00655     }
00656   }
00657 
00658   g_free(string);
00659   g_dir_close(dir);
00660 
00661   return SCM_BOOL_T;
00662 }
00663 
00674 SCM
00675 g_rc_rc_filename()
00676 {
00677   SCM stack, frame, source;
00678 
00679   stack = scm_make_stack (SCM_BOOL_T, SCM_EOL);
00680   if (scm_is_false (stack)) {
00681     return SCM_BOOL_F;
00682   }
00683 
00684   frame = scm_stack_ref (stack, scm_from_int(0));
00685   if (scm_is_false (frame)) {
00686     return SCM_BOOL_F;
00687   }
00688 
00689   source = scm_frame_source (frame);
00690   if (scm_is_false (source)) {
00691     return SCM_BOOL_F;
00692   }
00693 
00694   return scm_source_property (source, scm_sym_filename);
00695 }
00696 
00706 SCM g_rc_world_size(SCM width, SCM height, SCM border)
00707 #define FUNC_NAME "world-size"
00708 {
00709   int i_width, i_height, i_border;
00710   int init_right, init_bottom;
00711 
00712   SCM_ASSERT (SCM_NIMP (width) && SCM_REALP (width), width,
00713               SCM_ARG1, FUNC_NAME);
00714   SCM_ASSERT (SCM_NIMP (height) && SCM_REALP (height), height,
00715               SCM_ARG2, FUNC_NAME);
00716   SCM_ASSERT (SCM_NIMP (border) && SCM_REALP (border), border,
00717               SCM_ARG3, FUNC_NAME);
00718   
00719   /* yes this is legit, we are casing the resulting double to an int */
00720   i_width  = (int) (scm_to_double (width)  * MILS_PER_INCH);
00721   i_height = (int) (scm_to_double (height) * MILS_PER_INCH);
00722   i_border = (int) (scm_to_double (border) * MILS_PER_INCH);
00723 
00724   PAPERSIZEtoWORLD(i_width, i_height, i_border,
00725                    &init_right, &init_bottom);
00726 
00727 #if DEBUG
00728   printf("%d %d\n", i_width, i_height);
00729   printf("%d %d\n", init_right, init_bottom);
00730 #endif
00731 
00732   default_init_right  = init_right;
00733   default_init_bottom = init_bottom;
00734 
00735   return SCM_BOOL_T;
00736 }
00737 #undef FUNC_NAME
00738 
00746 SCM g_rc_untitled_name(SCM name)
00747 {
00748   char *temp;
00749   SCM_ASSERT (scm_is_string (name), name,
00750               SCM_ARG1, "untitled-name");
00751 
00752   g_free(default_untitled_name);
00753 
00754   temp = scm_to_utf8_string (name);
00755   default_untitled_name = g_strdup (temp);
00756   free (temp);
00757 
00758   return SCM_BOOL_T;
00759 }
00760 
00761 
00770 SCM g_rc_scheme_directory(SCM s_path)
00771 {
00772   char *temp;
00773   gchar *expanded;
00774   SCM s_load_path_var;
00775   SCM s_load_path;
00776 
00777   SCM_ASSERT (scm_is_string (s_path), s_path,
00778               SCM_ARG1, "scheme-directory");
00779 
00780   /* take care of any shell variables */
00781   temp = scm_to_utf8_string (s_path);
00782   expanded = s_expand_env_variables (temp);
00783   s_path = scm_from_utf8_string (expanded);
00784   free (temp);
00785   g_free (expanded);
00786 
00787   s_load_path_var = scm_c_lookup ("%load-path");
00788   s_load_path = scm_variable_ref (s_load_path_var);
00789   scm_variable_set_x (s_load_path_var, scm_cons (s_path, s_load_path));
00790 
00791   scm_remember_upto_here_2 (s_load_path_var, s_load_path);
00792   scm_remember_upto_here_1 (s_path);
00793 
00794   return SCM_BOOL_T;
00795 }
00796 
00804 SCM g_rc_bitmap_directory(SCM path)
00805 {
00806   gchar *string;
00807   char *temp;
00808 
00809   SCM_ASSERT (scm_is_string (path), path,
00810               SCM_ARG1, "bitmap-directory");
00811   
00812   /* take care of any shell variables */
00813   temp = scm_to_utf8_string (path);
00814   string = s_expand_env_variables (temp);
00815   free (temp);
00816 
00817   /* invalid path? */
00818   if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
00819     fprintf (stderr,
00820              "Invalid path [%s] passed to bitmap-directory\n",
00821              string);
00822     g_free(string);
00823     return SCM_BOOL_F;
00824   }
00825 
00826   g_free(default_bitmap_directory);
00827   default_bitmap_directory = string;
00828 
00829   return SCM_BOOL_T;
00830 }
00831 
00839 SCM g_rc_bus_ripper_symname(SCM scmsymname)
00840 {
00841   char *temp;
00842 
00843   SCM_ASSERT (scm_is_string (scmsymname), scmsymname,
00844               SCM_ARG1, "bus-ripper-symname");
00845 
00846   g_free(default_bus_ripper_symname);
00847 
00848   temp = scm_to_utf8_string (scmsymname);
00849   default_bus_ripper_symname = g_strdup (temp);
00850   free (temp);
00851 
00852   return SCM_BOOL_T;
00853 }
00854 
00862 SCM g_rc_postscript_prolog(SCM scmsymname)
00863 {
00864   char *temp;
00865 
00866   SCM_ASSERT (scm_is_string (scmsymname), scmsymname,
00867               SCM_ARG1, "postsript-prolog");
00868 
00869   g_free(default_postscript_prolog);
00870 
00871   /* take care of any shell variables */
00872   temp = scm_to_utf8_string (scmsymname);
00873   default_postscript_prolog =
00874     s_expand_env_variables (temp);
00875   free (temp);
00876 
00877   return SCM_BOOL_T;
00878 }
00879 
00886 SCM g_rc_reset_component_library(void)
00887 {
00888   s_clib_init();
00889   
00890   return SCM_BOOL_T;
00891 }
00892 
00899 SCM g_rc_reset_source_library(void)
00900 {
00901   s_slib_free();
00902   s_slib_init();
00903   
00904   return SCM_BOOL_T;
00905 }
00906 
00907 
00913 SCM g_rc_attribute_promotion(SCM mode)
00914 {
00915   static const vstbl_entry mode_table[] = {
00916     {TRUE , "enabled" },
00917     {FALSE, "disabled"},
00918   };
00919 
00920   RETURN_G_RC_MODE("attribute-promotion",
00921            default_attribute_promotion,
00922            2);
00923 }
00924 
00930 SCM g_rc_promote_invisible(SCM mode)
00931 {
00932   static const vstbl_entry mode_table[] = {
00933     {TRUE , "enabled" },
00934     {FALSE, "disabled"},
00935   };
00936 
00937   RETURN_G_RC_MODE("promote-invisible",
00938            default_promote_invisible,
00939            2);
00940 }
00941 
00947 SCM g_rc_keep_invisible(SCM mode)
00948 {
00949   static const vstbl_entry mode_table[] = {
00950     {TRUE , "enabled" },
00951     {FALSE, "disabled"},
00952   };
00953 
00954   RETURN_G_RC_MODE("keep-invisible",
00955            default_keep_invisible,
00956            2);
00957 }
00958 
00966 SCM g_rc_always_promote_attributes(SCM attrlist)
00967 {
00968   GList *list=NULL;
00969   int length, i;
00970   gchar *attr;
00971   gchar **attr2;
00972 
00973   g_list_foreach(default_always_promote_attributes, (GFunc)g_free, NULL);
00974   g_list_free(default_always_promote_attributes);
00975 
00976   if (scm_is_string (attrlist)) {
00977     char *temp;
00978     s_log_message(_("WARNING: using a string for 'always-promote-attributes'"
00979             " is deprecated. Use a list of strings instead\n"));
00980 
00981     /* convert the space separated strings into a GList */
00982     temp = scm_to_utf8_string (attrlist);
00983     attr2 = g_strsplit(temp," ", 0);
00984     free (temp);
00985 
00986     for (i=0; attr2[i] != NULL; i++) {
00987       if (strlen(attr2[i]) > 0) {
00988     list = g_list_prepend(list, g_strdup(attr2[i]));
00989       }
00990     }
00991     g_strfreev(attr2);
00992   } else {
00993     SCM_ASSERT(scm_list_p(attrlist), attrlist, SCM_ARG1, "always-promote-attributes");
00994     length = scm_ilength(attrlist);
00995     /* convert the scm list into a GList */
00996     for (i=0; i < length; i++) {
00997       char *temp;
00998       SCM_ASSERT(scm_is_string(scm_list_ref(attrlist, scm_from_int(i))), 
00999          scm_list_ref(attrlist, scm_from_int(i)), SCM_ARG1, 
01000          "always-promote-attribute: list element is not a string");
01001       temp = scm_to_utf8_string (scm_list_ref (attrlist, scm_from_int (i)));
01002       attr = g_strdup(temp);
01003       free (temp);
01004       list = g_list_prepend(list, attr);
01005     }
01006   }
01007 
01008   default_always_promote_attributes = g_list_reverse(list);
01009 
01010   return SCM_BOOL_T;
01011 }
01012 
01022 SCM g_rc_make_backup_files(SCM mode)
01023 {
01024   static const vstbl_entry mode_table[] = {
01025     {TRUE , "enabled" },
01026     {FALSE, "disabled"},
01027   };
01028 
01029   RETURN_G_RC_MODE("make-backup-files",
01030                   default_make_backup_files,
01031                   2);
01032 }
01033 
01034 extern COLOR print_colors[MAX_COLORS];
01035 
01036 SCM g_rc_print_color_map (SCM scm_map)
01037 {
01038   if (scm_map == SCM_UNDEFINED) {
01039     return s_color_map_to_scm (print_colors);
01040   }
01041 
01042   SCM_ASSERT (scm_is_true (scm_list_p (scm_map)),
01043               scm_map, SCM_ARG1, "print-color-map");
01044 
01045   s_color_map_from_scm (print_colors, scm_map, "print-color-map");
01046   return SCM_BOOL_T;
01047 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines