parent
7e8142f3cf
commit
9b162540e1
27
lib/rpmtd.c
27
lib/rpmtd.c
|
@ -276,6 +276,33 @@ static inline int rpmtdSet(rpmtd td, rpmTag tag, rpmTagType type,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count)
|
||||
{
|
||||
rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
|
||||
rpmTagReturnType retype = rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE;
|
||||
|
||||
if (count < 1)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* BIN type is really just an uint8_t array internally, it's just
|
||||
* treated specially otherwise.
|
||||
*/
|
||||
switch (type) {
|
||||
case RPM_CHAR_TYPE:
|
||||
case RPM_INT8_TYPE:
|
||||
if (retype != RPM_ARRAY_RETURN_TYPE && count > 1)
|
||||
return 0;
|
||||
/* fallthrough */
|
||||
case RPM_BIN_TYPE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rpmtdSet(td, tag, type, data, count);
|
||||
}
|
||||
|
||||
int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count)
|
||||
{
|
||||
rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
|
||||
|
|
13
lib/rpmtd.h
13
lib/rpmtd.h
|
@ -215,6 +215,19 @@ char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
|
|||
*/
|
||||
int rpmtdSetTag(rpmtd td, rpmTag tag);
|
||||
|
||||
/** \ingroup rpmtd
|
||||
* Construct tag container from uint8_t pointer.
|
||||
* Tag type is checked to be of compatible type (CHAR, INT8 or BIN).
|
||||
* For non-array types (BIN is a special case of INT8 array)
|
||||
* count must be exactly 1.
|
||||
* @param td Tag data container
|
||||
* @param tag Rpm tag to construct
|
||||
* @param data Pointer to uint8_t (value or array)
|
||||
* @param count Number of entries
|
||||
* @return 1 on success, 0 on error (eg wrong type)
|
||||
*/
|
||||
int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
|
||||
|
||||
/** \ingroup rpmtd
|
||||
* Construct tag container from uint16_t pointer.
|
||||
* Tag type is checked to be of INT16 type. For non-array types count
|
||||
|
|
Loading…
Reference in New Issue