Commit Graph

142 Commits

Author SHA1 Message Date
Panu Matilainen cd5222b6e3 Implement "fast" flag to headerImport()
- regionSwab() calling dataLength() on headerImport() is one of the
  busiest paths in rpm, and dataLength() on string types is a very
  expensive call as it has to walk through the string looking for \0's.
  The data size is actually available most of the time by just looking
  at offsets (idea lifted from rpm5.org), which is an order of magnitude
  faster than crawling string data. The downside (there always is one)
  is that with offsets, string data is not validated to contain
  sufficient number of \0's, which means malformed headers could cause
  us to crash, burn and overflow when accessing the string data.
- The new "fast" mode enables offset-based calculation at callers
  discretion, ie if the caller can reasonably assume the header is
  sane (known to be previously validated etc), using the fast-flag
  will make header loading/importing considerably faster.
  For now, only headerImport() will use the fast mode but it might
  make sense to remember the setting in the header and use for other
  operations as well.
2011-11-30 11:59:35 +02:00
Panu Matilainen 359baa2831 Add an enhanced interface for unloading, aka exporting, headers
- Most callers need the size of the blob as well, which the unloader
  internals know perfectly well but the interface doesn't support
  passing it. So callers were forced to make a second call to
  headerSizeof() to recalculate the size. Duh.
- Rename and export doHeaderUnload() as headerExport(), update internal
  callers to use the new name. headerExport() is hopefully a bit
  more obvious as a name than headerUnload() which doesn't actually
  undo the effect of headerLoad() for that header, but merely exports
  the data by serializing into on-disk format.
- Header size is not size_t really, its capped to fixed much lower
  size. Use unsigned int to better match reality.
2011-11-30 11:03:17 +02:00
Panu Matilainen 52bcafcfb2 Add an enhanced interface for loading, aka importing, headers
- Unlike headerLoad(), headerImport() takes a blob size argument
  to allow sanity checking the size calculated from the blob itself
  against the "physical" passed-in blob size so its a bit safer.
  Note that header size is capped by various things - its not size_t.
- headerImport() also takes a flags argument to allow controlling
  various aspects of importing.
- Implement "take copy of blob" as a flag to headerImport(), push
  the copying into headerCreate() where we already know the blob
  size, avoiding the need to do double-calculations on headerCopyLoad()..
- headerLoad() and headerCopyLoad() are now just compat wrappers
  around the new interface.
2011-11-30 10:41:00 +02:00
Panu Matilainen c43440f16b Yet another round of enum-as-function-argument elimination
- Pass the yes/no magic argument to headerRead(), headerWrite() and
  headerSizeof() as int instead of enum.
2010-11-17 08:52:18 +02:00
Panu Matilainen 1537f7d97e Avoid enum as function argument for headerConvert()
- While this /nearly/ qualifies for enum, places like python
  argument converting will not be able to produce "true enum" values.
  So dont even try.
2010-11-17 08:46:21 +02:00
Panu Matilainen 757d0b443b Switch header APIs to use rpmTagVal instead of rpmTag
- 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...)
2010-10-22 09:59:56 +03:00
Panu Matilainen 2fb15a5443 Stop abusing enum typedefs for bitfield types
- Enums are fine for defining the bitfield flags, but the bitfield
  itself is not an enumeration. Add a separate typedef on "rpmFlags"
  type (presenting a bitfield of flags) for all of these. Compilers
  hardly care, but the typedefs give a nice visual clue for
  us humans using these flags far away from ho^H^H definitions.
2010-09-21 11:10:14 +03:00
Panu Matilainen 92c12d1a8e Eliminate all fooUnlink() functions out of the API
- These are internal helpers only, all refcount users need to use
  fooFree() or similar for correct operation. Add fwd declarations
  where necessary to avoid moving code around unnecessarily.
- We could add these back later as aliases to fooFree() but for now,
  just get them out of the way.
2010-09-13 13:08:33 +03:00
Panu Matilainen 6cd0bb2b31 Passed-in values are const for every headerPutType() variant
- Silly oversight back then, oh well... this shouldn't affect any callers,
  just avoids dumb warnings where none should be seen
2010-09-01 10:46:57 +03:00
Panu Matilainen 3d5455d42d Add alternative header iterator method
- we dont always want the actual contents of the tag to be copied
  on iteration, so add an interface that returns the next tag in the
  header
- this lets callers to decide what to do with the tag and how to
  retrieve it
2009-09-30 14:48:19 +03:00
Panu Matilainen 9c7e4c70b9 Deprecate headerGetColor(), implement using headerGetNumber() 2009-09-02 13:58:59 +03:00
Panu Matilainen 1bf0d80281 Add convenience function for retrieving numeric header data 2009-09-02 13:27:18 +03:00
Panu Matilainen e0a4949bd4 Deprecate headerNVR() and friends
- reimplement using the new generic getters to simplify
- mark as deprecated, no uses inside rpm remain
2009-09-02 12:08:33 +03:00
Panu Matilainen e2239d295e Add two new convenience functions for header string data
- headerGetString() for retrieving const strings directly from header memory
- headerGetAsString() for converting any non-array tag to string
2009-09-02 10:48:54 +03:00
Panu Matilainen f128fea076 Add a bit of documentation for headerGet() flags 2009-01-20 14:48:05 +02:00
Panu Matilainen 05f5c35324 Add headerGet() flag to request argv-style NULL-terminated string arrays
- easy to do and some places would like the data this way so why not...
- also add corresponding rpmtd flag so caller can verify he got what
  was requested
2009-01-20 14:15:24 +02:00
Panu Matilainen 122e2d204e Eliminate header magic duplication all over the place, export it
- avoid several copies of the same thing...
- there are valid reasons for wanting to know header magic outside librpm,
  export it as rpm_header_magic
2009-01-05 11:18:46 +02:00
Panu Matilainen b9010a3510 Add rpmdb record number to headers retrieved from rpmdb
- set "instance" number on retrieval from rpmdb
- add public headerGetInstance() function for retrieving the value
- ported from rpm5.org, useful for number of things
2008-11-12 17:58:37 +02:00
Panu Matilainen 56f3545c68 Add headerConvert() "proxy" for performing various conversions on header data 2008-10-10 15:53:12 +03:00
Panu Matilainen 6ea17f9ca4 Shove header legacy interfaces into rpmlegacy.h
- get them out of sight from main header.h
- turn headerSprintf() into macro around headerFormat(), that way
  rpmTagTable and rpmHeaderFormats lossage can be hidden away as far
  as headerSprintf() use is concerned
2008-07-08 18:54:28 +03:00
Panu Matilainen 78040394a2 Change headerPutString() arg name to match the others
- doxygen whines a bit less..
2008-07-03 17:44:13 +03:00
Panu Matilainen 62d7b0c98d Add type-safe headerPutFoo() methods for supported tag data types
- requiring all access through rpmtdFromFoo() just adds unnecessary
  indirection and pain for little gain, the header is fairly intelligent
  when it comes to inserting data
- this gives us various benefits over the old headerAddEntry() interface too:
  + basic type checking done by compiler
  + extra sanity checking (ie you can't add string data to integer tags,
    don't permit adding more than one entry to non-array data etc)
  + "do the right thing" approach - add / append as needed and supported
    by various types
  + headerPutString() can now be used on both single strings and string
    arrays making the interface much nicer for the rather common case of
    appending strings one by one to string array tags
2008-06-19 15:41:58 +03:00
Panu Matilainen 0d1cdd4a96 Group legacy interfaces at the end of header.h
- out of sight, out of mind ;)
- add deprecation warnings where missing
- move to header_legacy doxygen group to avoid littering main documentation
2008-06-18 15:39:59 +03:00
Panu Matilainen efe4e4c946 Switch around headerAdd*Entry() family vs headerPut()
- make internal header add + append take rpmtd as argument, legacy
  interfaces are just wrappers around them
- add deprecation markers
2008-06-18 15:16:05 +03:00
Panu Matilainen b6577f0e6d Switch around headerMod() and headerModifyEntry()
- headerModifyEntry() is the legacy interface going away, make it
  use headerMod() and deprecate it
2008-06-18 14:59:13 +03:00
Panu Matilainen 312ab62fe1 Add headerMod() to headerPut() etc family
- just a dumb wrapper around old headerModifyEntry() for now
2008-06-18 10:59:45 +03:00
Panu Matilainen b6c2fd31d8 Rename headerRemoveEntry() to headerDel(), add compat wrapper
- no differences here except headerDel is a nice short name (lifted from
  rpm5.org) to go with the new headerGet() etc family
- deprecate headerRemoveEntry()
2008-06-17 09:02:41 +03:00
Panu Matilainen d8b28213ae Deprecate headerGetEntry() and headerGetEntryMinMemory() 2008-06-13 17:00:22 +03:00
Panu Matilainen bca23d19af Add headerGet() flag to force allocation of returned data
- earlier there was no way for caller to know if returned data or parts
  of it pointed to header memory (other than "know" how rpm behaves on
  given types), this allows consistent behavior for callers (ie you
  always "own" the returned data, not depending on header) when needed
- if HEADERGET_ALLOC flag is set, all returned data is malloced, instead
  of possibly pointing to header memory depending on type
- HEADERGET_ALLOC overrides HEADERGET_MINMEM if both specified
- adjust various header internal callers to accept flags instead of just
  minmem argument
- TODO: make sure tag extensions honor this too (all but fsnamesTag
  currently allocate anyway)
2008-06-11 12:26:52 +03:00
Panu Matilainen 965f806bce Treat epoch as unsigned integer 2008-05-26 11:00:06 +03:00
Panu Matilainen ec3ab45ad2 Deprecate headerNextIterator() 2008-05-26 09:32:57 +03:00
Panu Matilainen c227b9ebf9 Remove some leftover doxygen @todo markers 2008-05-22 11:25:15 +03:00
Panu Matilainen d1ad87a7f8 Eliminate rpmTagTable internals from API/ABI completely
- everything is now accessible through other methods, no need to expose
  our internals
- tagtbl.c is now included from tagname.c instead and not separately built
2008-05-21 17:59:05 +03:00
Panu Matilainen 7fedc20570 Add HEADERGET_RAW flag to disable i18n lookups 2008-05-17 09:50:39 +03:00
Panu Matilainen 89b8f53621 Push header getter flags down to internal helpers 2008-05-17 09:37:32 +03:00
Panu Matilainen ea0cdcc0dd Oops, thinko/typo in headerGetFlags 2008-05-17 09:28:32 +03:00
Panu Matilainen 0c75369d46 Add typedefs for header get/put flags, use instead of int 2008-05-17 09:25:04 +03:00
Panu Matilainen 7be1b1bafc Remove unused hRET_s and HE_s definitions for good 2008-05-16 18:17:53 +03:00
Panu Matilainen 019ee37f62 Eliminate rpmHeaderFormats and rpmHeaderTagExtensions from the API 2008-05-16 17:46:49 +03:00
Panu Matilainen cbf1a479ee Push finding of formatter and tag extension functions down to formats.c 2008-05-16 16:56:32 +03:00
Panu Matilainen eef5417dea Make extension formatter functions opaque
- tag extensions are only needed by headerGet(), formats only by headerFormat()
2008-05-16 16:26:19 +03:00
Panu Matilainen 696184533a Eliminate the now unnecessary extension type fields 2008-05-16 16:07:41 +03:00
Panu Matilainen 44bdb776b7 Split format and tag extensions to separate tables 2008-05-16 15:55:44 +03:00
Panu Matilainen a06b172d8d Change headerTagTagFunction() to take tag container as arg
- minimal, crude conversion of all formatTag() functions for now
2008-05-15 15:13:03 +03:00
Panu Matilainen 65100c8e1d Teach headerGet() to retrieve extension tags if enabled with flags
- bit of a kludgery until fooTag() formatters have been converted
  to take rpmtd struct as argument
- idea lifted from rpm5.org, implemented independently (and probably quite
  differently)
2008-05-14 14:36:36 +03:00
Panu Matilainen 7bb210e0af Teach rpm tag table about extensions
- add rpmTag_e enumerations for all extension tags
- add extension field to headerTagTableEntry_s for things that are "pure"
  extensions (instead of just extension overrides) so we have a chance to
  catch out anybody trying to insert such tags to headers
2008-05-14 13:20:46 +03:00
Panu Matilainen 0ee2364ae2 Add headerPut() for adding data to headers through tag container
- tag container isn't that big a win on add/append operations as it is on
  retrieval, just use the existing headerAddEntry() family to do the
  actual work
- headerPut() is a nice and short name, lifted from rpm5.org, API might
  differ
- flags to control operation, just whether append is permitted or not for now
2008-05-13 12:32:25 +03:00
Panu Matilainen 09807fed03 Convert header tag iterator to use rpmtd
- new API function headerNext() for the new interface
- headerNextIterator() is just a compat wrapper
2008-05-13 11:46:33 +03:00
Panu Matilainen 8cd92950bd Convert headerGetEntry() internals to use rpmtd for data
- new public API function headerGet() that returns data in rpmtd, with
  flags to control operation (just minmem or no for now)
- headerGet() is nice and short name, lifted from rpm5.org but our API
  differs as this takes a separate arg for the tag to get instead of
  (ab)using the container to pass data back and forth
- internal compatibility wrapper to keep headerGetEntry() and -MinMem
  version working
2008-05-13 11:38:38 +03:00
Panu Matilainen a83cfce188 New "tag data" container struct + some basic methods to deal with it
- to be used for passing around header and extension data
- inspired by similar changes in rpm5.org, details and implementation differ
2008-05-13 11:02:45 +03:00