CamelSExp

## CamelSExp CamelSExp |

## Synopsis

    struct              CamelSExp;
    struct              CamelSExpSymbol;
    struct              CamelSExpResult;
    struct              CamelSExpTerm;
    enum                CamelSExpResultType;
    CamelSExpResult     (*CamelSExpFunc)                    (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpResult **argv,
                                                             gpointer data);
    CamelSExpResult     (*CamelSExpIFunc)                   (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpTerm **argv,
                                                             gpointer data);
    enum                CamelSExpTermType;
    CamelSExp *         camel_sexp_new                      (void);
    void                camel_sexp_add_function             (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name,
                                                             CamelSExpFunc func,
                                                             gpointer data);
    void                camel_sexp_add_ifunction            (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name,
                                                             CamelSExpIFunc func,
                                                             gpointer data);
    void                camel_sexp_add_variable             (CamelSExp *sexp,
                                                             guint scope,
                                                             gchar *name,
                                                             CamelSExpTerm *value);
    void                camel_sexp_remove_symbol            (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name);
    gint                camel_sexp_set_scope                (CamelSExp *sexp,
                                                             guint scope);
    void                camel_sexp_input_text               (CamelSExp *sexp,
                                                             const gchar *text,
                                                             gint len);
    void                camel_sexp_input_file               (CamelSExp *sexp,
                                                             gint fd);
    gint                camel_sexp_parse                    (CamelSExp *sexp);
    CamelSExpResult *   camel_sexp_eval                     (CamelSExp *sexp);
    CamelSExpResult *   camel_sexp_term_eval                (CamelSExp *sexp,
                                                             CamelSExpTerm *term);
    CamelSExpResult *   camel_sexp_result_new               (CamelSExp *sexp,
                                                             gint type);
    void                camel_sexp_result_free              (CamelSExp *sexp,
                                                             CamelSExpResult *term);
    void                camel_sexp_resultv_free             (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpResult **argv);
    void                camel_sexp_encode_bool              (GString *string,
                                                             gboolean v_bool);
    void                camel_sexp_encode_string            (GString *string,
                                                             const gchar *v_string);
    void                camel_sexp_fatal_error              (CamelSExp *sexp,
                                                             const gchar *why,
                                                             ...);
    const gchar *       camel_sexp_error                    (CamelSExp *sexp);
    CamelSExpTerm *     camel_sexp_parse_value              (CamelSExp *sexp);
    gboolean            camel_sexp_evaluate_occur_times     (CamelSExp *sexp,
                                                             time_t *start,
                                                             time_t *end);

## Object Hierarchy

      GObject
       +----CamelSExp

## Description

## Details

### struct CamelSExp

    struct CamelSExp;

Since 3.4

### struct CamelSExpSymbol

    struct CamelSExpSymbol {
    	gint type;		/* TERM_FUNC or TERM_VAR */
    	gchar *name;
    	gpointer data;
    	union {
    		CamelSExpFunc func;
    		CamelSExpIFunc ifunc;
    	} f;
    };

Since 3.4

### struct CamelSExpResult

    struct CamelSExpResult {
    	CamelSExpResultType type;
    	union {
    		GPtrArray *ptrarray;
    		gint number;
    		gchar *string;
    		gint boolean;
    		time_t time;
    	} value;
    	gboolean time_generator;
    	time_t occuring_start;
    	time_t occuring_end;
    };

Since 3.4

### struct CamelSExpTerm

    struct CamelSExpTerm {
    	CamelSExpTermType type;
    	union {
    		gchar *string;
    		gint number;
    		gint boolean;
    		time_t time;
    		struct {
    			CamelSExpSymbol *sym;
    			CamelSExpTerm **terms;
    			gint termcount;
    		} func;
    		CamelSExpSymbol *var;
    	} value;
    };

Since 3.4

### enum CamelSExpResultType

    typedef enum {
    	CAMEL_SEXP_RES_ARRAY_PTR, /* type is a ptrarray, what it points to is implementation dependant */
    	CAMEL_SEXP_RES_INT,		/* type is a number */
    	CAMEL_SEXP_RES_STRING,		/* type is a pointer to a single string */
    	CAMEL_SEXP_RES_BOOL,		/* boolean type */
    	CAMEL_SEXP_RES_TIME,		/* time_t type */
    	CAMEL_SEXP_RES_UNDEFINED /* unknown type */
    } CamelSExpResultType;

Since 3.4

### CamelSExpFunc ()

    CamelSExpResult     (*CamelSExpFunc)                    (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpResult **argv,
                                                             gpointer data);

Since 3.4

### CamelSExpIFunc ()

    CamelSExpResult     (*CamelSExpIFunc)                   (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpTerm **argv,
                                                             gpointer data);

Since 3.4

### enum CamelSExpTermType

    typedef enum {
    	CAMEL_SEXP_TERM_INT, /* integer literal */
    	CAMEL_SEXP_TERM_BOOL, /* boolean literal */
    	CAMEL_SEXP_TERM_STRING, /* string literal */
    	CAMEL_SEXP_TERM_TIME, /* time_t literal (number of seconds past the epoch) */
    	CAMEL_SEXP_TERM_FUNC, /* normal function, arguments are evaluated before calling */
    	CAMEL_SEXP_TERM_IFUNC, /* immediate function, raw terms are arguments */
    	CAMEL_SEXP_TERM_VAR /* variable reference */
    } CamelSExpTermType;

Since 3.4

### camel_sexp_new ()

    CamelSExp *         camel_sexp_new                      (void);

Since 3.4

### camel_sexp_add_function ()

    void                camel_sexp_add_function             (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name,
                                                             CamelSExpFunc func,
                                                             gpointer data);

Since 3.4

### camel_sexp_add_ifunction ()

    void                camel_sexp_add_ifunction            (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name,
                                                             CamelSExpIFunc func,
                                                             gpointer data);

Since 3.4

### camel_sexp_add_variable ()

    void                camel_sexp_add_variable             (CamelSExp *sexp,
                                                             guint scope,
                                                             gchar *name,
                                                             CamelSExpTerm *value);

Since 3.4

### camel_sexp_remove_symbol ()

    void                camel_sexp_remove_symbol            (CamelSExp *sexp,
                                                             guint scope,
                                                             const gchar *name);

Since 3.4

### camel_sexp_set_scope ()

    gint                camel_sexp_set_scope                (CamelSExp *sexp,
                                                             guint scope);

Since 3.4

### camel_sexp_input_text ()

    void                camel_sexp_input_text               (CamelSExp *sexp,
                                                             const gchar *text,
                                                             gint len);

Since 3.4

### camel_sexp_input_file ()

    void                camel_sexp_input_file               (CamelSExp *sexp,
                                                             gint fd);

Since 3.4

### camel_sexp_parse ()

    gint                camel_sexp_parse                    (CamelSExp *sexp);

Since 3.4

### camel_sexp_eval ()

    CamelSExpResult *   camel_sexp_eval                     (CamelSExp *sexp);

Since 3.4

### camel_sexp_term_eval ()

    CamelSExpResult *   camel_sexp_term_eval                (CamelSExp *sexp,
                                                             CamelSExpTerm *term);

Since 3.4

### camel_sexp_result_new ()

    CamelSExpResult *   camel_sexp_result_new               (CamelSExp *sexp,
                                                             gint type);

Since 3.4

### camel_sexp_result_free ()

    void                camel_sexp_result_free              (CamelSExp *sexp,
                                                             CamelSExpResult *term);

Since 3.4

### camel_sexp_resultv_free ()

    void                camel_sexp_resultv_free             (CamelSExp *sexp,
                                                             gint argc,
                                                             CamelSExpResult **argv);

Since 3.4

### camel_sexp_encode_bool ()

    void                camel_sexp_encode_bool              (GString *string,
                                                             gboolean v_bool);

Encode a bool into an s-expression `string`. Bools are encoded using #t #f syntax.

Since 3.4

### camel_sexp_encode_string ()

    void                camel_sexp_encode_string            (GString *string,
                                                             const gchar *v_string);

Add a c string `v_string` to the s-expression stored in the gstring `s`. Quotes are added, and special characters are escaped appropriately.

`string` : | Destination string.
`v_string` : | String expression.

Since 3.4

### camel_sexp_fatal_error ()

    void                camel_sexp_fatal_error              (CamelSExp *sexp,
                                                             const gchar *why,
                                                             ...);

Since 3.4

### camel_sexp_error ()

    const gchar *       camel_sexp_error                    (CamelSExp *sexp);

Since 3.4

### camel_sexp_parse_value ()

    CamelSExpTerm *     camel_sexp_parse_value              (CamelSExp *sexp);

Since 3.4

### camel_sexp_evaluate_occur_times ()

    gboolean            camel_sexp_evaluate_occur_times     (CamelSExp *sexp,
                                                             time_t *start,
                                                             time_t *end);