+static int check_defined(const void *data, const char *name)
+{
+ if (data)
+ return 0;
+ ERROR("widget has no defined '%s' (temporary constraints)", name);
+ errno = EINVAL;
+ return -1;
+}
+
+static int check_valid_string(const char *value, const char *name)
+{
+ int pos;
+ char c;
+
+ if (check_defined(value, name))
+ return -1;
+ pos = 0;
+ c = value[pos];
+ if (c == 0) {
+ ERROR("empty string forbidden in '%s' (temporary constraints)", name);
+ errno = EINVAL;
+ return -1;
+ }
+ do {
+ if (!isalnum(c) && !strchr(".-_", c)) {
+ ERROR("forbidden char %c in '%s' -> '%s' (temporary constraints)", c, name, value);
+ errno = EINVAL;
+ return -1;
+ }
+ c = value[++pos];
+ } while(c);
+ return 0;
+}
+
+static int check_temporary_constraints(const struct wgt_desc *desc)
+{
+ int result;
+
+ result = check_valid_string(desc->id, "id");
+ result |= check_valid_string(desc->version, "version");
+ result |= check_valid_string(desc->ver, "ver");
+ result |= check_defined(desc->content_src, "content");
+ if (desc->icons)
+ result |= check_defined(desc->icons->src, "icon.src");
+ if (result)
+ return result;
+
+ if (desc->icons && desc->icons->next) {
+ ERROR("widget has more than one icon defined (temporary constraints)");
+ errno = EINVAL;
+ result = -1;
+ }