Having everything accessible to everything encourages fast and loose
includes from places one shouldn't be using, and makes it easy for
those cases to hide in plain sight as well. There were reasons for
the top-level include back in 2007 but our codebase is a rather
different beast these days. Limiting access through per-target
include directories on everything nicely highlights the exceptions
and makes the whole more controllable and manageable.
This change looks huge, but it's just due to stripping no longer valid
prefixes from all the gazillion internal includes. No rpm-side
functionality is affected, this is just source-level hygiene operation.
In the cases where zero is a sane return for non-existent data,
return it instead of barfing up an assert. Many more unnecessary
asserts left there but these are rather obvious...
Make rpmHeaderFormatFuncByName() and rpmHeaderFormatFuncByValue() return
an opaque pointer to the extension itself (instead of the actual function
pointer) and drop Func from the function and type names to signify the
point. Add rpmHeaderFormatCall() function through which all formatting
has to be done now.
This is not supposed to change anything in itself, but opens up
possibilities for central error checking etc.
- Add size member to rpmtd_s and accessor function to get it.
For now only works for data marked with RPMTD_IMMUTABLE.
- This is redundant for BIN type, but especially for string types this
info is impossible to get without walking the entire data.
- Using rpmtd iteration for this is slow and stupid as we keep
pointlessly re-re-re-re-re-validating the tag type and indexes.
- Change argument order to source -> destination
- Move to rpmtd.c where it belongs and make public with a decent
name. Not sure if this is the kind of an API we really want to make
public but ... at least for now it'll do.
- 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