forked from enlightenment/efl
Fixups, cleanups etc. ecore_config now working with an equate client :)
SVN revision: 8011
This commit is contained in:
parent
ac58ffd507
commit
e41d146893
|
@ -31,11 +31,18 @@
|
|||
# define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#include "debug.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include <Ecore_Ipc.h>
|
||||
|
||||
/* debug */
|
||||
#define DEBUG 999
|
||||
|
||||
#ifdef ECORE_CONFIG_DEBUG
|
||||
# define D(fmt,args...) do { if(DEBUG>=0) fprintf(stderr,fmt,## args); } while(0);
|
||||
#else
|
||||
# define D(msg,args...)
|
||||
#endif
|
||||
#define E(lvl,fmt,args...) do { if(DEBUG>=(lvl)) fprintf(stderr,fmt,## args); } while(0)
|
||||
|
||||
|
||||
/* structures */
|
||||
|
||||
|
@ -44,8 +51,7 @@ typedef enum Ecore_Config_Type {
|
|||
PT_INT=1,
|
||||
PT_FLT=2,
|
||||
PT_STR=3,
|
||||
PT_PTR=4,
|
||||
PT_RGB=5
|
||||
PT_RGB=4
|
||||
} Ecore_Config_Type;
|
||||
|
||||
|
||||
|
@ -74,8 +80,8 @@ typedef struct Ecore_Config_Listener_List {
|
|||
typedef struct Ecore_Config_Prop {
|
||||
char *key;
|
||||
char *description;
|
||||
void *ptr;
|
||||
Ecore_Config_Type type;
|
||||
char *ptr;
|
||||
long val,lo,hi,step;
|
||||
Ecore_Config_Flag flags;
|
||||
Ecore_Config_Listener_List *listeners;
|
||||
|
@ -116,6 +122,7 @@ int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val
|
|||
int ecore_config_set_string(Ecore_Config_Bundle *t,const char *key,char *val);
|
||||
int ecore_config_set_int(Ecore_Config_Bundle *t,const char *key,int val);
|
||||
int ecore_config_set_rgb(Ecore_Config_Bundle *t,const char *key,char *val);
|
||||
char *ecore_config_get_rgbstr(const Ecore_Config_Bundle *t,const char *key);
|
||||
int ecore_config_set_float(Ecore_Config_Bundle *t,const char *key,float val);
|
||||
int ecore_config_set_as_string(Ecore_Config_Bundle *t,const char *key,char *val);
|
||||
|
||||
|
@ -123,8 +130,9 @@ int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char
|
|||
int ecore_config_listen(Ecore_Config_Bundle *t,const char *name,const char *key,Ecore_Config_Listener listener,int tag,void *data);
|
||||
int ecore_config_deaf(Ecore_Config_Bundle *t,const char *name,const char *key,Ecore_Config_Listener listener);
|
||||
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Bundle *t,Ecore_Config_Prop *e);
|
||||
int ecore_config_guess_type(char *val);
|
||||
|
||||
Ecore_Config_Bundle *ecore_config_new_bundle(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_next(Ecore_Config_Bundle *ns);
|
||||
Ecore_Config_Bundle *ecore_config_bundle_get_by_serial(Ecore_Config_Server *srv, long serial);
|
||||
|
@ -142,4 +150,23 @@ int ecore_config_load_file(Ecore_Config_Bundle *b, char *file);
|
|||
int ecore_config_save(Ecore_Config_Bundle *b);
|
||||
int ecore_config_save_file(Ecore_Config_Bundle *b, char *file);
|
||||
|
||||
/* error codes */
|
||||
# define ECORE_CONFIG_ERR_NOTSUPP (-16)
|
||||
# define ECORE_CONFIG_ERR_NOFILE (-15)
|
||||
# define ECORE_CONFIG_ERR_META_DLFAIL (-14)
|
||||
# define ECORE_CONFIG_ERR_META_FILE (-13)
|
||||
# define ECORE_CONFIG_ERR_META_FORMAT (-12)
|
||||
# define ECORE_CONFIG_ERR_MONMIS (-11)
|
||||
# define ECORE_CONFIG_ERR_NOEXEC (-10)
|
||||
# define ECORE_CONFIG_ERR_PARTIAL (-9)
|
||||
# define ECORE_CONFIG_ERR_PATHEX (-8)
|
||||
# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
|
||||
# define ECORE_CONFIG_ERR_MUTEX (-6)
|
||||
# define ECORE_CONFIG_ERR_NOTFOUND (-5)
|
||||
# define ECORE_CONFIG_ERR_OOM (-4)
|
||||
# define ECORE_CONFIG_ERR_IGNORED (-3)
|
||||
# define ECORE_CONFIG_ERR_NODATA (-2)
|
||||
# define ECORE_CONFIG_ERR_FAIL (-1)
|
||||
# define ECORE_CONFIG_ERR_SUCC (0)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,4 @@ ipc_main.c \
|
|||
ipc.h \
|
||||
util.c \
|
||||
util.h \
|
||||
edb.c \
|
||||
debug.h \
|
||||
errors.h \
|
||||
structs.h
|
||||
edb.c
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
#define DEBUG 999
|
||||
|
||||
#ifdef ECORE_CONFIG_DEBUG
|
||||
# define D(fmt,args...) do { if(DEBUG>=0) fprintf(stderr,fmt,## args); } while(0);
|
||||
#else
|
||||
# define D(msg,args...)
|
||||
#endif
|
||||
#define E(lvl,fmt,args...) do { if(DEBUG>=(lvl)) fprintf(stderr,fmt,## args); } while(0)
|
||||
|
|
@ -91,8 +91,7 @@ const char *ecore_config_get_type(const Ecore_Config_Prop *e) {
|
|||
|
||||
void *ecore_config_get_data(const Ecore_Config_Bundle *t,const char *key) {
|
||||
Ecore_Config_Prop *e=ecore_config_get(t,key);
|
||||
return (e?(((e->type==PT_STR)||(e->type==PT_PTR))?((void *)&e->ptr)
|
||||
:((void *)&e->val))
|
||||
return (e?((e->type==PT_STR)?((void *)&e->ptr):((void *)&e->val))
|
||||
:NULL); }
|
||||
|
||||
|
||||
|
@ -125,7 +124,6 @@ int ecore_config_get_rgb(const Ecore_Config_Bundle *t,const char *key,int *r, in
|
|||
return ECORE_CONFIG_ERR_FAIL; }
|
||||
|
||||
char *ecore_config_get_rgbstr(const Ecore_Config_Bundle *t,const char *key) {
|
||||
Ecore_Config_Prop *e=ecore_config_get(t,key);
|
||||
char *r=NULL;
|
||||
esprintf(&r,"#%06x",ecore_config_get_int(t,key));
|
||||
return r; }
|
||||
|
@ -146,8 +144,6 @@ char *ecore_config_get_as_string(const Ecore_Config_Bundle *t,const char *key) {
|
|||
esprintf(&r,"%s:%s=%lf",key,type,ecore_config_get_float(t,key)); break;
|
||||
case PT_STR:
|
||||
esprintf(&r,"%s:%s=\"%s\"",key,type,ecore_config_get_string(t,key)); break;
|
||||
case PT_PTR:
|
||||
esprintf(&r,"%s:%s=%p",key,type,e->ptr); break;
|
||||
case PT_RGB:
|
||||
esprintf(&r,"%s:%s=#%06x",key,type,ecore_config_get_int(t,key)); break;
|
||||
default:
|
||||
|
@ -190,7 +186,6 @@ static int ecore_config_bound(Ecore_Config_Prop *e) {
|
|||
int ecore_config_guess_type(char *val) {
|
||||
char *l=NULL;
|
||||
long v;
|
||||
float f;
|
||||
|
||||
if(!val)
|
||||
return PT_NIL;
|
||||
|
@ -226,15 +221,15 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
|
|||
if (((char *)val)[0]=='#') {
|
||||
if((v=strtol(&((char *)val)[1],&l,16))<0) {
|
||||
v=0;
|
||||
E(0,"ecore_config_val: key \"%s\" -- hexadecimal value less than zero, bound to zero...\n",val);
|
||||
E(0,"ecore_config_val: key \"%s\" -- hexadecimal value less than zero, bound to zero...\n", (char *)val);
|
||||
l=(char *)val;
|
||||
}
|
||||
} else {
|
||||
E(0,"ecore_config_val: key \"%s\" -- value \"%s\" not a valid hexadecimal RGB value?\n",e->key,val);
|
||||
E(0,"ecore_config_val: key \"%s\" -- value \"%s\" not a valid hexadecimal RGB value?\n",e->key,(char *)val);
|
||||
return ECORE_CONFIG_ERR_FAIL;
|
||||
}
|
||||
if(*l)
|
||||
E(0,"ecore_config_val: key \"%s\" -- value \"%s\" not a valid hexadecimal RGB value?\n",e->key,val);
|
||||
E(0,"ecore_config_val: key \"%s\" -- value \"%s\" not a valid hexadecimal RGB value?\n",e->key,(char *)val);
|
||||
else {
|
||||
e->val=v;
|
||||
e->type=PT_RGB;
|
||||
|
@ -257,6 +252,7 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
|
|||
e->flags|=PF_MODIFIED;
|
||||
return ECORE_CONFIG_ERR_SUCC;
|
||||
}
|
||||
return ECORE_CONFIG_ERR_IGNORED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -477,7 +473,7 @@ char *ecore_config_bundle_get_label(Ecore_Config_Bundle *ns) {
|
|||
return ns?ns->identifier:NULL; }
|
||||
|
||||
|
||||
Ecore_Config_Bundle *ecore_config_new_bundle(Ecore_Config_Server *srv,const char *identifier) {
|
||||
Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv,const char *identifier) {
|
||||
Ecore_Config_Bundle *t;
|
||||
static long ss=0; /* bundle unique serial */
|
||||
|
||||
|
@ -486,6 +482,7 @@ Ecore_Config_Bundle *ecore_config_new_bundle(Ecore_Config_Server *srv,const char
|
|||
|
||||
t->identifier=identifier;
|
||||
t->serial=++ss;
|
||||
t->owner=srv->name;
|
||||
t->next=srv->bundles;
|
||||
srv->bundles=t;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
int ecore_config_load(Ecore_Config_Bundle *b) {
|
||||
char* file = malloc(1024); /* ### fixme */
|
||||
sprintf(file,"%s/.e/%s/config.db",getenv("HOME"),b->owner);
|
||||
sprintf(file,"%s/.e/apps/%s/config.db",getenv("HOME"),b->owner);
|
||||
return ecore_config_load_file(b,file);
|
||||
free(file);
|
||||
}
|
||||
|
||||
int ecore_config_save(Ecore_Config_Bundle *b) {
|
||||
char* file = malloc(1024); /* ### fixme */
|
||||
sprintf(file,"%s/.e/%s/config.db",getenv("HOME"),b->owner);
|
||||
sprintf(file,"%s/.e/apps/%s/config.db",getenv("HOME"),b->owner);
|
||||
return ecore_config_save_file(b,file);
|
||||
free(file);
|
||||
}
|
||||
|
@ -76,10 +76,8 @@ int ecore_config_load_file(Ecore_Config_Bundle *b, char *file) {
|
|||
int ecore_config_save_file(Ecore_Config_Bundle *b, char *file) {
|
||||
Ecore_Config_Prop *next=b->data;
|
||||
E_DB_File *db = NULL;
|
||||
int x;
|
||||
|
||||
/* ### we may need to create a directory or two here! */
|
||||
|
||||
db = e_db_open(file);
|
||||
if (!db) {
|
||||
E(0, "Cannot open database from file %s!\n", file);
|
||||
|
@ -100,6 +98,8 @@ int ecore_config_save_file(Ecore_Config_Bundle *b, char *file) {
|
|||
case PT_STR:
|
||||
e_db_str_set(db, next->key, ecore_config_get_string(b, next->key));
|
||||
break;
|
||||
case PT_NIL:
|
||||
/* currently we do nothing for undefined ojects */
|
||||
}
|
||||
|
||||
next=next->next;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef ECORE_CONFIG_ERRORS_H
|
||||
#define ECORE_CONFIG_ERRORS_H
|
||||
|
||||
# define ECORE_CONFIG_ERR_NOTSUPP (-16)
|
||||
# define ECORE_CONFIG_ERR_NOFILE (-15)
|
||||
# define ECORE_CONFIG_ERR_META_DLFAIL (-14)
|
||||
# define ECORE_CONFIG_ERR_META_FILE (-13)
|
||||
# define ECORE_CONFIG_ERR_META_FORMAT (-12)
|
||||
# define ECORE_CONFIG_ERR_MONMIS (-11)
|
||||
# define ECORE_CONFIG_ERR_NOEXEC (-10)
|
||||
# define ECORE_CONFIG_ERR_PARTIAL (-9)
|
||||
# define ECORE_CONFIG_ERR_PATHEX (-8)
|
||||
# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
|
||||
# define ECORE_CONFIG_ERR_MUTEX (-6)
|
||||
# define ECORE_CONFIG_ERR_NOTFOUND (-5)
|
||||
# define ECORE_CONFIG_ERR_OOM (-4)
|
||||
# define ECORE_CONFIG_ERR_IGNORED (-3)
|
||||
# define ECORE_CONFIG_ERR_NODATA (-2)
|
||||
# define ECORE_CONFIG_ERR_FAIL (-1)
|
||||
# define ECORE_CONFIG_ERR_SUCC (0)
|
||||
|
||||
#endif
|
|
@ -1,8 +1,5 @@
|
|||
/* by Azundris, with thanks to Corey Donohoe <atmos@atmos.org> */
|
||||
|
||||
//#include "config.h"
|
||||
#include "errors.h"
|
||||
#include "debug.h"
|
||||
#include "ipc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "Ecore_Config.h"
|
||||
#include "util.h"
|
||||
#include "ipc.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -141,7 +140,7 @@ char *ipc_bundle_list(Ecore_Config_Server *srv) {
|
|||
|
||||
int ipc_bundle_new(Ecore_Config_Server *srv, const char *label) {
|
||||
//Ecore_Config_Bundle *ns=ecore_config_bundle_get_by_serial(srv, 0);
|
||||
if (ecore_config_new_bundle(srv, label))
|
||||
if (ecore_config_bundle_new(srv, label))
|
||||
return ECORE_CONFIG_ERR_SUCC;
|
||||
return ECORE_CONFIG_ERR_FAIL; }
|
||||
|
||||
|
@ -212,7 +211,7 @@ Ecore_Config_Server *ipc_init(char *pipe_name) {
|
|||
unsigned int c;
|
||||
ipc *nm=NULL;
|
||||
Ecore_Config_Server *list=NULL;
|
||||
Ecore_Config_Server *ret_srv;
|
||||
Ecore_Config_Server *ret_srv=NULL;
|
||||
|
||||
if (nm) {
|
||||
list=(Ecore_Config_Server *)nm->data;
|
||||
|
@ -286,7 +285,7 @@ Ecore_Config_Server *ipc_init(char *pipe_name) {
|
|||
list->name=strdup(pipe_name);
|
||||
list->next=nm->data;
|
||||
nm->data=list;
|
||||
if (ret_srv) ret_srv=list;
|
||||
if (!ret_srv) ret_srv=list;
|
||||
|
||||
nm->next=ipc_modules;
|
||||
ipc_modules=nm; }}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/* azundris */
|
||||
|
||||
//#include "config.h"
|
||||
|
||||
//#include <glib.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -19,8 +17,7 @@
|
|||
/* #endif */
|
||||
|
||||
#include "util.h"
|
||||
//#include "evidence.h"
|
||||
#include "errors.h"
|
||||
#include "Ecore_Config.h"
|
||||
|
||||
#define CHUNKLEN 4096
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#define TIMER_STOP 0
|
||||
#define TIMER_CONT 1
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
typedef struct _estring {
|
||||
char *str;
|
||||
int alloc,used;
|
||||
|
|
Loading…
Reference in New Issue