header.h
Go to the documentation of this file.

    00001 #ifndef H_HEADER
    00002 #define H_HEADER
    00003
    00013 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
    00014
    00015 #include <rpm/rpmio.h>
    00016 #include <rpm/rpmtypes.h>
    00017 #include <rpm/rpmtd.h>
    00018 #include <rpm/rpmutil.h>
    00019
    00020 #ifdef __cplusplus
    00021 extern "C" {
    00022 #endif
    00023
    00027 extern const unsigned char rpm_header_magic[8];
    00028
    00032 enum hMagic {
    00033     HEADER_MAGIC_NO             = 0,
    00034     HEADER_MAGIC_YES            = 1
    00035 };
    00036
    00041 Header headerNew(void);
    00042
    00048 Header headerFree( Header h);
    00049
    00055 Header headerLink(Header h);
    00056
    00061 void headerSort(Header h);
    00062
    00067 void headerUnsort(Header h);
    00068
    00075 unsigned int headerSizeof(Header h, int magicp);
    00076
    00086 int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate);
    00087
    00093 void * headerUnload(Header h);
    00094
    00102 Header headerReload(Header h, rpmTagVal tag);
    00103
    00109 Header headerCopy(Header h);
    00110
    00116 Header headerLoad(void * uh);
    00117
    00123 Header headerCopyLoad(const void * uh);
    00124
    00131 Header headerRead(FD_t fd, int magicp);
    00132
    00140 int headerWrite(FD_t fd, Header h, int magicp);
    00141
    00148 int headerIsEntry(Header h, rpmTagVal tag);
    00149
    00159 enum headerGetFlags_e {
    00160     HEADERGET_DEFAULT   = 0,        /* legacy headerGetEntry() behavior */
    00161     HEADERGET_MINMEM    = (1 << 0), /* pointers can refer to header memory */
    00162     HEADERGET_EXT       = (1 << 1), /* lookup extension types too */
    00163     HEADERGET_RAW       = (1 << 2), /* return raw contents (no i18n lookups) */
    00164     HEADERGET_ALLOC     = (1 << 3), /* always allocate memory for all data */
    00165     HEADERGET_ARGV      = (1 << 4), /* return string arrays NULL-terminated */
    00166 };
    00167
    00168 typedef rpmFlags headerGetFlags;
    00169
    00178 int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags);
    00179
    00180
    00181 enum headerPutFlags_e {
    00182     HEADERPUT_DEFAULT   = 0,
    00183     HEADERPUT_APPEND    = (1 << 0),
    00184 };
    00185
    00186 typedef rpmFlags headerPutFlags;
    00187
    00196 int headerPut(Header h, rpmtd td, headerPutFlags flags);
    00197
    00221 int headerPutString(Header h, rpmTagVal tag, const char *val);
    00222 int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size);
    00223 int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
    00224 int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size);
    00225 int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
    00226 int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size);
    00227 int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size);
    00228 int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size);
    00251 int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
    00252                 const char * lang);
    00253
    00261 int headerMod(Header h, rpmtd td);
    00262
    00272 int headerDel(Header h, rpmTagVal tag);
    00273
    00283 char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
    00284
    00291 void headerCopyTags(Header headerFrom, Header headerTo,
    00292                     const rpmTagVal * tagstocopy);
    00293
    00299 HeaderIterator headerFreeIterator(HeaderIterator hi);
    00300
    00306 HeaderIterator headerInitIterator(Header h);
    00307
    00314 int headerNext(HeaderIterator hi, rpmtd td);
    00315
    00321 rpmTagVal headerNextTag(HeaderIterator hi);
    00322
    00331 RPM_GNUC_DEPRECATED
    00332 int headerNVR(Header h,
    00333                 const char ** np,
    00334                 const char ** vp,
    00335                 const char ** rp);
    00336
    00347 RPM_GNUC_DEPRECATED
    00348 int headerNEVRA(Header h,
    00349                 const char ** np,
    00350                 uint32_t ** ep,
    00351                 const char ** vp,
    00352                 const char ** rp,
    00353                 const char ** ap);
    00354
    00361 RPM_GNUC_DEPRECATED
    00362 char * headerGetNEVR(Header h, const char ** np );
    00363
    00370 RPM_GNUC_DEPRECATED
    00371 char * headerGetNEVRA(Header h, const char ** np );
    00372
    00373 /* \ingroup header
    00374  * Return (malloc'd) header (epoch:)version-release string.
    00375  * @param h             header
    00376  * @retval np           name tag value (or NULL)
    00377  * @return             (epoch:)version-release string
    00378  */
    00379 RPM_GNUC_DEPRECATED
    00380 char * headerGetEVR(Header h, const char **np);
    00381
    00388 char * headerGetAsString(Header h, rpmTagVal tag);
    00389
    00396 const char * headerGetString(Header h, rpmTagVal tag);
    00397
    00398 /* \ingroup header
    00399  * Return a simple number tag (or extension) from header
    00400  * @param h             header
    00401  * @param tag           tag to retrieve
    00402  * @return              numeric tag value or 0 on failure
    00403  */
    00404 uint64_t headerGetNumber(Header h, rpmTagVal tag);
    00405
    00411 RPM_GNUC_DEPRECATED
    00412 rpm_color_t headerGetColor(Header h);
    00413
    00419 int headerIsSource(Header h);
    00420
    00426 unsigned int headerGetInstance(Header h);
    00427
    00428 typedef enum headerConvOps_e {
    00429     HEADERCONV_EXPANDFILELIST   = 0,
    00430     HEADERCONV_COMPRESSFILELIST = 1,
    00431     HEADERCONV_RETROFIT_V3      = 2,
    00432 } headerConvOps;
    00433
    00440 int headerConvert(Header h, int op);
    00441
    00442 #ifdef __cplusplus
    00443 }
    00444 #endif
    00445
    00446 #endif  /* H_HEADER */