Main Page | Modules | Alphabetical List | Data Structures | 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 "misc.h"
#include "override.h"

Defines

#define MAX_STRING   1024 /**< Max length for substitution */
 Max length for substitution.


Functions

 RCSID ("$Id:eval.c, v 1.10 2005/10/01 17:13:43 cbiere Exp $")
gchar * get_home (void)
 Compute the user's home directory.

gchar * get_variable (gchar *s, gchar **end)
 Extract variable name from string `s', then fetch value from environment.

gchar * constant_make (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 (gchar *val, gchar *start, gint off, gint len, gint maxlen)
 Insert value `val' at beginning of string `start'.

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
gchar * home


Define Documentation

#define MAX_STRING   1024 /**< Max length for substitution */
 

Max length for substitution.


Function Documentation

gchar* constant_make 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.

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.

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.

gchar * get_variable gchar *  s,
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 gchar *  val,
gchar *  start,
gint  off,
gint  len,
gint  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.

RCSID "$Id:eval.  c,
v 1.10 2005/10/01 17:13:43 cbiere Exp $" 
 


Variable Documentation

guint32 common_dbg = 0 [static]
 

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

GHashTable* constants [static]
 

gchar* home [static]
 


Generated on Sun Feb 12 10:50:00 2006 for Gtk-Gnutella by doxygen 1.3.6