#include "system.h"
#include "rpmio_internal.h"
#include <rpmlib.h>
#include <rpmurl.h>
#include <rpmmacro.h>
#include "misc.h"
#include "debug.h"
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. | ||||
int | doputenv (const char *str) | |||
Like the libc function, but malloc()'s the space needed. | ||||
int | dosetenv (const char *name, const char *value, int overwrite) | |||
Like the libc function, but malloc()'s the space needed. | ||||
static int | rpmMkpath (const char *path, mode_t mode, uid_t uid, gid_t gid) | |||
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. | ||||
static int | dncmp (const void *a, const void *b) | |||
void | compressFilelist (Header h) | |||
Convert absolute path tag to (dirname,basename,dirindex) tags. | ||||
static void | doBuildFileList (Header h, const char ***fileListPtr, int *fileCountPtr, rpmTag baseNameTag, rpmTag dirNameTag, rpmTag dirIndexesTag) | |||
void | expandFilelist (Header h) | |||
Convert (dirname,basename,dirindex) tags to absolute path tag. | ||||
void | rpmBuildFileList (Header h, const char ***fileListPtr, int *fileCountPtr) | |||
Retrieve file names from header. | ||||
void | buildOrigFileList (Header h, const char ***fileListPtr, int *fileCountPtr) | |||
| ||||
int | myGlobPatternP (const char *patternURL) | |||
static int | glob_error (const char *foo, int bar) | |||
int | rpmGlob (const char *patterns, int *argcPtr, const char ***argvPtr) | |||
int | rpmHeaderGetEntry (Header h, int_32 tag, int_32 *type, void **p, int_32 *c) | |||
Retrieve tag info from header. | ||||
int | rpmPackageGetEntry (void *leadp, Header sigs, Header h, int_32 tag, int_32 *type, void **p, int_32 *c) | |||
Retrieve tag info from header. | ||||
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. | ||||
Variables | ||||
static int | _debug = 0 | |||
const char * | RPMVERSION = VERSION | |||
int | _noDirTokens = 0 | |||
Should version 3 packages be produced? |
Definition in file misc.c.
void buildOrigFileList | ( | Header | h, | |
const char *** | fileListPtr, | |||
int * | fileCountPtr | |||
) |
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.
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.
Definition at line 274 of file misc.c.
References errno, xmalloc(), and xrealloc().
Referenced by rpmRunTransactions().
static int dncmp | ( | const void * | a, | |
const void * | b | |||
) | [static] |
static void doBuildFileList | ( | Header | h, | |
const char *** | fileListPtr, | |||
int * | fileCountPtr, | |||
rpmTag | baseNameTag, | |||
rpmTag | dirNameTag, | |||
rpmTag | dirIndexesTag | |||
) | [static] |
Definition at line 389 of file misc.c.
References _free(), headerFreeData(), headerGetEntryMinMemory(), stpcpy(), and xmalloc().
Referenced by buildOrigFileList(), expandFilelist(), and rpmBuildFileList().
int domd5 | ( | const char * | fn, | |
unsigned char * | digest, | |||
int | asAscii | |||
) |
Calculate MD5 sum for file.
fn | file name |
digest | address of md5sum |
asAscii | return md5sum as ascii string? |
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.
str | "name=value" string |
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.
name | variable name | |
value | variable value | |
overwrte | should an existing variable be changed? |
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.
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.
list | argv array |
Definition at line 59 of file misc.c.
References _free().
Referenced by parsePrep(), processPackageFiles(), and processSourceFiles().
static int glob_error | ( | const char * | foo, | |
int | bar | |||
) | [static] |
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.
prefix | leading part of temp file path |
fnptr | temp file name (or NULL) | |
fdptr | temp file handle |
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().
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.
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().
void rpmBuildFileList | ( | Header | h, | |
const char *** | fileListPtr, | |||
int * | fileCountPtr | |||
) |
Retrieve file names from header.
The representation of file names in package headers changed in rpm-4.0. Originally, file names were stored as an array of paths. In rpm-4.0, file names are stored as separate arrays of dirname's and basename's, with a dirname index to associate the correct dirname with each basname. This function is used to retrieve file names independent of how the file names are represented in the package header.
h | header |
fileListPtr | address of array of file names | |
fileCountPtr | address of number of files |
Definition at line 459 of file misc.c.
References doBuildFileList(), RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, and RPMTAG_DIRNAMES.
Referenced by filenamesTag(), fssizesTag(), mungeFilelist(), psmStage(), rpmHeaderGetEntry(), rpmInstallSourcePackage(), and verifyHeader().
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().
Retrieve tag info from header.
This is a "dressed" entry to headerGetEntry to do: 1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions. 2) i18n lookaside (if enabled).
h | header | |
tag | tag |
type | address of tag value data type | |
p | address of pointer to tag value(s) | |
c | address of number of values |
Definition at line 627 of file misc.c.
References headerGetEntry(), headerSprintf(), RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmBuildFileList(), rpmHeaderFormats, RPMTAG_DESCRIPTION, RPMTAG_GROUP, RPMTAG_OLDFILENAMES, RPMTAG_SUMMARY, rpmTagTable, stpcpy(), and tagName().
Referenced by rpmPackageGetEntry().
static int rpmMkpath | ( | const char * | path, | |
mode_t | mode, | |||
uid_t | uid, | |||
gid_t | gid | |||
) | [static] |
Definition at line 120 of file misc.c.
References alloca(), errno, RPMMESS_WARNING, rpmMessage, and stpcpy().
Referenced by makeTempFile().
int rpmPackageGetEntry | ( | void * | leadp, | |
Header | sigs, | |||
Header | h, | |||
int_32 | tag, | |||
int_32 * | type, | |||
void ** | p, | |||
int_32 * | c | |||
) |
Retrieve tag info from header.
Yet Another "dressed" entry to headerGetEntry in order to unify signature/header tag retrieval.
leadp | rpm lead | |
h | header | |
sigs | signatures | |
tag | tag |
type | address of tag value data type | |
p | address of pointer to tag value(s) | |
c | address of number of values |
Definition at line 678 of file misc.c.
References headerGetEntry(), headerIsEntry(), rpmHeaderGetEntry(), RPMSIGTAG_GPG, RPMSIGTAG_LEMD5_1, RPMSIGTAG_LEMD5_2, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_SIZE, RPMTAG_SIGGPG, RPMTAG_SIGLEMD5_1, RPMTAG_SIGLEMD5_2, RPMTAG_SIGMD5, RPMTAG_SIGPGP, RPMTAG_SIGPGP5, and RPMTAG_SIGSIZE.
Referenced by hdrSubscript().
char** splitString | ( | const char * | str, | |
int | length, | |||
char | sep | |||
) |
Split string into fields separated by a character.
str | string | |
length | length of string | |
sep | separator character |
Definition at line 23 of file misc.c.
References xmalloc().
Referenced by parsePrep(), processPackageFiles(), processSourceFiles(), and skipFiles().
const char* RPMVERSION = VERSION |