summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/wgt-info.c45
-rw-r--r--src/wgt-info.h1
-rw-r--r--src/wgtpkg-install.c5
3 files changed, 35 insertions, 16 deletions
diff --git a/src/wgt-info.c b/src/wgt-info.c
index 4d6b37d..02a619b 100644
--- a/src/wgt-info.c
+++ b/src/wgt-info.c
@@ -75,28 +75,42 @@ static xmlChar *optcontent(xmlNodePtr node)
return node ? xmlNodeGetContent(node) : NULL;
}
-static char *mkidaver(char *id, char *version)
+static char *mkver(char *version)
{
- int lid, lver;
+ int lver;
char c, *r;
- if (id && version) {
- lid = strlen(id);
+ if (version) {
c = version[lver = 0];
- while(c && c != ' ') {
- if (c != '.')
+ while(c && c != ' ' && c != '.')
+ c = version[++lver];
+ if (c == '.') {
+ c = version[++lver];
+ while(c && c != ' ' && c != '.')
c = version[++lver];
- else {
- do {
- c = version[++lver];
- } while (c && c != ' ' && c != '.');
- break;
- }
}
+ r = malloc(lver + 1);
+ if (r) {
+ memcpy(r, version, lver);
+ r[lver] = 0;
+ return r;
+ }
+ }
+ return NULL;
+}
+
+static char *mkidaver(char *id, char *ver)
+{
+ int lid, lver;
+ char *r;
+ if (id && ver) {
+ lid = strlen(id);
+ lver = strlen(ver);
r = malloc(2 + lid + lver);
if (r) {
memcpy(r, id, lid);
r[lid] = '@';
- memcpy(r + lid + 1, version, lver + 1);
+ memcpy(r + lid + 1, ver, lver);
+ r[lid + lver + 1] = 0;
return r;
}
}
@@ -119,7 +133,8 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
}
desc->id = xmlGetProp(node, wgt_config_string_id);
desc->version = xmlGetProp(node, wgt_config_string_version);
- desc->idaver = mkidaver(desc->id, desc->version);
+ desc->ver = mkver(desc->version);
+ desc->idaver = mkidaver(desc->id, desc->ver);
desc->width = getpropnum(node, wgt_config_string_width, 0);
desc->height = getpropnum(node, wgt_config_string_height, 0);
desc->viewmodes = xmlGetProp(node, wgt_config_string_viewmodes);
@@ -266,6 +281,7 @@ static void free_desc(struct wgt_desc *desc)
xmlFree(desc->id);
xmlFree(desc->version);
+ free(desc->ver);
free(desc->idaver);
xmlFree(desc->viewmodes);
xmlFree(desc->defaultlocale);
@@ -320,6 +336,7 @@ static void dump_desc(struct wgt_desc *desc, FILE *f, const char *prefix)
if (desc->id) fprintf(f, "%sid: %s\n", prefix, desc->id);
if (desc->version) fprintf(f, "%sversion: %s\n", prefix, desc->version);
+ if (desc->ver) fprintf(f, "%sver: %s\n", prefix, desc->ver);
if (desc->idaver) fprintf(f, "%sidaver: %s\n", prefix, desc->idaver);
if (desc->width) fprintf(f, "%swidth: %d\n", prefix, desc->width);
if (desc->height) fprintf(f, "%sheight: %d\n", prefix, desc->height);
diff --git a/src/wgt-info.h b/src/wgt-info.h
index 3d0a593..4d27e21 100644
--- a/src/wgt-info.h
+++ b/src/wgt-info.h
@@ -48,6 +48,7 @@ struct wgt_desc {
int refcount;
char *id;
char *version;
+ char *ver;
char *idaver;
int width;
int height;
diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c
index 7b299f2..a405cfa 100644
--- a/src/wgtpkg-install.c
+++ b/src/wgtpkg-install.c
@@ -71,6 +71,7 @@ static int check_temporary_constraints(const struct wgt_desc *desc)
{
int 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->icons, "icon");
result |= check_defined(desc->content_src, "content");
if (result)
@@ -119,7 +120,7 @@ static int move_widget(const char *root, const struct wgt_desc *desc, int force)
char newdir[PATH_MAX];
int rc;
- rc = snprintf(newdir, sizeof newdir, "%s/%s/%s", root, desc->id, desc->version);
+ rc = snprintf(newdir, sizeof newdir, "%s/%s/%s", root, desc->id, desc->ver);
if (rc >= sizeof newdir) {
ERROR("path to long in move_widget");
errno = EINVAL;
@@ -136,7 +137,7 @@ static int install_icon(const struct wgt_desc *desc)
int rc;
create_directory(FWK_ICON_DIR, 0755, 1);
- rc = snprintf(link, sizeof link, "%s/%s@%s", FWK_ICON_DIR, desc->id, desc->version);
+ rc = snprintf(link, sizeof link, "%s/%s@%s", FWK_ICON_DIR, desc->id, desc->ver);
if (rc >= sizeof link) {
ERROR("link to long in install_icon");
errno = EINVAL;