- Eliminate the quirky formatPrefix buffer argument to formatter functions,
deal with the width at formatValue() if specified.
- This not only simplifies things a great deal, removes a nasty
unbounded buffer writing from formatter functions and speeds things
up somewhat by removing extra rasprintf()'s in many cases, it also
gives us width formatting of everything including "error messages"
like "(none)" and "(not a number)" which previously got dumped without
any formatting.
- The cost of this is the loss of zero padding support for numeric
data but that's hardly a big deal.
- The header getters are used for both signature header and the "normal"
header, and even beyond that there's no requirement for a tag in
the header to be part of rpmTag enum. The headerPutFoo() variants
technically do require the tag to be found in the tag table (ie be
an rpmTag) but they still operate on the integer value, they dont
require it to be a "true" enum.
- Inside tagexts.c there are a few "true" enum uses in the
internal helper functions, leave them be.
- While this technically changes some the most commonly used API's,
this wont affect callers really: if the callers were using an enum
before, enum can always be cast naturally to an integer. The other
way around was the problematic part (ie the braindamage we're fixing
here now...)
- Instead of masking and bitfiddling all over the place, use the
new getters to get the exact (enum) type directly. rpmTagGetType()
is now unused within rpm but leaving around for backwards compatibility
- returns the value (as opposed to pointer to, like the rpmtdGetUint32()
and the like do) of any numeric type as uint64_t (largest supported
integer type so everything can be converted to it)
- handy when you don't really care what the internal presentation is
- there's no rpmtdGetNextNumber() as there's no meaningful way to return
end-of-iteration here
- 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
- rpmtdFromString(), rpmtdFromStringArray() and rpmtdFromUint32() permit
populating tag containers of compatible datatypes that can be used for
headerPut() with some extra type-safety and sanity checks on the types
- permit change on non-empty container to compatible type to allow things like
headerGet(h, RPMTAG_FILENAMES, td, HEADERGET_EXT);
rpmtdSetTag(td, RPMTAG_OLDFILENAMES);
headerPut(h, td, HEADERPUT_DEFAULT);
- empty container can be set to any valid type
- just uint32 and string iterators for now, those are the most common ones
- allows somewhat more convenient code constructs when type is known,
eg no need to separately check for non-null inside loops
- headerGet() returns even array data in a single allocation block, but
regular (string) arrays need to have the pointers in array freed too
- set immutable flag on header data
- formatPrefix already contains the padding, just use rasprintf() on that
to get properly allocated buffer without messing with it manually
- xml format doesn't honor padding anyway so don't bother with it
- rpmtdGetUint() for 16 and 32 bit integer types, similar to
rpmtdGetString() (equally usable with scalar types and arrays)
- rpmtdToString() which converts "any" header data into string presentation