dan sinclair wrote:
no.. I'm referring to my patch implementing ecore_config list :)
Can you just resend the patch and make this easier for everyone.

sure thing..

Cheers,
--
Morten
Index: ecore_config.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/bin/ecore_config.c,v
retrieving revision 1.3
diff -u -r1.3 ecore_config.c
--- ecore_config.c      18 Sep 2005 12:48:24 -0000      1.3
+++ ecore_config.c      6 Nov 2005 16:34:14 -0000
@@ -8,6 +8,70 @@
 #ifdef BUILD_ECORE_CONFIG
 #include "Ecore_Config.h"
 
+
+#define OVERFLOW_CHECK
+
+#define LIMIT_SUPPORTED_KEYS 1000
+
+#if 1
+#define FILE_MAX 512
+
+#define BUBBLE_SORT_CMP pathcmp
+// strcmp for paths - for sorting folders before files
+int pathcmp(const char *s1, const char *s2)
+{
+       int i = 0, j = 0, d = 0;
+       char *s1d, *s2d;
+       s1d = malloc(FILE_MAX);
+       s2d = malloc(FILE_MAX);
+               
+       while(*s1 && *s2) {
+               
+               if(*s1 == '/') s1++;
+               i = 0;
+               while(*s1 && *s1 != '/') {
+                       s1d[i++] = *s1++;
+#ifdef OVERFLOW_CHECK
+                       if(i>=FILE_MAX) {
+                               while(*s1 && *s1!='/') s2++;
+                               break;
+                       }
+#endif
+               }
+
+               if(*s2 == '/') s2++;
+               j = 0;
+               while(*s2 && *s2 != '/') {
+                       s2d[j++] = *s2++;
+#ifdef OVERFLOW_CHECK
+                       if(j>=FILE_MAX) {
+                               while(*s2 && *s2!='/') s2++;
+                               break;
+                       }
+#endif
+               }
+       
+               // These returns order folders before files
+               if(!*s1 && *s2 == '/') return  1;
+               if(!*s2 && *s1 == '/') return -1;
+
+               // Perform regular strcmp of nodes
+               s1d[i] = 0;
+               s2d[j] = 0;
+               d = strcmp(s1d, s2d);
+
+               if(d != 0) {
+                       return d;
+               }
+       }
+       // We should never come here... 
+       fprintf(stderr,"Equal path!");
+       return 0;
+}
+#else
+#define BUBBLE_SORT_CMP strcmp
+#endif
+
 int
 set(const char *key, int ec_type, const char *value)
 {
@@ -49,22 +113,22 @@
                printf("\n");
                break;
        case ECORE_CONFIG_INT:
-               printf("%ld\n", ecore_config_int_get(key));
+               printf("int\t%ld\n", ecore_config_int_get(key));
                break;
        case ECORE_CONFIG_BLN:
-               printf("%d\n", ecore_config_boolean_get(key));
+               printf("bool\t%d\n", ecore_config_boolean_get(key));
                break;
        case ECORE_CONFIG_FLT:
-               printf("%lf\n", ecore_config_float_get(key));
+               printf("float\t%lf\n", ecore_config_float_get(key));
                break;
        case ECORE_CONFIG_STR:
-               printf("%s\n", ecore_config_string_get(key));
+               printf("string\t\"%s\"\n", ecore_config_string_get(key));
                break;
        case ECORE_CONFIG_RGB:
-               printf("%s\n", ecore_config_argbstr_get(key));
+               printf("rgb\t\"%s\"\n", ecore_config_argbstr_get(key));
                break;
        case ECORE_CONFIG_THM:
-               printf("%s\n", ecore_config_theme_get(key));
+               printf("theme\t\"%s\"\n", ecore_config_theme_get(key));
                break;
        default:
                fprintf(stderr, "Property has unrecognised type");
@@ -76,8 +140,42 @@
 int
 list(const char *file)
 {
-       fprintf(stderr, "Command not yet supported\n");
-       return -1;
+       Ecore_Config_Prop *e;
+       int n = 0, x, y;
+       char **keys;
+       char *temp;
+
+       keys = malloc(LIMIT_SUPPORTED_KEYS);
+
+       e = __ecore_config_bundle_local->data;
+
+       do {
+               keys[n++] = e->key;
+#ifdef OVERFLOW_CHECK
+               if(n >= LIMIT_SUPPORTED_KEYS) {
+                       fprintf(stderr, "Config file exceeds key limit\n");
+                       break;
+               }
+#endif
+       } while((e = e->next));
+
+       // Bubble sort
+       for(x=0; x < n; ++x) {
+               for(y=0; y < n-1; ++y) {
+                       if(BUBBLE_SORT_CMP(keys[y],keys[y+1])>0) {
+                               temp = keys[y+1];
+                               keys[y+1] = keys[y];
+                               keys[y] = temp;
+                       }
+               }
+       }
+
+       for(x=0; x < n; ++x) {
+               printf("%-28s\t", keys[x]);
+               get(keys[x]);
+       }
+
+       return 0;
 }
 
 int
@@ -154,6 +252,8 @@
 int
 main(int argc, const char **argv)
 {
+       Ecore_Config_Bundle *t;
+       Ecore_Config_Prop *e;
        const char *prog, *file, *cmd, *key, *type, *value;
        int ec_type = -1;
        int ret = 0;
@@ -194,8 +294,15 @@
                }
        }
        
-       // Load configuration from file
        ecore_config_init("econfig");
+
+       // Remove any config not from the file
+       t = __ecore_config_bundle_local;
+       while((e = t->data)) {
+               ecore_config_dst(e);
+       }
+
+       // Load configuration from file
        ecore_config_file_load(file);
        
        // Execute command

Reply via email to