libgeda

g_rc.c File Reference

Parse configuration files. More...

#include <config.h>
#include <missing.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <ctype.h>
#include "libgeda_priv.h"
Include dependency graph for g_rc.c:

Go to the source code of this file.

Defines

#define HANDLER_DISPATCH
#define FUNC_NAME   "world-size"

Functions

int vstbl_lookup_str (const vstbl_entry *table, int size, const char *str)
int vstbl_get_val (const vstbl_entry *table, int index)
SCM g_rc_mode_general (SCM scmmode, const char *rc_name, int *mode_var, const vstbl_entry *table, int table_size)
gboolean g_rc_parse_system (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
 Load a system configuration file.
gboolean g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
 Load a user configuration file.
gboolean g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path, GError **err)
 Load a local configuration file.
static gboolean g_rc_try_mark_read (TOPLEVEL *toplevel, gchar *filename, GError **err)
 Mark a configuration file as read.
gboolean g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
 Load a configuration file.
static void g_rc_parse__process_error (GError **err, const gchar *pname)
void g_rc_parse (TOPLEVEL *toplevel, const gchar *pname, const gchar *rcname, const gchar *rcfile)
 General RC file parsing function.
void g_rc_parse_handler (TOPLEVEL *toplevel, const gchar *rcname, const gchar *rcfile, ConfigParseErrorFunc handler, void *user_data)
 General RC file parsing function.
SCM g_rc_component_library (SCM path, SCM name)
SCM g_rc_component_library_command (SCM listcmd, SCM getcmd, SCM name)
 Guile callback for adding library commands.
SCM g_rc_component_library_funcs (SCM listfunc, SCM getfunc, SCM name)
 Guile callback for adding library functions.
SCM g_rc_source_library (SCM path)
SCM g_rc_source_library_search (SCM path)
SCM g_rc_rc_filename ()
 Get the name of the RC filename being evaluated.
SCM g_rc_world_size (SCM width, SCM height, SCM border)
SCM g_rc_untitled_name (SCM name)
SCM g_rc_scheme_directory (SCM s_path)
 Add a directory to the Guile load path.
SCM g_rc_bitmap_directory (SCM path)
SCM g_rc_bus_ripper_symname (SCM scmsymname)
SCM g_rc_postscript_prolog (SCM scmsymname)
SCM g_rc_reset_component_library (void)
SCM g_rc_reset_source_library (void)
SCM g_rc_attribute_promotion (SCM mode)
SCM g_rc_promote_invisible (SCM mode)
SCM g_rc_keep_invisible (SCM mode)
SCM g_rc_always_promote_attributes (SCM attrlist)
SCM g_rc_make_backup_files (SCM mode)
 Enable the creation of backup files when saving.
SCM g_rc_print_color_map (SCM scm_map)

Variables

COLOR print_colors [MAX_COLORS]

Detailed Description

Contains functions to open, parse and manage gEDA configuration (RC) files.

Definition in file g_rc.c.


Define Documentation

#define HANDLER_DISPATCH
Value:
do { if (err == NULL) break;  handler (&err, user_data);        \
       g_error_free (err); err = NULL; } while (0)
#define FUNC_NAME   "world-size"

Function Documentation

int vstbl_lookup_str ( const vstbl_entry table,
int  size,
const char *  str 
)
Todo:
Finish function documentation!!!
Function Description

Definition at line 55 of file g_rc.c.

int vstbl_get_val ( const vstbl_entry table,
int  index 
)
Todo:
Finish function documentation!!!
Function Description

Definition at line 73 of file g_rc.c.

SCM g_rc_mode_general ( SCM  scmmode,
const char *  rc_name,
int *  mode_var,
const vstbl_entry table,
int  table_size 
)
Todo:
Finish function documentation!!!
Function Description

Definition at line 83 of file g_rc.c.

Here is the call graph for this function:

gboolean g_rc_parse_system ( TOPLEVEL toplevel,
const gchar *  rcname,
GError **  err 
)
Function Description
Attempts to load the system configuration file with basename rcname. The string "system-" is prefixed to rcname. If rcname is NULL, the default value of "gafrc" is used.
Parameters:
toplevelThe current TOPLEVEL structure.
rcfileThe basename of the configuration file to load, or NULL.
errReturn location for errors, or NULL.
Returns:
TRUE on success, FALSE on failure.

Definition at line 128 of file g_rc.c.

Here is the call graph for this function:

gboolean g_rc_parse_user ( TOPLEVEL toplevel,
const gchar *  rcname,
GError **  err 
)
Function Description
Attempts to load the user configuration file with basename rcname. If rcname is NULL, the default value of "gafrc" is used.
Parameters:
toplevelThe current TOPLEVEL structure.
rcfileThe basename of the configuration file to load, or NULL.
errReturn location for errors, or NULL.
Returns:
TRUE on success, FALSE on failure.

Definition at line 154 of file g_rc.c.

Here is the call graph for this function:

gboolean g_rc_parse_local ( TOPLEVEL toplevel,
const gchar *  rcname,
const gchar *  path,
GError **  err 
)
Function Description
Attempts to load the configuration file with basename rcname corresponding to path, reporting errors via err. If path is a directory, looks for a file named rcname in that directory. Otherwise, looks for a file named rcname in the same directory as path. If path is NULL, looks in the current directory. If rcname is NULL, the default value of "gafrc" is used.
Parameters:
toplevelThe current TOPLEVEL structure.
rcnameThe basename of the configuration file to load, or NULL.
pathThe path to load a configuration file for, or NULL.
errReturn location for errors, or NULL.
Returns:
TRUE on success, FALSE on failure.

Definition at line 179 of file g_rc.c.

Here is the call graph for this function:

static gboolean g_rc_try_mark_read ( TOPLEVEL toplevel,
gchar *  filename,
GError **  err 
) [static]
Function Description
If the config file filename has not already been loaded, mark it as loaded and return TRUE, storing filename in toplevel (filename should not subsequently be freed). Otherwise, return FALSE, and set err appropriately.
Note:
Should only be called by g_rc_parse_file().
Parameters:
toplevelThe current TOPLEVEL structure.
filenameThe config file name to test.
errReturn location for errors, or NULL.
Returns:
TRUE if filename not already loaded, FALSE otherwise.

Definition at line 222 of file g_rc.c.

gboolean g_rc_parse_file ( TOPLEVEL toplevel,
const gchar *  rcfile,
GError **  err 
)
Function Description
Load the configuration file rcfile, reporting errors via err.
Parameters:
toplevelThe current TOPLEVEL structure.
rcfileThe filename of the configuration file to load.
errReturn location for errors, or NULL;
Returns:
TRUE on success, FALSE on failure.

Todo:
We should upgrade to GLib >= 2.16 and use g_propagate_prefixed_error().

Definition at line 252 of file g_rc.c.

Here is the call graph for this function:

static void g_rc_parse__process_error ( GError **  err,
const gchar *  pname 
) [static]

Definition at line 291 of file g_rc.c.

void g_rc_parse ( TOPLEVEL toplevel,
const gchar *  pname,
const gchar *  rcname,
const gchar *  rcfile 
)
Function Description
Calls g_rc_parse_handler() with the default error handler. If any error other than ENOENT occurs while parsing a configuration file, prints an informative message and calls exit(1).
Bug:
libgeda shouldn't call exit() - this function calls g_rc_parse__process_error(), which does.
Warning:
Since this function may not return, it should only be used on application startup or when there is no chance of data loss from an unexpected exit().
Parameters:
[in]toplevelThe current TOPLEVEL structure.
[in]pnameThe name of the application (usually argv[0]).
[in]rcnameConfig file basename, or NULL.
[in]rcfileSpecific config file path, or NULL.

Definition at line 341 of file g_rc.c.

Here is the call graph for this function:

void g_rc_parse_handler ( TOPLEVEL toplevel,
const gchar *  rcname,
const gchar *  rcfile,
ConfigParseErrorFunc  handler,
void *  user_data 
)
Function Description
Attempt to load system, user and local (current working directory) configuration files, first with the default "gafrc" basename and then with the basename rcname, if rcname is not NULL. Additionally, attempt to load configuration from rcfile if rcfile is not NULL.

If an error occurs, calls handler with the provided user_data and a GError.

See also:
g_rc_parse().
Parameters:
toplevelThe current TOPLEVEL structure.
rcnameConfig file basename, or NULL.
rcfileSpecific config file path, or NULL.
handlerHandler function for config parse errors.
user_dataData to be passed to handler.

Definition at line 369 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_component_library ( SCM  path,
SCM  name 
)
Function Description
Parameters:
[in]path
[in]nameOptional descriptive name for library directory.
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Definition at line 408 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_component_library_command ( SCM  listcmd,
SCM  getcmd,
SCM  name 
)
Function Description
Callback function for the "component-library-command" Guile function, which can be used in the rc files to add a command to the component library.
Parameters:
[in]listcmdcommand to get a list of symbols
[in]getcmdcommand to get a symbol from the library
[in]nameOptional descriptive name for component source.
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Bug:
this may be a security risk!
Bug:
this may be a security risk!

Definition at line 466 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_component_library_funcs ( SCM  listfunc,
SCM  getfunc,
SCM  name 
)
Function Description
Callback function for the "component-library-funcs" Guile function, which can be used in the rc files to add a set of Guile procedures for listing and generating symbols.
Parameters:
[in]listfuncA Scheme procedure which takes no arguments and returns a Scheme list of component names.
[in]getfuncA Scheme procedure which takes a component name as an argument and returns a symbol encoded in a string in gEDA format, or the #f if the component name is unknown.
[in]nameA descriptive name for this component source.
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Definition at line 525 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_source_library ( SCM  path)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]path
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Definition at line 554 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_source_library_search ( SCM  path)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]path
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Definition at line 599 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_rc_filename ( )
Function Description

Creates a Guile stack object, extracts the topmost frame from that stack and gets the sourcefile name.

Returns:
If the interpreter can resolve the filename, returns a Scheme object with the full path to the RC file, otherwise #f

Definition at line 675 of file g_rc.c.

SCM g_rc_world_size ( SCM  width,
SCM  height,
SCM  border 
)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]width
[in]height
[in]border
Returns:
SCM_BOOL_T always.

Definition at line 706 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_untitled_name ( SCM  name)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]name
Returns:
SCM_BOOL_T always.

Definition at line 746 of file g_rc.c.

SCM g_rc_scheme_directory ( SCM  s_path)
Function Description
Prepends s_path to the Guile system 'load-path', after expanding environment variables.
Parameters:
[in]s_pathPath to be added.
Returns:
SCM_BOOL_T.

Definition at line 770 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_bitmap_directory ( SCM  path)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]path
Returns:
SCM_BOOL_T on success, SCM_BOOL_F otherwise.

Definition at line 804 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_bus_ripper_symname ( SCM  scmsymname)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]scmsymname
Returns:
SCM_BOOL_T always.

Definition at line 839 of file g_rc.c.

SCM g_rc_postscript_prolog ( SCM  scmsymname)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]scmsymname
Returns:
SCM_BOOL_T always.

Definition at line 862 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_reset_component_library ( void  )
Todo:
Finish function description!!!
Function Description
Returns:
SCM_BOOL_T always.

Definition at line 886 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_reset_source_library ( void  )
Todo:
Finish function description!!!
Function Description
Returns:
SCM_BOOL_T always.

Definition at line 899 of file g_rc.c.

Here is the call graph for this function:

SCM g_rc_attribute_promotion ( SCM  mode)
Todo:
Finish function documentation!!!
Function Description

Definition at line 913 of file g_rc.c.

SCM g_rc_promote_invisible ( SCM  mode)
Todo:
Finish function documentation!!!
Function Description

Definition at line 930 of file g_rc.c.

SCM g_rc_keep_invisible ( SCM  mode)
Todo:
Finish function documentation!!!
Function Description

Definition at line 947 of file g_rc.c.

SCM g_rc_always_promote_attributes ( SCM  attrlist)
Todo:
Finish function description!!!
Function Description
Parameters:
[in]attrlist
Returns:
SCM_BOOL_T always.

Definition at line 966 of file g_rc.c.

SCM g_rc_make_backup_files ( SCM  mode)
Function Description
If enabled then a backup file, of the form 'example.sch~', is created when saving a file.
Parameters:
[in]modeString. 'enabled' or 'disabled'
Returns:
Bool. False if mode is not a valid value; true if it is.

Definition at line 1022 of file g_rc.c.

SCM g_rc_print_color_map ( SCM  scm_map)

Definition at line 1036 of file g_rc.c.

Here is the call graph for this function:


Variable Documentation

COLOR print_colors[MAX_COLORS]

Definition at line 35 of file s_color.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines