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

prop.h File Reference

#include "common.h"
#include "event.h"
#include "host_addr.h"

Go to the source code of this file.

Data Structures

struct  prop_def_choice
 Container struct definitions for the different property types. More...
struct  prop_def_guint32
struct  prop_def_guint64
struct  prop_def_timestamp
struct  prop_def_ip
struct  prop_def_storage
struct  prop_def_string
struct  prop_def_boolean
struct  prop_def
 Property definition. More...
struct  prop_set_stub
 Property set stub to access property set. More...
struct  prop_set
 Property set definition. More...

Defines

#define NO_PROP   (0)
#define PROP(ps, p)   (* get_prop((ps), (p), G_STRLOC))
 Use this macro access a property instead of ps->props[prop].

Typedefs

typedef guint32 property_t
typedef guint32 property_set_t
typedef gboolean(* prop_changed_listener_t )(property_t)
 Callback signature definition.
typedef void(* prop_add_prop_changed_listener_t )(property_t, prop_changed_listener_t, gboolean)
typedef void(* prop_add_prop_changed_listener_full_t )(property_t, prop_changed_listener_t, gboolean, enum frequency_type, guint32)
typedef void(* prop_remove_prop_changed_listener_t )(property_t, prop_changed_listener_t)
typedef prop_def_choice prop_def_choice_t
 Container struct definitions for the different property types.
typedef prop_def_guint32 prop_def_guint32_t
typedef void(* prop_set_guint32_t )(property_t, const guint32 *, size_t, size_t)
typedef guint32 *(* prop_get_guint32_t )(property_t, guint32 *, size_t, size_t)
typedef prop_def_guint64 prop_def_guint64_t
typedef void(* prop_set_guint64_t )(property_t, const guint64 *, size_t, size_t)
typedef guint64 *(* prop_get_guint64_t )(property_t, guint64 *, size_t, size_t)
typedef prop_def_timestamp prop_def_timestamp_t
typedef void(* prop_set_timestamp_t )(property_t, const time_t *, size_t, size_t)
typedef time_t *(* prop_get_timestamp_t )(property_t, time_t *, size_t, size_t)
typedef prop_def_ip prop_def_ip_t
typedef void(* prop_set_ip_t )(property_t, const host_addr_t *, size_t, size_t)
typedef host_addr_t *(* prop_get_ip_t )(property_t, host_addr_t *, size_t, size_t)
typedef prop_def_storage prop_def_storage_t
typedef void(* prop_set_storage_t )(property_t, gconstpointer, size_t)
typedef gpointer(* prop_get_storage_t )(property_t, gpointer, size_t)
typedef prop_def_string prop_def_string_t
typedef void(* prop_set_string_t )(property_t, const gchar *)
typedef gchar *(* prop_get_string_t )(property_t, gchar *, size_t)
typedef prop_def_boolean prop_def_boolean_t
typedef void(* prop_set_boolean_t )(property_t, const gboolean *, size_t, size_t)
typedef gboolean *(* prop_get_boolean_t )(property_t, gboolean *, size_t, size_t)
typedef prop_def prop_def_t
 Property definition.
typedef prop_set_stub prop_set_stub_t
 Property set stub to access property set.
typedef prop_set_stub_t *(* prop_set_get_stub_t )(void)
 Stub-fetcher signature.
typedef prop_set prop_set_t
 Property set definition.

Enumerations

enum  prop_type_t {
  PROP_TYPE_BOOLEAN, PROP_TYPE_GUINT32, PROP_TYPE_GUINT64, PROP_TYPE_IP,
  PROP_TYPE_MULTICHOICE, PROP_TYPE_STORAGE, PROP_TYPE_STRING, PROP_TYPE_TIMESTAMP,
  NUM_PROP_TYPES
}
 Available property types. More...

Functions

prop_def_tprop_get_def (prop_set_t *, property_t)
 Copy the property definition from the property set and return it.
void prop_free_def (prop_def_t *)
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_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)
 Fetch the property type.
const gchar * prop_default_to_string (prop_set_t *ps, property_t prop)
 Fetches the default value of property as a string.
gboolean prop_is_saved (prop_set_t *ps, property_t prop)
void prop_add_prop_changed_listener (prop_set_t *, property_t, prop_changed_listener_t, gboolean)
 Add a change listener to a given property.
void prop_add_prop_changed_listener_full (prop_set_t *, property_t, prop_changed_listener_t, gboolean, enum frequency_type, guint32)
 Add a change listener to a given property.
void prop_remove_prop_changed_listener (prop_set_t *, property_t, prop_changed_listener_t)
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_load_from_file (prop_set_t *ps, const gchar *dir, const gchar *filename)
void prop_set_boolean (prop_set_t *, property_t, const gboolean *, size_t, size_t)
gboolean * prop_get_boolean (prop_set_t *, property_t, gboolean *, size_t, size_t)
void prop_set_string (prop_set_t *, property_t, const gchar *)
gchar * prop_get_string (prop_set_t *, property_t, gchar *, size_t)
 Fetches the value of a string property.
void prop_set_guint32 (prop_set_t *, property_t, const guint32 *, size_t, size_t)
guint32 * prop_get_guint32 (prop_set_t *, property_t, guint32 *, size_t, size_t)
void prop_set_guint64 (prop_set_t *, property_t, const guint64 *, size_t, size_t)
guint64 * prop_get_guint64 (prop_set_t *, property_t, guint64 *, size_t, size_t)
void prop_set_timestamp (prop_set_t *, property_t, const time_t *, size_t, size_t)
time_t * prop_get_timestamp (prop_set_t *, property_t, time_t *, size_t, size_t)
void prop_set_ip (prop_set_t *, property_t, const host_addr_t *, size_t, size_t)
host_addr_tprop_get_ip (prop_set_t *, property_t, host_addr_t *, size_t, size_t)
void prop_set_storage (prop_set_t *, property_t, const gchar *, size_t)
gchar * prop_get_storage (prop_set_t *, property_t, gchar *, size_t)
property_t prop_get_by_name (prop_set_t *ps, const char *name)
GSList * prop_get_by_regex (prop_set_t *ps, const gchar *pattern, gint *error)
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.
gboolean prop_in_range (const prop_set_t *ps, property_t prop)
prop_def_tget_prop (prop_set_t *ps, property_t prop, const gchar *loc)


Define Documentation

#define NO_PROP   (0)
 

#define PROP ps,
 )     (* get_prop((ps), (p), G_STRLOC))
 

Use this macro access a property instead of ps->props[prop].

It will hide the offset of the properties, so the property array can be accessed.


Typedef Documentation

typedef void(* prop_add_prop_changed_listener_full_t)(property_t, prop_changed_listener_t, gboolean, enum frequency_type, guint32)
 

typedef void(* prop_add_prop_changed_listener_t)(property_t, prop_changed_listener_t, gboolean)
 

typedef gboolean(* prop_changed_listener_t)(property_t)
 

Callback signature definition.

typedef struct prop_def_boolean prop_def_boolean_t
 

typedef struct prop_def_choice prop_def_choice_t
 

Container struct definitions for the different property types.

typedef struct prop_def_guint32 prop_def_guint32_t
 

typedef struct prop_def_guint64 prop_def_guint64_t
 

typedef struct prop_def_ip prop_def_ip_t
 

typedef struct prop_def_storage prop_def_storage_t
 

typedef struct prop_def_string prop_def_string_t
 

typedef struct prop_def prop_def_t
 

Property definition.

typedef struct prop_def_timestamp prop_def_timestamp_t
 

typedef gboolean*(* prop_get_boolean_t)(property_t, gboolean *, size_t, size_t)
 

typedef guint32*(* prop_get_guint32_t)(property_t, guint32 *, size_t, size_t)
 

typedef guint64*(* prop_get_guint64_t)(property_t, guint64 *, size_t, size_t)
 

typedef host_addr_t*(* prop_get_ip_t)(property_t, host_addr_t *, size_t, size_t)
 

typedef gpointer(* prop_get_storage_t)(property_t, gpointer, size_t)
 

typedef gchar*(* prop_get_string_t)(property_t, gchar *, size_t)
 

typedef time_t*(* prop_get_timestamp_t)(property_t, time_t *, size_t, size_t)
 

typedef void(* prop_remove_prop_changed_listener_t)(property_t, prop_changed_listener_t)
 

typedef void(* prop_set_boolean_t)(property_t, const gboolean *, size_t, size_t)
 

typedef prop_set_stub_t*(* prop_set_get_stub_t)(void)
 

Stub-fetcher signature.

typedef void(* prop_set_guint32_t)(property_t, const guint32 *, size_t, size_t)
 

typedef void(* prop_set_guint64_t)(property_t, const guint64 *, size_t, size_t)
 

typedef void(* prop_set_ip_t)(property_t, const host_addr_t *, size_t, size_t)
 

typedef void(* prop_set_storage_t)(property_t, gconstpointer, size_t)
 

typedef void(* prop_set_string_t)(property_t, const gchar *)
 

typedef struct prop_set_stub prop_set_stub_t
 

Property set stub to access property set.

typedef struct prop_set prop_set_t
 

Property set definition.

typedef void(* prop_set_timestamp_t)(property_t, const time_t *, size_t, size_t)
 

typedef guint32 property_set_t
 

typedef guint32 property_t
 


Enumeration Type Documentation

enum prop_type_t
 

Available property types.

Enumeration values:
PROP_TYPE_BOOLEAN 
PROP_TYPE_GUINT32 
PROP_TYPE_GUINT64 
PROP_TYPE_IP 
PROP_TYPE_MULTICHOICE 
PROP_TYPE_STORAGE 
PROP_TYPE_STRING 
PROP_TYPE_TIMESTAMP 
NUM_PROP_TYPES 


Function Documentation

prop_def_t* get_prop prop_set_t ps,
property_t  prop,
const gchar *  loc
[inline, static]
 

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.

Returns:
The human-readable name of the property. There is not need to copy the returned string as it points to a "static const" buffer.

void prop_free_def prop_def_t  ) 
 

gboolean* prop_get_boolean prop_set_t ,
property_t  ,
gboolean *  ,
size_t  ,
size_t 
 

property_t prop_get_by_name prop_set_t ps,
const char *  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 ,
property_t  ,
guint32 *  ,
size_t  ,
size_t 
 

guint64* prop_get_guint64 prop_set_t ,
property_t  ,
guint64 *  ,
size_t  ,
size_t 
 

host_addr_t* prop_get_ip prop_set_t ,
property_t  ,
host_addr_t ,
size_t  ,
size_t 
 

gchar* prop_get_storage prop_set_t ,
property_t  ,
gchar *  ,
size_t 
 

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 ,
property_t  ,
time_t *  ,
size_t  ,
size_t 
 

gboolean prop_in_range const prop_set_t ps,
property_t  prop
[inline, static]
 

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.

Returns:
The human-readable name of the property. There is not need to copy the returned string as it points to a "static const" buffer.

void prop_remove_prop_changed_listener prop_set_t ,
property_t  ,
prop_changed_listener_t 
 

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 ,
property_t  ,
const gboolean *  ,
size_t  ,
size_t 
 

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 ,
property_t  ,
const guint32 *  ,
size_t  ,
size_t 
 

void prop_set_guint64 prop_set_t ,
property_t  ,
const guint64 *  ,
size_t  ,
size_t 
 

void prop_set_ip prop_set_t ,
property_t  ,
const host_addr_t ,
size_t  ,
size_t 
 

void prop_set_storage prop_set_t ,
property_t  ,
const gchar *  ,
size_t 
 

void prop_set_string prop_set_t ,
property_t  ,
const gchar * 
 

void prop_set_timestamp prop_set_t ,
property_t  ,
const time_t *  ,
size_t  ,
size_t 
 

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
 

Fetch the property type.

Returns:
The human-readable name of the property. There is not need to copy the returned string as it points to a "static const" buffer.


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