lib/misc.h File Reference

Go to the source code of this file.

Functions

char ** splitString (const char *str, int length, char sep)
 Split string into fields separated by a character.
void freeSplitString (char **list)
 Free split string argv array.
static char * stripTrailingChar (char *s, char c)
 Remove occurences of trailing character from string.
int dosetenv (const char *name, const char *value, int overwrite)
 Like the libc function, but malloc()'s the space needed.
int doputenv (const char *str)
 Like the libc function, but malloc()'s the space needed.
int makeTempFile (const char *prefix, const char **fnptr, FD_t *fdptr)
 Return file handle for a temporaray file.
char * currentDirectory (void)
 Return (malloc'd) current working directory.
void compressFilelist (Header h)
 Convert absolute path tag to (dirname,basename,dirindex) tags.
void expandFilelist (Header h)
 Convert (dirname,basename,dirindex) tags to absolute path tag.
void buildOrigFileList (Header h, const char ***fileListPtr, int *fileCountPtr)
 
Parameters:
h header

int myGlobPatternP (const char *patternURL)
int rpmGlob (const char *patterns, int *argcPtr, const char ***argvPtr)
void providePackageNVR (Header h)
 Retrofit a Provides: name = version-release dependency into legacy packages.
int domd5 (const char *fn, unsigned char *digest, int asAscii)
 Calculate MD5 sum for file.
static int mdfile (const char *fn, unsigned char *digest)
 Return MD5 sum of file as ASCII string.
static int mdbinfile (const char *fn, unsigned char *bindigest)
 Return MD5 sum of file as binary data.


Detailed Description

Definition in file misc.h.


Function Documentation

void buildOrigFileList ( Header  h,
const char ***  fileListPtr,
int *  fileCountPtr 
)

Parameters:
h header

Definition at line 465 of file misc.c.

References doBuildFileList(), RPMTAG_ORIGBASENAMES, RPMTAG_ORIGDIRINDEXES, and RPMTAG_ORIGDIRNAMES.

Referenced by psmStage().

void compressFilelist ( Header  h  ) 

Convert absolute path tag to (dirname,basename,dirindex) tags.

Parameters:
h header

Definition at line 298 of file misc.c.

References alloca(), dncmp(), headerAddEntry(), headerFreeData(), headerGetEntryMinMemory(), headerIsEntry(), headerRemoveEntry(), RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, and RPMTAG_OLDFILENAMES.

Referenced by doGetRecord(), genCpioListAndHeader(), hdrCompressFilelist(), hdrLoad(), mungeFilelist(), readPackageHeaders(), and rpmReadHeaders().

char* currentDirectory ( void   ) 

Return (malloc'd) current working directory.

Returns:
current working directory (malloc'ed)

Definition at line 274 of file misc.c.

References errno, xmalloc(), and xrealloc().

Referenced by rpmRunTransactions().

int domd5 ( const char *  fn,
unsigned char *  digest,
int  asAscii 
)

Calculate MD5 sum for file.

Todo:
Eliminate, use beecrypt instead.
Parameters:
fn file name
Return values:
digest address of md5sum
Parameters:
asAscii return md5sum as ascii string?
Returns:
0 on success, 1 on error

Definition at line 791 of file misc.c.

References _free(), Fclose(), fdFiniDigest(), fdInitDigest(), Ferror(), Fopen(), Fread(), and PGPHASHALGO_MD5.

Referenced by decideFileFate(), genCpioListAndHeader(), mdbinfile(), mdfile(), and rpmVerifyFile().

int doputenv ( const char *  str  ) 

Like the libc function, but malloc()'s the space needed.

Parameters:
str "name=value" string
Returns:
0 on success

Definition at line 98 of file misc.c.

References xmalloc().

Referenced by runScript().

int dosetenv ( const char *  name,
const char *  value,
int  overwrite 
)

Like the libc function, but malloc()'s the space needed.

Parameters:
name variable name
value variable value
overwrte should an existing variable be changed?
Returns:
0 on success

Definition at line 108 of file misc.c.

References getenv(), stpcpy(), and xmalloc().

Referenced by checkPassPhrase(), makeGPGSignature(), makePGPSignature(), verifyGPGSignature(), and verifyPGPSignature().

void expandFilelist ( Header  h  ) 

Convert (dirname,basename,dirindex) tags to absolute path tag.

Parameters:
h header

Definition at line 436 of file misc.c.

References _free(), doBuildFileList(), headerAddEntry(), headerIsEntry(), headerRemoveEntry(), RPM_STRING_ARRAY_TYPE, RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, and RPMTAG_OLDFILENAMES.

Referenced by dbiUpdateRecord(), genCpioListAndHeader(), hdrExpandFilelist(), and rpmdbAdd().

void freeSplitString ( char **  list  ) 

Free split string argv array.

Parameters:
list argv array

Definition at line 59 of file misc.c.

References _free().

Referenced by parsePrep(), processPackageFiles(), and processSourceFiles().

int makeTempFile ( const char *  prefix,
const char **  fnptr,
FD_t fdptr 
)

Return file handle for a temporaray file.

A unique temporaray file path will be generated using rpmGenPath(prefix, "%{_tmppath}/", "rpm-tmp.XXXXX") where "XXXXXX" is filled in using rand(3). The file is opened, and the link count and (dev,ino) location are verified after opening. The file name and the open file handle are returned.

Parameters:
prefix leading part of temp file path
Return values:
fnptr temp file name (or NULL)
fdptr temp file handle
Returns:
0 on success

Definition at line 170 of file misc.c.

References _, _free(), errno, Fclose(), Ferror(), Fileno(), Fopen(), RPMERR_SCRIPT, rpmError, rpmGenPath(), rpmMkpath(), S_ISLNK, URL_IS_DASH, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by doScript(), manageFile(), runScript(), verifyGPGSignature(), verifyPGPSignature(), and writeRPM().

static int mdbinfile ( const char *  fn,
unsigned char *  bindigest 
) [inline, static]

Return MD5 sum of file as binary data.

Todo:
Eliminate, use beecrypt instead.
Parameters:
fn file name
Return values:
bindigest MD5 digest
Returns:
0 on success, 1 on error

Definition at line 175 of file misc.h.

References domd5().

Referenced by rpmAddSignature(), and rpmVerifySignature().

static int mdfile ( const char *  fn,
unsigned char *  digest 
) [inline, static]

Return MD5 sum of file as ASCII string.

Todo:
Eliminate, use beecrypt instead.
Parameters:
fn file name
Return values:
digest MD5 digest
Returns:
0 on success, 1 on error

Definition at line 160 of file misc.h.

References domd5().

Referenced by hdrVerifyFile().

int myGlobPatternP ( const char *  patternURL  ) 

Definition at line 476 of file misc.c.

References urlPath().

Referenced by processBinaryFile(), and rpmGlob().

void providePackageNVR ( Header  h  ) 

Retrofit a Provides: name = version-release dependency into legacy packages.

Parameters:
h header

Definition at line 712 of file misc.c.

References alloca(), headerAddOrAppendEntry(), headerFreeData(), headerGetEntryMinMemory(), headerNVR(), name, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMSENSE_ANY, RPMSENSE_EQUAL, RPMTAG_EPOCH, RPMTAG_PROVIDEFLAGS, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, and stpcpy().

Referenced by doGetRecord(), hdrLoad(), packageBinaries(), readPackageHeaders(), rpmReadHeaders(), and writeRPM().

int rpmGlob ( const char *  patterns,
int *  argcPtr,
const char ***  argvPtr 
)

Definition at line 508 of file misc.c.

References _debug, _free(), Glob(), glob_error(), Globfree(), myGlobPatternP(), poptParseArgvString(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), xmalloc(), xrealloc(), and xstrdup().

Referenced by IDTXglob(), processBinaryFile(), rpmInstall(), rpmQueryVerify(), and rpmReadPackageManifest().

char** splitString ( const char *  str,
int  length,
char  sep 
)

Split string into fields separated by a character.

Parameters:
str string
length length of string
sep separator character
Returns:
(malloc'd) argv array

Definition at line 23 of file misc.c.

References xmalloc().

Referenced by parsePrep(), processPackageFiles(), processSourceFiles(), and skipFiles().

static char* stripTrailingChar ( char *  s,
char  c 
) [inline, static]

Remove occurences of trailing character from string.

Parameters:
s string
c character to strip
Returns:
string

Definition at line 37 of file misc.h.

Referenced by readPackageHeaders(), and relocateFileList().


Generated on Mon Dec 3 21:52:07 2007 for rpm by  doxygen 1.5.2