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

prop.c File Reference

#include "common.h"
#include "prop.h"
#include "file.h"
#include "misc.h"
#include "glib-missing.h"
#include "tm.h"
#include "override.h"

Defines

#define debug   track_props
#define prop_assert(ps, prop, x)

Typedefs

typedef gint(* prop_parse_func_t )(const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)

Functions

 RCSID ("$Id:prop.c, v 1.32 2005/11/13 12:00:26 cbiere Exp $")
gint prop_parse_guint64 (const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
gint prop_parse_timestamp (const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
gint prop_parse_guint32 (const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
gint prop_parse_ip (const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
gint prop_parse_boolean (const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
 Parse comma delimited boolean vector (TRUE/FALSE list).

void prop_parse_vector (const gchar *name, const gchar *str, size_t size, gpointer vec, prop_parse_func_t parser)
 Parse prop vector.

void prop_parse_guint64_vector (const gchar *name, const gchar *str, size_t size, guint64 *vec)
void prop_parse_timestamp_vector (const gchar *name, const gchar *str, size_t size, time_t *vec)
void prop_parse_guint32_vector (const gchar *name, const gchar *str, size_t size, guint32 *vec)
void prop_parse_ip_vector (const gchar *name, const gchar *str, size_t size, guint32 *vec)
void prop_parse_boolean_vector (const gchar *name, const gchar *str, size_t size, gboolean *vec)
void prop_parse_storage (const gchar *name, const gchar *str, size_t size, gchar *t)
 Parse a hex string into a gchar array.

prop_def_tprop_get_def (prop_set_t *ps, property_t p)
 Copy the property definition from the property set and return it.

void prop_free_def (prop_def_t *d)
void prop_add_prop_changed_listener (prop_set_t *ps, property_t prop, prop_changed_listener_t l, gboolean init)
 Add a change listener to a given property.

void prop_add_prop_changed_listener_full (prop_set_t *ps, property_t prop, prop_changed_listener_t l, gboolean init, enum frequency_type freq, guint32 interval)
 Add a change listener to a given property.

void prop_remove_prop_changed_listener (prop_set_t *ps, property_t prop, prop_changed_listener_t l)
void prop_emit_prop_changed (prop_set_t *ps, property_t prop)
void prop_set_boolean (prop_set_t *ps, property_t prop, const gboolean *src, size_t offset, size_t length)
gboolean * prop_get_boolean (prop_set_t *ps, property_t prop, gboolean *t, size_t offset, size_t length)
void prop_set_guint64 (prop_set_t *ps, property_t prop, const guint64 *src, size_t offset, size_t length)
guint64 * prop_get_guint64 (prop_set_t *ps, property_t prop, guint64 *t, size_t offset, size_t length)
void prop_set_guint32 (prop_set_t *ps, property_t prop, const guint32 *src, size_t offset, size_t length)
guint32 * prop_get_guint32 (prop_set_t *ps, property_t prop, guint32 *t, size_t offset, size_t length)
void prop_set_timestamp (prop_set_t *ps, property_t prop, const time_t *src, size_t offset, size_t length)
time_t * prop_get_timestamp (prop_set_t *ps, property_t prop, time_t *t, size_t offset, size_t length)
void prop_set_storage (prop_set_t *ps, property_t prop, const gchar *src, size_t length)
gchar * prop_get_storage (prop_set_t *ps, property_t prop, gchar *t, size_t length)
void prop_set_string (prop_set_t *ps, property_t prop, const gchar *val)
gchar * prop_get_string (prop_set_t *ps, property_t prop, gchar *t, size_t size)
 Fetches the value of a string property.

const gchar * prop_name (prop_set_t *ps, property_t prop)
 Fetch the property name in the config files.

const gchar * prop_description (prop_set_t *ps, property_t prop)
 Fetch the property description in the config files.

const gchar * prop_type_to_string (prop_set_t *ps, property_t prop)
gboolean prop_is_saved (prop_set_t *ps, property_t prop)
const gchar * prop_to_string (prop_set_t *ps, property_t prop)
 Fetches the value of property as a string.

const gchar * prop_default_to_string (prop_set_t *ps, property_t prop)
 Fetches the default value of property as a string.

const gchar * config_boolean (gboolean b)
gchar * config_comment (const gchar *s)
 Creates a string containing aset of lines from with words taken from s, each line no longer than 80 chars (except when a single words is very long) and prepended with "# ".

void prop_save_to_file_if_dirty (prop_set_t *ps, const gchar *dir, const gchar *filename)
 Like prop_save_to_file(), but only perform when dirty, i.e.

void prop_save_to_file (prop_set_t *ps, const gchar *dir, const gchar *filename)
 Read the all properties from the given property set and stores them along with their description to the given file in the given directory.

void prop_set_from_string (prop_set_t *ps, property_t prop, const gchar *val, gboolean saved_only)
 Called by prop_load_from_file to actually set the properties.

void load_helper (prop_set_t *ps, property_t prop, const gchar *val)
 Called by prop_load_from_file to actually set the properties.

void prop_load_from_file (prop_set_t *ps, const gchar *dir, const gchar *filename)
property_t prop_get_by_name (prop_set_t *ps, const gchar *name)
GSList * prop_get_by_regex (prop_set_t *ps, const gchar *pattern, gint *error)

Variables

guint32 track_props = 0
 XXX need to init lib's props--RAM.

guint32 common_dbg = 0
 XXX -- need to init lib's props --RAM.

struct {
   const gchar *   name
prop_type_str []


Define Documentation

#define debug   track_props
 

#define prop_assert ps,
prop,
 ) 
 

Value:

G_STMT_START {                                                      \
    if (!(x)) {                                                     \
        g_error("assertion failed for property \"%s\": %s",         \
            PROP(ps, prop).name, STRINGIFY(x));                     \
    }                                                               \
} G_STMT_END


Typedef Documentation

typedef gint(* prop_parse_func_t)(const gchar *name, const gchar *str, const gchar **endptr, gpointer vec, size_t i)
 


Function Documentation

const gchar* config_boolean gboolean  b  )  [static]
 

Returns:
"TRUE" or "FALSE" depending on the given boolean value.

gchar* config_comment const gchar *  s  )  [static]
 

Creates a string containing aset of lines from with words taken from s, each line no longer than 80 chars (except when a single words is very long) and prepended with "# ".

void load_helper prop_set_t ps,
property_t  prop,
const gchar *  val
[static]
 

Called by prop_load_from_file to actually set the properties.

void prop_add_prop_changed_listener prop_set_t ps,
property_t  prop,
prop_changed_listener_t  l,
gboolean  init
 

Add a change listener to a given property.

If init is TRUE then the listener is immediately called.

void prop_add_prop_changed_listener_full prop_set_t ps,
property_t  prop,
prop_changed_listener_t  l,
gboolean  init,
enum frequency_type  freq,
guint32  interval
 

Add a change listener to a given property.

If init is TRUE then the listener is immediately called.

const gchar* prop_default_to_string prop_set_t ps,
property_t  prop
 

Fetches the default value of property as a string.

const gchar* prop_description prop_set_t ps,
property_t  prop
 

Fetch the property description in the config files.

void prop_emit_prop_changed prop_set_t ps,
property_t  prop
[static]
 

void prop_free_def prop_def_t d  ) 
 

gboolean* prop_get_boolean prop_set_t ps,
property_t  prop,
gboolean *  t,
size_t  offset,
size_t  length
 

property_t prop_get_by_name prop_set_t ps,
const gchar *  name
 

GSList* prop_get_by_regex prop_set_t ps,
const gchar *  pattern,
gint *  error
 

prop_def_t* prop_get_def prop_set_t ps,
property_t  p
 

Copy the property definition from the property set and return it.

Use the prop_free_def call to free the memory again. A simple g_free won't do, since there are lot's of pointers to allocated memory in the definition structure.

The prop_changed_listeners field will always be NULL in the copy.

guint32* prop_get_guint32 prop_set_t ps,
property_t  prop,
guint32 *  t,
size_t  offset,
size_t  length
 

guint64* prop_get_guint64 prop_set_t ps,
property_t  prop,
guint64 *  t,
size_t  offset,
size_t  length
 

gchar* prop_get_storage prop_set_t ps,
property_t  prop,
gchar *  t,
size_t  length
 

gchar* prop_get_string prop_set_t ps,
property_t  prop,
gchar *  t,
size_t  size
 

Fetches the value of a string property.

If a string buffer is provided (t != NULL), then this is used. The size indicates the size of the given string buffer and may not be 0 in this case. The pointer which is returned will point to the given buffer.

If no string buffer is given (t == NULL), new memory is allocated and returned. This memory must be free'ed later. The size parameter has no effect in this case.

time_t* prop_get_timestamp prop_set_t ps,
property_t  prop,
time_t *  t,
size_t  offset,
size_t  length
 

gboolean prop_is_saved prop_set_t ps,
property_t  prop
 

void prop_load_from_file prop_set_t ps,
const gchar *  dir,
const gchar *  filename
 

const gchar* prop_name prop_set_t ps,
property_t  prop
 

Fetch the property name in the config files.

gint prop_parse_boolean const gchar *  name,
const gchar *  str,
const gchar **  endptr,
gpointer  vec,
size_t  i
[static]
 

Parse comma delimited boolean vector (TRUE/FALSE list).

void prop_parse_boolean_vector const gchar *  name,
const gchar *  str,
size_t  size,
gboolean *  vec
[static]
 

gint prop_parse_guint32 const gchar *  name,
const gchar *  str,
const gchar **  endptr,
gpointer  vec,
size_t  i
[static]
 

void prop_parse_guint32_vector const gchar *  name,
const gchar *  str,
size_t  size,
guint32 *  vec
[static]
 

gint prop_parse_guint64 const gchar *  name,
const gchar *  str,
const gchar **  endptr,
gpointer  vec,
size_t  i
[static]
 

void prop_parse_guint64_vector const gchar *  name,
const gchar *  str,
size_t  size,
guint64 *  vec
[static]
 

gint prop_parse_ip const gchar *  name,
const gchar *  str,
const gchar **  endptr,
gpointer  vec,
size_t  i
[static]
 

void prop_parse_ip_vector const gchar *  name,
const gchar *  str,
size_t  size,
guint32 *  vec
[static]
 

void prop_parse_storage const gchar *  name,
const gchar *  str,
size_t  size,
gchar *  t
[static]
 

Parse a hex string into a gchar array.

gint prop_parse_timestamp const gchar *  name,
const gchar *  str,
const gchar **  endptr,
gpointer  vec,
size_t  i
[static]
 

void prop_parse_timestamp_vector const gchar *  name,
const gchar *  str,
size_t  size,
time_t *  vec
[static]
 

void prop_parse_vector const gchar *  name,
const gchar *  str,
size_t  size,
gpointer  vec,
prop_parse_func_t  parser
[static]
 

Parse prop vector.

void prop_remove_prop_changed_listener prop_set_t ps,
property_t  prop,
prop_changed_listener_t  l
 

void prop_save_to_file prop_set_t ps,
const gchar *  dir,
const gchar *  filename
 

Read the all properties from the given property set and stores them along with their description to the given file in the given directory.

If this file was modified since the property set was read from it at startup, the modifies file will be renamed to [filename].old before saving.

void prop_save_to_file_if_dirty prop_set_t ps,
const gchar *  dir,
const gchar *  filename
 

Like prop_save_to_file(), but only perform when dirty, i.e.

when at least one persisted property changed since the last time we saved.

void prop_set_boolean prop_set_t ps,
property_t  prop,
const gboolean *  src,
size_t  offset,
size_t  length
 

void prop_set_from_string prop_set_t ps,
property_t  prop,
const gchar *  val,
gboolean  saved_only
 

Called by prop_load_from_file to actually set the properties.

void prop_set_guint32 prop_set_t ps,
property_t  prop,
const guint32 *  src,
size_t  offset,
size_t  length
 

void prop_set_guint64 prop_set_t ps,
property_t  prop,
const guint64 *  src,
size_t  offset,
size_t  length
 

void prop_set_storage prop_set_t ps,
property_t  prop,
const gchar *  src,
size_t  length
 

void prop_set_string prop_set_t ps,
property_t  prop,
const gchar *  val
 

void prop_set_timestamp prop_set_t ps,
property_t  prop,
const time_t *  src,
size_t  offset,
size_t  length
 

const gchar* prop_to_string prop_set_t ps,
property_t  prop
 

Fetches the value of property as a string.

const gchar* prop_type_to_string prop_set_t ps,
property_t  prop
 

RCSID "$Id:prop.  c,
v 1.32 2005/11/13 12:00:26 cbiere Exp $" 
 


Variable Documentation

guint32 common_dbg = 0 [static]
 

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

const gchar* name
 

const { ... } prop_type_str[]
 

guint32 track_props = 0 [static]
 

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


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