Start tidyup with namespaces - fingers crossed

SVN revision: 9186
This commit is contained in:
handyande 2004-03-01 23:11:28 +00:00 committed by handyande
parent 63cab74f85
commit 6fe7d8ea33
6 changed files with 229 additions and 205 deletions

View File

@ -112,10 +112,10 @@ typedef struct Ecore_Config_Server {
struct Ecore_Config_Server *next; } Ecore_Config_Server;
/* global ptrs to save passing them through the API */
extern Ecore_Config_Server *__server_global;
extern Ecore_Config_Server *__server_local;
extern Ecore_Config_Bundle *__bundle_local;
extern char *__app_name;
extern Ecore_Config_Server *__ecore_config_server_global;
extern Ecore_Config_Server *__ecore_config_server_local;
extern Ecore_Config_Bundle *__ecore_config_bundle_local;
extern char *__ecore_config_app_name;
Ecore_Config_Prop *ecore_config_get(Ecore_Config_Bundle *t,const char *key);
const char *ecore_config_get_type(const Ecore_Config_Prop *e);

View File

@ -12,41 +12,23 @@
#include <unistd.h>
#include <util.h>
Ecore_Config_Server *__server_global = NULL;
Ecore_Config_Server *__server_local = NULL;
Ecore_Config_Bundle *__bundle_local = NULL;
char *__app_name = NULL;
Ecore_Config_Server *__ecore_config_server_global = NULL;
Ecore_Config_Server *__ecore_config_server_local = NULL;
Ecore_Config_Bundle *__ecore_config_bundle_local = NULL;
char *__ecore_config_app_name = NULL;
Ecore_Config_Server *ipc_init(char *name);
int ipc_exit(void);
static char *ecore_config_type[]={ "undefined", "integer", "float", "string", "colour" };
/* tolower, weed out _ - */
char *prop_canonize_key(char *pn,int modify) {
char *v,*r;
if(!modify)
r=pn;
else if(!(r=strdup(pn)))
return NULL;
v=r;
while(*v) {
if(strchr("-_/",*v))
memmove(v,&v[1],strlen(v));
else {
if(isupper(*v))
*v=tolower(*v);
v++; }}
return r; }
Ecore_Config_Server *_ecore_config_ipc_init(char *name);
int _ecore_config_ipc_exit(void);
static char *_ecore_config_type[]={ "undefined", "integer", "float", "string", "colour" };
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop *e) {
Ecore_Config_Bundle *t;
Ecore_Config_Prop *p=NULL,*c=e;
Ecore_Config_Prop *p,*c;
Ecore_Config_Listener_List *l;
t = __bundle_local;
p=NULL;
c=e;
t = __ecore_config_bundle_local;
if(!e||!e->key)
return NULL;
@ -91,32 +73,37 @@ Ecore_Config_Prop *ecore_config_get(Ecore_Config_Bundle *t, const char *key) {
const char *ecore_config_get_type(const Ecore_Config_Prop *e) {
if(e) {
return ecore_config_type[e->type]; }
return _ecore_config_type[e->type]; }
return "not found"; }
void *ecore_config_get_data(const char *key) {
Ecore_Config_Prop *e=ecore_config_get(__bundle_local,key);
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
return (e?((e->type==PT_STR)?((void *)&e->ptr):((void *)&e->val))
:NULL); }
char *ecore_config_get_string(const char *key) {
Ecore_Config_Prop *e=ecore_config_get(__bundle_local,key);
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
return (e&&(e->type==PT_STR))?e->ptr:NULL; }
long ecore_config_get_int(const char *key) {
Ecore_Config_Prop *e=ecore_config_get(__bundle_local,key);
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
return (e&&((e->type==PT_INT)||(e->type==PT_RGB)))?e->val:0L; }
float ecore_config_get_float(const char *key) {
Ecore_Config_Prop *e=ecore_config_get(__bundle_local,key);
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
return (e&&(e->type==PT_FLT))?((float)e->val/ECORE_CONFIG_FLOAT_PRECISION):0.0; }
int ecore_config_get_rgb(const char *key,int *r, int *g, int *b) {
Ecore_Config_Prop *e=ecore_config_get(__bundle_local,key);
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
if(e&&((e->type==PT_RGB))) {
*r=(e->val>>16)&0xff;
@ -126,15 +113,17 @@ int ecore_config_get_rgb(const char *key,int *r, int *g, int *b) {
return ECORE_CONFIG_ERR_FAIL; }
char *ecore_config_get_rgbstr(const char *key) {
char *r=NULL;
char *r;
r=NULL;
esprintf(&r,"#%06x",ecore_config_get_int(key));
return r; }
char *ecore_config_get_as_string(const char *key) {
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
char *r=NULL;
t = __bundle_local;
char *r;
r=NULL;
t = __ecore_config_bundle_local;
if(!(e=ecore_config_get(t,key)))
E(0,"no such property, \"%s\"...\n",key);
else {
@ -156,8 +145,9 @@ char *ecore_config_get_as_string(const char *key) {
static int ecore_config_bound(Ecore_Config_Prop *e) {
int ret=ECORE_CONFIG_ERR_SUCC;
int ret;
long v;
ret=ECORE_CONFIG_ERR_SUCC;
if(!e)
return ECORE_CONFIG_ERR_FAIL;
@ -188,8 +178,9 @@ static int ecore_config_bound(Ecore_Config_Prop *e) {
return ret; }
int ecore_config_guess_type(char *val) {
char *l=NULL;
char *l;
long v;
l=NULL;
if(!val)
return PT_NIL;
@ -206,10 +197,12 @@ int ecore_config_guess_type(char *val) {
}
static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
char *l=NULL;
long v=0;
char *l;
long v;
float *f;
l=NULL;
v=0;
e->type=PT_NIL;
if(!val)
@ -252,14 +245,6 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
return ECORE_CONFIG_ERR_IGNORED;
}
#if 0 /* Not used */
static int ecore_config_val(Ecore_Config_Prop *e,char *val) {
int type = ecore_config_guess_type(val);
return ecore_config_val_typed(e,(void *)val,type); }
#endif
static int ecore_config_add_typed(Ecore_Config_Bundle *t, const char *key, void* val, int type) {
Ecore_Config_Prop *e;
@ -292,7 +277,8 @@ static int ecore_config_add_typed(Ecore_Config_Bundle *t, const char *key, void*
static int ecore_config_add(Ecore_Config_Bundle *t,const char *key,char *val) {
int type=ecore_config_guess_type(val);
int type;
type=ecore_config_guess_type(val);
return ecore_config_add_typed(t,key,val,type); }
int ecore_config_set_typed(Ecore_Config_Bundle *t,const char *key,void *val,int type) {
@ -318,28 +304,30 @@ int ecore_config_set_typed(Ecore_Config_Bundle *t,const char *key,void *val,int
}
int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val) {
int type=ecore_config_guess_type(val);
int type;
type=ecore_config_guess_type(val);
return ecore_config_set_typed(t,key,val,type); }
int ecore_config_set_as_string(const char *key,char *val) {
return ecore_config_set(__bundle_local,key,val); }
return ecore_config_set(__ecore_config_bundle_local,key,val); }
int ecore_config_set_int(const char *key, int val) {
return ecore_config_set_typed(__bundle_local,key,(void *)val,PT_INT); }
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_INT); }
int ecore_config_set_string(const char *key, char* val) {
return ecore_config_set_typed(__bundle_local,key,(void *)val,PT_STR); }
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_STR); }
int ecore_config_set_float(const char *key, float val) {
return ecore_config_set_typed(__bundle_local,key,(void *)&val,PT_FLT); }
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)&val,PT_FLT); }
int ecore_config_set_rgb(const char *key, char* val) {
return ecore_config_set_typed(__bundle_local,key,(void *)val,PT_RGB); }
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_RGB); }
static int ecore_config_default_typed(Ecore_Config_Bundle *t,const char *key,void *val,int type) {
int ret=ECORE_CONFIG_ERR_SUCC;
int ret;
Ecore_Config_Prop *e;
ret=ECORE_CONFIG_ERR_SUCC;
if(!(e=ecore_config_get(t,key))) { /* prop doesn't exist yet */
if((ret=ecore_config_add_typed(t,key,val,type))!=ECORE_CONFIG_ERR_SUCC) /* try to add it */
@ -354,7 +342,7 @@ int ecore_config_default(const char *key,char *val,float lo,float hi,float step)
int ret, type;
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
t = __bundle_local;
t = __ecore_config_bundle_local;
type=ecore_config_guess_type(val);
ret=ecore_config_default_typed(t, key, val, type);
@ -379,14 +367,14 @@ int ecore_config_default(const char *key,char *val,float lo,float hi,float step)
}
int ecore_config_default_int(const char *key,int val) {
return ecore_config_default_typed(__bundle_local, key, (void *) val, PT_INT);
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_INT);
}
int ecore_config_default_int_bound(const char *key,int val,int low,int high,int step) {
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
int ret;
t = __bundle_local;
t = __ecore_config_bundle_local;
ret=ecore_config_default_typed(t, key, (void *) val, PT_INT);
e=ecore_config_get(t,key);
@ -402,19 +390,19 @@ int ecore_config_default_int_bound(const char *key,int val,int low,int high,int
}
int ecore_config_default_string(const char *key,char *val) {
return ecore_config_default_typed(__bundle_local, key, (void *) val, PT_STR);
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_STR);
}
int ecore_config_default_float(const char *key,float val){
return ecore_config_default_typed(__bundle_local, key, (void *) &val, PT_FLT);
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) &val, PT_FLT);
}
int ecore_config_default_float_bound(const char *key,float val,float low,float high,float step) {
Ecore_Config_Prop *e;
int ret;
ret=ecore_config_default_typed(__bundle_local, key, (void *) &val, PT_FLT);
e=ecore_config_get(__bundle_local,key);
ret=ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) &val, PT_FLT);
e=ecore_config_get(__ecore_config_bundle_local,key);
if (e) {
e->step=(int)(step*ECORE_CONFIG_FLOAT_PRECISION);
e->flags|=PF_BOUNDS;
@ -427,7 +415,7 @@ int ecore_config_default_float_bound(const char *key,float val,float low,float h
}
int ecore_config_default_rgb(const char *key,char *val) {
return ecore_config_default_typed(__bundle_local, key, (void *) val, PT_RGB);
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_RGB);
}
int ecore_config_listen(const char *name,const char *key,
@ -435,7 +423,7 @@ int ecore_config_listen(const char *name,const char *key,
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
Ecore_Config_Listener_List *l;
t = __bundle_local;
t = __ecore_config_bundle_local;
if(!t||!key)
return ECORE_CONFIG_ERR_NODATA;
@ -478,12 +466,13 @@ int ecore_config_deaf(const char *name,const char *key,
Ecore_Config_Listener listener) {
Ecore_Config_Prop *e;
Ecore_Config_Listener_List *l,*p;
int ret=ECORE_CONFIG_ERR_NOTFOUND;
int ret;
ret=ECORE_CONFIG_ERR_NOTFOUND;
if(!__bundle_local||!key)
if(!__ecore_config_bundle_local||!key)
return ECORE_CONFIG_ERR_NODATA;
if(!(e=ecore_config_get(__bundle_local,key)))
if(!(e=ecore_config_get(__ecore_config_bundle_local,key)))
return ECORE_CONFIG_ERR_NOTFOUND;
for(p=NULL,l=e->listeners;l;p=l,l=l->next) {
@ -505,7 +494,8 @@ Ecore_Config_Bundle *ecore_config_bundle_get_next(Ecore_Config_Bundle *ns) {
return ns?ns->next:NULL; }
Ecore_Config_Bundle *ecore_config_bundle_get_by_serial(Ecore_Config_Server *srv, long serial) {
Ecore_Config_Bundle *eb=srv->bundles;
Ecore_Config_Bundle *eb;
eb=srv->bundles;
if(serial<0)
return NULL;
@ -520,7 +510,8 @@ Ecore_Config_Bundle *ecore_config_bundle_get_by_serial(Ecore_Config_Server *srv,
return NULL; }
Ecore_Config_Bundle *ecore_config_bundle_get_by_label(Ecore_Config_Server *srv, const char *label) {
Ecore_Config_Bundle *ns=srv->bundles;
Ecore_Config_Bundle *ns;
ns=srv->bundles;
while(ns) {
if(ns->identifier&&!strcmp(ns->identifier,label))
@ -552,7 +543,7 @@ Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv,const char
return t; }
Ecore_Config_Server *do_init(char *name) {
return ipc_init(name);
return _ecore_config_ipc_init(name);
}
Ecore_Config_Server *ecore_config_init_local(char *name) {
@ -573,8 +564,9 @@ Ecore_Config_Server *ecore_config_init_local(char *name) {
Ecore_Config_Server *ecore_config_init_global(char *name) {
char *p;
int global=0;
int global;
char *buf;
global=0;
if((p=getenv("HOME"))) { /* debug-only ### FIXME */
if (!(buf=malloc(PATH_MAX*sizeof(char))))
@ -593,16 +585,16 @@ int ecore_config_init(char *name) {
char *buf, *p;
Ecore_Config_Prop *sys;
__app_name = strdup(name);
__server_local = ecore_config_init_local(name);
if (!__server_local)
__ecore_config_app_name = strdup(name);
__ecore_config_server_local = ecore_config_init_local(name);
if (!__ecore_config_server_local)
return ECORE_CONFIG_ERR_FAIL;
__server_global = ecore_config_init_global(ECORE_CONFIG_GLOBAL_ID);
if (!__server_global)
__ecore_config_server_global = ecore_config_init_global(ECORE_CONFIG_GLOBAL_ID);
if (!__ecore_config_server_global)
return ECORE_CONFIG_ERR_FAIL;
__bundle_local = ecore_config_bundle_new(__server_local, "config");
__ecore_config_bundle_local = ecore_config_bundle_new(__ecore_config_server_local, "config");
if((p=getenv("HOME"))) { /* debug-only ### FIXME */
if ((buf=malloc(PATH_MAX*sizeof(char)))) {
@ -610,7 +602,7 @@ int ecore_config_init(char *name) {
if (ecore_config_load_file(buf) != 0)
if (ecore_config_load_file(PACKAGE_DATA_DIR "/system.db") != 0)
return ECORE_CONFIG_ERR_NOFILE;
sys = __bundle_local->data;
sys = __ecore_config_bundle_local->data;
while (sys) {
/* unmark it modified - modification will mean it has been overridden */
sys->flags&=~PF_MODIFIED;
@ -627,11 +619,11 @@ int ecore_config_init(char *name) {
int ecore_config_exit(void) {
int ret;
ret = ipc_exit();
free(__app_name);
free(__bundle_local);
free(__server_local);
free(__server_global);
ret = _ecore_config_ipc_exit();
free(__ecore_config_app_name);
free(__ecore_config_bundle_local);
free(__ecore_config_server_local);
free(__ecore_config_server_global);
return ret;
}

View File

@ -8,18 +8,18 @@
int ecore_config_load(void) {
char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__app_name);
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__ecore_config_app_name);
return ecore_config_load_file(file);
}
int ecore_config_save(void) {
char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__app_name);
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db",getenv("HOME"),__ecore_config_app_name);
return ecore_config_save_file(file);
}
int ecore_config_load_file(char *file) {
E_DB_File *db = NULL;
E_DB_File *db;
char **keys;
int key_count;
int x;
@ -27,6 +27,7 @@ int ecore_config_load_file(char *file) {
float ftmp;
char *type;
char *data;
db=NULL;
type = NULL;
data = NULL;
@ -78,8 +79,10 @@ int ecore_config_load_file(char *file) {
}
int ecore_config_save_file(char *file) {
Ecore_Config_Prop *next=__bundle_local->data;
E_DB_File *db = NULL;
Ecore_Config_Prop *next;
E_DB_File *db;
next=__ecore_config_bundle_local->data;
db = NULL;
/* ### we may need to create a directory or two here! */
db = e_db_open(file);

View File

@ -15,18 +15,18 @@ typedef enum {
IPC_BUNDLE_LABEL_FIND,
IPC_LAST
} ex_ipc_call;
} Ecore_Config_Ipc_Call;
Ecore_Config_Server *srv2ecore_config_srv(void *srv);
Ecore_Config_Server *_ecore_config_server_convert(void *srv);
char *ipc_prop_list(Ecore_Config_Server *srv, const long serial);
char *ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key);
char *ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key);
int ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,const char *val);
char *_ecore_config_ipc_prop_list(Ecore_Config_Server *srv, const long serial);
char *_ecore_config_ipc_prop_desc(Ecore_Config_Server *srv, 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 *ipc_bundle_list(Ecore_Config_Server *srv);
int ipc_bundle_new(Ecore_Config_Server *srv, const char *);
char *ipc_bundle_label_get(Ecore_Config_Server *srv, const long);
int ipc_bundle_label_set(Ecore_Config_Server *srv, const long,const char *);
long ipc_bundle_label_find(Ecore_Config_Server *srv, const char *);
char *_ecore_config_ipc_bundle_list(Ecore_Config_Server *srv);
int _ecore_config_ipc_bundle_new(Ecore_Config_Server *srv, const char *);
char *_ecore_config_ipc_bundle_label_get(Ecore_Config_Server *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 *);

View File

@ -22,7 +22,7 @@
static int get_string(char **m,char **r) {
static int _ecore_config_ipc_ecore_get_string(char **m,char **r) {
char *q;
int l=0;
@ -51,7 +51,7 @@ static int get_string(char **m,char **r) {
static int send(Ecore_Ipc_Event_Client_Data *e,int code,char *reply) {
static int _ecore_config_ipc_ecore_send(Ecore_Ipc_Event_Client_Data *e,int code,char *reply) {
static int our_ref=0;
int len=reply?strlen(reply)+1:0;
our_ref++;
@ -65,53 +65,55 @@ static int send(Ecore_Ipc_Event_Client_Data *e,int code,char *reply) {
/*****************************************************************************/
static int 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;
long serial=e->minor;
long serial;
int ret=ECORE_CONFIG_ERR_FAIL;
char *r=NULL,*k,*v,*m=(char *)e->data;
srv=srv2ecore_config_srv(server);
char *r=NULL,*k,*v,*m;
srv=_ecore_config_server_convert(server);
serial=e->minor;
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);
switch(e->major) {
case IPC_PROP_LIST:
r=ipc_prop_list(srv, serial);
r=_ecore_config_ipc_prop_list(srv, serial);
break;
case IPC_PROP_DESC:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
r=ipc_prop_desc(srv, serial,k);
if(_ecore_config_ipc_ecore_get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
r=_ecore_config_ipc_prop_desc(srv, serial,k);
break;
case IPC_PROP_GET:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
r=ipc_prop_get(srv, serial,k);
if(_ecore_config_ipc_ecore_get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
r=_ecore_config_ipc_prop_get(srv, serial,k);
break;
case IPC_PROP_SET:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC) {
if(get_string(&m,&v)==ECORE_CONFIG_ERR_SUCC)
return send(e,ipc_prop_set(srv, serial,k,v),NULL); }
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); }
break;
case IPC_BUNDLE_LIST:
r=ipc_bundle_list(srv);
r=_ecore_config_ipc_bundle_list(srv);
break;
case IPC_BUNDLE_NEW:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
return send(e,k?ipc_bundle_new(srv, k):ECORE_CONFIG_ERR_FAIL,NULL);
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);
break;
case IPC_BUNDLE_LABEL_SET:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
return send(e,k?ipc_bundle_label_set(srv, serial,k):ECORE_CONFIG_ERR_FAIL,NULL);
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);
break;
case IPC_BUNDLE_LABEL_FIND:
if(get_string(&m,&k)==ECORE_CONFIG_ERR_SUCC)
return send(e,ipc_bundle_label_find(srv, k),NULL);
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);
break;
case IPC_BUNDLE_LABEL_GET:
r=ipc_bundle_label_get(srv, serial);
r=_ecore_config_ipc_bundle_label_get(srv, serial);
break; }
ret=send(e,r?ECORE_CONFIG_ERR_SUCC:ECORE_CONFIG_ERR_FAIL,r);
ret=_ecore_config_ipc_ecore_send(e,r?ECORE_CONFIG_ERR_SUCC:ECORE_CONFIG_ERR_FAIL,r);
if(r) {
free(r);
return ret; }
@ -126,9 +128,11 @@ static int handle_request(Ecore_Ipc_Server *server,Ecore_Ipc_Event_Client_Data *
static int ipc_client_add(void *data,int type,void *event) {
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
Ecore_Ipc_Event_Client_Data *e=(Ecore_Ipc_Event_Client_Data *)event;
static int _ecore_config_ipc_client_add(void *data,int type,void *event) {
Ecore_Ipc_Server **server;
Ecore_Ipc_Event_Client_Data *e;
server=(Ecore_Ipc_Server **)data;
e=(Ecore_Ipc_Event_Client_Data *)event;
if (*server != ecore_ipc_client_server_get(e->client))
return 1;
@ -138,9 +142,11 @@ static int ipc_client_add(void *data,int type,void *event) {
static int ipc_client_del(void *data, int type, void *event) {
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
Ecore_Ipc_Event_Client_Data *e=(Ecore_Ipc_Event_Client_Data *)event;
static int _ecore_config_ipc_client_del(void *data, int type, void *event) {
Ecore_Ipc_Server **server;
Ecore_Ipc_Event_Client_Data *e;
server=(Ecore_Ipc_Server **)data;
e=(Ecore_Ipc_Event_Client_Data *)event;
if (*server != ecore_ipc_client_server_get(e->client))
return 1;
@ -150,14 +156,16 @@ static int ipc_client_del(void *data, int type, void *event) {
static int ipc_client_sent(void *data,int type,void *event) {
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
Ecore_Ipc_Event_Client_Data *e=(Ecore_Ipc_Event_Client_Data *)event;
static int _ecore_config_ipc_client_sent(void *data,int type,void *event) {
Ecore_Ipc_Server **server;
Ecore_Ipc_Event_Client_Data *e;
server=(Ecore_Ipc_Server **)data;
e=(Ecore_Ipc_Event_Client_Data *)event;
if (*server != ecore_ipc_client_server_get(e->client))
return 1;
handle_request(*server,e);
_ecore_config_ipc_ecore_handle_request(*server,e);
return 1; }
@ -169,13 +177,15 @@ static int ipc_client_sent(void *data,int type,void *event) {
int ecore_config_mod_init(char *pipe_name, void **data) {
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
int _ecore_config_mod_init(char *pipe_name, void **data) {
Ecore_Ipc_Server **server;
struct stat st;
char *p;
int port=0;
int port;
char socket[PATH_MAX];
server=(Ecore_Ipc_Server **)data;
port=0;
if(!server)
return ECORE_CONFIG_ERR_FAIL;
@ -203,9 +213,9 @@ int ecore_config_mod_init(char *pipe_name, void **data) {
}
}
*server=ecore_ipc_server_add(ECORE_IPC_LOCAL_USER,pipe_name,port,NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, ipc_client_add, server);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, ipc_client_del, server);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,ipc_client_sent,server);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _ecore_config_ipc_client_add, 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) {
E(1,"IPC/eCore: Server is listening on %s.\n", pipe_name);
@ -215,9 +225,11 @@ int ecore_config_mod_init(char *pipe_name, void **data) {
int ecore_config_mod_exit(void **data) {
int ret=ECORE_CONFIG_ERR_SUCC;
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
int _ecore_config_mod_exit(void **data) {
int ret;
Ecore_Ipc_Server **server;
ret=ECORE_CONFIG_ERR_SUCC;
server=(Ecore_Ipc_Server **)data;
if(!server)
return ECORE_CONFIG_ERR_FAIL;
@ -239,8 +251,9 @@ int ecore_config_mod_exit(void **data) {
int ecore_config_mod_poll(void **data) {
Ecore_Ipc_Server **server=(Ecore_Ipc_Server **)data;
int _ecore_config_mod_poll(void **data) {
Ecore_Ipc_Server **server;
server=(Ecore_Ipc_Server **)data;
if(!server)
return ECORE_CONFIG_ERR_FAIL;

View File

@ -21,23 +21,23 @@
# define TRUE (!FALSE)
#endif
typedef struct _ipc {
typedef struct _ecore_config_ipc {
void *lib;
void *data;
int (*ipc_init)(char *pipe_name,void **data);
int (*ipc_exit)(void **data);
int (*ipc_poll)(void **data);
struct _ipc *next;
} ipc;
struct _ecore_config_ipc *next;
} Ecore_Config_Ipc;
static ipc *ipc_modules=NULL;
static Ecore_Config_Ipc *ipc_modules=NULL;
static unsigned long ipc_timer=0L;
Ecore_Config_Server *srv2ecore_config_srv(void *srv) {
ipc *ipc_tmp;
Ecore_Config_Server *_ecore_config_server_convert(void *srv) {
Ecore_Config_Ipc *ipc_tmp;
Ecore_Config_Server *srv_tmp;
ipc_tmp = ipc_modules;
@ -51,7 +51,7 @@ Ecore_Config_Server *srv2ecore_config_srv(void *srv) {
ipc_tmp = ipc_tmp->next;
}
return __server_global;
return __ecore_config_server_global;
}
/*****************************************************************************/
@ -60,12 +60,16 @@ Ecore_Config_Server *srv2ecore_config_srv(void *srv) {
char *ipc_prop_list(Ecore_Config_Server *srv, const long serial) {
Ecore_Config_Bundle *theme=ecore_config_bundle_get_by_serial(srv, serial);
Ecore_Config_Prop *e=theme?theme->data:NULL;
estring *s=estring_new(8192);
int f=0;
char *_ecore_config_ipc_prop_list(Ecore_Config_Server *srv, const long serial) {
Ecore_Config_Bundle *theme;
Ecore_Config_Prop *e;
estring *s;
int f;
theme=ecore_config_bundle_get_by_serial(srv, serial);
e=theme?theme->data:NULL;
s=estring_new(8192);
f=0;
while(e) {
estring_appendf(s,"%s%s: %s",f?"\n":"",e->key,ecore_config_get_type(e));
if(e->flags&PF_BOUNDS) {
@ -81,10 +85,12 @@ char *ipc_prop_list(Ecore_Config_Server *srv, const long serial) {
char *ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key) {
char *_ecore_config_ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key) {
#ifdef HAVE_EVAS2
Ecore_Config_Bundle *theme=ecore_config_bundle_get_by_serial(srv, serial);
Ecore_Config_Prop *e=ecore_config_get(theme,key);
Ecore_Config_Bundle *theme;
Ecore_Config_Prop *e;
theme=ecore_config_bundle_get_by_serial(srv, serial);
e=ecore_config_get(theme,key);
if(e) {
estring *s=estring_new(512);
@ -97,10 +103,12 @@ char *ipc_prop_desc(Ecore_Config_Server *srv, const long serial,const char *key)
char *ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key) {
char *_ecore_config_ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key) {
#ifdef HAVE_EVAS2
char *ret=NULL;
Ecore_Config_Bundle *theme=ecore_config_bundle_get_by_serial(srv, serial);
char *ret;
Ecore_Config_Bundle *theme;
ret=NULL;
theme=ecore_config_bundle_get_by_serial(srv, serial);
if((ret=ecore_config_get_as_string(/*theme,*/key)))
return ret;
#endif
@ -108,11 +116,12 @@ char *ipc_prop_get(Ecore_Config_Server *srv, const long serial,const char *key)
int ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,const char *val) {
int _ecore_config_ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,const char *val) {
#ifdef HAVE_EVAS2
int ret;
Ecore_Config_Bundle *theme=ecore_config_bundle_get_by_serial(srv, serial);
Ecore_Config_Bundle *theme;
ret=ecore_config_set(theme,key,(char *)val);
theme=ecore_config_bundle_get_by_serial(srv, serial);
E(1,"ipc.prop.set(%s->%s,\"%s\") => %d\n",theme->identifier,key,val,ret);
return ret;
#else
@ -124,11 +133,14 @@ int ipc_prop_set(Ecore_Config_Server *srv, const long serial,const char *key,con
/*****************************************************************************/
char *ipc_bundle_list(Ecore_Config_Server *srv) {
Ecore_Config_Bundle *ns=ecore_config_bundle_get_1st(srv);
estring *s=estring_new(8192);
int f=0;
char *_ecore_config_ipc_bundle_list(Ecore_Config_Server *srv) {
Ecore_Config_Bundle *ns;
estring *s;
int f;
ns=ecore_config_bundle_get_1st(srv);
s=estring_new(8192);
f=0;
if(!ns)
return strdup("<no_bundles_created>");
@ -141,22 +153,25 @@ char *ipc_bundle_list(Ecore_Config_Server *srv) {
int 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))
return ECORE_CONFIG_ERR_SUCC;
return ECORE_CONFIG_ERR_FAIL; }
char *ipc_bundle_label_get(Ecore_Config_Server *srv, const long serial) {
Ecore_Config_Bundle *ns=ecore_config_bundle_get_by_serial(srv, serial);
char *label=ecore_config_bundle_get_label(ns);
char *_ecore_config_ipc_bundle_label_get(Ecore_Config_Server *srv, const long serial) {
Ecore_Config_Bundle *ns;
char *label;
ns=ecore_config_bundle_get_by_serial(srv, serial);
label=ecore_config_bundle_get_label(ns);
return strdup(label?label:"<no such bundle>"); }
int ipc_bundle_label_set(Ecore_Config_Server *srv, const long serial,const char *label) {
Ecore_Config_Bundle *ns=ecore_config_bundle_get_by_serial(srv, serial);
int _ecore_config_ipc_bundle_label_set(Ecore_Config_Server *srv, const long serial,const char *label) {
Ecore_Config_Bundle *ns;
ns=ecore_config_bundle_get_by_serial(srv, serial);
if (!(ns->identifier=malloc(sizeof(label))))
return ECORE_CONFIG_ERR_OOM;
memcpy(ns->identifier,label,sizeof(label));
@ -164,17 +179,19 @@ int ipc_bundle_label_set(Ecore_Config_Server *srv, const long serial,const char
long ipc_bundle_label_find(Ecore_Config_Server *srv, const char *label) {
Ecore_Config_Bundle *ns=ecore_config_bundle_get_by_label(srv, label);
long _ecore_config_ipc_bundle_label_find(Ecore_Config_Server *srv, const char *label) {
Ecore_Config_Bundle *ns;
ns=ecore_config_bundle_get_by_label(srv, label);
return ns?ecore_config_bundle_get_serial(ns):-1; }
static int ipc_poll(void *data) {
ipc *m=(ipc *)data;
static int _ecore_config_ipc_poll(void *data) {
Ecore_Config_Ipc *m;
Ecore_Config_Server *s;
m=(Ecore_Config_Ipc *)data;
while(m) {
s = m->data;
while (s) {
@ -187,8 +204,8 @@ static int ipc_poll(void *data) {
int ipc_exit(void) {
ipc *m;
int _ecore_config_ipc_exit(void) {
Ecore_Config_Ipc *m;
Ecore_Config_Server *l;
if(ipc_timer)
@ -206,14 +223,17 @@ int ipc_exit(void) {
Ecore_Config_Server *ipc_init(char *pipe_name) {
Ecore_Config_Server *_ecore_config_ipc_init(char *pipe_name) {
char buf[PATH_MAX];
glob_t globbuf;
int ret;
unsigned int c;
ipc *nm=NULL;
Ecore_Config_Server *list=NULL;
Ecore_Config_Server *ret_srv=NULL;
Ecore_Config_Ipc *nm;
Ecore_Config_Server *list;
Ecore_Config_Server *ret_srv;
nm=NULL;
list=NULL;
ret_srv=NULL;
if (nm) {
list=(Ecore_Config_Server *)nm->data;
@ -233,11 +253,11 @@ Ecore_Config_Server *ipc_init(char *pipe_name) {
list=malloc(sizeof(Ecore_Config_Server));
memset(list, 0, sizeof(Ecore_Config_Server));
if((ret=nm->ipc_init(pipe_name,&list->server))!=ECORE_CONFIG_ERR_SUCC) {
E(2,"ipc_init: failed to register %s, code %d\n", pipe_name, ret);
E(2,"_ecore_config_ipc_init: failed to register %s, code %d\n", pipe_name, ret);
break;
}
E(2,"ipc_init: registered \"%s\"...\n",pipe_name);
E(2,"_ecore_config_ipc_init: registered \"%s\"...\n",pipe_name);
list->name=strdup(pipe_name);
list->next=nm->data;
@ -259,30 +279,30 @@ Ecore_Config_Server *ipc_init(char *pipe_name) {
return NULL;
for(c=0;c<globbuf.gl_pathc;c++) {
if(!(nm=malloc(sizeof(ipc)))) {
if(!(nm=malloc(sizeof(Ecore_Config_Ipc)))) {
ret=ECORE_CONFIG_ERR_OOM;
goto done; }
memset(nm,0,sizeof(ipc));
memset(nm,0,sizeof(Ecore_Config_Ipc));
E(1,"ipc_init: checking \"%s\"...\n",globbuf.gl_pathv[c]);
E(1,"_ecore_config_ipc_init: checking \"%s\"...\n",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);
if(ret==ECORE_CONFIG_ERR_NODATA)
E(0,"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",globbuf.gl_pathv[c],dlerror());
else if(ret==ECORE_CONFIG_ERR_SUCC) {
list=malloc(sizeof(Ecore_Config_Server));
/* memcpy(list, 0, sizeof(Ecore_Config_Server));*/
if((ret=nm->ipc_init(pipe_name,&list->server))!=ECORE_CONFIG_ERR_SUCC)
E(0,"ipc_init: could not initialize \"%s\": %d\n",globbuf.gl_pathv[c],ret);
E(0,"_ecore_config_ipc_init: could not initialize \"%s\": %d\n",globbuf.gl_pathv[c],ret);
else {
char *p=globbuf.gl_pathv[c];
if(DEBUG!=0) {
char *q=strrchr(p,DIR_DELIMITER);
if(q)
p=++q; }
E(0,"ipc_init: adding \"%s\"...\n",p);
E(2,"ipc_init: registered \"%s\"...\n",pipe_name);
E(0,"_ecore_config_ipc_init: adding \"%s\"...\n",p);
E(2,"_ecore_config_ipc_init: registered \"%s\"...\n",pipe_name);
list->name=strdup(pipe_name);
list->next=nm->data;
@ -298,11 +318,7 @@ Ecore_Config_Server *ipc_init(char *pipe_name) {
globfree(&globbuf);
if(ipc_modules) {
/* ### temporary evilness */
/* if((debug>0)||(getenv("USER")&&!strcmp(getenv("USER"),"aje"))) {
signal(SIGINT,SIG_DFL);
signal(SIGSEGV,SIG_DFL); } */
ipc_timer=timeout_add(100,ipc_poll,ipc_modules); }
ipc_timer=timeout_add(100,_ecore_config_ipc_poll,ipc_modules); }
return ret_srv; }