summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-11-17 11:31:00 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-11-17 11:31:00 +0200
commited5306b0be4b8b0df205b066d2646b4e1dd93545 (patch)
tree55ad70d82dd1d66cbd601ec9aceed2fbcafb68be /lib
parent4fa662abd1d1f5b5f155a734d0e87aa7e7894ae3 (diff)
downloadlibrpm-tizen-ed5306b0be4b8b0df205b066d2646b4e1dd93545.tar.gz
librpm-tizen-ed5306b0be4b8b0df205b066d2646b4e1dd93545.tar.bz2
librpm-tizen-ed5306b0be4b8b0df205b066d2646b4e1dd93545.zip
Introduce rpm tag "classes"
- rpm tag data can be either numeric, strings or binary data, each with their own "subclasses" (different sized integers etc), add new enumeration for these - add rpmTagGetClass(), rpmtdClass() public functions for retrieving the base class of tag and container - useful for getting a basic idea how to handle tag/container data
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmtag.h17
-rw-r--r--lib/rpmtd.c6
-rw-r--r--lib/rpmtd.h7
-rw-r--r--lib/tagname.c27
4 files changed, 57 insertions, 0 deletions
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
index efcbd0088..335d413da 100644
--- a/lib/rpmtag.h
+++ b/lib/rpmtag.h
@@ -330,6 +330,16 @@ typedef enum rpmTagType_e {
#define RPM_MASK_TYPE 0x0000ffff
} rpmTagType;
+/** \ingroup rpmtag
+ * The classes of data in tags from headers.
+ */
+typedef enum rpmTagClass_e {
+ RPM_NULL_CLASS = 0,
+ RPM_NUMERIC_CLASS = 1,
+ RPM_STRING_CLASS = 2,
+ RPM_BINARY_CLASS = 3,
+} rpmTagClass;
+
/** \ingroup header
* New rpm data types under consideration/development.
* These data types may (or may not) be added to rpm at some point. In order
@@ -374,6 +384,13 @@ const char * rpmTagGetName(rpmTag tag);
rpmTagType rpmTagGetType(rpmTag tag);
/** \ingroup rpmtag
+ * Return tag data class from value.
+ * @param tag tag value
+ * @return tag data class, RPM_NULL_CLASS on not found.
+ */
+rpmTagClass rpmTagGetClass(rpmTag tag);
+
+/** \ingroup rpmtag
* Return tag value from name.
* @param tagstr name of tag
* @return tag value, -1 on not found
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index a3fb0a09d..5c7378d5d 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -71,6 +71,12 @@ rpmTagType rpmtdType(rpmtd td)
return td->type;
}
+rpmTagClass rpmtdClass(rpmtd td)
+{
+ assert(td != NULL);
+ return rpmTagGetClass(td->tag);
+}
+
int rpmtdGetIndex(rpmtd td)
{
assert(td != NULL);
diff --git a/lib/rpmtd.h b/lib/rpmtd.h
index 0ca711fdf..e8ba737e2 100644
--- a/lib/rpmtd.h
+++ b/lib/rpmtd.h
@@ -77,6 +77,13 @@ rpmTag rpmtdTag(rpmtd td);
rpmTagType rpmtdType(rpmtd td);
/** \ingroup rpmtd
+ * Retrieve class of the container.
+ * @param td Tag data container
+ * @return Rpm tag class
+ */
+rpmTagClass rpmtdClass(rpmtd td);
+
+/** \ingroup rpmtd
* Retrieve current iteration index of the container.
* @param td Tag data container
* @return Iteration index (or -1 if not iterating)
diff --git a/lib/tagname.c b/lib/tagname.c
index 2a844d656..a81424dfa 100644
--- a/lib/tagname.c
+++ b/lib/tagname.c
@@ -294,6 +294,33 @@ rpmTagType rpmTagGetType(rpmTag tag)
return ((*rpmTags->tagType)(tag));
}
+rpmTagClass rpmTagGetClass(rpmTag tag)
+{
+ rpmTagClass class;
+ switch (rpmTagGetType(tag) & RPM_MASK_TYPE) {
+ case RPM_CHAR_TYPE:
+ case RPM_INT8_TYPE:
+ case RPM_INT16_TYPE:
+ case RPM_INT32_TYPE:
+ case RPM_INT64_TYPE:
+ class = RPM_NUMERIC_CLASS;
+ break;
+ case RPM_STRING_TYPE:
+ case RPM_STRING_ARRAY_TYPE:
+ case RPM_I18NSTRING_TYPE:
+ class = RPM_STRING_CLASS;
+ break;
+ case RPM_BIN_TYPE:
+ class = RPM_BINARY_CLASS;
+ break;
+ case RPM_NULL_TYPE:
+ default:
+ class = RPM_NULL_CLASS;
+ break;
+ }
+ return class;
+}
+
rpmTag rpmTagGetValue(const char * tagstr)
{
return ((*rpmTags->tagValue)(tagstr));