perhaps looking at this on an ecore_config API level, rather than on a
ecore_config binary tool parameters level would help.
We need generic list handling in ecore_config and it is something I have
pondered over much and never come to a satisfactory solution...

A

On Mon, Dec 19, 2005 at 05:10:29AM +0100, Morten Nilsen wrote:
> Phuah Yee Keat wrote:
> >>I'll clean it up a bit and send it in a little while..
> >
> >How about this:
> >-addstring "/usr/local/e17/applications"
> >-removestring "/usr/local/share/applications"
> >
> >Hehe, this was more like what's on my mind, since the advantage of 
> >having a list is the ability to have --addstring/--additem 
> >--removestring/--removeitem.
> 
> yes, I know that's what was on your mind, it's just not quite as easy to 
> do as a --append :)
> 
> I'm thinking of something a bit more generic than a list of strings..
> 
> something along the lines of;
> -k /foo/bar --array -s "test 1"
> -k /foo/bar -y -s "test 2"
> -k /foo/bar -y -s "test 3"
> -k /foo/bar -y -d "test 2"
> 
> where the first set operation on an array would define its type.
> 
> >Anyway, list items really looks useful in ecore_config. :)
> 
> yes, like I mentioned in an earlier mail, I've been thinking about how 
> to best implement lists.. not quite reached a conclusion yet, though..
> 
> the --append patch still is useful, and gets you partially what you 
> need, as a start :)
> 
> # ./ecore_config -c /etc/entrance_config.cfg -k /entrance/greeting/before -g
> string  "Welcome to "
> # ./ecore_config -c /etc/entrance_config.cfg -k 
> /entrance/greeting/before -p testing
> # ./ecore_config -c /etc/entrance_config.cfg -k 
> /entrance/greeting/before -g
> string  "Welcome to testing"
> 
> attached is a patch against current cvs to add --append/-p
> 
> Cheers,
> -- 
> Morten
> :wq

> Index: ecore_config.c
> ===================================================================
> RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/bin/ecore_config.c,v
> retrieving revision 1.7
> diff -u -r1.7 ecore_config.c
> --- ecore_config.c      18 Dec 2005 19:07:52 -0000      1.7
> +++ ecore_config.c      19 Dec 2005 04:05:01 -0000
> @@ -152,10 +152,36 @@
>     fprintf(stderr, "  -r, --rgb=VALUE    set RGBA\n");
>     fprintf(stderr, "  -s, --string=VALUE set string\n");
>     fprintf(stderr, "  -t, --theme=VALUE  set theme\n\n");
> +   fprintf(stderr, "  -p, --append=VALUE append string\n");
>     exit(ret);
>  }
>  
>  int
> +append(const char *key, const char *str)
> +{
> +   char *buf;
> +   char *old;
> +   int len;
> +
> +   old = ecore_config_string_get(key);
> +   if(old == NULL)
> +     return 1;
> +
> +   len = strlen(str) + strlen(old) + 1;
> +   buf = malloc(len);
> +   snprintf(buf, len, "%s%s", old, str);
> +
> +   len = 0;
> +   if(ecore_config_string_set(key, buf) != ECORE_CONFIG_ERR_SUCC)
> +     len = 2;
> +
> +   free(buf);
> +   free(old);
> +
> +   return len;
> +}
> +
> +int
>  main(int argc, char * const argv[])
>  {
>     const char *prog, *file, *key;
> @@ -188,10 +214,11 @@
>            {"string", 1, 0, 's'},
>            {"theme",  1, 0, 't'},
>            {"key",    1, 0, 'k'},
> +          {"append", 1, 0, 'p'},
>            {0, 0, 0, 0}
>         };
>  
> -       ret = getopt_long(argc, argv, "c:agdb:f:i:nr:s:t:k:", long_options, 
> NULL);
> +       ret = getopt_long(argc, argv, "c:agdb:f:i:nr:s:t:k:p:", long_options, 
> NULL);
>         if(ret == -1)
>            break;
>  
> @@ -231,6 +258,11 @@
>                 type = ECORE_CONFIG_THM;
>                 value = strdup(optarg);
>                 break;
> +            case 'p':
> +               cmd = 'p';
> +               type = ECORE_CONFIG_STR;
> +               value = strdup(optarg);
> +               break;
>              case 'c':
>                 file = strdup(optarg);
>                 break;
> @@ -272,6 +304,15 @@
>                 ecore_config_file_save(file);
>              }
>            break;
> +       case 'p':
> +          if (append(key, value))
> +            {
> +               fprintf(stderr, "Append failed for %s", key);
> +               ret = 1;
> +            } else {
> +               ecore_config_file_save(file);
> +            }
> +          break;
>         case 'd':
>            if(del(key))
>              {



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to