diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-10-18 04:28:43 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-10-18 04:28:43 +0200 |
commit | 1c52a32779de1569ea41267ac6fc8f51c5a8b7fd (patch) | |
tree | 7e2e19d50109b5e38fdfcf47fb1c41a9bee4cc98 /pcilib/xml.c | |
parent | c8628b2a715a7cfaaccbd7e403cd1c6c76b918cd (diff) | |
download | pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.gz pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.bz2 pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.xz pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.zip |
Support XML properties
Diffstat (limited to 'pcilib/xml.c')
-rw-r--r-- | pcilib/xml.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/pcilib/xml.c b/pcilib/xml.c index 4df0d2d..4ecd16d 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -488,7 +488,12 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc if (!value) continue; if (!strcasecmp(name, "name")) { - desc->name = value; + // Overriden by path + if (!desc->name) + desc->name = value; + } else if (!strcasecmp(name, "path")) { + desc->name = value; + desc->flags |= PCILIB_VIEW_FLAG_PROPERTY; } else if (!strcasecmp((char*)name, "description")) { desc->description = value; } else if (!strcasecmp((char*)name, "unit")) { @@ -529,10 +534,22 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp if (!value) continue; if (!strcasecmp(name, "read_from_register")) { + if (desc.base.flags&PCILIB_VIEW_FLAG_PROPERTY) { + if (strstr(value, "$value")) { + pcilib_error("Invalid transform specified in XML property (%s). The properties can't reference $value (%s)", desc.base.name, value); + return PCILIB_ERROR_INVALID_DATA; + } + } desc.read_from_reg = value; if ((value)&&(*value)) desc.base.mode |= PCILIB_ACCESS_R; } else if (!strcasecmp(name, "write_to_register")) { - desc.write_to_reg = value; + if (desc.base.flags&PCILIB_VIEW_FLAG_PROPERTY) { + if (strstr(value, "$value")) { + pcilib_error("Invalid transform specified in XML property (%s). The properties can't reference $value (%s)", desc.base.name, value); + return PCILIB_ERROR_INVALID_DATA; + } + } + desc.write_to_reg = value; if ((value)&&(*value)) desc.base.mode |= PCILIB_ACCESS_W; } } |