ecore_config now formats like most of the rest of ecore!!!
and - errr - handy - need to talk to you about function call names, and the use of "long's" :) SVN revision: 10112
This commit is contained in:
parent
a3f6222d01
commit
20df203105
|
@ -5,10 +5,6 @@
|
||||||
* @file
|
* @file
|
||||||
* @brief Provides the Enlightened Property Library.
|
* @brief Provides the Enlightened Property Library.
|
||||||
*
|
*
|
||||||
* The Enlightened Property Library (Ecore_Config) is an adbstraction from the
|
|
||||||
* complexities of writing your own configuration. It provides many features
|
|
||||||
* using the Enlightenment 17 development libraries.
|
|
||||||
*
|
|
||||||
* This file provies all headers and structs for use with Ecore_Config.
|
* This file provies all headers and structs for use with Ecore_Config.
|
||||||
* Using individual header files should not be necessary.
|
* Using individual header files should not be necessary.
|
||||||
*/
|
*/
|
||||||
|
@ -41,75 +37,90 @@
|
||||||
|
|
||||||
/* structures */
|
/* structures */
|
||||||
|
|
||||||
typedef enum Ecore_Config_Type {
|
/**
|
||||||
PT_NIL=0,
|
* Valid configuration property types.
|
||||||
PT_INT=1,
|
*/
|
||||||
PT_FLT=2,
|
typedef enum Ecore_Config_Type
|
||||||
PT_STR=3,
|
{
|
||||||
PT_RGB=4,
|
PT_NIL = 0, ///< Property with no value.
|
||||||
PT_THM=5
|
PT_INT = 1, ///< Integer property type.
|
||||||
|
PT_FLT = 2, ///< Float property type.
|
||||||
|
PT_STR = 3, ///< String property type.
|
||||||
|
PT_RGB = 4, ///< Colour property type.
|
||||||
|
PT_THM = 5 ///< Theme property type.
|
||||||
} Ecore_Config_Type;
|
} Ecore_Config_Type;
|
||||||
|
|
||||||
|
typedef enum Ecore_Config_Flag
|
||||||
|
{
|
||||||
typedef enum Ecore_Config_Flag {
|
|
||||||
PF_NONE = 0,
|
PF_NONE = 0,
|
||||||
PF_BOUNDS = 1,
|
PF_BOUNDS = 1,
|
||||||
PF_MODIFIED = 2,
|
PF_MODIFIED = 2,
|
||||||
PF_SYSTEM = 4
|
PF_SYSTEM = 4
|
||||||
} Ecore_Config_Flag;
|
} Ecore_Config_Flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property change callback function prototype.
|
||||||
|
*/
|
||||||
|
typedef int (*Ecore_Config_Listener) (const char *key,
|
||||||
|
const Ecore_Config_Type type,
|
||||||
|
const int tag, void *data);
|
||||||
|
|
||||||
|
typedef struct Ecore_Config_Listener_List
|
||||||
typedef int (*Ecore_Config_Listener)(const char *key,const Ecore_Config_Type type,const int tag,void *data);
|
{
|
||||||
|
|
||||||
|
|
||||||
typedef struct Ecore_Config_Listener_List {
|
|
||||||
Ecore_Config_Listener listener;
|
Ecore_Config_Listener listener;
|
||||||
const char *name;
|
const char *name;
|
||||||
void *data;
|
void *data;
|
||||||
int tag;
|
int tag;
|
||||||
struct Ecore_Config_Listener_List *next; } Ecore_Config_Listener_List;
|
struct Ecore_Config_Listener_List *next;
|
||||||
|
} Ecore_Config_Listener_List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual property for storing a key-value pair.
|
* The actual property for storing a key-value pair.
|
||||||
*/
|
*/
|
||||||
typedef struct Ecore_Config_Prop {
|
typedef struct Ecore_Config_Prop
|
||||||
char *key;
|
{
|
||||||
char *description;
|
char *key; ///< Property key.
|
||||||
|
char *description; ///< Description set by ecore_config_descibe.
|
||||||
char short_opt;
|
char short_opt;
|
||||||
char *long_opt;
|
char *long_opt;
|
||||||
char *ptr;
|
char *ptr; ///< Used as the value when the property is a string or theme.
|
||||||
Ecore_Config_Type type;
|
Ecore_Config_Type type; ///< Property type.
|
||||||
long val,lo,hi,step;
|
long val; ///< Used as the value when the property is an integer, float or colour.
|
||||||
Ecore_Config_Flag flags;
|
long lo; ///< Lower bound for the value when the property is an integer or float.
|
||||||
Ecore_Config_Listener_List *listeners;
|
long hi; ///< Higher bound for the value when the property is an integer or float.
|
||||||
void *data;
|
long step; ///< Increment for the value when the property is an integer or float.
|
||||||
struct Ecore_Config_Prop *next; /**< pointer to the next property in the list */
|
Ecore_Config_Flag flags; /// < Configuration flags.
|
||||||
|
Ecore_Config_Listener_List *listeners; ///< List of change listeners.
|
||||||
|
void *data; /// < Stores extra data for the property.
|
||||||
|
struct Ecore_Config_Prop *next; ///< Pointer to the next property in the list.
|
||||||
} Ecore_Config_Prop;
|
} Ecore_Config_Prop;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* A container for a list of properties. Provided so that an application can
|
* A container for a list of properties. Provided so that an
|
||||||
* use different set of properties at any time. This is useful for multiple
|
* application can use different set of properties at any time. This
|
||||||
* window support.
|
* is useful for multiple window support.
|
||||||
*/
|
*/
|
||||||
typedef struct Ecore_Config_Bundle {
|
typedef struct Ecore_Config_Bundle
|
||||||
char *identifier; /**< identifier for this set of properties (window ID for example) */
|
{
|
||||||
char *owner; /**< this is used to store the application name related to the bundle */
|
char *identifier; ///< Identifier for this set of properties (window ID for example)
|
||||||
long serial; /**< unique identifier to identify bundle */
|
char *owner; ///< This is used to store the application name related to the bundle
|
||||||
Ecore_Config_Prop *data; /**< pointer to root of property list */
|
long serial; ///< Unique identifier to identify bundle
|
||||||
void *user_data; /**< app specific pointer to "other data" */
|
Ecore_Config_Prop *data; ///< Pointer to root of property list
|
||||||
struct Ecore_Config_Bundle *next; /**< pointer to next bundle in this application */
|
void *user_data; ///< App specific pointer to "other data"
|
||||||
|
struct Ecore_Config_Bundle *next; ///< Pointer to next bundle in this application
|
||||||
} Ecore_Config_Bundle;
|
} Ecore_Config_Bundle;
|
||||||
|
|
||||||
typedef struct Ecore_Config_Server {
|
typedef struct Ecore_Config_Server
|
||||||
|
{
|
||||||
void *server;
|
void *server;
|
||||||
char *name;
|
char *name;
|
||||||
Ecore_Config_Bundle *bundles; /* data anchor */
|
Ecore_Config_Bundle *bundles; /* data anchor */
|
||||||
struct Ecore_Config_Server *next; } Ecore_Config_Server;
|
struct Ecore_Config_Server *next;
|
||||||
|
} Ecore_Config_Server;
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* global ptrs to save passing them through the API */
|
/* global ptrs to save passing them through the API */
|
||||||
|
@ -123,48 +134,64 @@ const char *ecore_config_get_type(const Ecore_Config_Prop *e);
|
||||||
void *ecore_config_get_data(const char *key);
|
void *ecore_config_get_data(const char *key);
|
||||||
char *ecore_config_get_string(const char *key);
|
char *ecore_config_get_string(const char *key);
|
||||||
long ecore_config_get_int(const char *key);
|
long ecore_config_get_int(const char *key);
|
||||||
int ecore_config_get_rgb(const char *key,int *r, int *g, int *b);
|
int ecore_config_get_rgb(const char *key, int *r, int *g,
|
||||||
|
int *b);
|
||||||
float ecore_config_get_float(const char *key);
|
float ecore_config_get_float(const char *key);
|
||||||
char *ecore_config_get_theme(const char *key);
|
char *ecore_config_get_theme(const char *key);
|
||||||
char *ecore_config_get_as_string(const char *key);
|
char *ecore_config_get_as_string(const char *key);
|
||||||
int ecore_config_describe(const char *key, char *desc);
|
int ecore_config_describe(const char *key, char *desc);
|
||||||
int ecore_config_set_short_opt(const char *key, char short_opt);
|
int ecore_config_set_short_opt(const char *key,
|
||||||
int ecore_config_set_long_opt(const char *key, char *long_opt);
|
char short_opt);
|
||||||
|
int ecore_config_set_long_opt(const char *key,
|
||||||
|
char *long_opt);
|
||||||
int ecore_config_set(const char *key, char *val);
|
int ecore_config_set(const char *key, char *val);
|
||||||
int ecore_config_set_typed(const char *key,void *val,int type);
|
int ecore_config_set_typed(const char *key, void *val,
|
||||||
|
int type);
|
||||||
int ecore_config_set_string(const char *key, char *val);
|
int ecore_config_set_string(const char *key, char *val);
|
||||||
int ecore_config_set_int(const char *key, int val);
|
int ecore_config_set_int(const char *key, int val);
|
||||||
int ecore_config_set_rgb(const char *key, char *val);
|
int ecore_config_set_rgb(const char *key, char *val);
|
||||||
char *ecore_config_get_rgbstr(const char *key);
|
char *ecore_config_get_rgbstr(const char *key);
|
||||||
int ecore_config_set_float(const char *key, float val);
|
int ecore_config_set_float(const char *key, float val);
|
||||||
int ecore_config_set_theme(const char *key, char *val);
|
int ecore_config_set_theme(const char *key, char *val);
|
||||||
int ecore_config_set_theme_preview_group(const char *key, char *group);
|
int ecore_config_set_theme_preview_group(const char *key,
|
||||||
|
char *group);
|
||||||
int ecore_config_set_as_string(const char *key, char *val);
|
int ecore_config_set_as_string(const char *key, char *val);
|
||||||
|
|
||||||
int ecore_config_default(const char *key,char *val,float lo,float hi,float step);
|
int ecore_config_default(const char *key, char *val,
|
||||||
int ecore_config_default_typed(const char *key,void *val,int type);
|
float lo, float hi, float step);
|
||||||
|
int ecore_config_default_typed(const char *key, void *val,
|
||||||
|
int type);
|
||||||
int ecore_config_default_int(const char *key, int val);
|
int ecore_config_default_int(const char *key, int val);
|
||||||
int ecore_config_default_int_bound(const char *key,int val,int lo,int hi,int step);
|
int ecore_config_default_int_bound(const char *key, int val,
|
||||||
|
int lo, int hi, int step);
|
||||||
int ecore_config_default_string(const char *key, char *val);
|
int ecore_config_default_string(const char *key, char *val);
|
||||||
int ecore_config_default_float(const char *key, float val);
|
int ecore_config_default_float(const char *key, float val);
|
||||||
int ecore_config_default_float_bound(const char *key,float val,float lo,float hi,float step);
|
int ecore_config_default_float_bound(const char *key,
|
||||||
|
float val, float lo,
|
||||||
|
float hi, float step);
|
||||||
int ecore_config_default_rgb(const char *key, char *val);
|
int ecore_config_default_rgb(const char *key, char *val);
|
||||||
int ecore_config_default_theme(const char *key, char *val);
|
int ecore_config_default_theme(const char *key, char *val);
|
||||||
|
|
||||||
int ecore_config_listen(const char *name,const char *key,Ecore_Config_Listener listener,int tag,void *data);
|
int ecore_config_listen(const char *name, const char *key,
|
||||||
int ecore_config_deaf(const char *name,const char *key,Ecore_Config_Listener listener);
|
Ecore_Config_Listener listener,
|
||||||
|
int tag, void *data);
|
||||||
|
int ecore_config_deaf(const char *name, const char *key,
|
||||||
|
Ecore_Config_Listener listener);
|
||||||
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop * e);
|
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop * e);
|
||||||
int ecore_config_guess_type(const char *key, char *val);
|
int ecore_config_guess_type(const char *key, char *val);
|
||||||
|
|
||||||
Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv, const char *id);
|
Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server * srv,
|
||||||
|
const char *id);
|
||||||
Ecore_Config_Bundle *ecore_config_bundle_get_1st(Ecore_Config_Server * srv);
|
Ecore_Config_Bundle *ecore_config_bundle_get_1st(Ecore_Config_Server * srv);
|
||||||
Ecore_Config_Bundle *ecore_config_bundle_get_next(Ecore_Config_Bundle * ns);
|
Ecore_Config_Bundle *ecore_config_bundle_get_next(Ecore_Config_Bundle * ns);
|
||||||
Ecore_Config_Bundle *ecore_config_bundle_get_by_serial(Ecore_Config_Server *srv, long serial);
|
Ecore_Config_Bundle *ecore_config_bundle_get_by_serial(Ecore_Config_Server *
|
||||||
Ecore_Config_Bundle *ecore_config_bundle_get_by_label(Ecore_Config_Server *srv, const char *label);
|
srv, long serial);
|
||||||
|
Ecore_Config_Bundle *ecore_config_bundle_get_by_label(Ecore_Config_Server *
|
||||||
|
srv,
|
||||||
|
const char *label);
|
||||||
long ecore_config_bundle_get_serial(Ecore_Config_Bundle * ns);
|
long ecore_config_bundle_get_serial(Ecore_Config_Bundle * ns);
|
||||||
char *ecore_config_bundle_get_label(Ecore_Config_Bundle * ns);
|
char *ecore_config_bundle_get_label(Ecore_Config_Bundle * ns);
|
||||||
|
|
||||||
|
|
||||||
int ecore_config_init(char *name);
|
int ecore_config_init(char *name);
|
||||||
int ecore_config_shutdown(void);
|
int ecore_config_shutdown(void);
|
||||||
|
|
||||||
|
@ -185,12 +212,12 @@ int ecore_config_save_file(char *file);
|
||||||
# define ECORE_CONFIG_ERR_PATHEX (-8)
|
# define ECORE_CONFIG_ERR_PATHEX (-8)
|
||||||
# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
|
# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
|
||||||
# define ECORE_CONFIG_ERR_MUTEX (-6)
|
# define ECORE_CONFIG_ERR_MUTEX (-6)
|
||||||
# define ECORE_CONFIG_ERR_NOTFOUND (-5)
|
# define ECORE_CONFIG_ERR_NOTFOUND (-5) ///< Error indicating that the item searched for could not be found.
|
||||||
# define ECORE_CONFIG_ERR_OOM (-4)
|
# define ECORE_CONFIG_ERR_OOM (-4) ///< Error given when the program runs out of memory.
|
||||||
# define ECORE_CONFIG_ERR_IGNORED (-3)
|
# define ECORE_CONFIG_ERR_IGNORED (-3) ///< Error occurred, but was ignored.
|
||||||
# define ECORE_CONFIG_ERR_NODATA (-2)
|
# define ECORE_CONFIG_ERR_NODATA (-2) ///< Error given when necessary data is not provided.
|
||||||
# define ECORE_CONFIG_ERR_FAIL (-1)
|
# define ECORE_CONFIG_ERR_FAIL (-1) ///< Failure result.
|
||||||
# define ECORE_CONFIG_ERR_SUCC (0)
|
# define ECORE_CONFIG_ERR_SUCC (0) ///< Success result.
|
||||||
|
|
||||||
# define ECORE_CONFIG_PARSE_HELP (-2)
|
# define ECORE_CONFIG_PARSE_HELP (-2)
|
||||||
# define ECORE_CONFIG_PARSE_EXIT (-1)
|
# define ECORE_CONFIG_PARSE_EXIT (-1)
|
||||||
|
@ -202,16 +229,38 @@ void ecore_config_args_display(void);
|
||||||
int ecore_config_args_parse(int argc, char **argv);
|
int ecore_config_args_parse(int argc, char **argv);
|
||||||
void ecore_config_app_describe(char *description);
|
void ecore_config_app_describe(char *description);
|
||||||
|
|
||||||
int ecore_config_create(const char *key, void *val, char short_opt, char *long_opt, char *desc);
|
int ecore_config_create(const char *key, void *val,
|
||||||
int ecore_config_create_typed(const char *key, void *val, int type, char short_opt, char *long_opt, char *desc);
|
char short_opt, char *long_opt,
|
||||||
int ecore_config_create_int(const char *key, int val, char short_opt, char *long_opt, char *desc);
|
char *desc);
|
||||||
int ecore_config_create_int_bound(const char *key, int val, int low, int high, int step, char short_opt, char *long_opt, char *desc);
|
int ecore_config_create_typed(const char *key, void *val,
|
||||||
int ecore_config_create_string(const char *key, char *val, char short_opt, char *long_opt, char *desc);
|
int type, char short_opt,
|
||||||
int ecore_config_create_float(const char *key, float val, char short_opt, char *long_opt, char *desc);
|
char *long_opt, char *desc);
|
||||||
int ecore_config_create_float_bound(const char *key, float val, float low, float high, float step, char short_opt, char *long_opt, char *desc);
|
int ecore_config_create_int(const char *key, int val,
|
||||||
int ecore_config_create_rgb(const char *key, char *val, char short_opt, char *long_opt, char *desc);
|
char short_opt, char *long_opt,
|
||||||
int ecore_config_create_theme(const char *key, char *val, char short_opt, char *long_opt, char *desc);
|
char *desc);
|
||||||
|
int ecore_config_create_int_bound(const char *key, int val,
|
||||||
|
int low, int high,
|
||||||
|
int step, char short_opt,
|
||||||
|
char *long_opt,
|
||||||
|
char *desc);
|
||||||
|
int ecore_config_create_string(const char *key, char *val,
|
||||||
|
char short_opt,
|
||||||
|
char *long_opt, char *desc);
|
||||||
|
int ecore_config_create_float(const char *key, float val,
|
||||||
|
char short_opt, char *long_opt,
|
||||||
|
char *desc);
|
||||||
|
int ecore_config_create_float_bound(const char *key,
|
||||||
|
float val, float low,
|
||||||
|
float high, float step,
|
||||||
|
char short_opt,
|
||||||
|
char *long_opt,
|
||||||
|
char *desc);
|
||||||
|
int ecore_config_create_rgb(const char *key, char *val,
|
||||||
|
char short_opt, char *long_opt,
|
||||||
|
char *desc);
|
||||||
|
int ecore_config_create_theme(const char *key, char *val,
|
||||||
|
char short_opt, char *long_opt,
|
||||||
|
char *desc);
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,78 +7,139 @@
|
||||||
char *__ecore_config_app_description;
|
char *__ecore_config_app_description;
|
||||||
|
|
||||||
extern int ecore_config_bound(Ecore_Config_Prop * e);
|
extern int ecore_config_bound(Ecore_Config_Prop * e);
|
||||||
|
|
||||||
/* shorthand prop setup code to make client apps a little smaller ;) */
|
/* shorthand prop setup code to make client apps a little smaller ;) */
|
||||||
|
|
||||||
int ecore_config_create(const char *key, void *val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create(const char *key, void *val, char short_opt, char *long_opt,
|
||||||
|
char *desc)
|
||||||
|
{
|
||||||
int type = ecore_config_guess_type(key, val);
|
int type = ecore_config_guess_type(key, val);
|
||||||
return ecore_config_create_typed(key, val, type, short_opt, long_opt, desc);}
|
|
||||||
|
|
||||||
int ecore_config_create_typed(const char *key, void *val, int type, char short_opt, char *long_opt, char *desc) {
|
return ecore_config_create_typed(key, val, type, short_opt, long_opt, desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ecore_config_create_typed(const char *key, void *val, int type, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret=ecore_config_default_typed(key, val, type)) != ECORE_CONFIG_ERR_SUCC)
|
if ((ret =
|
||||||
|
ecore_config_default_typed(key, val, type)) != ECORE_CONFIG_ERR_SUCC)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret=ecore_config_set_short_opt(key, short_opt)) != ECORE_CONFIG_ERR_SUCC)
|
if ((ret =
|
||||||
|
ecore_config_set_short_opt(key, short_opt)) != ECORE_CONFIG_ERR_SUCC)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret=ecore_config_set_long_opt(key, long_opt)) != ECORE_CONFIG_ERR_SUCC)
|
if ((ret =
|
||||||
|
ecore_config_set_long_opt(key, long_opt)) != ECORE_CONFIG_ERR_SUCC)
|
||||||
return ret;
|
return ret;
|
||||||
ret = ecore_config_describe(key, desc);
|
ret = ecore_config_describe(key, desc);
|
||||||
return ret;}
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_int(const char *key, int val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_int(const char *key, int val, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
return
|
return
|
||||||
ecore_config_create_typed(key, (void *)&val, PT_INT, short_opt, long_opt, desc);}
|
ecore_config_create_typed(key, (void *)&val, PT_INT, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_int_bound(const char *key, int val, int low, int high, int step, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_int_bound(const char *key, int val, int low, int high,
|
||||||
|
int step, char short_opt, char *long_opt,
|
||||||
|
char *desc)
|
||||||
|
{
|
||||||
Ecore_Config_Prop *e;
|
Ecore_Config_Prop *e;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
ecore_config_create_typed(key, (void *)&val, PT_INT, short_opt, long_opt, desc);
|
ecore_config_create_typed(key, (void *)&val, PT_INT, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
if (ret != ECORE_CONFIG_ERR_SUCC)
|
if (ret != ECORE_CONFIG_ERR_SUCC)
|
||||||
return ret;
|
return ret;
|
||||||
e = ecore_config_get(key);
|
e = ecore_config_get(key);
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
e->step = step;
|
e->step = step;
|
||||||
e->flags |= PF_BOUNDS;
|
e->flags |= PF_BOUNDS;
|
||||||
e->lo = low;
|
e->lo = low;
|
||||||
e->hi = high;
|
e->hi = high;
|
||||||
ecore_config_bound(e);
|
ecore_config_bound(e);
|
||||||
}
|
}
|
||||||
return ret;}
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_string(const char *key, char *val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_string(const char *key, char *val, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
return
|
return
|
||||||
ecore_config_create_typed(key, (void *)val, PT_STR, short_opt, long_opt, desc);}
|
ecore_config_create_typed(key, (void *)val, PT_STR, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_float(const char *key, float val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_float(const char *key, float val, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
return
|
return
|
||||||
ecore_config_create_typed(key, (void *)&val, PT_FLT, short_opt, long_opt, desc);}
|
ecore_config_create_typed(key, (void *)&val, PT_FLT, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_float_bound(const char *key, float val, float low, float high, float step, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_float_bound(const char *key, float val, float low,
|
||||||
|
float high, float step, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
Ecore_Config_Prop *e;
|
Ecore_Config_Prop *e;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
ecore_config_create_typed(key, (void *)&val, PT_FLT, short_opt, long_opt, desc);
|
ecore_config_create_typed(key, (void *)&val, PT_FLT, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
e = ecore_config_get(key);
|
e = ecore_config_get(key);
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
|
e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
|
||||||
e->flags |= PF_BOUNDS;
|
e->flags |= PF_BOUNDS;
|
||||||
e->lo = (int)(low * ECORE_CONFIG_FLOAT_PRECISION);
|
e->lo = (int)(low * ECORE_CONFIG_FLOAT_PRECISION);
|
||||||
e->hi = (int)(high * ECORE_CONFIG_FLOAT_PRECISION);
|
e->hi = (int)(high * ECORE_CONFIG_FLOAT_PRECISION);
|
||||||
ecore_config_bound(e);
|
ecore_config_bound(e);
|
||||||
}
|
}
|
||||||
return ret;}
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_rgb(const char *key, char *val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_rgb(const char *key, char *val, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
return
|
return
|
||||||
ecore_config_create_typed(key, (void *)val, PT_RGB, short_opt, long_opt, desc);}
|
ecore_config_create_typed(key, (void *)val, PT_RGB, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
|
}
|
||||||
|
|
||||||
int ecore_config_create_theme(const char *key, char *val, char short_opt, char *long_opt, char *desc) {
|
int
|
||||||
|
ecore_config_create_theme(const char *key, char *val, char short_opt,
|
||||||
|
char *long_opt, char *desc)
|
||||||
|
{
|
||||||
return
|
return
|
||||||
ecore_config_create_typed(key, (void *)val, PT_THM, short_opt, long_opt, desc);}
|
ecore_config_create_typed(key, (void *)val, PT_THM, short_opt, long_opt,
|
||||||
|
desc);
|
||||||
|
}
|
||||||
|
|
||||||
/* this should only be built if evas is present */
|
/* this should only be built if evas is present */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls evas_font_path_append on @evas for each of the font names stored
|
||||||
|
* in the property "/e/font/path".
|
||||||
|
* @param evas Evas object to append the font names to.
|
||||||
|
* @return ECORE_CONFIG_ERR_SUCC on success. ECORE_CONFIG_ERR_NODATA
|
||||||
|
* is returned if the property has not been set.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
ecore_config_evas_font_path_apply(Evas * evas)
|
ecore_config_evas_font_path_apply(Evas * evas)
|
||||||
{
|
{
|
||||||
|
@ -108,8 +169,12 @@ ecore_config_evas_font_path_apply (Evas * evas)
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *_ecore_config_short_types[]={ "nil", "int", "flt", "str", "rgb", "str"};
|
static char *_ecore_config_short_types[] =
|
||||||
|
{ "nil", "int", "flt", "str", "rgb", "str" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the property list of the local configuration bundle to output.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
ecore_config_args_display(void)
|
ecore_config_args_display(void)
|
||||||
{
|
{
|
||||||
|
@ -119,33 +184,41 @@ ecore_config_args_display(void)
|
||||||
printf("%s\n\n", __ecore_config_app_description);
|
printf("%s\n\n", __ecore_config_app_description);
|
||||||
printf("Supported Options:\n");
|
printf("Supported Options:\n");
|
||||||
printf(" -h, --help\t Print this text\n");
|
printf(" -h, --help\t Print this text\n");
|
||||||
if (!__ecore_config_bundle_local) return;
|
if (!__ecore_config_bundle_local)
|
||||||
|
return;
|
||||||
props = __ecore_config_bundle_local->data;
|
props = __ecore_config_bundle_local->data;
|
||||||
while (props)
|
while (props)
|
||||||
{
|
{
|
||||||
if (props->flags&PF_SYSTEM) {
|
if (props->flags & PF_SYSTEM)
|
||||||
|
{
|
||||||
props = props->next;
|
props = props->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf(" %c%c%c --%s\t<%s> %s\n", props->short_opt ? '-' : ' ',
|
printf(" %c%c%c --%s\t<%s> %s\n", props->short_opt ? '-' : ' ',
|
||||||
props->short_opt?props->short_opt:' ', props->short_opt?',':' ',
|
props->short_opt ? props->short_opt : ' ',
|
||||||
|
props->short_opt ? ',' : ' ',
|
||||||
props->long_opt ? props->long_opt : props->key,
|
props->long_opt ? props->long_opt : props->key,
|
||||||
_ecore_config_short_types[props->type],
|
_ecore_config_short_types[props->type],
|
||||||
props->description?props->description:"(no description available)");
|
props->description ? props->
|
||||||
|
description : "(no description available)");
|
||||||
|
|
||||||
props = props->next;
|
props = props->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_config_parse_set(Ecore_Config_Prop *prop,char *arg,char *opt,char opt2) {
|
ecore_config_parse_set(Ecore_Config_Prop * prop, char *arg, char *opt,
|
||||||
if (!arg) {
|
char opt2)
|
||||||
|
{
|
||||||
|
if (!arg)
|
||||||
|
{
|
||||||
if (opt)
|
if (opt)
|
||||||
printf("Missing expected argument for option --%s\n", opt);
|
printf("Missing expected argument for option --%s\n", opt);
|
||||||
else
|
else
|
||||||
printf("Missing expected argument for option -%c\n", opt2);
|
printf("Missing expected argument for option -%c\n", opt2);
|
||||||
return ECORE_CONFIG_PARSE_EXIT;
|
return ECORE_CONFIG_PARSE_EXIT;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
ecore_config_set(prop->key, arg);
|
ecore_config_set(prop->key, arg);
|
||||||
return ECORE_CONFIG_PARSE_CONTINUE;
|
return ECORE_CONFIG_PARSE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -159,10 +232,12 @@ ecore_config_args_parse(int argc, char **argv)
|
||||||
Ecore_Config_Prop *prop;
|
Ecore_Config_Prop *prop;
|
||||||
|
|
||||||
nextarg = 1;
|
nextarg = 1;
|
||||||
while (nextarg < argc) {
|
while (nextarg < argc)
|
||||||
|
{
|
||||||
arg = argv[nextarg];
|
arg = argv[nextarg];
|
||||||
|
|
||||||
if (*arg != '-') {
|
if (*arg != '-')
|
||||||
|
{
|
||||||
printf("Unexpected attribute \"%s\"\n", arg);
|
printf("Unexpected attribute \"%s\"\n", arg);
|
||||||
nextarg++;
|
nextarg++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -171,54 +246,76 @@ ecore_config_args_parse(int argc, char **argv)
|
||||||
next_short_opt = 1;
|
next_short_opt = 1;
|
||||||
short_opt = *(arg + next_short_opt);
|
short_opt = *(arg + next_short_opt);
|
||||||
|
|
||||||
if (short_opt == '-') {
|
if (short_opt == '-')
|
||||||
|
{
|
||||||
long_opt = arg + 2;
|
long_opt = arg + 2;
|
||||||
|
|
||||||
if (!strcmp(long_opt, "help")) {
|
if (!strcmp(long_opt, "help"))
|
||||||
|
{
|
||||||
ecore_config_args_display();
|
ecore_config_args_display();
|
||||||
return ECORE_CONFIG_PARSE_HELP;
|
return ECORE_CONFIG_PARSE_HELP;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = 0;
|
found = 0;
|
||||||
prop = __ecore_config_bundle_local->data;
|
prop = __ecore_config_bundle_local->data;
|
||||||
while (prop) {
|
while (prop)
|
||||||
|
{
|
||||||
if ((prop->long_opt && !strcmp(long_opt, prop->long_opt))
|
if ((prop->long_opt && !strcmp(long_opt, prop->long_opt))
|
||||||
|| !strcmp(long_opt, prop->key)) {
|
|| !strcmp(long_opt, prop->key))
|
||||||
|
{
|
||||||
found = 1;
|
found = 1;
|
||||||
if ((ret=ecore_config_parse_set(prop, argv[++nextarg], long_opt,'\0'))
|
if ((ret =
|
||||||
!= ECORE_CONFIG_PARSE_CONTINUE);
|
ecore_config_parse_set(prop, argv[++nextarg],
|
||||||
|
long_opt,
|
||||||
|
'\0')) !=
|
||||||
|
ECORE_CONFIG_PARSE_CONTINUE);
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prop = prop->next;
|
prop = prop->next;
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found)
|
||||||
|
{
|
||||||
printf("Unrecognised option \"%s\"\n", long_opt);
|
printf("Unrecognised option \"%s\"\n", long_opt);
|
||||||
printf("Try using -h or --help for more information.\n\n");
|
printf("Try using -h or --help for more information.\n\n");
|
||||||
return ECORE_CONFIG_PARSE_EXIT;
|
return ECORE_CONFIG_PARSE_EXIT;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
while (short_opt) {
|
else
|
||||||
if (short_opt == 'h') {
|
{
|
||||||
|
while (short_opt)
|
||||||
|
{
|
||||||
|
if (short_opt == 'h')
|
||||||
|
{
|
||||||
ecore_config_args_display();
|
ecore_config_args_display();
|
||||||
return ECORE_CONFIG_PARSE_HELP;
|
return ECORE_CONFIG_PARSE_HELP;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
found = 0;
|
found = 0;
|
||||||
prop = __ecore_config_bundle_local->data;
|
prop = __ecore_config_bundle_local->data;
|
||||||
while (prop) {
|
while (prop)
|
||||||
if (short_opt == prop->short_opt) {
|
{
|
||||||
|
if (short_opt == prop->short_opt)
|
||||||
|
{
|
||||||
found = 1;
|
found = 1;
|
||||||
if ((ret=ecore_config_parse_set(prop, argv[++nextarg], NULL, short_opt))
|
if ((ret =
|
||||||
!= ECORE_CONFIG_PARSE_CONTINUE)
|
ecore_config_parse_set(prop,
|
||||||
|
argv[++nextarg],
|
||||||
|
NULL,
|
||||||
|
short_opt)) !=
|
||||||
|
ECORE_CONFIG_PARSE_CONTINUE)
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prop = prop->next;
|
prop = prop->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found)
|
||||||
|
{
|
||||||
printf("Unrecognised option '%c'\n", short_opt);
|
printf("Unrecognised option '%c'\n", short_opt);
|
||||||
printf("Try using -h or --help for more information.\n\n");
|
printf
|
||||||
|
("Try using -h or --help for more information.\n\n");
|
||||||
return ECORE_CONFIG_PARSE_EXIT;
|
return ECORE_CONFIG_PARSE_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +329,8 @@ ecore_config_args_parse(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_config_app_describe(char *description) {
|
ecore_config_app_describe(char *description)
|
||||||
|
{
|
||||||
if (__ecore_config_app_description)
|
if (__ecore_config_app_description)
|
||||||
free(__ecore_config_app_description);
|
free(__ecore_config_app_description);
|
||||||
__ecore_config_app_description = strdup(description);
|
__ecore_config_app_description = strdup(description);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,19 +10,45 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int ecore_config_load(void) {
|
/**
|
||||||
|
* Loads the default configuration.
|
||||||
|
* @return ECORE_CONFIG_ERR_SUCC on success. ECORE_CONFIG_ERR_NODATA is
|
||||||
|
* returned if the file cannot be loaded.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ecore_config_load(void)
|
||||||
|
{
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__ecore_config_app_name);
|
|
||||||
|
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"),
|
||||||
|
__ecore_config_app_name);
|
||||||
return ecore_config_load_file(file);
|
return ecore_config_load_file(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecore_config_save(void) {
|
/**
|
||||||
|
* Saves the current configuration to the default file.
|
||||||
|
* @return ECORE_CONFIG_ERR_SUCC is returned on success.
|
||||||
|
* ECORE_CONFIG_ERR_FAIL is returned if the data cannot be saved.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ecore_config_save(void)
|
||||||
|
{
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__ecore_config_app_name);
|
|
||||||
|
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"),
|
||||||
|
__ecore_config_app_name);
|
||||||
return ecore_config_save_file(file);
|
return ecore_config_save_file(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecore_config_load_file(char *file) {
|
/**
|
||||||
|
* Load the given configuration file to the local configuration.
|
||||||
|
* @param file Name of the file to load.
|
||||||
|
* @return ECORE_CONFIG_ERR_SUCC on success. ECORE_CONFIG_ERR_NODATA is
|
||||||
|
* returned if the file cannot be loaded.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ecore_config_load_file(char *file)
|
||||||
|
{
|
||||||
E_DB_File *db;
|
E_DB_File *db;
|
||||||
char **keys;
|
char **keys;
|
||||||
int key_count;
|
int key_count;
|
||||||
|
@ -31,39 +57,56 @@ int ecore_config_load_file(char *file) {
|
||||||
float ftmp;
|
float ftmp;
|
||||||
char *type;
|
char *type;
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
db = NULL;
|
db = NULL;
|
||||||
type = NULL;
|
type = NULL;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
|
||||||
db = e_db_open_read(file);
|
db = e_db_open_read(file);
|
||||||
if (!db) {
|
if (!db)
|
||||||
|
{
|
||||||
E(0, "Cannot open database from file %s!\n", file);
|
E(0, "Cannot open database from file %s!\n", file);
|
||||||
return ECORE_CONFIG_ERR_NODATA;
|
return ECORE_CONFIG_ERR_NODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
keys = e_db_dump_key_list(file, &key_count);
|
keys = e_db_dump_key_list(file, &key_count);
|
||||||
for (x = 0; x < key_count; x++) {
|
for (x = 0; x < key_count; x++)
|
||||||
|
{
|
||||||
|
|
||||||
type = e_db_type_get(db, keys[x]);
|
type = e_db_type_get(db, keys[x]);
|
||||||
if (!type) type = "?";
|
if (!type)
|
||||||
|
type = "?";
|
||||||
|
|
||||||
if (!strcmp(type, "int")) {
|
if (!strcmp(type, "int"))
|
||||||
if (e_db_int_get(db, keys[x], &itmp)) {
|
{
|
||||||
|
if (e_db_int_get(db, keys[x], &itmp))
|
||||||
|
{
|
||||||
ecore_config_set_int(keys[x], itmp);
|
ecore_config_set_int(keys[x], itmp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
E(0, "Could not read key %s!\n", keys[x]);
|
E(0, "Could not read key %s!\n", keys[x]);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(type, "float")) {
|
}
|
||||||
if (e_db_float_get(db, keys[x], &ftmp)) {
|
else if (!strcmp(type, "float"))
|
||||||
|
{
|
||||||
|
if (e_db_float_get(db, keys[x], &ftmp))
|
||||||
|
{
|
||||||
ecore_config_set_float(keys[x], ftmp);
|
ecore_config_set_float(keys[x], ftmp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
E(0, "Could not read key %s!\n", keys[x]);
|
E(0, "Could not read key %s!\n", keys[x]);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(type, "str")) {
|
}
|
||||||
|
else if (!strcmp(type, "str"))
|
||||||
|
{
|
||||||
data = e_db_str_get(db, keys[x]);
|
data = e_db_str_get(db, keys[x]);
|
||||||
if (data) {
|
if (data)
|
||||||
|
{
|
||||||
itmp = ecore_config_guess_type(keys[x], data);
|
itmp = ecore_config_guess_type(keys[x], data);
|
||||||
switch (itmp) {
|
switch (itmp)
|
||||||
|
{
|
||||||
case PT_RGB:
|
case PT_RGB:
|
||||||
ecore_config_set_rgb(keys[x], data);
|
ecore_config_set_rgb(keys[x], data);
|
||||||
break;
|
break;
|
||||||
|
@ -74,22 +117,29 @@ int ecore_config_load_file(char *file) {
|
||||||
ecore_config_set_string(keys[x], data);
|
ecore_config_set_string(keys[x], data);
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
E(0, "Could not read key %s!\n", keys[x]);
|
E(0, "Could not read key %s!\n", keys[x]);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
E(1, "Unexpected type: %s\n", type);
|
E(1, "Unexpected type: %s\n", type);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type) free(type);
|
if (type)
|
||||||
|
free(type);
|
||||||
}
|
}
|
||||||
e_db_close(db);
|
e_db_close(db);
|
||||||
free(keys);
|
free(keys);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_config_recurse_mkdir(char *file) {
|
_ecore_config_recurse_mkdir(char *file)
|
||||||
|
{
|
||||||
char *file_ptr;
|
char *file_ptr;
|
||||||
char *file_tmp;
|
char *file_tmp;
|
||||||
struct stat status;
|
struct stat status;
|
||||||
|
@ -100,17 +150,27 @@ _ecore_config_recurse_mkdir(char *file) {
|
||||||
file_ptr--;
|
file_ptr--;
|
||||||
*file_ptr = '\0';
|
*file_ptr = '\0';
|
||||||
|
|
||||||
if(stat(file_tmp, &status)) {
|
if (stat(file_tmp, &status))
|
||||||
|
{
|
||||||
_ecore_config_recurse_mkdir(file_tmp);
|
_ecore_config_recurse_mkdir(file_tmp);
|
||||||
mkdir(file_tmp, S_IRUSR | S_IWUSR | S_IXUSR);
|
mkdir(file_tmp, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||||
}
|
}
|
||||||
free(file_tmp);
|
free(file_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecore_config_save_file(char *file) {
|
/**
|
||||||
|
* Saves the local configuration to the given file.
|
||||||
|
* @param file Name of the file to save to.
|
||||||
|
* @return ECORE_CONFIG_ERR_SUCC is returned on success.
|
||||||
|
* ECORE_CONFIG_ERR_FAIL is returned if the data cannot be saved.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ecore_config_save_file(char *file)
|
||||||
|
{
|
||||||
Ecore_Config_Prop *next;
|
Ecore_Config_Prop *next;
|
||||||
E_DB_File *db;
|
E_DB_File *db;
|
||||||
struct stat status;
|
struct stat status;
|
||||||
|
|
||||||
next = __ecore_config_bundle_local->data;
|
next = __ecore_config_bundle_local->data;
|
||||||
db = NULL;
|
db = NULL;
|
||||||
|
|
||||||
|
@ -119,17 +179,21 @@ int ecore_config_save_file(char *file) {
|
||||||
_ecore_config_recurse_mkdir(file);
|
_ecore_config_recurse_mkdir(file);
|
||||||
|
|
||||||
db = e_db_open(file);
|
db = e_db_open(file);
|
||||||
if (!db) {
|
if (!db)
|
||||||
|
{
|
||||||
E(0, "Cannot open database from file %s!\n", file);
|
E(0, "Cannot open database from file %s!\n", file);
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (next) {
|
while (next)
|
||||||
if (!(next->flags&PF_MODIFIED)) {
|
{
|
||||||
|
if (!(next->flags & PF_MODIFIED))
|
||||||
|
{
|
||||||
next = next->next;
|
next = next->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (next->type) {
|
switch (next->type)
|
||||||
|
{
|
||||||
case PT_INT:
|
case PT_INT:
|
||||||
e_db_int_set(db, next->key, ecore_config_get_int(next->key));
|
e_db_int_set(db, next->key, ecore_config_get_int(next->key));
|
||||||
break;
|
break;
|
||||||
|
@ -157,4 +221,3 @@ int ecore_config_save_file(char *file) {
|
||||||
e_db_flush();
|
e_db_flush();
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include <Ecore_Ipc.h>
|
#include <Ecore_Ipc.h>
|
||||||
#include "Ecore_Config.h"
|
#include "Ecore_Config.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
IPC_NONE,
|
IPC_NONE,
|
||||||
IPC_PROP_LIST,
|
IPC_PROP_LIST,
|
||||||
IPC_GLOBAL_PROP_LIST,
|
IPC_GLOBAL_PROP_LIST,
|
||||||
|
@ -20,14 +21,26 @@ typedef enum {
|
||||||
|
|
||||||
Ecore_Config_Server *_ecore_config_server_convert(void *srv);
|
Ecore_Config_Server *_ecore_config_server_convert(void *srv);
|
||||||
|
|
||||||
char *_ecore_config_ipc_prop_list(Ecore_Config_Server *srv, const long serial);
|
char *_ecore_config_ipc_prop_list(Ecore_Config_Server * srv,
|
||||||
char *_ecore_config_ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key);
|
const long serial);
|
||||||
char *_ecore_config_ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key);
|
char *_ecore_config_ipc_prop_desc(Ecore_Config_Server * srv,
|
||||||
int _ecore_config_ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,const char *val);
|
const long serial,
|
||||||
|
const char *key);
|
||||||
|
char *_ecore_config_ipc_prop_get(Ecore_Config_Server * srv,
|
||||||
|
const long serial,
|
||||||
|
const char *key);
|
||||||
|
int _ecore_config_ipc_prop_set(Ecore_Config_Server * srv,
|
||||||
|
const long serial,
|
||||||
|
const char *key,
|
||||||
|
const char *val);
|
||||||
|
|
||||||
char *_ecore_config_ipc_bundle_list(Ecore_Config_Server * srv);
|
char *_ecore_config_ipc_bundle_list(Ecore_Config_Server * srv);
|
||||||
int _ecore_config_ipc_bundle_new(Ecore_Config_Server *srv, const char *);
|
int _ecore_config_ipc_bundle_new(Ecore_Config_Server * srv,
|
||||||
char *_ecore_config_ipc_bundle_label_get(Ecore_Config_Server *srv, const long);
|
const char *);
|
||||||
int _ecore_config_ipc_bundle_label_set(Ecore_Config_Server *srv, const long,const char *);
|
char *_ecore_config_ipc_bundle_label_get(Ecore_Config_Server *
|
||||||
long _ecore_config_ipc_bundle_label_find(Ecore_Config_Server *srv, const char *);
|
srv, const long);
|
||||||
|
int _ecore_config_ipc_bundle_label_set(Ecore_Config_Server *
|
||||||
|
srv, const long,
|
||||||
|
const char *);
|
||||||
|
long _ecore_config_ipc_bundle_label_find(Ecore_Config_Server *
|
||||||
|
srv, const char *);
|
||||||
|
|
|
@ -21,12 +21,11 @@
|
||||||
#include "Ecore_Config.h"
|
#include "Ecore_Config.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_ecore_get_string(char **m, char **r)
|
||||||
static int _ecore_config_ipc_ecore_get_string(char **m,char **r) {
|
{
|
||||||
char *q;
|
char *q;
|
||||||
int l = 0;
|
int l = 0;
|
||||||
|
|
||||||
|
@ -44,10 +43,12 @@ static int _ecore_config_ipc_ecore_get_string(char **m,char **r) {
|
||||||
q += l;
|
q += l;
|
||||||
*m = q;
|
*m = q;
|
||||||
E(1, "IPC/eCore: got string-%d \"%s\"\n", l, *r);
|
E(1, "IPC/eCore: got string-%d \"%s\"\n", l, *r);
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
char *_ecore_config_ipc_global_prop_list(Ecore_Config_Server *srv, const long serial) {
|
_ecore_config_ipc_global_prop_list(Ecore_Config_Server * srv, const long serial)
|
||||||
|
{
|
||||||
E_DB_File *db;
|
E_DB_File *db;
|
||||||
char **keys;
|
char **keys;
|
||||||
int key_count, x;
|
int key_count, x;
|
||||||
|
@ -57,8 +58,10 @@ char *_ecore_config_ipc_global_prop_list(Ecore_Config_Server *srv, const long se
|
||||||
|
|
||||||
s = estring_new(8192);
|
s = estring_new(8192);
|
||||||
f = 0;
|
f = 0;
|
||||||
if((p=getenv("HOME"))) { /* debug-only ### FIXME */
|
if ((p = getenv("HOME")))
|
||||||
if ((buf=malloc(PATH_MAX*sizeof(char)))) {
|
{ /* debug-only ### FIXME */
|
||||||
|
if ((buf = malloc(PATH_MAX * sizeof(char))))
|
||||||
|
{
|
||||||
snprintf(buf, PATH_MAX, "%s/.e/config.db", p);
|
snprintf(buf, PATH_MAX, "%s/.e/config.db", p);
|
||||||
db = e_db_open_read(buf);
|
db = e_db_open_read(buf);
|
||||||
if (!(db = e_db_open_read(buf)))
|
if (!(db = e_db_open_read(buf)))
|
||||||
|
@ -70,57 +73,67 @@ char *_ecore_config_ipc_global_prop_list(Ecore_Config_Server *srv, const long se
|
||||||
keys = e_db_dump_key_list(buf, &key_count);
|
keys = e_db_dump_key_list(buf, &key_count);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
for (x = 0; x < key_count; x++) {
|
for (x = 0; x < key_count; x++)
|
||||||
|
{
|
||||||
type = e_db_type_get(db, keys[x]);
|
type = e_db_type_get(db, keys[x]);
|
||||||
if (!type) type = "?";
|
if (!type)
|
||||||
|
type = "?";
|
||||||
|
|
||||||
if (!strcmp(type, "int"))
|
if (!strcmp(type, "int"))
|
||||||
estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]);
|
||||||
else if (!strcmp(type, "float"))
|
else if (!strcmp(type, "float"))
|
||||||
estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]);
|
||||||
else if (!strcmp(type, "str")) {
|
else if (!strcmp(type, "str"))
|
||||||
|
{
|
||||||
data = e_db_str_get(db, keys[x]);
|
data = e_db_str_get(db, keys[x]);
|
||||||
if (data) {
|
if (data)
|
||||||
|
{
|
||||||
if (ecore_config_guess_type(keys[x], data) == PT_RGB)
|
if (ecore_config_guess_type(keys[x], data) == PT_RGB)
|
||||||
estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]);
|
||||||
else
|
else
|
||||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]);
|
estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]);
|
||||||
|
|
||||||
if (type) free(type);
|
if (type)
|
||||||
|
free(type);
|
||||||
f = 1;
|
f = 1;
|
||||||
}
|
}
|
||||||
e_db_close(db);
|
e_db_close(db);
|
||||||
free(keys);
|
free(keys);
|
||||||
|
|
||||||
return estring_disown(s);}
|
return estring_disown(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_ecore_send(Ecore_Ipc_Event_Client_Data * e, int code,
|
||||||
static int _ecore_config_ipc_ecore_send(Ecore_Ipc_Event_Client_Data *e,int code,char *reply) {
|
char *reply)
|
||||||
|
{
|
||||||
static int our_ref = 0;
|
static int our_ref = 0;
|
||||||
int len = reply ? strlen(reply) + 1 : 0;
|
int len = reply ? strlen(reply) + 1 : 0;
|
||||||
|
|
||||||
our_ref++;
|
our_ref++;
|
||||||
E(1,"IPC/eCore: replying [0,0] %d IRT %d => %d {\"%s\":%d}\n",our_ref,e->ref,code,reply?reply:"",len);
|
E(1, "IPC/eCore: replying [0,0] %d IRT %d => %d {\"%s\":%d}\n", our_ref,
|
||||||
return ecore_ipc_client_send(e->client,0,0,our_ref,e->ref,code,reply,len); }
|
e->ref, code, reply ? reply : "", len);
|
||||||
|
return ecore_ipc_client_send(e->client, 0, 0, our_ref, e->ref, code, reply,
|
||||||
|
len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static int _ecore_config_ipc_ecore_handle_request(Ecore_Ipc_Server *server,Ecore_Ipc_Event_Client_Data *e) {
|
static int
|
||||||
|
_ecore_config_ipc_ecore_handle_request(Ecore_Ipc_Server * server,
|
||||||
|
Ecore_Ipc_Event_Client_Data * e)
|
||||||
|
{
|
||||||
Ecore_Config_Server *srv;
|
Ecore_Config_Server *srv;
|
||||||
long serial;
|
long serial;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -131,9 +144,11 @@ static int _ecore_config_ipc_ecore_handle_request(Ecore_Ipc_Server *server,Ecore
|
||||||
ret = ECORE_CONFIG_ERR_FAIL;
|
ret = ECORE_CONFIG_ERR_FAIL;
|
||||||
r = NULL;
|
r = NULL;
|
||||||
m = (char *)e->data;
|
m = (char *)e->data;
|
||||||
E(1,"IPC/eCore: client sent: [%d,%d] #%d (%d) @ %p\n",e->major,e->minor,e->ref,e->size,server);
|
E(1, "IPC/eCore: client sent: [%d,%d] #%d (%d) @ %p\n", e->major, e->minor,
|
||||||
|
e->ref, e->size, server);
|
||||||
|
|
||||||
switch(e->major) {
|
switch (e->major)
|
||||||
|
{
|
||||||
case IPC_PROP_LIST:
|
case IPC_PROP_LIST:
|
||||||
if (srv == __ecore_config_server_global)
|
if (srv == __ecore_config_server_global)
|
||||||
r = _ecore_config_ipc_global_prop_list(srv, serial);
|
r = _ecore_config_ipc_global_prop_list(srv, serial);
|
||||||
|
@ -149,9 +164,14 @@ static int _ecore_config_ipc_ecore_handle_request(Ecore_Ipc_Server *server,Ecore
|
||||||
r = _ecore_config_ipc_prop_get(srv, serial, k);
|
r = _ecore_config_ipc_prop_get(srv, serial, k);
|
||||||
break;
|
break;
|
||||||
case IPC_PROP_SET:
|
case IPC_PROP_SET:
|
||||||
if(_ecore_config_ipc_ecore_get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC) {
|
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
||||||
if(_ecore_config_ipc_ecore_get_string(&m,&v)==ECORE_CONFIG_ERR_SUCC)
|
{
|
||||||
return _ecore_config_ipc_ecore_send(e,_ecore_config_ipc_prop_set(srv, serial,k,v),NULL); }
|
if (_ecore_config_ipc_ecore_get_string(&m, &v) ==
|
||||||
|
ECORE_CONFIG_ERR_SUCC)
|
||||||
|
return _ecore_config_ipc_ecore_send(e,
|
||||||
|
_ecore_config_ipc_prop_set
|
||||||
|
(srv, serial, k, v), NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IPC_BUNDLE_LIST:
|
case IPC_BUNDLE_LIST:
|
||||||
|
@ -159,38 +179,52 @@ static int _ecore_config_ipc_ecore_handle_request(Ecore_Ipc_Server *server,Ecore
|
||||||
break;
|
break;
|
||||||
case IPC_BUNDLE_NEW:
|
case IPC_BUNDLE_NEW:
|
||||||
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
||||||
return _ecore_config_ipc_ecore_send(e,k?_ecore_config_ipc_bundle_new(srv, k):ECORE_CONFIG_ERR_FAIL,NULL);
|
return _ecore_config_ipc_ecore_send(e,
|
||||||
|
k ?
|
||||||
|
_ecore_config_ipc_bundle_new(srv,
|
||||||
|
k) :
|
||||||
|
ECORE_CONFIG_ERR_FAIL, NULL);
|
||||||
break;
|
break;
|
||||||
case IPC_BUNDLE_LABEL_SET:
|
case IPC_BUNDLE_LABEL_SET:
|
||||||
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
||||||
return _ecore_config_ipc_ecore_send(e,k?_ecore_config_ipc_bundle_label_set(srv, serial,k):ECORE_CONFIG_ERR_FAIL,NULL);
|
return _ecore_config_ipc_ecore_send(e,
|
||||||
|
k ?
|
||||||
|
_ecore_config_ipc_bundle_label_set
|
||||||
|
(srv, serial,
|
||||||
|
k) : ECORE_CONFIG_ERR_FAIL,
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
case IPC_BUNDLE_LABEL_FIND:
|
case IPC_BUNDLE_LABEL_FIND:
|
||||||
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
if (_ecore_config_ipc_ecore_get_string(&m, &k) == ECORE_CONFIG_ERR_SUCC)
|
||||||
return _ecore_config_ipc_ecore_send(e,_ecore_config_ipc_bundle_label_find(srv, k),NULL);
|
return _ecore_config_ipc_ecore_send(e,
|
||||||
|
_ecore_config_ipc_bundle_label_find
|
||||||
|
(srv, k), NULL);
|
||||||
break;
|
break;
|
||||||
case IPC_BUNDLE_LABEL_GET:
|
case IPC_BUNDLE_LABEL_GET:
|
||||||
r = _ecore_config_ipc_bundle_label_get(srv, serial);
|
r = _ecore_config_ipc_bundle_label_get(srv, serial);
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret=_ecore_config_ipc_ecore_send(e,r?ECORE_CONFIG_ERR_SUCC:ECORE_CONFIG_ERR_FAIL,r);
|
ret =
|
||||||
if(r) {
|
_ecore_config_ipc_ecore_send(e,
|
||||||
|
r ? ECORE_CONFIG_ERR_SUCC :
|
||||||
|
ECORE_CONFIG_ERR_FAIL, r);
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
free(r);
|
free(r);
|
||||||
return ret; }
|
return ret;
|
||||||
return ECORE_CONFIG_ERR_NOTFOUND; }
|
}
|
||||||
|
return ECORE_CONFIG_ERR_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_client_add(void *data, int type, void *event)
|
||||||
static int _ecore_config_ipc_client_add(void *data,int type,void *event) {
|
{
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
Ecore_Ipc_Event_Client_Data *e;
|
Ecore_Ipc_Event_Client_Data *e;
|
||||||
|
|
||||||
server = (Ecore_Ipc_Server **) data;
|
server = (Ecore_Ipc_Server **) data;
|
||||||
e = (Ecore_Ipc_Event_Client_Data *) event;
|
e = (Ecore_Ipc_Event_Client_Data *) event;
|
||||||
|
|
||||||
|
@ -198,13 +232,15 @@ static int _ecore_config_ipc_client_add(void *data,int type,void *event) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
E(1, "IPC/eCore: Client connected. @ %p\n", server);
|
E(1, "IPC/eCore: Client connected. @ %p\n", server);
|
||||||
return 1; }
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_client_del(void *data, int type, void *event)
|
||||||
static int _ecore_config_ipc_client_del(void *data, int type, void *event) {
|
{
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
Ecore_Ipc_Event_Client_Data *e;
|
Ecore_Ipc_Event_Client_Data *e;
|
||||||
|
|
||||||
server = (Ecore_Ipc_Server **) data;
|
server = (Ecore_Ipc_Server **) data;
|
||||||
e = (Ecore_Ipc_Event_Client_Data *) event;
|
e = (Ecore_Ipc_Event_Client_Data *) event;
|
||||||
|
|
||||||
|
@ -212,13 +248,15 @@ static int _ecore_config_ipc_client_del(void *data, int type, void *event) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
E(1, "IPC/eCore: Client disconnected. @ %p\n", server);
|
E(1, "IPC/eCore: Client disconnected. @ %p\n", server);
|
||||||
return 1; }
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_client_sent(void *data, int type, void *event)
|
||||||
static int _ecore_config_ipc_client_sent(void *data,int type,void *event) {
|
{
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
Ecore_Ipc_Event_Client_Data *e;
|
Ecore_Ipc_Event_Client_Data *e;
|
||||||
|
|
||||||
server = (Ecore_Ipc_Server **) data;
|
server = (Ecore_Ipc_Server **) data;
|
||||||
e = (Ecore_Ipc_Event_Client_Data *) event;
|
e = (Ecore_Ipc_Event_Client_Data *) event;
|
||||||
|
|
||||||
|
@ -226,18 +264,14 @@ static int _ecore_config_ipc_client_sent(void *data,int type,void *event) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
_ecore_config_ipc_ecore_handle_request(*server, e);
|
_ecore_config_ipc_ecore_handle_request(*server, e);
|
||||||
return 1; }
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_mod_init(char *pipe_name, void **data)
|
||||||
int _ecore_config_mod_init(char *pipe_name, void **data) {
|
{
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -256,63 +290,74 @@ int _ecore_config_mod_init(char *pipe_name, void **data) {
|
||||||
if (ecore_ipc_init() < 1)
|
if (ecore_ipc_init() < 1)
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
|
|
||||||
if((p=getenv("HOME"))) { /* debug-only ### FIXME */
|
if ((p = getenv("HOME")))
|
||||||
|
{ /* debug-only ### FIXME */
|
||||||
int stale;
|
int stale;
|
||||||
|
|
||||||
stale = 1;
|
stale = 1;
|
||||||
while (stale) {
|
while (stale)
|
||||||
|
{
|
||||||
snprintf(socket, PATH_MAX, "%s/.ecore/%s/%d", p, pipe_name, port);
|
snprintf(socket, PATH_MAX, "%s/.ecore/%s/%d", p, pipe_name, port);
|
||||||
|
|
||||||
if(!stat(socket,&st)) {
|
if (!stat(socket, &st))
|
||||||
|
{
|
||||||
E(0, "IPC/eCore: pipe \"%s\" already exists!?\n", socket);
|
E(0, "IPC/eCore: pipe \"%s\" already exists!?\n", socket);
|
||||||
/* if(unlink(buf))
|
/* if(unlink(buf))
|
||||||
E(0,"IPC/eCore: could not remove pipe \"%s\": %d\n",buf,errno); }}*/
|
E(0,"IPC/eCore: could not remove pipe \"%s\": %d\n",buf,errno); }}*/
|
||||||
port++;
|
port++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
stale = 0;
|
stale = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, pipe_name, port, NULL);
|
*server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, pipe_name, port, NULL);
|
||||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _ecore_config_ipc_client_add, server);
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
|
||||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _ecore_config_ipc_client_del, server);
|
_ecore_config_ipc_client_add, server);
|
||||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,_ecore_config_ipc_client_sent,server);
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
|
||||||
|
_ecore_config_ipc_client_del, server);
|
||||||
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,
|
||||||
|
_ecore_config_ipc_client_sent, server);
|
||||||
|
|
||||||
if(server) {
|
if (server)
|
||||||
|
{
|
||||||
E(1, "IPC/eCore: Server is listening on %s.\n", pipe_name);
|
E(1, "IPC/eCore: Server is listening on %s.\n", pipe_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_mod_exit(void **data)
|
||||||
int _ecore_config_mod_exit(void **data) {
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
|
|
||||||
ret = ECORE_CONFIG_ERR_SUCC;
|
ret = ECORE_CONFIG_ERR_SUCC;
|
||||||
server = (Ecore_Ipc_Server **) data;
|
server = (Ecore_Ipc_Server **) data;
|
||||||
|
|
||||||
if (!server)
|
if (!server)
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
|
|
||||||
if(*server) {
|
if (*server)
|
||||||
|
{
|
||||||
ecore_ipc_server_del(*server);
|
ecore_ipc_server_del(*server);
|
||||||
*server=NULL; }
|
*server = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ecore_ipc_shutdown();
|
ecore_ipc_shutdown();
|
||||||
|
|
||||||
return ret; }
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_mod_poll(void **data)
|
||||||
int _ecore_config_mod_poll(void **data) {
|
{
|
||||||
Ecore_Ipc_Server **server;
|
Ecore_Ipc_Server **server;
|
||||||
|
|
||||||
server = (Ecore_Ipc_Server **) data;
|
server = (Ecore_Ipc_Server **) data;
|
||||||
|
|
||||||
if (!server)
|
if (!server)
|
||||||
|
@ -320,8 +365,7 @@ int _ecore_config_mod_poll(void **data) {
|
||||||
|
|
||||||
ecore_main_loop_iterate();
|
ecore_main_loop_iterate();
|
||||||
|
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* ############## bad */
|
/* ############## bad */
|
||||||
#define HAVE_EVAS2
|
#define HAVE_EVAS2
|
||||||
|
|
||||||
|
|
||||||
#include "Ecore_Config.h"
|
#include "Ecore_Config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
@ -21,7 +20,8 @@
|
||||||
# define TRUE (!FALSE)
|
# define TRUE (!FALSE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _ecore_config_ipc {
|
typedef struct _ecore_config_ipc
|
||||||
|
{
|
||||||
void *lib;
|
void *lib;
|
||||||
void *data;
|
void *data;
|
||||||
int (*ipc_init) (char *pipe_name, void **data);
|
int (*ipc_init) (char *pipe_name, void **data);
|
||||||
|
@ -30,20 +30,21 @@ typedef struct _ecore_config_ipc {
|
||||||
struct _ecore_config_ipc *next;
|
struct _ecore_config_ipc *next;
|
||||||
} Ecore_Config_Ipc;
|
} Ecore_Config_Ipc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Ecore_Config_Ipc *ipc_modules = NULL;
|
static Ecore_Config_Ipc *ipc_modules = NULL;
|
||||||
static unsigned long ipc_timer = 0L;
|
static unsigned long ipc_timer = 0L;
|
||||||
|
|
||||||
|
Ecore_Config_Server *
|
||||||
Ecore_Config_Server *_ecore_config_server_convert(void *srv) {
|
_ecore_config_server_convert(void *srv)
|
||||||
|
{
|
||||||
Ecore_Config_Ipc *ipc_tmp;
|
Ecore_Config_Ipc *ipc_tmp;
|
||||||
Ecore_Config_Server *srv_tmp;
|
Ecore_Config_Server *srv_tmp;
|
||||||
|
|
||||||
ipc_tmp = ipc_modules;
|
ipc_tmp = ipc_modules;
|
||||||
while (ipc_tmp) {
|
while (ipc_tmp)
|
||||||
|
{
|
||||||
srv_tmp = ipc_tmp->data;
|
srv_tmp = ipc_tmp->data;
|
||||||
while (srv_tmp) {
|
while (srv_tmp)
|
||||||
|
{
|
||||||
if (srv_tmp->server == srv)
|
if (srv_tmp->server == srv)
|
||||||
return srv_tmp;
|
return srv_tmp;
|
||||||
srv_tmp = srv_tmp->next;
|
srv_tmp = srv_tmp->next;
|
||||||
|
@ -58,9 +59,9 @@ Ecore_Config_Server *_ecore_config_server_convert(void *srv) {
|
||||||
/* INTERFACE FOR IPC MODULES */
|
/* INTERFACE FOR IPC MODULES */
|
||||||
/*****************************/
|
/*****************************/
|
||||||
|
|
||||||
|
char *
|
||||||
|
_ecore_config_ipc_prop_list(Ecore_Config_Server * srv, const long serial)
|
||||||
char *_ecore_config_ipc_prop_list(Ecore_Config_Server *srv, const long serial) {
|
{
|
||||||
Ecore_Config_Bundle *theme;
|
Ecore_Config_Bundle *theme;
|
||||||
Ecore_Config_Prop *e;
|
Ecore_Config_Prop *e;
|
||||||
estring *s;
|
estring *s;
|
||||||
|
@ -70,77 +71,97 @@ char *_ecore_config_ipc_prop_list(Ecore_Config_Server *srv, const long serial) {
|
||||||
e = theme ? theme->data : NULL;
|
e = theme ? theme->data : NULL;
|
||||||
s = estring_new(8192);
|
s = estring_new(8192);
|
||||||
f = 0;
|
f = 0;
|
||||||
while(e) {
|
while (e)
|
||||||
|
{
|
||||||
/* ignore system properties in listings, unless they have been overridden */
|
/* ignore system properties in listings, unless they have been overridden */
|
||||||
if (e->flags&PF_SYSTEM && !(e->flags&PF_MODIFIED)) {
|
if (e->flags & PF_SYSTEM && !(e->flags & PF_MODIFIED))
|
||||||
|
{
|
||||||
e = e->next;
|
e = e->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
estring_appendf(s,"%s%s: %s",f?"\n":"",e->key,ecore_config_get_type(e));
|
estring_appendf(s, "%s%s: %s", f ? "\n" : "", e->key,
|
||||||
if(e->flags&PF_BOUNDS) {
|
ecore_config_get_type(e));
|
||||||
|
if (e->flags & PF_BOUNDS)
|
||||||
|
{
|
||||||
if (e->type == PT_FLT)
|
if (e->type == PT_FLT)
|
||||||
estring_appendf(s,", range %le..%le",(float)e->lo/ECORE_CONFIG_FLOAT_PRECISION,(float)e->hi/ECORE_CONFIG_FLOAT_PRECISION);
|
estring_appendf(s, ", range %le..%le",
|
||||||
|
(float)e->lo / ECORE_CONFIG_FLOAT_PRECISION,
|
||||||
|
(float)e->hi / ECORE_CONFIG_FLOAT_PRECISION);
|
||||||
else
|
else
|
||||||
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
||||||
}
|
}
|
||||||
if (e->type == PT_THM)
|
if (e->type == PT_THM)
|
||||||
estring_appendf(s, ", group %s", e->data ? e->data : "Main");
|
estring_appendf(s, ", group %s", e->data ? e->data : "Main");
|
||||||
f = 1;
|
f = 1;
|
||||||
e=e->next; }
|
e = e->next;
|
||||||
|
}
|
||||||
|
|
||||||
return estring_disown(s); }
|
return estring_disown(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_ecore_config_ipc_prop_desc(Ecore_Config_Server * srv, const long serial,
|
||||||
char *_ecore_config_ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key) {
|
const char *key)
|
||||||
|
{
|
||||||
#ifdef HAVE_EVAS2
|
#ifdef HAVE_EVAS2
|
||||||
Ecore_Config_Bundle *theme;
|
Ecore_Config_Bundle *theme;
|
||||||
Ecore_Config_Prop *e;
|
Ecore_Config_Prop *e;
|
||||||
|
|
||||||
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
||||||
e = ecore_config_get(key);
|
e = ecore_config_get(key);
|
||||||
|
|
||||||
if(e) {
|
if (e)
|
||||||
|
{
|
||||||
estring *s = estring_new(512);
|
estring *s = estring_new(512);
|
||||||
|
|
||||||
estring_appendf(s, "%s: %s", e->key, ecore_config_get_type(e));
|
estring_appendf(s, "%s: %s", e->key, ecore_config_get_type(e));
|
||||||
if (e->flags & PF_BOUNDS)
|
if (e->flags & PF_BOUNDS)
|
||||||
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
||||||
return estring_disown(s); }
|
return estring_disown(s);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return strdup("<undefined>"); }
|
return strdup("<undefined>");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_ecore_config_ipc_prop_get(Ecore_Config_Server * srv, const long serial,
|
||||||
char *_ecore_config_ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key) {
|
const char *key)
|
||||||
|
{
|
||||||
#ifdef HAVE_EVAS2
|
#ifdef HAVE_EVAS2
|
||||||
char *ret;
|
char *ret;
|
||||||
Ecore_Config_Bundle *theme;
|
Ecore_Config_Bundle *theme;
|
||||||
|
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
||||||
if ((ret = ecore_config_get_as_string( /*theme, */ key)))
|
if ((ret = ecore_config_get_as_string( /*theme, */ key)))
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
return strdup("<undefined>"); }
|
return strdup("<undefined>");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_ipc_prop_set(Ecore_Config_Server * srv, const long serial,
|
||||||
int _ecore_config_ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,const char *val) {
|
const char *key, const char *val)
|
||||||
|
{
|
||||||
#ifdef HAVE_EVAS2
|
#ifdef HAVE_EVAS2
|
||||||
int ret;
|
int ret;
|
||||||
Ecore_Config_Bundle *theme;
|
Ecore_Config_Bundle *theme;
|
||||||
|
|
||||||
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
theme = ecore_config_bundle_get_by_serial(srv, serial);
|
||||||
ret = ecore_config_set(key, (char *)val);
|
ret = ecore_config_set(key, (char *)val);
|
||||||
E(1,"ipc.prop.set(%s->%s,\"%s\") => %d\n",theme?theme->identifier:"",key,val,ret);
|
E(1, "ipc.prop.set(%s->%s,\"%s\") => %d\n", theme ? theme->identifier : "",
|
||||||
|
key, val, ret);
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP;
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
char *
|
||||||
char *_ecore_config_ipc_bundle_list(Ecore_Config_Server *srv) {
|
_ecore_config_ipc_bundle_list(Ecore_Config_Server * srv)
|
||||||
|
{
|
||||||
Ecore_Config_Bundle *ns;
|
Ecore_Config_Bundle *ns;
|
||||||
estring *s;
|
estring *s;
|
||||||
int f;
|
int f;
|
||||||
|
@ -151,86 +172,107 @@ char *_ecore_config_ipc_bundle_list(Ecore_Config_Server *srv) {
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return strdup("<no_bundles_created>");
|
return strdup("<no_bundles_created>");
|
||||||
|
|
||||||
while(ns) {
|
while (ns)
|
||||||
estring_appendf(s,"%s%d: %s",f?"\n":"",ecore_config_bundle_get_serial(ns),ecore_config_bundle_get_label(ns));
|
{
|
||||||
|
estring_appendf(s, "%s%d: %s", f ? "\n" : "",
|
||||||
|
ecore_config_bundle_get_serial(ns),
|
||||||
|
ecore_config_bundle_get_label(ns));
|
||||||
f = 1;
|
f = 1;
|
||||||
ns=ecore_config_bundle_get_next(ns); }
|
ns = ecore_config_bundle_get_next(ns);
|
||||||
|
}
|
||||||
|
|
||||||
return estring_disown(s); }
|
return estring_disown(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_ipc_bundle_new(Ecore_Config_Server * srv, const char *label)
|
||||||
int _ecore_config_ipc_bundle_new(Ecore_Config_Server *srv, const char *label) {
|
{
|
||||||
if (ecore_config_bundle_new(srv, label))
|
if (ecore_config_bundle_new(srv, label))
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
return ECORE_CONFIG_ERR_FAIL; }
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_ecore_config_ipc_bundle_label_get(Ecore_Config_Server * srv, const long serial)
|
||||||
char *_ecore_config_ipc_bundle_label_get(Ecore_Config_Server *srv, const long serial) {
|
{
|
||||||
Ecore_Config_Bundle *ns;
|
Ecore_Config_Bundle *ns;
|
||||||
char *label;
|
char *label;
|
||||||
|
|
||||||
ns = ecore_config_bundle_get_by_serial(srv, serial);
|
ns = ecore_config_bundle_get_by_serial(srv, serial);
|
||||||
label = ecore_config_bundle_get_label(ns);
|
label = ecore_config_bundle_get_label(ns);
|
||||||
return strdup(label?label:"<no such bundle>"); }
|
return strdup(label ? label : "<no such bundle>");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_ipc_bundle_label_set(Ecore_Config_Server * srv, const long serial,
|
||||||
int _ecore_config_ipc_bundle_label_set(Ecore_Config_Server *srv, const long serial,const char *label) {
|
const char *label)
|
||||||
|
{
|
||||||
Ecore_Config_Bundle *ns;
|
Ecore_Config_Bundle *ns;
|
||||||
|
|
||||||
ns = ecore_config_bundle_get_by_serial(srv, serial);
|
ns = ecore_config_bundle_get_by_serial(srv, serial);
|
||||||
if (!(ns->identifier = malloc(sizeof(label))))
|
if (!(ns->identifier = malloc(sizeof(label))))
|
||||||
return ECORE_CONFIG_ERR_OOM;
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
memcpy(ns->identifier, label, sizeof(label));
|
memcpy(ns->identifier, label, sizeof(label));
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
_ecore_config_ipc_bundle_label_find(Ecore_Config_Server * srv,
|
||||||
long _ecore_config_ipc_bundle_label_find(Ecore_Config_Server *srv, const char *label) {
|
const char *label)
|
||||||
|
{
|
||||||
Ecore_Config_Bundle *ns;
|
Ecore_Config_Bundle *ns;
|
||||||
|
|
||||||
ns = ecore_config_bundle_get_by_label(srv, label);
|
ns = ecore_config_bundle_get_by_label(srv, label);
|
||||||
return ns?ecore_config_bundle_get_serial(ns):-1; }
|
return ns ? ecore_config_bundle_get_serial(ns) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_config_ipc_poll(void *data)
|
||||||
|
{
|
||||||
static int _ecore_config_ipc_poll(void *data) {
|
|
||||||
Ecore_Config_Ipc *m;
|
Ecore_Config_Ipc *m;
|
||||||
Ecore_Config_Server *s;
|
Ecore_Config_Server *s;
|
||||||
|
|
||||||
m = (Ecore_Config_Ipc *) data;
|
m = (Ecore_Config_Ipc *) data;
|
||||||
while(m) {
|
while (m)
|
||||||
|
{
|
||||||
s = m->data;
|
s = m->data;
|
||||||
while (s) {
|
while (s)
|
||||||
|
{
|
||||||
m->ipc_poll(&s->server);
|
m->ipc_poll(&s->server);
|
||||||
s = s->next;
|
s = s->next;
|
||||||
}
|
}
|
||||||
m=m->next; }
|
m = m->next;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE; }
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_ecore_config_ipc_exit(void)
|
||||||
int _ecore_config_ipc_exit(void) {
|
{
|
||||||
Ecore_Config_Ipc *m;
|
Ecore_Config_Ipc *m;
|
||||||
Ecore_Config_Server *l;
|
Ecore_Config_Server *l;
|
||||||
|
|
||||||
if (ipc_timer)
|
if (ipc_timer)
|
||||||
timeout_remove(ipc_timer);
|
timeout_remove(ipc_timer);
|
||||||
while(ipc_modules) {
|
while (ipc_modules)
|
||||||
|
{
|
||||||
m = ipc_modules;
|
m = ipc_modules;
|
||||||
ipc_modules = ipc_modules->next;
|
ipc_modules = ipc_modules->next;
|
||||||
l = m->data;
|
l = m->data;
|
||||||
while(l) {
|
while (l)
|
||||||
|
{
|
||||||
m->ipc_exit(&l->server);
|
m->ipc_exit(&l->server);
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
free(m); }
|
free(m);
|
||||||
return ECORE_CONFIG_ERR_IGNORED; }
|
}
|
||||||
|
return ECORE_CONFIG_ERR_IGNORED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ecore_Config_Server *
|
||||||
|
_ecore_config_ipc_init(char *pipe_name)
|
||||||
Ecore_Config_Server *_ecore_config_ipc_init(char *pipe_name) {
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
glob_t globbuf;
|
glob_t globbuf;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -238,13 +280,16 @@ Ecore_Config_Server *_ecore_config_ipc_init(char *pipe_name) {
|
||||||
Ecore_Config_Ipc *nm;
|
Ecore_Config_Ipc *nm;
|
||||||
Ecore_Config_Server *list;
|
Ecore_Config_Server *list;
|
||||||
Ecore_Config_Server *ret_srv;
|
Ecore_Config_Server *ret_srv;
|
||||||
|
|
||||||
nm = NULL;
|
nm = NULL;
|
||||||
list = NULL;
|
list = NULL;
|
||||||
ret_srv = NULL;
|
ret_srv = NULL;
|
||||||
|
|
||||||
if (nm) {
|
if (nm)
|
||||||
|
{
|
||||||
list = (Ecore_Config_Server *) nm->data;
|
list = (Ecore_Config_Server *) nm->data;
|
||||||
while (list) {
|
while (list)
|
||||||
|
{
|
||||||
if (!strcmp(list->name, pipe_name))
|
if (!strcmp(list->name, pipe_name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -254,13 +299,20 @@ Ecore_Config_Server *_ecore_config_ipc_init(char *pipe_name) {
|
||||||
|
|
||||||
list = NULL;
|
list = NULL;
|
||||||
|
|
||||||
if (ipc_modules) {
|
if (ipc_modules)
|
||||||
|
{
|
||||||
nm = ipc_modules;
|
nm = ipc_modules;
|
||||||
while (nm) {
|
while (nm)
|
||||||
|
{
|
||||||
list = malloc(sizeof(Ecore_Config_Server));
|
list = malloc(sizeof(Ecore_Config_Server));
|
||||||
memset(list, 0, sizeof(Ecore_Config_Server));
|
memset(list, 0, sizeof(Ecore_Config_Server));
|
||||||
if((ret=nm->ipc_init(pipe_name,&list->server))!=ECORE_CONFIG_ERR_SUCC) {
|
if ((ret =
|
||||||
E(2,"_ecore_config_ipc_init: failed to register %s, code %d\n", pipe_name, ret);
|
nm->ipc_init(pipe_name,
|
||||||
|
&list->server)) != ECORE_CONFIG_ERR_SUCC)
|
||||||
|
{
|
||||||
|
E(2,
|
||||||
|
"_ecore_config_ipc_init: failed to register %s, code %d\n",
|
||||||
|
pipe_name, ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,64 +322,88 @@ Ecore_Config_Server *_ecore_config_ipc_init(char *pipe_name) {
|
||||||
list->next = nm->data;
|
list->next = nm->data;
|
||||||
|
|
||||||
nm->data = list;
|
nm->data = list;
|
||||||
if (!ret_srv) ret_srv=list;
|
if (!ret_srv)
|
||||||
|
ret_srv = list;
|
||||||
nm = nm->next;
|
nm = nm->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_srv;
|
return ret_srv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((ret=snprintf(buf,PATH_MAX,PACKAGE_LIB_DIR "/ecore_config_ipc_*.so"))<0)||
|
if (((ret =
|
||||||
(ret>=PATH_MAX))
|
snprintf(buf, PATH_MAX, PACKAGE_LIB_DIR "/ecore_config_ipc_*.so")) < 0)
|
||||||
|
|| (ret >= PATH_MAX))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
glob(buf, 0, NULL, &globbuf);
|
glob(buf, 0, NULL, &globbuf);
|
||||||
if (!globbuf.gl_pathc)
|
if (!globbuf.gl_pathc)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for(c=0;c<globbuf.gl_pathc;c++) {
|
for (c = 0; c < globbuf.gl_pathc; c++)
|
||||||
if(!(nm=malloc(sizeof(Ecore_Config_Ipc)))) {
|
{
|
||||||
|
if (!(nm = malloc(sizeof(Ecore_Config_Ipc))))
|
||||||
|
{
|
||||||
ret = ECORE_CONFIG_ERR_OOM;
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
goto done; }
|
goto done;
|
||||||
|
}
|
||||||
memset(nm, 0, sizeof(Ecore_Config_Ipc));
|
memset(nm, 0, sizeof(Ecore_Config_Ipc));
|
||||||
|
|
||||||
E(1,"_ecore_config_ipc_init: checking \"%s\"...\n",globbuf.gl_pathv[c]);
|
E(1, "_ecore_config_ipc_init: checking \"%s\"...\n",
|
||||||
ret=dlmulti("IPC-plugin",globbuf.gl_pathv[c],RTLD_NOW,&nm->lib,
|
globbuf.gl_pathv[c]);
|
||||||
|
ret =
|
||||||
|
dlmulti("IPC-plugin", globbuf.gl_pathv[c], RTLD_NOW, &nm->lib,
|
||||||
"!_ecore_config_mod_init !_ecore_config_mod_exit !_ecore_config_mod_poll",
|
"!_ecore_config_mod_init !_ecore_config_mod_exit !_ecore_config_mod_poll",
|
||||||
&nm->ipc_init, &nm->ipc_exit, &nm->ipc_poll);
|
&nm->ipc_init, &nm->ipc_exit, &nm->ipc_poll);
|
||||||
if (ret == ECORE_CONFIG_ERR_NODATA)
|
if (ret == ECORE_CONFIG_ERR_NODATA)
|
||||||
E(0,"_ecore_config_ipc_init: could not load \"%s\": %s...\n",globbuf.gl_pathv[c],dlerror());
|
E(0, "_ecore_config_ipc_init: could not load \"%s\": %s...\n",
|
||||||
else if(ret==ECORE_CONFIG_ERR_SUCC) {
|
globbuf.gl_pathv[c], dlerror());
|
||||||
|
else if (ret == ECORE_CONFIG_ERR_SUCC)
|
||||||
|
{
|
||||||
list = malloc(sizeof(Ecore_Config_Server));
|
list = malloc(sizeof(Ecore_Config_Server));
|
||||||
/* memcpy(list, 0, sizeof(Ecore_Config_Server));*/
|
/* memcpy(list, 0, sizeof(Ecore_Config_Server));*/
|
||||||
if((ret=nm->ipc_init(pipe_name,&list->server))!=ECORE_CONFIG_ERR_SUCC)
|
if ((ret =
|
||||||
E(0,"_ecore_config_ipc_init: could not initialize \"%s\": %d\n",globbuf.gl_pathv[c],ret);
|
nm->ipc_init(pipe_name,
|
||||||
else {
|
&list->server)) != ECORE_CONFIG_ERR_SUCC)
|
||||||
|
E(0,
|
||||||
|
"_ecore_config_ipc_init: could not initialize \"%s\": %d\n",
|
||||||
|
globbuf.gl_pathv[c], ret);
|
||||||
|
else
|
||||||
|
{
|
||||||
char *p = globbuf.gl_pathv[c];
|
char *p = globbuf.gl_pathv[c];
|
||||||
if(DEBUG!=0) {
|
|
||||||
|
if (DEBUG != 0)
|
||||||
|
{
|
||||||
char *q = strrchr(p, DIR_DELIMITER);
|
char *q = strrchr(p, DIR_DELIMITER);
|
||||||
|
|
||||||
if (q)
|
if (q)
|
||||||
p=++q; }
|
p = ++q;
|
||||||
|
}
|
||||||
E(0, "_ecore_config_ipc_init: adding \"%s\"...\n", p);
|
E(0, "_ecore_config_ipc_init: adding \"%s\"...\n", p);
|
||||||
E(2,"_ecore_config_ipc_init: registered \"%s\"...\n",pipe_name);
|
E(2, "_ecore_config_ipc_init: registered \"%s\"...\n",
|
||||||
|
pipe_name);
|
||||||
|
|
||||||
list->name = strdup(pipe_name);
|
list->name = strdup(pipe_name);
|
||||||
list->next = nm->data;
|
list->next = nm->data;
|
||||||
nm->data = list;
|
nm->data = list;
|
||||||
if (!ret_srv) ret_srv=list;
|
if (!ret_srv)
|
||||||
|
ret_srv = list;
|
||||||
|
|
||||||
nm->next = ipc_modules;
|
nm->next = ipc_modules;
|
||||||
ipc_modules=nm; }}
|
ipc_modules = nm;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ret != ECORE_CONFIG_ERR_SUCC)
|
if (ret != ECORE_CONFIG_ERR_SUCC)
|
||||||
free(nm); }
|
free(nm);
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
|
||||||
if(ipc_modules) {
|
if (ipc_modules)
|
||||||
ipc_timer=timeout_add(100,_ecore_config_ipc_poll,ipc_modules); }
|
{
|
||||||
return ret_srv; }
|
ipc_timer = timeout_add(100, _ecore_config_ipc_poll, ipc_modules);
|
||||||
|
}
|
||||||
|
return ret_srv;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -21,14 +21,13 @@
|
||||||
|
|
||||||
#define CHUNKLEN 4096
|
#define CHUNKLEN 4096
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* MISC */
|
/* MISC */
|
||||||
/********/
|
/********/
|
||||||
|
|
||||||
|
int
|
||||||
|
dlmulti(char *name, char *file, int flag, void **libr, const char *fmt, ...)
|
||||||
int dlmulti(char *name,char *file,int flag,void **libr,const char *fmt, ...) {
|
{
|
||||||
#define MAX_SYM_LEN 256
|
#define MAX_SYM_LEN 256
|
||||||
va_list ap;
|
va_list ap;
|
||||||
void *lib;
|
void *lib;
|
||||||
|
@ -43,15 +42,18 @@ int dlmulti(char *name,char *file,int flag,void **libr,const char *fmt, ...) {
|
||||||
|
|
||||||
*libr = NULL;
|
*libr = NULL;
|
||||||
|
|
||||||
if((lib=dlopen(file,flag))) {
|
if ((lib = dlopen(file, flag)))
|
||||||
|
{
|
||||||
void **funr, *fun;
|
void **funr, *fun;
|
||||||
char *b, *e;
|
char *b, *e;
|
||||||
size_t l;
|
size_t l;
|
||||||
int required = 1;
|
int required = 1;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
while(*fmt) {
|
while (*fmt)
|
||||||
switch(*fmt) {
|
{
|
||||||
|
switch (*fmt)
|
||||||
|
{
|
||||||
case '?':
|
case '?':
|
||||||
required = 0;
|
required = 0;
|
||||||
fmt++;
|
fmt++;
|
||||||
|
@ -82,49 +84,62 @@ int dlmulti(char *name,char *file,int flag,void **libr,const char *fmt, ...) {
|
||||||
ret = ECORE_CONFIG_ERR_NODATA;
|
ret = ECORE_CONFIG_ERR_NODATA;
|
||||||
else if ((l = (e - b)) >= MAX_SYM_LEN)
|
else if ((l = (e - b)) >= MAX_SYM_LEN)
|
||||||
ret = ECORE_CONFIG_ERR_OOM;
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
memcpy(buf, b, l);
|
memcpy(buf, b, l);
|
||||||
buf[l] = '\0';
|
buf[l] = '\0';
|
||||||
funr = va_arg(ap, void **);
|
funr = va_arg(ap, void **);
|
||||||
if(!(fun=dlsym(lib,buf))) {
|
|
||||||
if((ret=required?ECORE_CONFIG_ERR_NOTFOUND:ECORE_CONFIG_ERR_PARTIAL)==ECORE_CONFIG_ERR_NOTFOUND)
|
if (!(fun = dlsym(lib, buf)))
|
||||||
E(1,"DLMulti: library/plugin/engine \"%s\" (\"%s\") did not contain required function \"%s\"...\n",name,file,buf); }
|
{
|
||||||
E(2,"DLMulti: %p => %p %c\"%s\"\n",fun,funr,required?'!':'?',buf);
|
if ((ret =
|
||||||
|
required ? ECORE_CONFIG_ERR_NOTFOUND :
|
||||||
|
ECORE_CONFIG_ERR_PARTIAL) ==
|
||||||
|
ECORE_CONFIG_ERR_NOTFOUND)
|
||||||
|
E(1,
|
||||||
|
"DLMulti: library/plugin/engine \"%s\" (\"%s\") did not contain required function \"%s\"...\n",
|
||||||
|
name, file, buf);
|
||||||
|
}
|
||||||
|
E(2, "DLMulti: %p => %p %c\"%s\"\n", fun, funr,
|
||||||
|
required ? '!' : '?', buf);
|
||||||
if (funr)
|
if (funr)
|
||||||
*funr=fun; }
|
*funr = fun;
|
||||||
required=1; }}
|
}
|
||||||
|
required = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if ((ret == ECORE_CONFIG_ERR_SUCC) || (ret == ECORE_CONFIG_ERR_PARTIAL))
|
if ((ret == ECORE_CONFIG_ERR_SUCC) || (ret == ECORE_CONFIG_ERR_PARTIAL))
|
||||||
*libr = lib;
|
*libr = lib;
|
||||||
else
|
else
|
||||||
dlclose(lib); }
|
dlclose(lib);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = ECORE_CONFIG_ERR_NODATA;
|
ret = ECORE_CONFIG_ERR_NODATA;
|
||||||
|
|
||||||
return ret; }
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
now(long delay)
|
||||||
unsigned long now(long delay) {
|
{
|
||||||
static struct timeval tv;
|
static struct timeval tv;
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
r = tv.tv_sec * 1000 + (((float)tv.tv_usec) / 1000.0) + delay;
|
r = tv.tv_sec * 1000 + (((float)tv.tv_usec) / 1000.0) + delay;
|
||||||
return r; }
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
|
parse_line(char *in, char **o1, char **o2, char **o3, char **o4)
|
||||||
int parse_line(char *in,char **o1,char **o2,char **o3,char **o4) {
|
{
|
||||||
#define PLMAX 16
|
#define PLMAX 16
|
||||||
int c;
|
int c;
|
||||||
char *p = in;
|
char *p = in;
|
||||||
|
@ -137,42 +152,53 @@ int parse_line(char *in,char **o1,char **o2,char **o3,char **o4) {
|
||||||
if (!in || !*in)
|
if (!in || !*in)
|
||||||
goto pl_end;
|
goto pl_end;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
while (isspace(*p))
|
while (isspace(*p))
|
||||||
*(p++) = '\0';
|
*(p++) = '\0';
|
||||||
|
|
||||||
if (!*p || (strchr("#;", *p) && (!p[1] || isspace(p[1]))))
|
if (!*p || (strchr("#;", *p) && (!p[1] || isspace(p[1]))))
|
||||||
*p = '\0'; /* it ends HERE */
|
*p = '\0'; /* it ends HERE */
|
||||||
else {
|
else
|
||||||
if(*p=='\"') {
|
{
|
||||||
|
if (*p == '\"')
|
||||||
|
{
|
||||||
r[c++] = ++p;
|
r[c++] = ++p;
|
||||||
while(*p&&(*p!='\"')) {
|
while (*p && (*p != '\"'))
|
||||||
|
{
|
||||||
if ((*p == '\\') && p[1])
|
if ((*p == '\\') && p[1])
|
||||||
p += 2;
|
p += 2;
|
||||||
else
|
else
|
||||||
p++; }
|
p++;
|
||||||
|
}
|
||||||
if (*p)
|
if (*p)
|
||||||
*(p++)='\0'; }
|
*(p++) = '\0';
|
||||||
else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
r[c++] = p;
|
r[c++] = p;
|
||||||
while (*p && !isspace(*p))
|
while (*p && !isspace(*p))
|
||||||
p++; }}
|
p++;
|
||||||
} while(*p);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (*p);
|
||||||
|
|
||||||
pl_end:
|
pl_end:
|
||||||
if(o1) *o1=r[0];
|
if (o1)
|
||||||
if(o2) *o2=r[1];
|
*o1 = r[0];
|
||||||
if(o3) *o3=r[2];
|
if (o2)
|
||||||
if(o4) *o4=r[3];
|
*o2 = r[1];
|
||||||
|
if (o3)
|
||||||
return c; }
|
*o3 = r[2];
|
||||||
|
if (o4)
|
||||||
|
*o4 = r[3];
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*char *unit_size(char *size) {
|
/*char *unit_size(char *size) {
|
||||||
gchar *unit="byte";
|
gchar *unit="byte";
|
||||||
long s;
|
long s;
|
||||||
|
@ -200,96 +226,104 @@ int parse_line(char *in,char **o1,char **o2,char **o3,char **o4) {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
qsrt(void *a[], void *data, int lo, int hi,
|
||||||
void qsrt(void *a[],void *data,int lo,int hi,int (*compare)(const void *,const void *,const void *)) {
|
int (*compare) (const void *, const void *, const void *))
|
||||||
|
{
|
||||||
int h, l;
|
int h, l;
|
||||||
void *p, *t;
|
void *p, *t;
|
||||||
|
|
||||||
if(lo<hi) {
|
if (lo < hi)
|
||||||
|
{
|
||||||
l = lo;
|
l = lo;
|
||||||
h = hi;
|
h = hi;
|
||||||
p = a[hi];
|
p = a[hi];
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
while ((l < h) && (compare(data, a[l], p) <= 0))
|
while ((l < h) && (compare(data, a[l], p) <= 0))
|
||||||
l = l + 1;
|
l = l + 1;
|
||||||
while ((h > l) && (compare(data, a[h], p) >= 0))
|
while ((h > l) && (compare(data, a[h], p) >= 0))
|
||||||
h = h - 1;
|
h = h - 1;
|
||||||
if(l<h) {
|
if (l < h)
|
||||||
|
{
|
||||||
t = a[l];
|
t = a[l];
|
||||||
a[l] = a[h];
|
a[l] = a[h];
|
||||||
a[h]=t; }
|
a[h] = t;
|
||||||
} while(l<h);
|
}
|
||||||
|
}
|
||||||
|
while (l < h);
|
||||||
|
|
||||||
t = a[l];
|
t = a[l];
|
||||||
a[l] = a[hi];
|
a[l] = a[hi];
|
||||||
a[hi] = t;
|
a[hi] = t;
|
||||||
|
|
||||||
qsrt(a, data, lo, l - 1, compare);
|
qsrt(a, data, lo, l - 1, compare);
|
||||||
qsrt(a,data,l+1,hi,compare); }}
|
qsrt(a, data, l + 1, hi, compare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* TIMERS */
|
/* TIMERS */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
timeout_add(uint f, int (*fun) (void *), void *data)
|
||||||
unsigned long timeout_add(uint f,int(*fun)(void *),void *data) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
return g_timeout_add((guint) f, (GSourceFunc) fun, (gpointer) data);
|
return g_timeout_add((guint) f, (GSourceFunc) fun, (gpointer) data);
|
||||||
#endif
|
#endif
|
||||||
return 0; }
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
timeout_remove(unsigned long handle)
|
||||||
int timeout_remove(unsigned long handle) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
return g_source_remove(handle)?ECORE_CONFIG_ERR_SUCC:ECORE_CONFIG_ERR_FAIL;
|
return g_source_remove(handle) ? ECORE_CONFIG_ERR_SUCC :
|
||||||
|
ECORE_CONFIG_ERR_FAIL;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* HASHES */
|
/* HASHES */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
|
int
|
||||||
|
eslist_free(eslist ** l)
|
||||||
int eslist_free(eslist **l) {
|
{
|
||||||
eslist *e, *f;
|
eslist *e, *f;
|
||||||
|
|
||||||
if (!l)
|
if (!l)
|
||||||
return ECORE_CONFIG_ERR_NODATA;
|
return ECORE_CONFIG_ERR_NODATA;
|
||||||
for(e=*l;e;e=f) {
|
for (e = *l; e; e = f)
|
||||||
|
{
|
||||||
f = e->next;
|
f = e->next;
|
||||||
free(e); }
|
free(e);
|
||||||
|
}
|
||||||
*l = NULL;
|
*l = NULL;
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
eslist_next(eslist ** e)
|
||||||
int eslist_next(eslist **e) {
|
{
|
||||||
if (!e || !*e)
|
if (!e || !*e)
|
||||||
return ECORE_CONFIG_ERR_NODATA;
|
return ECORE_CONFIG_ERR_NODATA;
|
||||||
*e = (*e)->next;
|
*e = (*e)->next;
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
eslist_payload(eslist ** e)
|
||||||
|
{
|
||||||
|
return (!e || !*e) ? NULL : (*e)->payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
void *eslist_payload(eslist **e) {
|
eslist_prepend(eslist ** e, void *p)
|
||||||
return (!e||!*e)?NULL:(*e)->payload; }
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int eslist_prepend(eslist **e,void *p) {
|
|
||||||
eslist *f;
|
eslist *f;
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
|
@ -303,11 +337,12 @@ int eslist_prepend(eslist **e,void *p) {
|
||||||
|
|
||||||
*e = f;
|
*e = f;
|
||||||
|
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
eslist_append(eslist ** e, void *p)
|
||||||
int eslist_append(eslist **e,void *p) {
|
{
|
||||||
eslist *f;
|
eslist *f;
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
|
@ -321,133 +356,159 @@ int eslist_append(eslist **e,void *p) {
|
||||||
|
|
||||||
if (!*e)
|
if (!*e)
|
||||||
*e = f;
|
*e = f;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
eslist *g = *e;
|
eslist *g = *e;
|
||||||
|
|
||||||
while (g->next)
|
while (g->next)
|
||||||
g = g->next;
|
g = g->next;
|
||||||
g->next=f; }
|
g->next = f;
|
||||||
|
}
|
||||||
return ECORE_CONFIG_ERR_SUCC; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* HASHES */
|
/* HASHES */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
|
void *
|
||||||
|
hash_table_new(void (*freekey), void (*freeval))
|
||||||
void *hash_table_new(void (*freekey),void (*freeval)) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
return g_hash_table_new_full(g_str_hash, g_str_equal, freekey, freeval);
|
return g_hash_table_new_full(g_str_hash, g_str_equal, freekey, freeval);
|
||||||
#endif
|
#endif
|
||||||
return NULL; }
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
hash_table_fetch(void *hashtable, char *key)
|
||||||
void *hash_table_fetch(void *hashtable,char *key) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
return g_hash_table_lookup(hashtable, key);
|
return g_hash_table_lookup(hashtable, key);
|
||||||
#endif
|
#endif
|
||||||
return NULL; }
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hash_table_insert(void *hashtable, char *key, void *value)
|
||||||
int hash_table_insert(void *hashtable,char *key,void *value) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
g_hash_table_insert(hashtable, key, value);
|
g_hash_table_insert(hashtable, key, value);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hash_table_replace(void *hashtable, char *key, void *value)
|
||||||
int hash_table_replace(void *hashtable,char *key,void *value) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
g_hash_table_replace(hashtable, key, value);
|
g_hash_table_replace(hashtable, key, value);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hash_table_remove(void *hashtable, char *key)
|
||||||
int hash_table_remove(void *hashtable,char *key) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
g_hash_table_remove(hashtable, key);
|
g_hash_table_remove(hashtable, key);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hash_table_dst(void *hashtable)
|
||||||
int hash_table_dst(void *hashtable) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
g_hash_table_destroy(hashtable);
|
g_hash_table_destroy(hashtable);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hash_table_walk(void *hashtable, hash_walker fun, void *data)
|
||||||
int hash_table_walk(void *hashtable,hash_walker fun,void *data) {
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
g_hash_table_foreach(hashtable, (GHFunc) fun, data);
|
g_hash_table_foreach(hashtable, (GHFunc) fun, data);
|
||||||
return ECORE_CONFIG_ERR_SUCC;
|
return ECORE_CONFIG_ERR_SUCC;
|
||||||
#endif
|
#endif
|
||||||
return ECORE_CONFIG_ERR_NOTSUPP; }
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* STRINGS */
|
/* STRINGS */
|
||||||
/***********/
|
/***********/
|
||||||
|
|
||||||
|
estring *
|
||||||
|
estring_new(int size)
|
||||||
estring *estring_new(int size) {
|
{
|
||||||
estring *e = malloc(sizeof(estring));
|
estring *e = malloc(sizeof(estring));
|
||||||
if(e) {
|
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
memset(e, 0, sizeof(estring));
|
memset(e, 0, sizeof(estring));
|
||||||
if ((size > 0) && (e->str = malloc(size)))
|
if ((size > 0) && (e->str = malloc(size)))
|
||||||
e->alloc=size; }
|
e->alloc = size;
|
||||||
return e; }
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
estring *estring_dst(estring *e) {
|
estring *
|
||||||
if(e) {
|
estring_dst(estring * e)
|
||||||
|
{
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
if (e->str)
|
if (e->str)
|
||||||
free(e->str);
|
free(e->str);
|
||||||
free(e); }
|
|
||||||
return NULL; }
|
|
||||||
|
|
||||||
char *estring_disown(estring *e) {
|
|
||||||
if(e) {
|
|
||||||
char *r=e->str;
|
|
||||||
free(e);
|
free(e);
|
||||||
return r; }
|
}
|
||||||
return NULL; }
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *estring_free(estring *e,int release_payload) { /* glib compat */
|
char *
|
||||||
if(release_payload) {
|
estring_disown(estring * e)
|
||||||
|
{
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
char *r = e->str;
|
||||||
|
|
||||||
|
free(e);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
estring_free(estring * e, int release_payload)
|
||||||
|
{ /* glib compat */
|
||||||
|
if (release_payload)
|
||||||
|
{
|
||||||
estring_dst(e);
|
estring_dst(e);
|
||||||
return NULL; }
|
return NULL;
|
||||||
return estring_disown(e); }
|
}
|
||||||
|
return estring_disown(e);
|
||||||
|
}
|
||||||
|
|
||||||
int estring_truncate(estring *e,int size) {
|
int
|
||||||
|
estring_truncate(estring * e, int size)
|
||||||
|
{
|
||||||
if (!e || (size < 0))
|
if (!e || (size < 0))
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
if (e->used <= size)
|
if (e->used <= size)
|
||||||
return e->used;
|
return e->used;
|
||||||
e->str[size] = '\0';
|
e->str[size] = '\0';
|
||||||
e->used = size;
|
e->used = size;
|
||||||
return size; }
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
int estring_printf(estring *e,char *fmt, ...) {
|
int
|
||||||
|
estring_printf(estring * e, char *fmt, ...)
|
||||||
|
{
|
||||||
int need;
|
int need;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -455,31 +516,40 @@ int estring_printf(estring *e,char *fmt, ...) {
|
||||||
if (!e)
|
if (!e)
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
|
|
||||||
if(!(e->str)) {
|
if (!(e->str))
|
||||||
|
{
|
||||||
if (!(e->str = (char *)malloc(e->alloc = 512)))
|
if (!(e->str = (char *)malloc(e->alloc = 512)))
|
||||||
return ECORE_CONFIG_ERR_OOM; }
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
need = vsnprintf(e->str, e->alloc, fmt, ap);
|
need = vsnprintf(e->str, e->alloc, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if((need>=e->alloc)||(need<0)) {
|
if ((need >= e->alloc) || (need < 0))
|
||||||
|
{
|
||||||
if (need < 0)
|
if (need < 0)
|
||||||
need = 2 * e->alloc;
|
need = 2 * e->alloc;
|
||||||
else
|
else
|
||||||
need++;
|
need++;
|
||||||
if(!(p=(char*)realloc(e->str,need))) {
|
if (!(p = (char *)realloc(e->str, need)))
|
||||||
|
{
|
||||||
free(e->str);
|
free(e->str);
|
||||||
e->alloc = e->used = 0;
|
e->alloc = e->used = 0;
|
||||||
return ECORE_CONFIG_ERR_OOM; }
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
e->alloc = need;
|
e->alloc = need;
|
||||||
e->str = p;
|
e->str = p;
|
||||||
goto retry; }
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
return e->used=need; }
|
return e->used = need;
|
||||||
|
}
|
||||||
|
|
||||||
int estring_appendf(estring *e,char *fmt, ...) {
|
int
|
||||||
|
estring_appendf(estring * e, char *fmt, ...)
|
||||||
|
{
|
||||||
int need;
|
int need;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -487,17 +557,20 @@ int estring_appendf(estring *e,char *fmt, ...) {
|
||||||
if (!e)
|
if (!e)
|
||||||
return ECORE_CONFIG_ERR_FAIL;
|
return ECORE_CONFIG_ERR_FAIL;
|
||||||
|
|
||||||
if(!e->str) {
|
if (!e->str)
|
||||||
|
{
|
||||||
e->used = e->alloc = 0;
|
e->used = e->alloc = 0;
|
||||||
if (!(e->str = (char *)malloc(e->alloc = 512)))
|
if (!(e->str = (char *)malloc(e->alloc = 512)))
|
||||||
return ECORE_CONFIG_ERR_OOM; }
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
need = vsnprintf(e->str + e->used, e->alloc - e->used, fmt, ap);
|
need = vsnprintf(e->str + e->used, e->alloc - e->used, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if((need>=(e->alloc-e->used))||(need<0)) {
|
if ((need >= (e->alloc - e->used)) || (need < 0))
|
||||||
|
{
|
||||||
if (need < 0)
|
if (need < 0)
|
||||||
need = 2 * e->alloc;
|
need = 2 * e->alloc;
|
||||||
else
|
else
|
||||||
|
@ -505,19 +578,23 @@ retry:
|
||||||
need += e->used;
|
need += e->used;
|
||||||
need += (CHUNKLEN - (need % CHUNKLEN));
|
need += (CHUNKLEN - (need % CHUNKLEN));
|
||||||
|
|
||||||
if(!(p=(char*)realloc(e->str,need))) {
|
if (!(p = (char *)realloc(e->str, need)))
|
||||||
|
{
|
||||||
free(e->str);
|
free(e->str);
|
||||||
e->alloc = e->used = 0;
|
e->alloc = e->used = 0;
|
||||||
return ECORE_CONFIG_ERR_OOM; }
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
e->alloc = need;
|
e->alloc = need;
|
||||||
e->str = p;
|
e->str = p;
|
||||||
goto retry; }
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
return e->used+=need; }
|
return e->used += need;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
esprintf(char **result, char *fmt, ...)
|
||||||
int esprintf(char **result,char *fmt, ...) {
|
{
|
||||||
int need, have;
|
int need, have;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *n;
|
char *n;
|
||||||
|
@ -533,29 +610,35 @@ retry:
|
||||||
need = vsnprintf(n, have, fmt, ap);
|
need = vsnprintf(n, have, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if((need>=have)||(need<0)) {
|
if ((need >= have) || (need < 0))
|
||||||
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (need < 0)
|
if (need < 0)
|
||||||
need = 2 * have;
|
need = 2 * have;
|
||||||
else
|
else
|
||||||
need++;
|
need++;
|
||||||
if(!(p=(char*)realloc(n,need))) {
|
if (!(p = (char *)realloc(n, need)))
|
||||||
|
{
|
||||||
free(n);
|
free(n);
|
||||||
return ECORE_CONFIG_ERR_OOM; }
|
return ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
have = need;
|
have = need;
|
||||||
n = p;
|
n = p;
|
||||||
goto retry; }
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
if (*result)
|
if (*result)
|
||||||
free(*result);
|
free(*result);
|
||||||
*result = n;
|
*result = n;
|
||||||
|
|
||||||
return need; }
|
return need;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int ejoin(char **result,char *delim, ...) {
|
int
|
||||||
|
ejoin(char **result, char *delim, ...)
|
||||||
|
{
|
||||||
int dl, cl, ret = ECORE_CONFIG_ERR_SUCC;
|
int dl, cl, ret = ECORE_CONFIG_ERR_SUCC;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *e, *n;
|
char *e, *n;
|
||||||
|
@ -570,34 +653,44 @@ int ejoin(char **result,char *delim, ...) {
|
||||||
cl = -dl;
|
cl = -dl;
|
||||||
while ((e = va_arg(ap, char *)))
|
while ((e = va_arg(ap, char *)))
|
||||||
cl += strlen(e) + dl;
|
cl += strlen(e) + dl;
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(cl<=0) {
|
if (cl <= 0)
|
||||||
|
{
|
||||||
if (!(n = strdup("")))
|
if (!(n = strdup("")))
|
||||||
ret=ECORE_CONFIG_ERR_OOM; }
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
else if (!(n = malloc(cl + 1)))
|
else if (!(n = malloc(cl + 1)))
|
||||||
ret = ECORE_CONFIG_ERR_OOM;
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
char *p = n;
|
char *p = n;
|
||||||
|
|
||||||
va_start(ap, delim);
|
va_start(ap, delim);
|
||||||
while((e=va_arg(ap,char *))) {
|
while ((e = va_arg(ap, char *)))
|
||||||
if(dl&&(p!=n)) {
|
{
|
||||||
|
if (dl && (p != n))
|
||||||
|
{
|
||||||
strcpy(p, delim);
|
strcpy(p, delim);
|
||||||
p+=dl; }
|
p += dl;
|
||||||
|
}
|
||||||
strcpy(p, e);
|
strcpy(p, e);
|
||||||
p+=strlen(p); }
|
p += strlen(p);
|
||||||
va_end(ap); }
|
}
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
if (*result)
|
if (*result)
|
||||||
free(*result);
|
free(*result);
|
||||||
*result = n;
|
*result = n;
|
||||||
|
|
||||||
return ret; }
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ecat(char **result, ...)
|
||||||
int ecat(char **result, ...) {
|
{
|
||||||
int cl, ret = ECORE_CONFIG_ERR_SUCC;
|
int cl, ret = ECORE_CONFIG_ERR_SUCC;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *e, *n;
|
char *e, *n;
|
||||||
|
@ -609,32 +702,35 @@ int ecat(char **result, ...) {
|
||||||
cl = 0;
|
cl = 0;
|
||||||
while ((e = va_arg(ap, char *)))
|
while ((e = va_arg(ap, char *)))
|
||||||
cl += strlen(e);
|
cl += strlen(e);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(cl<=0) {
|
if (cl <= 0)
|
||||||
|
{
|
||||||
if (!(n = strdup("")))
|
if (!(n = strdup("")))
|
||||||
ret=ECORE_CONFIG_ERR_OOM; }
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
|
}
|
||||||
else if (!(n = malloc(cl + 1)))
|
else if (!(n = malloc(cl + 1)))
|
||||||
ret = ECORE_CONFIG_ERR_OOM;
|
ret = ECORE_CONFIG_ERR_OOM;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
char *p = n;
|
char *p = n;
|
||||||
|
|
||||||
va_start(ap, result);
|
va_start(ap, result);
|
||||||
while((e=va_arg(ap,char *))) {
|
while ((e = va_arg(ap, char *)))
|
||||||
|
{
|
||||||
strcpy(p, e);
|
strcpy(p, e);
|
||||||
p+=strlen(p); }
|
p += strlen(p);
|
||||||
va_end(ap); }
|
}
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
if (*result)
|
if (*result)
|
||||||
free(*result);
|
free(*result);
|
||||||
*result = n;
|
*result = n;
|
||||||
|
|
||||||
return ret; }
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
#define TIMER_STOP 0
|
#define TIMER_STOP 0
|
||||||
#define TIMER_CONT 1
|
#define TIMER_CONT 1
|
||||||
|
|
||||||
typedef struct _estring {
|
typedef struct _estring
|
||||||
|
{
|
||||||
char *str;
|
char *str;
|
||||||
int alloc, used;
|
int alloc, used;
|
||||||
} estring;
|
} estring;
|
||||||
|
|
||||||
typedef struct _eslist {
|
typedef struct _eslist
|
||||||
|
{
|
||||||
void *payload;
|
void *payload;
|
||||||
struct _eslist *next;
|
struct _eslist *next;
|
||||||
} eslist;
|
} eslist;
|
||||||
|
|
||||||
|
|
||||||
int parse_line(char *, char **, char **, char **, char **);
|
int parse_line(char *, char **, char **, char **, char **);
|
||||||
char *unit_size(char *size);
|
char *unit_size(char *size);
|
||||||
|
|
||||||
/*unsigned long now(long delay);*/
|
/*unsigned long now(long delay);*/
|
||||||
void qsrt(void *a[],void *data,int lo,int hi,int (*compare)(const void *,const void *,const void *));
|
void qsrt(void *a[], void *data, int lo, int hi,
|
||||||
int dlmulti(char *name,char *file,int flag,void **libr,const char *fmt, ...);
|
int (*compare) (const void *, const void *,
|
||||||
|
const void *));
|
||||||
|
int dlmulti(char *name, char *file, int flag, void **libr,
|
||||||
|
const char *fmt, ...);
|
||||||
|
|
||||||
typedef void (*hash_walker) (char *key, void *value, void *data);
|
typedef void (*hash_walker) (char *key, void *value, void *data);
|
||||||
|
|
||||||
|
@ -28,12 +31,15 @@ int hash_table_insert( void *hashtable,char *key,void *value);
|
||||||
int hash_table_replace(void *hashtable, char *key, void *value);
|
int hash_table_replace(void *hashtable, char *key, void *value);
|
||||||
int hash_table_remove(void *hashtable, char *key);
|
int hash_table_remove(void *hashtable, char *key);
|
||||||
int hash_table_dst(void *hashtable);
|
int hash_table_dst(void *hashtable);
|
||||||
int hash_table_walk( void *hashtable,hash_walker fun,void *data);
|
int hash_table_walk(void *hashtable, hash_walker fun,
|
||||||
|
void *data);
|
||||||
|
|
||||||
int eslist_free(eslist **);
|
int eslist_free(eslist **);
|
||||||
int eslist_next(eslist **);
|
int eslist_next(eslist **);
|
||||||
|
|
||||||
#define ESLIST_NEXT(e) (e=e->next)
|
#define ESLIST_NEXT(e) (e=e->next)
|
||||||
void *eslist_payload(eslist **);
|
void *eslist_payload(eslist **);
|
||||||
|
|
||||||
#define ESLIST_PAYLOAD(e) ((e)->payload)
|
#define ESLIST_PAYLOAD(e) ((e)->payload)
|
||||||
int eslist_prepend(eslist **, void *);
|
int eslist_prepend(eslist **, void *);
|
||||||
int eslist_append(eslist **, void *);
|
int eslist_append(eslist **, void *);
|
||||||
|
@ -45,14 +51,13 @@ char *estring_free(estring *e,int release_payload); /* glib compat */
|
||||||
int estring_printf(estring * e, char *fmt, ...);
|
int estring_printf(estring * e, char *fmt, ...);
|
||||||
int estring_appendf(estring * e, char *fmt, ...);
|
int estring_appendf(estring * e, char *fmt, ...);
|
||||||
int estring_truncate(estring * e, int size);
|
int estring_truncate(estring * e, int size);
|
||||||
|
|
||||||
#define ESTRING_GET_CSTRING(a) ((a)->str)
|
#define ESTRING_GET_CSTRING(a) ((a)->str)
|
||||||
|
|
||||||
int esprintf(char **result, char *fmt, ...);
|
int esprintf(char **result, char *fmt, ...);
|
||||||
int ejoin(char **result, char *delim, ...);
|
int ejoin(char **result, char *delim, ...);
|
||||||
int ecat(char **result, ...);
|
int ecat(char **result, ...);
|
||||||
|
|
||||||
|
unsigned long timeout_add(unsigned int f, int (*fun) (void *),
|
||||||
|
void *data);
|
||||||
unsigned long timeout_add(unsigned int f,int(*fun)(void *),void *data);
|
|
||||||
int timeout_remove(unsigned long handle);
|
int timeout_remove(unsigned long handle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue