Re: [E-devel] Ecore_config command line tool
one request - can you call it ecore_config? :) i just like namespacing all the binaries as well as libs and everything else :) Here's the patch renamed to ecore_config (generated against ecore-0.9.9.010). -- Simon Poole www.appliancestudio.comdiff -urN ecore-0.9.9.010.orig/src/bin/ecore_config.c ecore-0.9.9.010/src/bin/ecore_config.c --- ecore-0.9.9.010.orig/src/bin/ecore_config.c 1970-01-01 01:00:00.0 +0100 +++ ecore-0.9.9.010/src/bin/ecore_config.c 2005-06-13 13:32:45.606272368 +0100 @@ -0,0 +1,229 @@ +#include config.h +#include Ecore.h + +#ifdef BUILD_ECORE_CONFIG +#include Ecore_Config.h + +int +set(const char *key, int ec_type, const char *value) +{ + int i; + float f; + + switch (ec_type) { + case PT_INT: + case PT_BLN: + i = atoi(value); + if (ecore_config_typed_set(key, i, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + case PT_FLT: + f = atof(value); + if (ecore_config_typed_set(key, f, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + case PT_STR: + case PT_RGB: + case PT_THM: + case PT_NIL: + if (ecore_config_typed_set(key, value, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + } + return 0; +} + +int +get(const char *key) +{ + Ecore_Config_Prop *e; + + if (!(e = ecore_config_get(key))) { + fprintf(stderr, No such property\n); + return -1; + } + + switch (e-type) { + case PT_NIL: + printf(\n); + break; + case PT_INT: + printf(%ld\n, ecore_config_int_get(key)); + break; + case PT_BLN: + printf(%d\n, ecore_config_boolean_get(key)); + break; + case PT_FLT: + printf(%lf\n, ecore_config_float_get(key)); + break; + case PT_STR: + printf(%s\n, ecore_config_string_get(key)); + break; + case PT_RGB: + printf(%s\n, ecore_config_argbstr_get(key)); + break; + case PT_THM: + printf(%s\n, ecore_config_theme_get(key)); + break; + default: + fprintf(stderr, Property has unrecognised type); + return -1; + } + return 0; +} + +int +list(const char *file) +{ + fprintf(stderr, Command not yet supported\n); + return -1; +} + +int +get_type(const char *key) +{ + Ecore_Config_Prop *e; + if (!(e = ecore_config_get(key))) { + fprintf(stderr, No such property\n); + return -1; + } + + switch (e-type) { + case PT_NIL: + printf(nil\n); + break; + case PT_INT: + printf(int\n); + break; + case PT_BLN: + printf(bool\n); + break; + case PT_FLT: + printf(float\n); + break; + case PT_STR: + printf(string\n); + break; + case PT_RGB: + printf(rgb\n); + break; + case PT_THM: + printf(theme\n); + break; + default: + fprintf(stderr, Property has unrecognised type); + return -1; + } + return 0; +} + +int +parse_type(const char *type) +{ + if (!strcmp(nil, type)) { + return PT_NIL; + } else if (!strcmp(int, type)) { + return PT_INT; + } else if (!strcmp(float, type)) { + return PT_FLT; + } else if (!strcmp(bool, type)) { + return PT_BLN; + } else if (!strcmp(str, type)) { + return PT_STR; + } else if (!strcmp(rgb, type)) { + return PT_RGB; + } else if (!strcmp(theme, type)) { + return PT_THM; + } + return -1; +} + +void +usage_and_exit(const char *prog, int ret, const char *msg) +{ + if (msg) fprintf(stderr, msg); + fprintf(stderr, Usage: %s config-file {get|set|type|list} [args...]\n, prog); + fprintf(stderr, LIST: %s config-file list\n, prog); + fprintf(stderr, GET:%s config-file get key\n, prog); + fprintf(stderr, GET TYPE: %s config-file type key\n, prog); + fprintf(stderr, SET:%s config-file set key {nil|int|float|bool|str|rgb|theme} value\n, prog); + exit(ret); +} + +int +main(int argc, const char **argv) +{ + const char *prog, *file, *cmd, *key, *type, *value; + int ec_type = -1; + int ret = 0; + prog = file = cmd = key = type = value = NULL; + + prog = argv[0]; + if (argc 3) usage_and_exit(prog, 2, Not enough arguments\n); + + file = argv[1]; + cmd = argv[2]; + + // Check for valid
Re: [E-devel] Ecore_config command line tool
Carsten Haitzler (The Rasterman) wrote: On Wed, 25 May 2005 12:47:57 +0100 Simon Poole [EMAIL PROTECTED] babbled: Okay Raster, I took the bait.. Here's a simple command-line tool ('econfig') to read and write settings to an Ecore_config file. The name was chosen to avoid confusion with the altogether different 'ecore-config'. one request - can you call it ecore_config? :) i just like namespacing all the binaries as well as libs and everything else :) Suits me. Do you want me to regenerate the patch? -- Simon Poole www.appliancestudio.com --- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
On Wed, 25 May 2005 12:47:57 +0100 Simon Poole [EMAIL PROTECTED] babbled: Okay Raster, I took the bait.. Here's a simple command-line tool ('econfig') to read and write settings to an Ecore_config file. The name was chosen to avoid confusion with the altogether different 'ecore-config'. one request - can you call it ecore_config? :) i just like namespacing all the binaries as well as libs and everything else :) Provided as a patch against ecore-0.9.9.007, but should apply cleanly against CVS HEAD. Given my inexperience with ecore_config, someone should cast an eye over it before committing. Example usage: To set EWL apps to always render to the framebuffer for the current user: # mkdir $HOME/.e # econfig $HOME/.e/config.eet set /ewl/evas/render_method str "fb" Just type 'econfig' for usage information One thing -- I've not been diligent about free()ing stuff as it's a fire and forget command-line tool so that kind of thing is done for you by the Linux kernel on exit. Does that create portability problems wrt other OSes? nah - i dont think efl is really ever destined for os's that dont free up for you on exit... :) i've gotten lazy over the years and just ASSUME it will be done for me now :) -- - Codito, ergo sum - "I code, therefore I am" -- The Rasterman (Carsten Haitzler)[EMAIL PROTECTED] 裸好多 [EMAIL PROTECTED] Tokyo, Japan (東京 日本) --- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
what is wrong with exsh? Simon Poole wrote: Okay Raster, I took the bait.. Here's a simple command-line tool ('econfig') to read and write settings to an Ecore_config file. The name was chosen to avoid confusion with the altogether different 'ecore-config'. Provided as a patch against ecore-0.9.9.007, but should apply cleanly against CVS HEAD. Given my inexperience with ecore_config, someone should cast an eye over it before committing. Example usage: To set EWL apps to always render to the framebuffer for the current user: # mkdir $HOME/.e # econfig $HOME/.e/config.eet set /ewl/evas/render_method str fb Just type 'econfig' for usage information One thing -- I've not been diligent about free()ing stuff as it's a fire and forget command-line tool so that kind of thing is done for you by the Linux kernel on exit. Does that create portability problems wrt other OSes? -- Simon Poole www.appliancestudio.com diff -urN ecore-0.9.9.007.orig/src/bin/Makefile.am ecore-0.9.9.007/src/bin/Makefile.am --- ecore-0.9.9.007.orig/src/bin/Makefile.am 2005-03-10 14:41:52.0 + +++ ecore-0.9.9.007/src/bin/Makefile.am 2005-05-25 11:35:15.635880880 + @@ -73,7 +73,8 @@ bin_PROGRAMS = \ ecore_test \ -ecore_evas_test +ecore_evas_test \ +econfig ecore_test_SOURCES = \ ecore_test.c @@ -135,3 +136,13 @@ $(ECORE_IPC_LIB) \ $(ECORE_TXT_LIB) +econfig_SOURCES = \ +econfig.c + +econfig_LDADD = \ +$(ECORE_CONFIG_LIB) + +econfig_DEPENDENCIES = \ +$(top_builddir)/src/lib/ecore/libecore.la \ +$(ECORE_CONFIG_LIB) + diff -urN ecore-0.9.9.007.orig/src/bin/econfig.c ecore-0.9.9.007/src/bin/econfig.c --- ecore-0.9.9.007.orig/src/bin/econfig.c1970-01-01 00:00:00.0 + +++ ecore-0.9.9.007/src/bin/econfig.c 2005-05-25 11:37:26.795941520 + @@ -0,0 +1,229 @@ +#include config.h +#include Ecore.h + +#ifdef BUILD_ECORE_CONFIG +#include Ecore_Config.h + +int +set(const char *key, int ec_type, const char *value) +{ + int i; + float f; + + switch (ec_type) { + case PT_INT: + case PT_BLN: + i = atoi(value); + if (ecore_config_typed_set(key, i, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + case PT_FLT: + f = atof(value); + if (ecore_config_typed_set(key, f, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + case PT_STR: + case PT_RGB: + case PT_THM: + case PT_NIL: + if (ecore_config_typed_set(key, value, ec_type) != ECORE_CONFIG_ERR_SUCC) return -1; + break; + } + return 0; +} + +int +get(const char *key) +{ + Ecore_Config_Prop *e; + + if (!(e = ecore_config_get(key))) { + fprintf(stderr, No such property\n); + return -1; + } + + switch (e-type) { + case PT_NIL: + printf(\n); + break; + case PT_INT: + printf(%ld\n, ecore_config_int_get(key)); + break; + case PT_BLN: + printf(%d\n, ecore_config_boolean_get(key)); + break; + case PT_FLT: + printf(%lf\n, ecore_config_float_get(key)); + break; + case PT_STR: + printf(%s\n, ecore_config_string_get(key)); + break; + case PT_RGB: + printf(%s\n, ecore_config_argbstr_get(key)); + break; + case PT_THM: + printf(%s\n, ecore_config_theme_get(key)); + break; + default: + fprintf(stderr, Property has unrecognised type); + return -1; + } + return 0; +} + +int +list(const char *file) +{ + fprintf(stderr, Command not yet supported\n); + return -1; +} + +int +get_type(const char *key) +{ + Ecore_Config_Prop *e; + if (!(e = ecore_config_get(key))) { + fprintf(stderr, No such property\n); + return -1; + } + + switch (e-type) { + case PT_NIL: + printf(nil\n); + break; + case PT_INT: + printf(int\n); + break; + case PT_BLN: + printf(bool\n); + break; + case PT_FLT: + printf(float\n); + break; + case PT_STR: + printf(string\n); + break; + case PT_RGB: + printf(rgb\n); + break; + case PT_THM: + printf(theme\n); + break; + default: + fprintf(stderr, Property has unrecognised type); + return -1; + } + return 0; +} + +int +parse_type(const char *type) +{ + if (!strcmp(nil, type)) { + return PT_NIL; + } else if (!strcmp(int, type)) { + return
Re: [E-devel] Ecore_config command line tool
Andrew Elcock wrote: what is wrong with exsh? Ooo.. I wasn't aware it existed (newbie to E17).. However, it is different. I've just had a look through examine and exsh and they both appear to only offer IPC access to the configuration of a running program. My quick hack allows you to view and edit ecore_config .eet files on the local file system. You could argue that it would be better to add this functionality to exsh or move econfig into e17/apps/examine. I'll leave that for the maintainers to decide. BTW, I couldn't see a way of implementing list which would list all the properties in the file. Anyone? -- Simon Poole www.appliancestudio.com --- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
the reason it only works over IPC is because that is how it is supposed to work!!! if you edit the file then the app has no idea - over IPC the application gets alerted to the change and picks it up immediately. Ecore_Config is due some very heavy work, and may change a lot in the near future Simon Poole wrote: Andrew Elcock wrote: what is wrong with exsh? Ooo.. I wasn't aware it existed (newbie to E17).. However, it is different. I've just had a look through examine and exsh and they both appear to only offer IPC access to the configuration of a running program. My quick hack allows you to view and edit ecore_config .eet files on the local file system. You could argue that it would be better to add this functionality to exsh or move econfig into e17/apps/examine. I'll leave that for the maintainers to decide. BTW, I couldn't see a way of implementing list which would list all the properties in the file. Anyone? -- Simon Poole www.appliancestudio.com --- SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate online with coworkers and clients while avoiding the high cost of travel and communications. There is no equipment to buy and you can meet as often as you want. Try it free.http://ads.osdn.com/?ad_id=7402alloc_id=16135op=click ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
On Wednesday, 25 May 2005, at 14:23:39 (+0100), Andrew Elcock wrote: the reason it only works over IPC is because that is how it is supposed to work!!! Thank you, Captain Obvious. if you edit the file then the app has no idea - over IPC the application gets alerted to the change and picks it up immediately. You're assuming the application is running. It may not be. Simon's work has an entirely different purpose and is perfectly suited for situations where exsh is not. And vice versa. Michael -- Michael Jennings (a.k.a. KainX) http://www.kainx.org/ [EMAIL PROTECTED] n + 1, Inc., http://www.nplus1.net/ Author, Eterm (www.eterm.org) --- But what better way to go out than in the cause of advancing scientific knowledge? Is this a multiple choice question? 'cause I have some ideas -- Jim Ishida and Claudia Christian, Babylon Five --- SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate online with coworkers and clients while avoiding the high cost of travel and communications. There is no equipment to buy and you can meet as often as you want. Try it free.http://ads.osdn.com/?ad_id=7402alloc_id=16135op=click ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
Michael Jennings wrote: On Wednesday, 25 May 2005, at 14:23:39 (+0100), Andrew Elcock wrote: the reason it only works over IPC is because that is how it is supposed to work!!! Thank you, Captain Obvious. if you edit the file then the app has no idea - over IPC the application gets alerted to the change and picks it up immediately. You're assuming the application is running. It may not be. Simon's work has an entirely different purpose and is perfectly suited for situations where exsh is not. And vice versa. Michael ah, OK - just better make sure the app is not running before you make file changes, as they would likely be overwritten otherwise --- SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate online with coworkers and clients while avoiding the high cost of travel and communications. There is no equipment to buy and you can meet as often as you want. Try it free.http://ads.osdn.com/?ad_id=7402alloc_id=16135op=click ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] Ecore_config command line tool
Michael Jennings wrote: On Wednesday, 25 May 2005, at 14:23:39 (+0100), Andrew Elcock wrote: if you edit the file then the app has no idea - over IPC the application gets alerted to the change and picks it up immediately. You're assuming the application is running. It may not be. Simon's work has an entirely different purpose and is perfectly suited for situations where exsh is not. And vice versa. Exactly correct. I'm doing embedded Linux development and the entire kernel+rootfs for our products are built and configured by nightly build scripts which spit out a firmware image for flashing onto the boards. I wanted to be able to create the default config.eet files as part of this automated build process. -- Simon Poole www.appliancestudio.com --- SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate online with coworkers and clients while avoiding the high cost of travel and communications. There is no equipment to buy and you can meet as often as you want. Try it free.http://ads.osdn.com/?ad_id=7402alloc_id=16135op=click ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel