13 #include "Ecore_Config.h"
15 #include "ecore_config_private.h"
16 #include "ecore_config_ipc.h"
18 #include "ecore_config_util.h"
21 EAPI Ecore_Config_Server *__ecore_config_server_global = NULL;
22 EAPI Ecore_Config_Server *__ecore_config_server_local = NULL;
23 EAPI Ecore_Config_Bundle *__ecore_config_bundle_local = NULL;
24 EAPI char *__ecore_config_app_name = NULL;
25 int __ecore_config_system_init = 0;
27 static int _ecore_config_system_init_no_load(void);
28 static int _ecore_config_system_load(void);
30 static inline void *__ecore_argb_to_long(int a, int r, int g, int b, long *v);
31 static inline void *__ecore_argbstr_to_long(const char *argb, long *v);
33 static const char *_ecore_config_type[] =
34 { "undefined", "integer", "float", "string", "colour", "theme", "boolean", "structure" };
37 * @defgroup Ecore_Config_Property_Group Ecore Config Property Functions
39 * Functions that retrieve or set the attributes relating to a property.
43 * Removes the given property from the local configuration and destroys it.
44 * @param e Property to destroy.
46 * @ingroup Ecore_Config_Property_Group
48 EAPI Ecore_Config_Prop *
49 ecore_config_dst(Ecore_Config_Prop * e)
51 Ecore_Config_Bundle *t;
52 Ecore_Config_Prop *p, *c;
53 Ecore_Config_Listener_List *l;
57 t = __ecore_config_bundle_local;
72 while (c && (c != e));
73 if (c) /* remove from list if even in there */
81 e->listeners = e->listeners->next;
87 if (e->ptr && ((e->type == ECORE_CONFIG_STR) || (e->type == ECORE_CONFIG_THM)))
90 memset(e, 0, sizeof(Ecore_Config_Prop));
97 * @defgroup Ecore_Config_Get_Group Configuration Retrieve Functions
99 * Functions that retrieve configuration values, based on type.
103 * Returns the property with the given key.
104 * @param key The unique name of the wanted property.
105 * @return The property that corresponds to the given key. @c NULL if the
106 * key could not be found.
107 * @ingroup Ecore_Config_Get_Group
109 EAPI Ecore_Config_Prop *
110 ecore_config_get(const char *key)
112 Ecore_Config_Bundle *t;
113 Ecore_Config_Prop *e;
115 t = __ecore_config_bundle_local;
121 if (!strcmp(key, e->key))
129 * Returns the type of the property.
130 * @param e Property to get the type of.
131 * @returns The type of the property. If the property is invalid, then the
132 * string "not found" is returned.
133 * @ingroup Ecore_Config_Property_Group
136 ecore_config_type_get(const Ecore_Config_Prop * e)
140 return _ecore_config_type[e->type];
146 * Returns the specified property as a string.
147 * @param key The property key.
148 * @return The string value of the property. The function returns @c NULL if
149 * the property is not a string or is not set.
150 * @ingroup Ecore_Config_Get_Group
153 ecore_config_string_get(const char *key)
155 return _ecore_config_string_get( ecore_config_get(key) );
159 _ecore_config_string_get(Ecore_Config_Prop *e)
161 return (e && (e->type == ECORE_CONFIG_STR) && e->ptr) ? strdup(e->ptr) : NULL;
165 * Returns the specified property as an integer.
166 * @param key The property key.
167 * @return The value of the property. The function returns -1 if the
168 * property is not an integer or is not set.
169 * @ingroup Ecore_Config_Get_Group
172 ecore_config_boolean_get(const char *key)
174 return _ecore_config_boolean_get( ecore_config_get(key) );
178 _ecore_config_boolean_get(Ecore_Config_Prop *e)
180 return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_BLN))) ? (e->val != 0) : -1;
184 * Returns the specified property as a long integer.
185 * @param key The property key.
186 * @return The integer value of the property. The function returns 0 if the
187 * property is not an integer or is not set.
188 * @ingroup Ecore_Config_Get_Group
191 ecore_config_int_get(const char *key)
193 return _ecore_config_int_get( ecore_config_get(key) );
197 _ecore_config_int_get(Ecore_Config_Prop *e)
199 return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_RGB))) ? e->val : 0L;
203 * Returns the specified property as a float.
204 * @param key The property key.
205 * @return The float value of the property. The function returns 0.0 if the
206 * property is not a float or is not set.
207 * @ingroup Ecore_Config_Get_Group
210 ecore_config_float_get(const char *key)
212 return _ecore_config_float_get( ecore_config_get(key) );
216 _ecore_config_float_get(Ecore_Config_Prop *e)
218 return (e && (e->type == ECORE_CONFIG_FLT)) ? ((float)e->val / ECORE_CONFIG_FLOAT_PRECISION) : 0.0;
222 * Finds the alpha, red, green and blue values of a color property.
223 * @param key The property key.
224 * @param a A pointer to an integer to store the alpha value into.
225 * @param r A pointer to an integer to store the red value into.
226 * @param g A pointer to an integer to store the green value into.
227 * @param b A pointer to an integer to store the blue value into.
228 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL
230 * @ingroup Ecore_Config_Get_Group
233 ecore_config_argb_get(const char *key, int *a, int *r, int *g, int *b)
235 return _ecore_config_argb_get( ecore_config_get(key), a, r, g, b);
239 _ecore_config_argb_get(Ecore_Config_Prop *e, int *a, int *r, int *g, int *b)
241 if (e && ((e->type == ECORE_CONFIG_RGB)))
243 if(a) *a = (e->val >> 24) & 0xff;
244 if(r) *r = (e->val >> 16) & 0xff;
245 if(g) *g = (e->val >> 8) & 0xff;
246 if(b) *b = e->val & 0xff;
247 return ECORE_CONFIG_ERR_SUCC;
249 return ECORE_CONFIG_ERR_FAIL;
253 * Returns a color property as a long
254 * @param key The property key.
255 * @return ARGB data as long
256 * @ingroup Ecore_Config_Get_Group
259 ecore_config_argbint_get(const char *key)
261 return _ecore_config_argbint_get( ecore_config_get(key) );
265 _ecore_config_argbint_get(Ecore_Config_Prop *e)
267 if (e && ((e->type == ECORE_CONFIG_RGB)))
275 * Returns a color property as a string of hexadecimal characters.
276 * @param key The property key.
277 * @return A string of hexadecimal characters in the format #aarrggbb.
278 * @ingroup Ecore_Config_Get_Group
281 ecore_config_argbstr_get(const char *key)
283 return _ecore_config_argbstr_get( ecore_config_get(key) );
287 _ecore_config_argbstr_get(Ecore_Config_Prop *e)
292 esprintf(&r, "#%08x", _ecore_config_int_get(e));
297 * Returns a theme property.
298 * @param key The property key.
299 * @return The name of the theme the property refers to. The function returns
300 * @c NULL if the property is not a theme or is not set.
301 * @ingroup Ecore_Config_Get_Group
304 ecore_config_theme_get(const char *key)
306 return _ecore_config_theme_get( ecore_config_get(key) );
310 _ecore_config_theme_get(Ecore_Config_Prop *e)
312 return (e && (e->type == ECORE_CONFIG_THM)) ? strdup(e->ptr) : NULL;
316 * Retrieves the key as a string.
317 * @param key The property key.
318 * @return Returns a character array in the form of 'key:type=value'. @c NULL
319 * is returned if the property does not exist.
320 * @ingroup Ecore_Config_Get_Group
323 ecore_config_as_string_get(const char *key)
325 Ecore_Config_Prop *e;
331 if (!(e = ecore_config_get(key)))
332 E(0, "no such property, \"%s\"...\n", key);
337 case ECORE_CONFIG_NIL:
338 val = strdup("<nil>");
340 case ECORE_CONFIG_INT:
341 esprintf(&val, "%ld", _ecore_config_int_get(e));
343 case ECORE_CONFIG_BLN:
344 esprintf(&val, "%ld", _ecore_config_boolean_get(e));
346 case ECORE_CONFIG_FLT:
347 esprintf(&val, "%lf", _ecore_config_float_get(e));
349 case ECORE_CONFIG_STR:
350 esprintf(&val, "\"%s\"", _ecore_config_string_get(e));
352 case ECORE_CONFIG_RGB:
353 esprintf(&val, "#%08x", _ecore_config_int_get(e));
355 case ECORE_CONFIG_THM:
356 esprintf(&val, "\"%s\"", _ecore_config_theme_get(e));
358 case ECORE_CONFIG_SCT:
361 esprintf(&r, "%s:unknown_type", key);
366 esprintf(&r, "%s:%s=%s", key, _ecore_config_type[e->type], val);
374 ecore_config_bound(Ecore_Config_Prop * e)
379 ret = ECORE_CONFIG_ERR_SUCC;
382 return ECORE_CONFIG_ERR_FAIL;
383 if (e->flags & ECORE_CONFIG_FLAG_BOUNDS)
385 if ((e->val < e->lo))
388 "ecore_config_bounds(\"%s\",%ld): value out of range; adjusted to %ld...\n",
389 e->key, e->val, e->lo);
392 else if ((e->val > e->hi))
395 "ecore_config_bounds(\"%s\",%ld): value out of range; adjusted to %ld...\n",
396 e->key, e->val, e->hi);
400 ret = ECORE_CONFIG_ERR_IGNORED;
403 ret = ECORE_CONFIG_ERR_IGNORED;
407 v = ((int)(e->val / e->step)) * e->step;
410 if (e->type == ECORE_CONFIG_FLT)
412 "ecore_config_bound(\"%s\"): float value %f not a multiple of %f, adjusted to %f...\n",
413 e->key, ((double)e->val) / ECORE_CONFIG_FLOAT_PRECISION,
414 ((double)e->step) / ECORE_CONFIG_FLOAT_PRECISION,
415 ((double)v) / ECORE_CONFIG_FLOAT_PRECISION);
418 "ecore_config_bound(\"%s\"): integer value %ld not a multiple of %ld, adjusted to %ld...\n",
419 e->key, e->val, e->step, v);
420 ret = ECORE_CONFIG_ERR_SUCC;
429 * Tries to guess the type of a property.
431 * This function first checks to see if the property exists. If it does, then
432 * the type of the stored property is returned. Otherwise, the function tries
433 * to guess the type of the property based on @p val.
435 * @param key The property key.
436 * @param val The value in string form.
437 * @return The type of the property determined by the function. Note that if
438 * val is @c NULL, @c ECORE_CONFIG_NIL will be returned.
441 ecore_config_type_guess(const char *key, const char *val)
443 Ecore_Config_Prop *p;
449 if (key && (p = ecore_config_get(key)) && p->type != ECORE_CONFIG_NIL)
453 return ECORE_CONFIG_NIL;
455 return ECORE_CONFIG_RGB;
456 v = strtol(val, &l, 10);
461 if (sscanf(val, "%f%*s", &f) != 1)
462 return ECORE_CONFIG_STR;
463 return ECORE_CONFIG_FLT;
465 return ECORE_CONFIG_INT;
469 ecore_config_typed_val(Ecore_Config_Prop * e, const void *val, int type)
473 return ECORE_CONFIG_ERR_NODATA;
475 if (!(val) && (type != ECORE_CONFIG_NIL && type != ECORE_CONFIG_SCT))
479 if (type == ECORE_CONFIG_INT || type == ECORE_CONFIG_BLN)
481 e->val = (long) *((int *)val);
484 else if (type == ECORE_CONFIG_STR || type == ECORE_CONFIG_THM)
486 if (!(e->ptr = strdup(val)))
487 return ECORE_CONFIG_ERR_OOM;
488 if (e->type == ECORE_CONFIG_NIL)
491 else if (type == ECORE_CONFIG_RGB)
493 __ecore_argbstr_to_long((char *)val, &e->val);
494 e->type = ECORE_CONFIG_RGB;
496 else if (type == ECORE_CONFIG_FLT)
498 e->val = (long) ((*((float *)val)) * ECORE_CONFIG_FLOAT_PRECISION);
499 e->type = ECORE_CONFIG_FLT;
501 else if (type == ECORE_CONFIG_SCT)
503 e->type = ECORE_CONFIG_SCT;
507 e->type = ECORE_CONFIG_NIL;
510 ecore_config_bound(e);
511 e->flags |= ECORE_CONFIG_FLAG_MODIFIED;
512 e->flags &= ~ECORE_CONFIG_FLAG_CMDLN;
513 return ECORE_CONFIG_ERR_SUCC;
515 return ECORE_CONFIG_ERR_IGNORED;
519 ecore_config_typed_add(const char *key, const void *val, int type)
521 int error = ECORE_CONFIG_ERR_SUCC;
522 Ecore_Config_Prop *e = NULL;
523 Ecore_Config_Bundle *t;
525 t = __ecore_config_bundle_local;
527 return ECORE_CONFIG_ERR_NODATA;
529 if (!(e = calloc(1, sizeof(Ecore_Config_Prop))))
531 error = ECORE_CONFIG_ERR_OOM;
533 else if (!(e->key = strdup(key)))
535 error = ECORE_CONFIG_ERR_OOM;
537 else if ((error = ecore_config_typed_val(e, val, type)) == ECORE_CONFIG_ERR_SUCC)
544 return ECORE_CONFIG_ERR_SUCC;
552 if (error == ECORE_CONFIG_ERR_SUCC)
553 error = ECORE_CONFIG_ERR_FAIL;
559 ecore_config_add(const char *key, const char *val)
563 type = ecore_config_type_guess(key, val);
564 return ecore_config_typed_add(key, val, type);
568 * Sets the description field of the indicated property.
569 * @param key The property key.
570 * @param desc Description string.
571 * @note The description string is copied for the property's use. You can
572 * free @p desc once this function is called.
573 * @ingroup Ecore_Config_Property_Group
576 ecore_config_describe(const char *key, const char *desc)
578 Ecore_Config_Prop *e;
580 if (!(e = ecore_config_get(key)))
581 return ECORE_CONFIG_ERR_NODATA;
582 e->description = strdup(desc);
583 return ECORE_CONFIG_ERR_SUCC;
587 * Set the short option character of a property.
588 * @param key The property key.
589 * @param short_opt Character used to indicate the value of a property
590 * given on the command line.
591 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_NODATA
592 * is returned if the property does not exist.
593 * @ingroup Ecore_Config_Property_Group
596 ecore_config_short_opt_set(const char *key, char short_opt)
598 Ecore_Config_Prop *e;
600 if (!(e = ecore_config_get(key)))
601 return ECORE_CONFIG_ERR_NODATA;
602 e->short_opt = short_opt;
603 return ECORE_CONFIG_ERR_SUCC;
607 * Set the long option string of the property.
608 * @param key The property key.
609 * @param long_opt String used to indicate the value of a property given
610 * on the command line.
611 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_NODATA
612 * is returned if the property does not exist.
613 * @ingroup Ecore_Config_Property_Group
616 ecore_config_long_opt_set(const char *key, const char *long_opt)
618 Ecore_Config_Prop *e;
620 if (!(e = ecore_config_get(key)))
621 return ECORE_CONFIG_ERR_NODATA;
625 e->long_opt = strdup(long_opt);
626 return ECORE_CONFIG_ERR_SUCC;
630 _ecore_config_listener_fire(Ecore_Config_Prop *prop)
632 Ecore_Config_Listener_List *l;
633 for (l = prop->listeners; l; l = l->next)
634 l->listener(prop->key, prop->type, l->tag, l->data);
636 /* fire change listeners for the generic struct container etc */
638 _ecore_config_listener_fire(prop->parent);
642 * Sets the indicated property to the given value and type.
643 * @param key The property key.
644 * @param val A pointer to the value to set the property to.
645 * @param type The type of the property.
646 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
647 * @ingroup Ecore_Config_Property_Group
650 ecore_config_typed_set(const char *key, const void *val, int type)
652 Ecore_Config_Prop *e;
656 return ECORE_CONFIG_ERR_NODATA;
657 /* if (!t) { * global prop *
658 e=ecore_config_get(key);
660 for(l=e->listeners;l;l=l->next)
661 l->listener(e->key,e->type,l->tag,l->data,t);
662 return ECORE_CONFIG_ERR_SUCC;
665 if (!(e = ecore_config_get(key)))
666 return ecore_config_typed_add(key, val, type);
668 if ((ret = ecore_config_typed_val(e, val, type)) == ECORE_CONFIG_ERR_SUCC)
670 _ecore_config_listener_fire(e);
675 "ecore_config_typed_set(\"%s\"): ecore_config_typed_val() failed: %d\n",
683 * @defgroup Ecore_Config_Set_Group Ecore Config Setters
685 * Functions that set the value of a property.
689 * Sets the indicated property to the value indicated by @a val.
690 * @param key The property key.
691 * @param val String representation of value to set.
692 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
693 * @ingroup Ecore_Config_Set_Group
696 ecore_config_set(const char *key, const char *val)
703 type = ecore_config_type_guess(key, val);
704 if (type == ECORE_CONFIG_INT || type == ECORE_CONFIG_BLN)
707 return ecore_config_typed_set(key, &tmpi, type);
709 else if (type == ECORE_CONFIG_FLT)
712 return ecore_config_typed_set(key, &tmpf, type);
714 else if (type == ECORE_CONFIG_RGB)
716 __ecore_argbstr_to_long(val, &tmpl);
717 return ecore_config_typed_set(key, &tmpl, type);
720 return ecore_config_typed_set(key, val, type);
724 * Sets the indicated property to the value given in the string.
725 * @param key The property key.
726 * @param val String representation of the value.
727 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
728 * @ingroup Ecore_Config_Set_Group
731 ecore_config_as_string_set(const char *key, const char *val)
733 return ecore_config_set(key, val);
737 * Sets the indicated property to the given boolean.
738 * @param key The property key.
739 * @param val Boolean integer to set the property to.
740 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
741 * @ingroup Ecore_Config_Set_Group
744 ecore_config_boolean_set(const char *key, int val)
747 return ecore_config_typed_set(key, &val, ECORE_CONFIG_BLN);
751 * Sets the indicated property to the given integer.
752 * @param key The property key.
753 * @param val Integer to set the property to.
754 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
755 * @ingroup Ecore_Config_Set_Group
758 ecore_config_int_set(const char *key, int val)
760 return ecore_config_typed_set(key, &val, ECORE_CONFIG_INT);
764 * Sets the indicated property to the given string.
765 * @param key The property key.
766 * @param val String to set the property to.
767 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
768 * @ingroup Ecore_Config_Set_Group
771 ecore_config_string_set(const char *key, const char *val)
773 return ecore_config_typed_set(key, val, ECORE_CONFIG_STR);
777 * Sets the indicated property to the given float value.
778 * @param key The property key.
779 * @param val Float to set the property to.
780 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
781 * @ingroup Ecore_Config_Set_Group
784 ecore_config_float_set(const char *key, float val)
786 return ecore_config_typed_set(key, &val, ECORE_CONFIG_FLT);
790 * Sets the indicated property to a color value.
791 * @param key The property key
792 * @param a integer 0..255
793 * @param r integer 0..255
794 * @param g integer 0..255
795 * @param b integer 0..255
796 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
797 * @ingroup Ecore_Config_Set_Group
800 ecore_config_argb_set(const char *key, int a, int r, int g, int b)
803 return ecore_config_typed_set(key, __ecore_argb_to_long(a,r,g,b, &v), ECORE_CONFIG_RGB);
807 * Sets the indicated property to a color value.
808 * @param key The property key
809 * @param argb ARGB data as long
810 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
811 * @ingroup Ecore_Config_Set_Group
814 ecore_config_argbint_set(const char *key, long argb)
816 return ecore_config_typed_set(key, &argb, ECORE_CONFIG_RGB);
820 * Sets the indicated property to a color value.
821 * @param key The property key
822 * @param val Color value in ARGB format.
823 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
824 * @ingroup Ecore_Config_Set_Group
827 ecore_config_argbstr_set(const char *key, const char *val)
830 return ecore_config_typed_set(key, __ecore_argbstr_to_long(val, &v), ECORE_CONFIG_RGB);
834 * Sets the indicated property to a theme name.
835 * @param key The property key.
836 * @param val String giving the name of the theme.
837 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
838 * @ingroup Ecore_Config_Set_Group
841 ecore_config_theme_set(const char *key, const char *val)
843 return ecore_config_typed_set(key, val, ECORE_CONFIG_THM);
847 * Sets the theme preview group of an indicated property.
848 * @param key The property key.
849 * @param group The group name.
850 * @return @c ECORE_CONFIG_ERR_SUCC on success.
851 * @ingroup Ecore_Config_Set_Group
854 ecore_config_theme_preview_group_set(const char *key, const char *group)
857 Ecore_Config_Prop *e;
859 ret = ECORE_CONFIG_ERR_SUCC;
860 if (!(e = ecore_config_get(key)))
861 { /* prop doesn't exist yet */
862 if ((ret = ecore_config_typed_add(key, "", ECORE_CONFIG_THM)) != ECORE_CONFIG_ERR_SUCC) /* try to add it */
863 return ret; /* ...failed */
864 if (!(e = ecore_config_get(key))) /* get handle */
865 return ECORE_CONFIG_ERR_FAIL;
869 e->data = strdup(group);
875 ecore_config_typed_default(const char *key, const void *val, int type)
878 Ecore_Config_Prop *e;
880 ret = ECORE_CONFIG_ERR_SUCC;
882 if (!(e = ecore_config_get(key)))
883 { /* prop doesn't exist yet */
884 if ((ret = ecore_config_typed_add(key, val, type)) != ECORE_CONFIG_ERR_SUCC) /* try to add it */
885 return ret; /* ...failed */
886 if (!(e = ecore_config_get(key))) /* get handle */
887 return ECORE_CONFIG_ERR_FAIL;
888 e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED;
890 else if (!(e->flags & ECORE_CONFIG_FLAG_MODIFIED) && !(e->flags & ECORE_CONFIG_FLAG_SYSTEM))
892 ecore_config_typed_set(key, val, type);
893 if (!(e = ecore_config_get(key))) /* get handle */
894 return ECORE_CONFIG_ERR_FAIL;
895 e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED;
901 * @defgroup Ecore_Config_Default_Group Ecore Config Defaults
903 * Functions that are used to set the default values of properties.
907 * Sets the indicated property if it has not already been set or loaded.
908 * @param key The property key.
909 * @param val Default value of the key.
910 * @param lo Lowest valid value for the key.
911 * @param hi Highest valid value for the key.
912 * @param step Used by integer and float values.
913 * @return @c ECORE_CONFIG_ERR_SUCC if there are no errors.
914 * @note The @p lo, @p hi and @p step parameters are only used when storing
915 * integer and float properties.
916 * @ingroup Ecore_Config_Default_Group
919 ecore_config_default(const char *key, const char *val, float lo, float hi, float step)
922 Ecore_Config_Prop *e;
924 type = ecore_config_type_guess(key, val);
925 ret = ecore_config_typed_default(key, val, type);
926 e = ecore_config_get(key);
929 if (type == ECORE_CONFIG_INT)
932 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
935 ecore_config_bound(e);
937 else if (type == ECORE_CONFIG_FLT)
939 e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
940 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
941 e->lo = (int)(lo * ECORE_CONFIG_FLOAT_PRECISION);
942 e->hi = (int)(hi * ECORE_CONFIG_FLOAT_PRECISION);
943 ecore_config_bound(e);
951 * Sets the indicated property to the given boolean if the property has not yet
953 * @param key The property key.
954 * @param val Boolean Integer to set the value to.
955 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
956 * @ingroup Ecore_Config_Default_Group
959 ecore_config_boolean_default(const char *key, int val)
962 return ecore_config_typed_default(key, &val, ECORE_CONFIG_BLN);
966 * Sets the indicated property to the given integer if the property has not yet
968 * @param key The property key.
969 * @param val Integer to set the value to.
970 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
971 * @ingroup Ecore_Config_Default_Group
974 ecore_config_int_default(const char *key, int val)
976 return ecore_config_typed_default(key, &val, ECORE_CONFIG_INT);
980 * Sets the indicated property to the given integer if the property has not yet
983 * The bounds and step values are set regardless.
985 * @param key The property key.
986 * @param val Integer to set the property to.
987 * @param low Lowest valid integer value for the property.
988 * @param high Highest valid integer value for the property.
989 * @param step Increment value for the property.
990 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
991 * @ingroup Ecore_Config_Default_Group
994 ecore_config_int_default_bound(const char *key, int val, int low, int high,
997 Ecore_Config_Prop *e;
1000 ret = ecore_config_typed_default(key, &val, ECORE_CONFIG_INT);
1001 e = ecore_config_get(key);
1005 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
1008 ecore_config_bound(e);
1015 * Sets the indicated property to the given string if the property has not yet
1017 * @param key The property key.
1018 * @param val String to set the property to.
1019 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1020 * @ingroup Ecore_Config_Default_Group
1023 ecore_config_string_default(const char *key, const char *val)
1025 return ecore_config_typed_default(key, val, ECORE_CONFIG_STR);
1029 * Sets the indicated property to the given float if the property has not yet
1031 * @param key The property key.
1032 * @param val Float to set the property to.
1033 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1034 * @ingroup Ecore_Config_Default_Group
1037 ecore_config_float_default(const char *key, float val)
1039 return ecore_config_typed_default(key, &val, ECORE_CONFIG_FLT);
1043 * Sets the indicated property to the given float if the property has not yet
1046 * The bounds and step values are set regardless.
1048 * @param key The property key.
1049 * @param val Float to set the property to.
1050 * @param low Lowest valid integer value for the property.
1051 * @param high Highest valid float value for the property.
1052 * @param step Increment value for the property.
1053 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1054 * @ingroup Ecore_Config_Default_Group
1057 ecore_config_float_default_bound(const char *key, float val, float low,
1058 float high, float step)
1060 Ecore_Config_Prop *e;
1063 ret = ecore_config_typed_default(key, &val, ECORE_CONFIG_FLT);
1064 e = ecore_config_get(key);
1067 e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
1068 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
1069 e->lo = (int)(low * ECORE_CONFIG_FLOAT_PRECISION);
1070 e->hi = (int)(high * ECORE_CONFIG_FLOAT_PRECISION);
1071 ecore_config_bound(e);
1078 * Sets the indicated property to a color value if the property has not yet
1080 * @param key The property key.
1081 * @param a integer 0..255
1082 * @param r integer 0..255
1083 * @param g integer 0..255
1084 * @param b integer 0..255
1085 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1086 * @ingroup Ecore_Config_Default_Group
1089 ecore_config_argb_default(const char *key, int a, int r, int g, int b)
1092 return ecore_config_typed_default(key, __ecore_argb_to_long(a,r,g,b, &v), ECORE_CONFIG_RGB);
1096 * Sets the indicated property to a color value if the property has not yet
1098 * @param key The property key.
1099 * @param argb ARGB data as long
1100 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1101 * @ingroup Ecore_Config_Default_Group
1104 ecore_config_argbint_default(const char *key, long argb)
1106 return ecore_config_typed_default(key, &argb, ECORE_CONFIG_RGB);
1110 * Sets the indicated property to a color value if the property has not yet
1112 * @param key The property key.
1113 * @param val Color value in ARGB format.
1114 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1115 * @ingroup Ecore_Config_Default_Group
1118 ecore_config_argbstr_default(const char *key, const char *val)
1121 return ecore_config_typed_default(key, __ecore_argbstr_to_long(val, &v), ECORE_CONFIG_RGB);
1125 * Sets the indicated property to a theme name if the property has not yet
1127 * @param key The property key.
1128 * @param val String giving the name of the theme.
1129 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1130 * @ingroup Ecore_Config_Default_Group
1133 ecore_config_theme_default(const char *key, const char *val)
1135 return ecore_config_typed_default(key, val, ECORE_CONFIG_THM);
1139 * @defgroup Ecore_Config_Struct_Group Ecore Config Structures
1141 * Functions that are used to create structures of properties.
1145 * Sets the indicated property to a structure if the property has not yet
1147 * @param key The property key.
1148 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1149 * @ingroup Ecore_Config_Struct_Group
1152 ecore_config_struct_create(const char *key)
1154 printf("WARNING: you are using ecore_config structures. These are very young");
1155 printf(" and not complete - you have been warned");
1157 return ecore_config_typed_default(key, NULL, ECORE_CONFIG_SCT);
1161 _ecore_config_struct_append(Ecore_Config_Prop *sct, Ecore_Config_Prop *add)
1165 if (!sct || !add || sct->type != ECORE_CONFIG_SCT)
1166 return ECORE_CONFIG_ERR_IGNORED;
1169 sct->data = evas_list_append(l, add);
1172 return ECORE_CONFIG_ERR_SUCC;
1176 _ecore_config_struct_typed_add(const char *key, const char *name, const void *val,
1182 subkey = malloc((strlen(key) + strlen(name) + 2) * sizeof(char));
1183 strcpy(subkey, key);
1184 strcat(subkey, ".");
1185 strcat(subkey, name);
1187 ecore_config_typed_default(subkey, val, type);
1188 ret = _ecore_config_struct_append(ecore_config_get(key),
1189 ecore_config_get(subkey));
1195 * Add an int property to the named structure. The property is set if it has not
1197 * @param key The key of the structure to add to.
1198 * @param name The name of the item to add - this will be appended to the key
1199 * @param val the int to default to
1200 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1201 * @ingroup Ecore_Config_Struct_Group
1204 ecore_config_struct_int_add(const char *key, const char *name, int val)
1206 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_INT);
1210 * Add a float property to the named structure. The property is set if it has
1212 * @param key The key of the structure to add to.
1213 * @param name The name of the item to add - this will be appended to the key
1214 * @param val The float to default to
1215 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1216 * @ingroup Ecore_Config_Struct_Group
1219 ecore_config_struct_float_add(const char *key, const char *name, float val)
1221 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_FLT);
1225 * Add a string property to the named structure. The property is set if it has
1227 * @param key The key of the structure to add to.
1228 * @param name The name of the item to add - this will be appended to the key
1229 * @param val The string to default to
1230 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1231 * @ingroup Ecore_Config_Struct_Group
1234 ecore_config_struct_string_add(const char *key, const char *name, const char* val)
1236 return _ecore_config_struct_typed_add(key, name, val, ECORE_CONFIG_STR);
1240 * Add an argb property to the named structure. The property is set if it has
1242 * @param key The key of the structure to add to.
1243 * @param name The name of the item to add - this will be appended to the key
1244 * @param a The alpha to default to
1245 * @param r The red to default to
1246 * @param g The green to default to
1247 * @param b The blue to default to
1248 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1249 * @ingroup Ecore_Config_Struct_Group
1252 ecore_config_struct_argb_add(const char *key, const char *name, int a, int r,
1257 __ecore_argb_to_long(a, r, g, b, &argb);
1258 return _ecore_config_struct_typed_add(key, name, &argb, ECORE_CONFIG_RGB);
1262 * Add a theme property to the named structure. The property is set if it has
1264 * @param key The key of the structure to add to.
1265 * @param name The name of the item to add - this will be appended to the key
1266 * @param val The theme name to default to
1267 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1268 * @ingroup Ecore_Config_Struct_Group
1271 ecore_config_struct_theme_add(const char *key, const char *name, const char* val)
1273 return _ecore_config_struct_typed_add(key, name, val, ECORE_CONFIG_THM);
1277 * Add a boolean property to the named structure. The property is set if it has
1279 * @param key The key of the structure to add to.
1280 * @param name The name of the item to add - this will be appended to the key
1281 * @param val The boolean to default to
1282 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1283 * @ingroup Ecore_Config_Struct_Group
1286 ecore_config_struct_boolean_add(const char *key, const char *name, int val)
1289 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_BLN);
1293 * Get the contents of a defined structure property and load it into the passed
1295 * @param key The name of the structure property to look up.
1296 * @param data The struct to write into.
1297 * @return @c ECORE_CONFIG_ERR_SUCC if the structure is written successfully.
1298 * @ingroup Ecore_Config_Struct_Group
1301 ecore_config_struct_get(const char *key, void *data)
1303 Ecore_Config_Prop *e, *f;
1308 e = ecore_config_get(key);
1310 return ECORE_CONFIG_ERR_NODATA;
1316 f = (Ecore_Config_Prop *) l->data;
1319 case ECORE_CONFIG_INT:
1320 *((int *) ptr) = _ecore_config_int_get(f);
1323 case ECORE_CONFIG_BLN:
1324 *((int *) ptr) = _ecore_config_boolean_get(f);
1327 case ECORE_CONFIG_FLT:
1328 *((float *) ptr) = _ecore_config_float_get(f);
1329 ptr += sizeof(float);
1331 case ECORE_CONFIG_STR:
1332 case ECORE_CONFIG_THM:
1333 *((char **) ptr) = _ecore_config_string_get(f);
1334 ptr += sizeof(char *);
1336 case ECORE_CONFIG_RGB:
1337 argb = _ecore_config_argbint_get(f);
1338 *((int *) ptr) = (argb >> 24) & 0xff;
1340 *((int *) ptr) = (argb >> 16) & 0xff;
1342 *((int *) ptr) = (argb >> 8) & 0xff;
1344 *((int *) ptr) = argb & 0xff;
1348 printf("ARGH - STRUCT coding not implemented yet\n");
1350 l = evas_list_next(l);
1352 return ECORE_CONFIG_ERR_SUCC;
1356 * @defgroup Ecore_Config_Listeners_Group Ecore Config Listeners
1358 * Functions that set and unset property listener callbacks.
1362 * Adds a callback function to the list of functions called when a property
1364 * @param name Name of the callback.
1365 * @param key The key of the property to listen to.
1366 * @param listener Listener callback function.
1367 * @param tag Tag to pass to @p listener when it is called.
1368 * @param data Data to pass to @p listener when it is called.
1369 * @return @c ECORE_CONFIG_ERR_SUCC if successful in setting up the callback.
1370 * @ingroup Ecore_Config_Listeners_Group
1373 ecore_config_listen(const char *name, const char *key,
1374 Ecore_Config_Listener listener, int tag, void *data)
1376 Ecore_Config_Prop *e;
1377 Ecore_Config_Listener_List *l;
1380 return ECORE_CONFIG_ERR_NODATA;
1382 if (!(e = ecore_config_get(key)))
1384 int ret = ecore_config_add(key, "");
1386 if (ret != ECORE_CONFIG_ERR_SUCC)
1388 E(0, "ecore_config_listen: ecore_config_add(\"%s\") failed: %d\n",
1392 if (!(e = ecore_config_get(key)))
1394 E(0, "ecore_config_listen: list of properties corrupted!?\n");
1395 return ECORE_CONFIG_ERR_FAIL;
1399 for (l = e->listeners; l; l = l->next)
1400 if (!strcmp(l->name, name) || (l->listener == listener))
1403 "ecore_config_listen: %s is already listening for changes of %s...\n",
1405 return ECORE_CONFIG_ERR_IGNORED;
1408 if (!(l = malloc(sizeof(Ecore_Config_Listener_List))))
1409 return ECORE_CONFIG_ERR_OOM;
1411 E(1, "registering listener \"%s\" for \"%s\" (%d)...\n", name, key, e->type);
1413 memset(l, 0, sizeof(Ecore_Config_Listener_List));
1415 l->listener = listener;
1419 l->next = e->listeners;
1422 if (e->type != ECORE_CONFIG_NIL) /* call right on creation if prop exists and has val */
1423 listener(key, e->type, tag, data);
1425 return ECORE_CONFIG_ERR_SUCC;
1429 * Removes a listener callback.
1430 * @param name Name of the callback to remove.
1431 * @param key The property key the callback is listening to.
1432 * @param listener The callback function to remove.
1433 * @return @c ECORE_CONFIG_ERR_SUCC if successful in removing the callback.
1434 * If no callback matches the given parameters, then
1435 * @c ECORE_CONFIG_ERR_NOTFOUND is returned. If @c NULL is passed
1436 * for the key pointer, @c ECORE_CONFIG_ERR_NODATA is returned.
1437 * @ingroup Ecore_Config_Listeners_Group
1440 ecore_config_deaf(const char *name, const char *key,
1441 Ecore_Config_Listener listener)
1443 Ecore_Config_Prop *e;
1444 Ecore_Config_Listener_List *l, *p;
1447 ret = ECORE_CONFIG_ERR_NOTFOUND;
1450 return ECORE_CONFIG_ERR_NODATA;
1452 if (!(e = ecore_config_get(key)))
1453 return ECORE_CONFIG_ERR_NOTFOUND;
1455 for (p = NULL, l = e->listeners; l; p = l)
1457 Ecore_Config_Listener_List *nl;
1460 if ((name && !strcmp(l->name, name)) || (l->listener == listener))
1462 ret = ECORE_CONFIG_ERR_SUCC;
1464 e->listeners = e->listeners->next;
1467 memset(l, 0, sizeof(Ecore_Config_Listener));
1477 * Locates the first configuration bundle on the given server.
1478 * @param srv The configuration server.
1479 * @return Pointer to the first configuration bundle.
1481 EAPI Ecore_Config_Bundle *
1482 ecore_config_bundle_1st_get(Ecore_Config_Server * srv)
1483 { /* anchor: global, but read-only */
1484 return srv->bundles;
1488 * Locates the configuration bundle after the given one.
1489 * @param ns The configuration bundle.
1490 * @return The next configuration bundle.
1492 EAPI Ecore_Config_Bundle *
1493 ecore_config_bundle_next_get(Ecore_Config_Bundle * ns)
1495 return ns ? ns->next : NULL;
1499 * Locates a configuration bundle on a configuration server based on its serial
1501 * @param srv The configuration server.
1502 * @param serial Serial number.
1503 * @return The configuration bundle with the given serial number.
1505 EAPI Ecore_Config_Bundle *
1506 ecore_config_bundle_by_serial_get(Ecore_Config_Server * srv, long serial)
1508 Ecore_Config_Bundle *eb;
1514 else if (serial == 0)
1516 Ecore_Config_Bundle *r = eb;
1523 if (eb->serial == serial)
1531 * Gets the Ecore_Config_Bundle with the given identifier from the given
1533 * @param srv The configuration server.
1534 * @param label The bundle's identifier string.
1535 * @return The bundle with the given identifier string, or @c NULL if it
1536 * could not be found.
1538 EAPI Ecore_Config_Bundle *
1539 ecore_config_bundle_by_label_get(Ecore_Config_Server * srv, const char *label)
1541 Ecore_Config_Bundle *ns;
1547 if (ns->identifier && !strcmp(ns->identifier, label))
1555 * Retrieves the bundle's serial number.
1556 * @param ns The configuration bundle.
1557 * @return The bundle's identifier string, or -1 if ns is @c NULL.
1560 ecore_config_bundle_serial_get(Ecore_Config_Bundle * ns)
1562 return ns ? ns->serial : -1;
1566 * Retrieves the bundle's identifier.
1567 * @param ns The configuration bundle.
1568 * @return The bundle's identifer string.
1571 ecore_config_bundle_label_get(Ecore_Config_Bundle * ns)
1573 return ns ? ns->identifier : NULL;
1577 * Creates a new Ecore_Config_Bundle.
1578 * @param srv Config server.
1579 * @param identifier Identifier string for the new bundle.
1580 * @return A pointer to a new Ecore_Config_Bundle. @c NULL is returned if the
1581 * structure couldn't be allocated.
1583 EAPI Ecore_Config_Bundle *
1584 ecore_config_bundle_new(Ecore_Config_Server * srv, const char *identifier)
1586 Ecore_Config_Bundle *t;
1589 ss = 0; /* bundle unique serial */
1591 if ((t = malloc(sizeof(Ecore_Config_Bundle))))
1593 memset(t, 0, sizeof(Ecore_Config_Bundle));
1595 t->identifier = (char *)identifier;
1597 t->owner = srv->name;
1598 t->next = srv->bundles;
1604 static Ecore_Config_Server *
1605 do_init(const char *name)
1607 return _ecore_config_ipc_init(name);
1610 static Ecore_Config_Server *
1611 ecore_config_init_local(const char *name)
1616 if ((p = getenv("HOME")))
1617 { /* debug-only ### FIXME */
1618 if (!(buf = malloc(PATH_MAX * sizeof(char))))
1620 snprintf(buf, PATH_MAX, "%s/.ecore/%s/.global", p, name);
1626 return do_init(name);
1629 static Ecore_Config_Server *
1630 ecore_config_init_global(const char *name)
1637 if ((p = getenv("HOME")))
1638 { /* debug-only ### FIXME */
1639 if (!(buf = malloc(PATH_MAX * sizeof(char))))
1641 snprintf(buf, PATH_MAX, "%s/.ecore/%s/.global", p, name);
1642 global = creat(buf, S_IRWXU);
1650 return do_init(name);
1654 * @defgroup Ecore_Config_App_Lib_Group Ecore Config App Library Functions
1656 * Functions that are used to start up and shutdown the Enlightened
1657 * Property Library when used directly by an application.
1661 * Initializes the Enlightened Property Library.
1663 * Either this function or @ref ecore_config_system_init must be run
1664 * before any other function in the Enlightened Property Library, even
1665 * if you have run @ref ecore_init . The name given is used to
1666 * determine the default configuration to load.
1668 * @param name Application name
1669 * @return @c ECORE_CONFIG_ERR_SUCC if the library is successfully set up.
1670 * @c ECORE_CONFIG_ERR_FAIL otherwise.
1671 * @ingroup Ecore_Config_App_Lib_Group
1674 ecore_config_init(const char *name)
1677 Ecore_Config_Prop *list;
1678 _ecore_config_system_init_no_load();
1680 __ecore_config_app_name = strdup(name);
1681 __ecore_config_server_local = ecore_config_init_local(name);
1682 if (!__ecore_config_server_local)
1683 return ECORE_CONFIG_ERR_FAIL;
1685 list = __ecore_config_bundle_local->data;
1686 free( __ecore_config_bundle_local );
1687 __ecore_config_bundle_local =
1688 ecore_config_bundle_new(__ecore_config_server_local, "config");
1689 __ecore_config_bundle_local->data = list;
1691 path = ecore_config_theme_default_path_get();
1692 ecore_config_string_default("/e/themes/search_path", path);
1696 list = ecore_config_get("/e/themes/search_path");
1699 list->flags |= ECORE_CONFIG_FLAG_SYSTEM;
1700 list->flags &= ~ECORE_CONFIG_FLAG_MODIFIED;
1703 return _ecore_config_system_load();
1707 * Frees memory and shuts down the library for an application.
1708 * @return @c ECORE_CONFIG_ERR_IGNORED .
1709 * @ingroup Ecore_Config_App_Lib_Group
1712 ecore_config_shutdown(void)
1714 return ecore_config_system_shutdown();
1718 * @defgroup Ecore_Config_Lib_Lib_Group Ecore Config Library Functions
1720 * Functions that are used to start up and shutdown the Enlightened
1721 * Property Library when used directly by an application.
1725 * Initializes the Enlightened Property Library.
1727 * This function is meant to be run from other programming libraries.
1728 * It should not be called from applications.
1730 * This function (or @ref ecore_config_init )
1731 * must be run before any other function in the
1732 * Enlightened Property Library, even if you have run @ref ecore_init .
1734 * @return @c ECORE_CONFIG_ERR_SUCC if the library is successfully set up.
1735 * @c ECORE_CONFIG_ERR_FAIL otherwise.
1736 * @ingroup Ecore_Config_Lib_Lib_Group
1739 ecore_config_system_init(void)
1741 _ecore_config_system_init_no_load();
1742 return _ecore_config_system_load();
1746 _ecore_config_system_init_no_load(void)
1750 __ecore_config_system_init++;
1751 if (__ecore_config_system_init > 1)
1752 return ECORE_CONFIG_ERR_IGNORED;
1755 if ((p = getenv("ECORE_CONFIG_DEBUG")) && p[0] != 0)
1760 __ecore_config_server_global =
1761 ecore_config_init_global(ECORE_CONFIG_GLOBAL_ID);
1762 if (!__ecore_config_server_global)
1763 return ECORE_CONFIG_ERR_FAIL;
1765 __ecore_config_bundle_local =
1766 ecore_config_bundle_new(__ecore_config_server_global, "system");
1768 /* set up a simple default path */
1769 ecore_config_string_default("/e/themes/search_path", PACKAGE_DATA_DIR "../ewl/themes");
1771 return ECORE_CONFIG_ERR_SUCC;
1776 _ecore_config_system_load(void)
1779 Ecore_Config_Prop *sys;
1781 if (__ecore_config_system_init != 1)
1782 return ECORE_CONFIG_ERR_FAIL;
1784 if ((p = getenv("HOME")))
1785 { /* debug-only ### FIXME */
1786 if ((buf = malloc(PATH_MAX * sizeof(char))))
1788 snprintf(buf, PATH_MAX, "%s/.e/config.eet", p);
1789 if (ecore_config_file_load(buf) != 0) {
1790 /* even if this file (system.eet) dosen't exist we can
1791 * continue without it as it isn't striclty necessary.
1793 ecore_config_file_load(PACKAGE_DATA_DIR "/system.eet");
1795 sys = __ecore_config_bundle_local->data;
1798 /* unmark it modified - modification will mean it has been overridden */
1799 sys->flags &= ~ECORE_CONFIG_FLAG_MODIFIED;
1800 /* mark as system so that examine can hide them */
1801 sys->flags |= ECORE_CONFIG_FLAG_SYSTEM;
1808 return ECORE_CONFIG_ERR_SUCC;
1813 * Frees memory and shuts down the library for other programming libraries.
1814 * @return @c ECORE_CONFIG_ERR_IGNORED
1815 * @ingroup Ecore_Config_Lib_Lib_Group
1818 ecore_config_system_shutdown(void)
1822 __ecore_config_system_init--;
1823 if (__ecore_config_system_init > 0)
1824 return ECORE_CONFIG_ERR_IGNORED;
1826 ret = _ecore_config_ipc_exit();
1827 if (__ecore_config_app_name)
1828 free(__ecore_config_app_name);
1829 while(__ecore_config_bundle_local->data)
1830 ecore_config_dst(__ecore_config_bundle_local->data);
1831 free(__ecore_config_bundle_local);
1832 free(__ecore_config_server_local);
1833 free(__ecore_config_server_global);
1837 static inline void *
1838 __ecore_argb_to_long(int a, int r, int g, int b, long *v)
1840 *v = ((a << 24) & 0xff000000 )
1841 | ((r << 16) & 0xff0000 )
1842 | ((g << 8) & 0xff00 )
1848 static inline void *
1849 __ecore_argbstr_to_long(const char *argb, long *v)
1853 // convert hexadecimal string #..., #0x..., 0x..., ... to long
1856 *v = (long)strtoul( argb, &l, 16);
1860 E(0, "ecore_config_val: value \"%s\" not a valid hexadecimal RGB value?\n", argb);