Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

eval.c File Reference


Detailed Description

String evaluation.

Author:
Raphael Manfredi
Date:
2003

#include "common.h"
#include "eval.h"
#include "atoms.h"
#include "glib-missing.h"
#include "misc.h"
#include "override.h"

Defines

#define MAX_STRING   1024
 Max length for substitution.

Functions

const gchar * get_home (void)
 Compute the user's home directory.
const gchar * get_variable (const gchar *s, const gchar **end)
 Extract variable name from string `s', then fetch value from environment.
const gchar * constant_make (const gchar *s)
 Create a constant string, or reuse an existing one if possible.
void eval_init (void)
 Initialize string evaluation.
void constants_free_kv (gpointer key, gpointer unused_val, gpointer unused_x)
void eval_close (void)
 Cleanup local structures at shutdown time.
gchar * insert_value (const gchar *val, gchar *start, size_t off, size_t len, size_t maxlen)
 Insert value `val' at beginning of string `start'.
const gchar * eval_subst (const gchar *str)
 Needs brief description here.

Variables

guint32 common_dbg = 0
 XXX -- need to init lib's props --RAM.
GHashTable * constants
const gchar * home
gboolean initialized


Define Documentation

#define MAX_STRING   1024
 

Max length for substitution.


Function Documentation

const gchar* constant_make const gchar *  s  )  [static]
 

Create a constant string, or reuse an existing one if possible.

Returns:
a string atom.

void constants_free_kv gpointer  key,
gpointer  unused_val,
gpointer  unused_x
[static]
 

void eval_close void   ) 
 

Cleanup local structures at shutdown time.

void eval_init void   ) 
 

Initialize string evaluation.

const gchar* eval_subst const gchar *  str  ) 
 

Needs brief description here.

Substitutes variables from string:

  • The leading "~" is replaced by the home directory.
  • Variables like "$PATH" or "${PATH}" are replaced by their value, as fetched from the environment, or the empty string if not found.

If given a NULL input, we return NULL.

Returns:
string atom, which is not meant to be freed until exit time.

const gchar * get_home void   )  [static]
 

Compute the user's home directory.

Uses the HOME environment variable first, then the entry from /etc/passwd.

Returns:
string atom.

const gchar * get_variable const gchar *  s,
const gchar **  end
[static]
 

Extract variable name from string `s', then fetch value from environment.

Returns:
variable's value, or "" if not found and set `end' to the address of the character right after the variable name.

gchar* insert_value const gchar *  val,
gchar *  start,
size_t  off,
size_t  len,
size_t  maxlen
[static]
 

Insert value `val' at beginning of string `start'.

The string `start' is held in a buffer capable of holding a string of `maxlen' bytes, and the string is currently `len' bytes long, with `start' being at the offset `off' within buffer.

Returns:
the pointer right after the inserted value.


Variable Documentation

guint32 common_dbg = 0 [static]
 

XXX -- need to init lib's props --RAM.

GHashTable* constants [static]
 

const gchar* home [static]
 

gboolean initialized [static]
 


Generated on Sat Jun 30 17:53:26 2007 for gtk-gnutella by  doxygen 1.3.9.1