Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

lib/header.c File Reference

More...

#include "system.h"
#include <netinet/in.h>
#include <header.h>
#include "debug.h"

Go to the source code of this file.

Compounds

struct  entryInfo
struct  extensionCache
struct  headerIteratorS
struct  headerToken
struct  indexEntry
struct  sprintfTag
struct  sprintfToken

Defines

#define _DEBUG_SWAB   1
#define _DEBUG_INDEX   1
#define HEADER_OLDFILENAMES   1027
#define HEADER_BASENAMES   1117
#define INDEX_MALLOC_SIZE   8
#define PARSER_BEGIN   0
#define PARSER_IN_ARRAY   1
#define PARSER_IN_EXPR   2
#define REGION_TAG_TYPE   RPM_BIN_TYPE
#define REGION_TAG_COUNT   sizeof(struct entryInfo)
#define ENTRY_IS_REGION(_e)    ((_e)->info.tag < HEADER_I18NTABLE)
#define ENTRY_IN_REGION(_e)    ((_e)->info.offset < 0)

Functions

const char* const tagName (int tag)
 Return name of tag from value. More...

int dataLength (int_32 type, const void * p, int_32 count, int onDisk)
 Return length of entry data. More...

int regionSwab (struct indexEntry * entry, int il, int dl, const struct entryInfo * pe, char * dataStart, int regionid)
 Swap int_32 and int_16 arrays within header region. More...

void copyEntry (const struct indexEntry * entry, int_32 * type, const void ** p, int_32 * c, int minMem)
 Retrieve data from header entry. More...

HeaderIterator headerInitIterator (Header h)
void headerFreeIterator (HeaderIterator iter)
int headerNextIterator (HeaderIterator hi, int_32 * tag, int_32 * type, const void ** p, int_32 * c)
int indexCmp (const void *avp, const void *bvp)
void headerSort (Header h)
int offsetCmp (const void *avp, const void *bvp)
void headerUnsort (Header h)
Header headerCopy (Header h)
Header headerLoad (void *uh)
Header headerCopyLoad (void *uh)
void* doHeaderUnload (Header h, int * lengthPtr)
void* headerUnload (Header h)
Header headerReload (Header h, int tag)
int headerWrite (FD_t fd, Header h, enum hMagic magicp)
Header headerRead (FD_t fd, enum hMagic magicp)
void headerDump (Header h, FILE *f, int flags, const struct headerTagTableEntry * tags)
struct indexEntryfindEntry (Header h, int_32 tag, int_32 type)
 Find matching (tag,type) entry in header. More...

int headerIsEntry (Header h, int_32 tag)
int headerGetRawEntry (Header h, int_32 tag, int_32 * type, const void ** p, int_32 *c)
int headerMatchLocale (const char *td, const char *l, const char *le)
 Does locale match entry in header i18n table? More...

char* headerFindI18NString (Header h, struct indexEntry *entry)
 Return i18n string from header that matches locale. More...

int intGetEntry (Header h, int_32 tag, int_32 *type, const void **p, int_32 *c, int minMem)
 Retrieve tag data from header. More...

int headerGetEntryMinMemory (Header h, int_32 tag, int_32 *type, const void **p, int_32 *c)
int headerGetEntry (Header h, int_32 tag, int_32 * type, void **p, int_32 * c)
Header headerNew ()
void headerFree (Header h)
Header headerLink (Header h)
int headerUsageCount (Header h)
unsigned int headerSizeof (Header h, enum hMagic magicp)
void copyData (int_32 type, void * dstPtr, const void * srcPtr, int_32 c, int dataLength)
void* grabData (int_32 type, const void * p, int_32 c, int * lengthPtr)
 Return (malloc'ed) copy of entry data. More...

int headerAddEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c)
char** headerGetLangs (Header h)
int headerAddI18NString (Header h, int_32 tag, const char * string, const char * lang)
int headerModifyEntry (Header h, int_32 tag, int_32 type, void *p, int_32 c)
int headerAddOrAppendEntry (Header h, int_32 tag, int_32 type, void * p, int_32 c)
int headerAppendEntry (Header h, int_32 tag, int_32 type, void * p, int_32 c)
int headerRemoveEntry (Header h, int_32 tag)
char escapedChar (const char ch)
void freeFormat ( struct sprintfToken * format, int num)
void findTag (char * name, const struct headerTagTableEntry * tags, const struct headerSprintfExtension * extensions, const struct headerTagTableEntry ** tagMatch, const struct headerSprintfExtension ** extMatch)
int parseExpression (struct sprintfToken * token, char * str, const struct headerTagTableEntry * tags, const struct headerSprintfExtension * extensions, char ** endPtr, const char ** errmsg)
int parseFormat (char * str, const struct headerTagTableEntry * tags, const struct headerSprintfExtension * extensions, struct sprintfToken ** formatPtr, int * numTokensPtr, char ** endPtr, int state, const char ** errmsg)
int getExtension (Header h, headerTagTagFunction fn, int_32 * typeptr, const void ** data, int_32 * countptr, struct extensionCache * ext)
char* formatValue (struct sprintfTag * tag, Header h, const struct headerSprintfExtension * extensions, struct extensionCache * extCache, int element)
const char* singleSprintf (Header h, struct sprintfToken * token, const struct headerSprintfExtension * extensions, struct extensionCache * extCache, int element)
struct extensionCacheallocateExtensionCache ( const struct headerSprintfExtension * extensions)
void freeExtensionCache (const struct headerSprintfExtension * extensions, struct extensionCache * cache)
char* headerSprintf (Header h, const char * origFmt, const struct headerTagTableEntry * tags, const struct headerSprintfExtension * extensions, const char ** errmsg)
char* octalFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element)
char* hexFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element)
char* realDateFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element, char * strftimeFormat)
char* dateFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element)
char* dayFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element)
char* shescapeFormat (int_32 type, const void * data, char * formatPrefix, int padding, int element)
void headerCopyTags (Header headerFrom, Header headerTo, int *tagstocopy)

Variables

unsigned char header_magic [8]
int typeSizes []
const struct headerSprintfExtension headerDefaultFormats []


Detailed Description

Definition in file header.c.


Define Documentation

#define ENTRY_IN_REGION( _e )   ((_e)->info.offset < 0)
 

Definition at line 74 of file header.c.

Referenced by headerAddI18NString(), headerAppendEntry(), headerFree(), headerModifyEntry(), and headerRemoveEntry().

#define ENTRY_IS_REGION( _e )   ((_e)->info.tag < HEADER_I18NTABLE)
 

Definition at line 73 of file header.c.

Referenced by copyEntry(), doHeaderUnload(), headerFree(), headerNextIterator(), headerReload(), and headerSizeof().

#define HEADER_BASENAMES   1117
 

Definition at line 32 of file header.c.

#define HEADER_OLDFILENAMES   1027
 

Definition at line 31 of file header.c.

#define INDEX_MALLOC_SIZE   8
 

Definition at line 34 of file header.c.

#define PARSER_BEGIN   0
 

Definition at line 36 of file header.c.

#define PARSER_IN_ARRAY   1
 

Definition at line 37 of file header.c.

#define PARSER_IN_EXPR   2
 

Definition at line 38 of file header.c.

#define REGION_TAG_COUNT   sizeof(struct entryInfo)
 

Definition at line 71 of file header.c.

#define REGION_TAG_TYPE   RPM_BIN_TYPE
 

Definition at line 70 of file header.c.

#define _DEBUG_INDEX   1
 

Definition at line 7 of file header.c.

#define _DEBUG_SWAB   1
 

Definition at line 6 of file header.c.


Function Documentation

struct extensionCache * allocateExtensionCache ( const struct headerSprintfExtension * extensions ) [static]
 

Definition at line 2496 of file header.c.

Referenced by headerSprintf().

void copyData ( int_32 type,
void * dstPtr,
const void * srcPtr,
int_32 c,
int dataLength ) [static]
 

Definition at line 1448 of file header.c.

Referenced by grabData(), and headerAppendEntry().

void copyEntry ( const struct indexEntry * entry,
int_32 * type,
const void ** p,
int_32 * c,
int minMem ) [static]
 

Retrieve data from header entry.

Parameters:
entry   header entry
Return values:
type   address of type (or NULL)
p   address of data (or NULL)
c   address of count (or NULL)
Parameters:
minMem   string pointers refer to header memory?

Definition at line 283 of file header.c.

Referenced by headerGetRawEntry(), headerNextIterator(), and intGetEntry().

int dataLength ( int_32 type,
const void * p,
int_32 count,
int onDisk ) [static]
 

Return length of entry data.

Parameters:
type   entry data type
p   entry data
count   entry item count
onDisk   data is concatenated strings (with NUL's))?
Returns:
no. bytes in data

Definition at line 160 of file header.c.

Referenced by grabData(), headerAppendEntry(), and regionSwab().

char * dateFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element ) [static]
 

Definition at line 2649 of file header.c.

char * dayFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element ) [static]
 

Definition at line 2656 of file header.c.

void * doHeaderUnload ( Header h,
int * lengthPtr ) [static]
 

Definition at line 633 of file header.c.

Referenced by headerReload(), headerUnload(), and headerWrite().

char escapedChar ( const char ch ) [static]
 

Definition at line 1784 of file header.c.

Referenced by parseFormat().

struct indexEntry * findEntry ( Header h,
int_32 tag,
int_32 type ) [static]
 

Find matching (tag,type) entry in header.

Parameters:
h   header
tag   entry tag
type   entry type
Returns:
header entry

Definition at line 1098 of file header.c.

void findTag ( char * name,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
const struct headerTagTableEntry ** tagMatch,
const struct headerSprintfExtension ** extMatch ) [static]
 

Definition at line 1823 of file header.c.

Referenced by parseExpression(), and parseFormat().

char * formatValue ( struct sprintfTag * tag,
Header h,
const struct headerSprintfExtension * extensions,
struct extensionCache * extCache,
int element ) [static]
 

Definition at line 2254 of file header.c.

Referenced by singleSprintf().

void freeExtensionCache ( const struct headerSprintfExtension * extensions,
struct extensionCache * cache ) [static]
 

Definition at line 2514 of file header.c.

Referenced by headerSprintf().

void freeFormat ( struct sprintfToken * format,
int num ) [static]
 

Definition at line 1798 of file header.c.

Referenced by parseExpression(), and parseFormat().

int getExtension ( Header h,
headerTagTagFunction fn,
int_32 * typeptr,
const void ** data,
int_32 * countptr,
struct extensionCache * ext ) [static]
 

Definition at line 2236 of file header.c.

Referenced by formatValue(), and singleSprintf().

void * grabData ( int_32 type,
const void * p,
int_32 c,
int * lengthPtr ) [static]
 

Return (malloc'ed) copy of entry data.

Parameters:
type   entry data type
p   entry data
c   entry item count
Return values:
lengthPtr   no. bytes in returned data
Returns:
(malloc'ed) copy of entry data

Definition at line 1485 of file header.c.

Referenced by headerAddEntry(), and headerModifyEntry().

void headerCopyTags ( Header headerFrom,
Header headerTo,
int * tagstocopy )
 

Definition at line 2708 of file header.c.

char * headerFindI18NString ( Header h,
struct indexEntry * entry ) [static]
 

Return i18n string from header that matches locale.

Parameters:
h   header
entry   i18n string data
Returns:
matching i18n string (or 1st string if no match)

Definition at line 1248 of file header.c.

Referenced by intGetEntry().

int headerMatchLocale ( const char * td,
const char * l,
const char * le ) [static]
 

Does locale match entry in header i18n table?

 * The range [l,le) contains the next locale to match:
 *    ll[_CC][.EEEEE][@dddd]
 * where
 *    ll        ISO language code (in lowercase).
 *    CC        (optional) ISO coutnry code (in uppercase).
 *    EEEEE     (optional) encoding (not really standardized).
 *    dddd      (optional) dialect.
 * 
Parameters:
td   header i18n table data, NUL terminated
l   start of locale to match
le   end of locale to match
Returns:
1 on match, 0 on no match

Definition at line 1175 of file header.c.

Referenced by headerFindI18NString().

char * headerSprintf ( Header h,
const char * origFmt,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
const char ** errmsg )
 

Definition at line 2533 of file header.c.

char * hexFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element ) [static]
 

Definition at line 2606 of file header.c.

int indexCmp ( const void * avp,
const void * bvp ) [static]
 

Definition at line 406 of file header.c.

int intGetEntry ( Header h,
int_32 tag,
int_32 * type,
const void ** p,
int_32 * c,
int minMem ) [static]
 

Retrieve tag data from header.

Parameters:
h   header
tag   tag to retrieve
Return values:
type   address of type (or NULL)
p   address of data (or NULL)
c   address of count (or NULL)
Parameters:
minMem   string pointers reference header memory?
Returns:
1 on success, 0 on not found

Definition at line 1299 of file header.c.

Referenced by headerGetEntry(), and headerGetEntryMinMemory().

char * octalFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element ) [static]
 

Definition at line 2589 of file header.c.

int offsetCmp ( const void * avp,
const void * bvp ) [static]
 

Definition at line 420 of file header.c.

int parseExpression ( struct sprintfToken * token,
char * str,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
char ** endPtr,
const char ** errmsg ) [static]
 

Definition at line 2115 of file header.c.

Referenced by parseFormat().

int parseFormat ( char * str,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
struct sprintfToken ** formatPtr,
int * numTokensPtr,
char ** endPtr,
int state,
const char ** errmsg ) [static]
 

Definition at line 1878 of file header.c.

Referenced by headerSprintf(), and parseExpression().

char * realDateFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element,
char * strftimeFormat ) [static]
 

Definition at line 2623 of file header.c.

Referenced by dateFormat(), and dayFormat().

int regionSwab ( struct indexEntry * entry,
int il,
int dl,
const struct entryInfo * pe,
char * dataStart,
int regionid ) [static]
 

Swap int_32 and int_16 arrays within header region.

Parameters:
entry   header entry
il   no. of entries
dl   start no. bytes of data
pe   header physical entry pointer (swapped)
dataStart   header data
regionid   region offset
Returns:
no. bytes of data in region

Definition at line 225 of file header.c.

Referenced by copyEntry(), doHeaderUnload(), and headerLoad().

char * shescapeFormat ( int_32 type,
const void * data,
char * formatPrefix,
int padding,
int element ) [static]
 

Definition at line 2664 of file header.c.

const char * singleSprintf ( Header h,
struct sprintfToken * token,
const struct headerSprintfExtension * extensions,
struct extensionCache * extCache,
int element ) [static]
 

Definition at line 2382 of file header.c.

Referenced by headerSprintf().

const char *const tagName ( int tag )
 

Return name of tag from value.

Parameters:
tag   tag value
Returns:
name of tag

Definition at line 10 of file tagName.c.

Referenced by XdbiCclose(), XdbiCopen(), checkForDuplicates(), checkForRequired(), db1basename(), dbiClose(), dbiDel(), dbiGet(), dbiOpen(), dbiPut(), dbiSearch(), dbiSync(), dbiUpdateIndex(), handlePreambleTag(), i18nTag(), printNewSpecfile(), rpmHeaderGetEntry(), rpmdbAdd(), rpmdbInitIterator(), rpmdbMoveDatabase(), rpmdbRemove(), rpmdbRemoveDatabase(), and stashSt().


Variable Documentation

unsigned char header_magic[8] [static]
 

Initializer:

{
        0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
}

Definition at line 40 of file header.c.


Generated at Sun Apr 8 18:43:04 2001 for rpm by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000