Morten Nilsen wrote:
Here you have my second patch - I've really wanted this functionality,
so I decided to have a go at implementing it..
This patch also removes the theme path for "econfig" that is set by the
init function (and any others it might set) before loading the file
I've written a different version of this code, that sorts the list, but
still uses ecore_config_as_string_get to actually print info, so the
output isn't nicely tabulated..
However, I don't think this code is all that neat, and would like some
input on it...
Cheers,
--
Morten
#include <Ecore_Config.h>
#include <stdlib.h>
int pathcmp(const char *s1, const char *s2) {
int i = 0, j = 0, d = 0, c = 0;
char *s1d, *s2d;
s1d = malloc(512);
s2d = malloc(512);
while(*s1 && *s2) {
if(*s1 == '/') s1++;
i = 0;
while(*s1 && *s1 != '/') {
s1d[i++] = *s1++;
}
if(*s2 == '/') s2++;
j = 0;
while(*s2 && *s2 != '/') {
s2d[j++] = *s2++;
}
if(!*s1 && *s2 == '/')
return 1;
if(!*s2 && *s1 == '/')
return -1;
s1d[i] = 0;
s2d[j] = 0;
d = strcmp(s1d, s2d);
if(d != 0) {
return d;
}
}
return 0;
}
int main(int argc, char ** argv) {
if(argc != 2) {
printf("Usage: %s <ecore_config_file>\n", argv[0]);
return 1;
}
if (ecore_config_init("eec") != ECORE_CONFIG_ERR_SUCC) {
printf("Cannot init Ecore_Config");
return 1;
}
char **keys;
char *key;
keys = malloc(1024);
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
t = __ecore_config_bundle_local;
while(e = t->data) {
ecore_config_dst(e);
}
if(ecore_config_file_load(argv[1]) == ECORE_CONFIG_ERR_NODATA)
{
printf("Error opening entrance_config.cfg");
return 1;
}
int i = 0, x, y, klen = 0;
char *temp;
e = t->data;
do {
keys[i++] = e->key;
} while(e = e->next);
// sort
for(x=0; x < i; ++x) {
for(y=0; y < i-1; ++y) {
if(pathcmp(keys[y],keys[y+1])>0) {
temp = keys[y+1];
keys[y+1] = keys[y];
keys[y] = temp;
}
}
}
for(x=0; x < i; ++x)
printf("%s\n", ecore_config_as_string_get(keys[x]));
ecore_config_shutdown();
return 0;
}