146 lines
5.5 KiB
C
146 lines
5.5 KiB
C
#ifndef _ECORE_CONFIG_H
|
|
#define _ECORE_CONFIG_H
|
|
|
|
/**
|
|
* @file Ecore_Config.h
|
|
* @brief The file that any project using ecore_config will want to include.
|
|
*
|
|
* This file provies all headers and structs for use with Ecore_Config.
|
|
* Using individual header files should not be necessary.
|
|
*/
|
|
|
|
/**
|
|
* @mainpage Enlightened Configuration Library Documentation
|
|
*
|
|
* @image html ecore_config_mini.png
|
|
*
|
|
* @section intro Introduction
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#define DIR_DELIMITER '/'
|
|
#define ECORE_CONFIG_FLOAT_PRECISION 1000
|
|
|
|
#ifndef TRUE
|
|
# define FALSE (0)
|
|
# define TRUE (!FALSE)
|
|
#endif
|
|
|
|
#include "debug.h"
|
|
#include "errors.h"
|
|
|
|
#include <Ecore_Ipc.h>
|
|
|
|
|
|
/* structures */
|
|
|
|
typedef enum Ecore_Config_Type {
|
|
PT_NIL=0,
|
|
PT_INT=1,
|
|
PT_FLT=2,
|
|
PT_STR=3,
|
|
PT_PTR=4,
|
|
PT_RGB=5
|
|
} Ecore_Config_Type;
|
|
|
|
|
|
|
|
typedef enum Ecore_Config_Flag {
|
|
PF_NONE=0,
|
|
PF_BOUNDS=1,
|
|
PF_MODIFIED=2
|
|
} Ecore_Config_Flag;
|
|
|
|
|
|
|
|
typedef int (*Ecore_Config_Listener)(const char *key,const Ecore_Config_Type type,const int tag,void *data,void *bundle);
|
|
|
|
|
|
typedef struct Ecore_Config_Listener_List {
|
|
Ecore_Config_Listener listener;
|
|
const char *name;
|
|
void *data;
|
|
int tag;
|
|
struct Ecore_Config_Listener_List *next; } Ecore_Config_Listener_List;
|
|
|
|
/**
|
|
* The actual property for storing a key-value pair.
|
|
*/
|
|
typedef struct Ecore_Config_Prop {
|
|
char *key;
|
|
char *description;
|
|
Ecore_Config_Type type;
|
|
char *ptr;
|
|
long val,lo,hi,step;
|
|
Ecore_Config_Flag flags;
|
|
Ecore_Config_Listener_List *listeners;
|
|
struct Ecore_Config_Prop *next; /**< pointer to the next property in the list */
|
|
} Ecore_Config_Prop;
|
|
|
|
/**
|
|
* A container for a list of properties. Provided so that an application can
|
|
* use different set of properties at any time. This is useful for multiple
|
|
* window support.
|
|
*/
|
|
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 */
|
|
long serial; /**< unique identifier to identify bundle */
|
|
Ecore_Config_Prop *data; /**< pointer to root of property list */
|
|
void *user_data; /**< app specific pointer to "other data" */
|
|
struct Ecore_Config_Bundle *next; /**< pointer to next bundle in this application */
|
|
} Ecore_Config_Bundle;
|
|
|
|
typedef struct Ecore_Config_Server {
|
|
void *server;
|
|
char *name;
|
|
Ecore_Config_Bundle *bundles; /* data anchor */
|
|
struct Ecore_Config_Server *next; } Ecore_Config_Server;
|
|
|
|
|
|
Ecore_Config_Prop *ecore_config_get(const Ecore_Config_Bundle *t,const char *key);
|
|
const char *ecore_config_get_type(const Ecore_Config_Prop *e);
|
|
void *ecore_config_get_data(const Ecore_Config_Bundle *t,const char *key);
|
|
char *ecore_config_get_string(const Ecore_Config_Bundle *t,const char *key);
|
|
long ecore_config_get_int(const Ecore_Config_Bundle *t,const char *key);
|
|
int ecore_config_get_rgb(const Ecore_Config_Bundle *t,const char *key,int *r, int *g, int *b);
|
|
float ecore_config_get_float(const Ecore_Config_Bundle *t,const char *key);
|
|
char *ecore_config_get_as_string(const Ecore_Config_Bundle *t,const char *key);
|
|
char *ecore_config_canonize_key(char *,int modify);
|
|
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);
|
|
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);
|
|
|
|
int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char *val,float lo,float hi,float step);
|
|
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);
|
|
|
|
Ecore_Config_Bundle *ecore_config_new_bundle(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);
|
|
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);
|
|
char *ecore_config_bundle_get_label(Ecore_Config_Bundle *ns);
|
|
|
|
|
|
Ecore_Config_Server *ecore_config_init(char *name);
|
|
Ecore_Config_Server *ecore_config_init_global(char *name);
|
|
int ecore_config_exit(void);
|
|
|
|
int ecore_config_load(Ecore_Config_Bundle *b);
|
|
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);
|
|
|
|
#endif
|