lib/misc.h File Reference

#include <string.h>

Go to the source code of this file.

Functions

rpmRC rpmMkdirPath (const char *dpath, const char *dname)
 Create directory if it does not exist, and make sure path is writable.
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.


Detailed Description

Definition in file misc.h.


Function Documentation

char* currentDirectory ( void   ) 

Return (malloc'd) current working directory.

Returns:
current working directory (malloc'ed)

Definition at line 229 of file misc.c.

References errno, and xrealloc().

Referenced by rpmQueryVerify(), and rpmtsRun().

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 100 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
overwrite should an existing variable be changed?
Returns:
0 on success

Definition at line 110 of file misc.c.

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

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

void freeSplitString ( char **  list  ) 

Free split string argv array.

Parameters:
list argv array

Definition at line 92 of file misc.c.

References _free().

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

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 122 of file misc.c.

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

Referenced by doScript(), makeHDRSignature(), manageFile(), runScript(), and writeRPM().

rpmRC rpmMkdirPath ( const char *  dpath,
const char *  dname 
)

Create directory if it does not exist, and make sure path is writable.

Note:
This will only create last component of directory path.
Parameters:
dpath directory path
dname directory use string
Returns:
rpmRC return code

Definition at line 18 of file misc.c.

References _, Access(), errno, Mkdir(), RPMERR_CREATE, rpmError, RPMRC_FAIL, RPMRC_OK, Stat(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), and W_OK.

Referenced by main().

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 53 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 50 of file misc.h.

Referenced by legacyRetrofit(), and relocateFileList().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2