libgeda

g_basic.c File Reference

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

Go to the source code of this file.

Data Structures

struct  g_read_file_data_t

Functions

static void process_error_stack (SCM s_stack, SCM s_key, SCM s_args, GError **err)
 Process a Scheme error into the log and/or a GError.
static SCM protected_pre_unwind_handler (void *data, SCM key, SCM args)
static SCM protected_post_unwind_handler (void *data, SCM key, SCM args)
static SCM protected_body_eval (void *data)
SCM g_scm_eval_protected (SCM exp, SCM module_or_state)
 Evaluate a Scheme expression safely.
SCM g_scm_c_eval_string_protected (const gchar *str)
 Evaluate a C string as a Scheme expression safely.
SCM g_scm_eval_string_protected (SCM str)
 Evaluate a string as a Scheme expression safely.
SCM g_read_file__body (struct g_read_file_data_t *data)
SCM g_read_file__post_handler (struct g_read_file_data_t *data, SCM key, SCM args)
SCM g_read_file__pre_handler (struct g_read_file_data_t *data, SCM key, SCM args)
gboolean g_read_file (TOPLEVEL *toplevel, const gchar *filename, GError **err)
 Load a Scheme file, catching and logging errors.

Function Documentation

static void process_error_stack ( SCM  s_stack,
SCM  s_key,
SCM  s_args,
GError **  err 
) [static]
Function Description
Process a captured Guile exception with the given s_key and s_args, and optionally the stack trace s_stack. The stack trace and source location are logged, and if a GError return location err is provided, it is populated with an informative error message.

Definition at line 244 of file g_basic.c.

static SCM protected_pre_unwind_handler ( void *  data,
SCM  key,
SCM  args 
) [static]

Definition at line 48 of file g_basic.c.

static SCM protected_post_unwind_handler ( void *  data,
SCM  key,
SCM  args 
) [static]

Definition at line 59 of file g_basic.c.

Here is the call graph for this function:

static SCM protected_body_eval ( void *  data) [static]

Definition at line 70 of file g_basic.c.

SCM g_scm_eval_protected ( SCM  exp,
SCM  module_or_state 
)
Function Description

Often a libgeda program (or libgeda itself) will need to call out to Scheme code, for example to load a Scheme configuration file. If an error or exception caused by such code goes uncaught, it locks up the Scheme interpreter, stopping any further Scheme code from being run until the program is restarted.

This function is equivalent to scm_eval (), with the important difference that any errors or exceptions caused by the evaluated expression exp are caught and reported via the libgeda logging mechanism. If an error occurs during evaluation, this function returns SCM_BOOL_F. If module_or_state is undefined, uses the current interaction environment.

Parameters:
expExpression to evaluate
module_or_stateEnvironment in which to evaluate exp
Returns:
Evaluation results or SCM_BOOL_F if exception caught.

Definition at line 97 of file g_basic.c.

Here is the call graph for this function:

SCM g_scm_c_eval_string_protected ( const gchar *  str)
Function Description

Evaluates a C string like scm_c_eval_string(). Simple wrapper for g_scm_eval_string_protected().

Parameters:
strString to evaluate.
Returns:
Evaluation results or SCM_BOOL_F if exception caught.

Definition at line 133 of file g_basic.c.

Here is the call graph for this function:

SCM g_scm_eval_string_protected ( SCM  str)
Function Description

Evaluates a string similarly to scm_eval_string(), but catching any errors or exceptions and reporting them via the libgeda logging mechanism.

See also g_scm_eval_protected() and g_scm_c_eval_string_protected().

Parameters:
strString to evaluate.
Returns:
Evaluation results or SCM_BOOL_F if exception caught.

Definition at line 153 of file g_basic.c.

Here is the call graph for this function:

SCM g_read_file__body ( struct g_read_file_data_t data)

Definition at line 172 of file g_basic.c.

SCM g_read_file__post_handler ( struct g_read_file_data_t data,
SCM  key,
SCM  args 
)

Definition at line 180 of file g_basic.c.

Here is the call graph for this function:

SCM g_read_file__pre_handler ( struct g_read_file_data_t data,
SCM  key,
SCM  args 
)

Definition at line 189 of file g_basic.c.

gboolean g_read_file ( TOPLEVEL toplevel,
const gchar *  filename,
GError **  err 
)
Function Description
Loads filename, catching any uncaught errors and logging them.
Bug:
Most other functions in the libgeda API return TRUE on success and FALSE on failure. g_read_file() shouldn't be an exception.
Parameters:
toplevelThe TOPLEVEL structure.
filenameThe file name of the Scheme file to load.
errReturn location for errors, or NULL.
Returns:
TRUE on success, FALSE on failure.

Definition at line 208 of file g_basic.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines