rpm  4.8.1
Macros | Typedefs | Functions
rpmstring.h File Reference

String manipulation helper functions. More...

#include <stddef.h>
#include <string.h>
#include <rpm/rpmutil.h>
Include dependency graph for rpmstring.h:

Go to the source code of this file.

Macros

#define appendStringBuf(sb, s)   appendStringBufAux(sb, s, 0)
 
#define appendLineStringBuf(sb, s)   appendStringBufAux(sb, s, 1)
 

Typedefs

typedef struct StringBufRec * StringBuf
 

Functions

static RPM_GNUC_CONST int rislower (int c)
 Locale insensitive islower(3) More...
 
static RPM_GNUC_CONST int risupper (int c)
 Locale insensitive isupper(3) More...
 
static RPM_GNUC_CONST int risalpha (int c)
 Locale insensitive isalpha(3) More...
 
static RPM_GNUC_CONST int risdigit (int c)
 Locale insensitive isdigit(3) More...
 
static RPM_GNUC_CONST int risalnum (int c)
 Locale insensitive isalnum(3) More...
 
static RPM_GNUC_CONST int risblank (int c)
 Locale insensitive isblank(3) More...
 
static RPM_GNUC_CONST int risspace (int c)
 Locale insensitive isspace(3) More...
 
static RPM_GNUC_CONST int rtolower (int c)
 Locale insensitive tolower(3) More...
 
static RPM_GNUC_CONST int rtoupper (int c)
 Locale insensitive toupper(3) More...
 
static RPM_GNUC_CONST unsigned char rnibble (char c)
 Convert hex to binary nibble. More...
 
static int rstreq (const char *s1, const char *s2)
 Test for string equality. More...
 
static int rstreqn (const char *s1, const char *s2, size_t n)
 Test for string equality. More...
 
RPM_GNUC_PURE int rstrcasecmp (const char *s1, const char *s2)
 Locale insensitive strcasecmp(3). More...
 
RPM_GNUC_PURE int rstrncasecmp (const char *s1, const char *s2, size_t n)
 Locale insensitive strncasecmp(3). More...
 
int rasprintf (char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
 asprintf() clone More...
 
int char * rstrcat (char **dest, const char *src)
 Concatenate two strings with dynamically (re)allocated memory. More...
 
char * rstrscat (char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
 Concatenate multiple strings with dynamically (re)allocated memory. More...
 
size_t rstrlcpy (char *dest, const char *src, size_t n)
 strlcpy() clone: Copy src to string dest of size n. More...
 
char * stripTrailingChar (char *s, char c)
 Remove occurences of trailing character from string. More...
 
StringBuf newStringBuf (void)
 
StringBuf freeStringBuf (StringBuf sb)
 
void truncStringBuf (StringBuf sb)
 
char * getStringBuf (StringBuf sb)
 
void stripTrailingBlanksStringBuf (StringBuf sb)
 
void appendStringBufAux (StringBuf sb, const char *s, int nl)
 

Detailed Description

String manipulation helper functions.

Definition in file rpmstring.h.

Macro Definition Documentation

◆ appendLineStringBuf

#define appendLineStringBuf (   sb,
 
)    appendStringBufAux(sb, s, 1)

Definition at line 213 of file rpmstring.h.

◆ appendStringBuf

#define appendStringBuf (   sb,
 
)    appendStringBufAux(sb, s, 0)

Definition at line 209 of file rpmstring.h.

Typedef Documentation

◆ StringBuf

typedef struct StringBufRec* StringBuf

Definition at line 185 of file rpmstring.h.

Function Documentation

◆ appendStringBufAux()

void appendStringBufAux ( StringBuf  sb,
const char *  s,
int  nl 
)

◆ freeStringBuf()

StringBuf freeStringBuf ( StringBuf  sb)

◆ getStringBuf()

char* getStringBuf ( StringBuf  sb)

◆ newStringBuf()

StringBuf newStringBuf ( void  )

◆ rasprintf()

int rasprintf ( char **  strp,
const char *  fmt,
  ... 
)

asprintf() clone

Referenced by buildForTarget(), getTarSpec(), and rstreqn().

◆ risalnum()

static RPM_GNUC_CONST int risalnum ( int  c)
inlinestatic

Locale insensitive isalnum(3)

Definition at line 54 of file rpmstring.h.

References risalpha(), risdigit(), and RPM_GNUC_CONST.

◆ risalpha()

static RPM_GNUC_CONST int risalpha ( int  c)
inlinestatic

Locale insensitive isalpha(3)

Definition at line 38 of file rpmstring.h.

References rislower(), risupper(), and RPM_GNUC_CONST.

Referenced by risalnum().

◆ risblank()

static RPM_GNUC_CONST int risblank ( int  c)
inlinestatic

Locale insensitive isblank(3)

Definition at line 62 of file rpmstring.h.

References RPM_GNUC_CONST.

Referenced by risspace().

◆ risdigit()

static RPM_GNUC_CONST int risdigit ( int  c)
inlinestatic

Locale insensitive isdigit(3)

Definition at line 46 of file rpmstring.h.

References RPM_GNUC_CONST.

Referenced by risalnum().

◆ rislower()

static RPM_GNUC_CONST int rislower ( int  c)
inlinestatic

Locale insensitive islower(3)

Definition at line 22 of file rpmstring.h.

References RPM_GNUC_CONST.

Referenced by risalpha(), and rtoupper().

◆ risspace()

static RPM_GNUC_CONST int risspace ( int  c)
inlinestatic

Locale insensitive isspace(3)

Definition at line 70 of file rpmstring.h.

References risblank(), and RPM_GNUC_CONST.

◆ risupper()

static RPM_GNUC_CONST int risupper ( int  c)
inlinestatic

Locale insensitive isupper(3)

Definition at line 30 of file rpmstring.h.

References RPM_GNUC_CONST.

Referenced by risalpha(), and rtolower().

◆ rnibble()

static RPM_GNUC_CONST unsigned char rnibble ( char  c)
inlinestatic

Convert hex to binary nibble.

Parameters
chex character
Returns
binary nibble

Definition at line 96 of file rpmstring.h.

◆ rstrcasecmp()

RPM_GNUC_PURE int rstrcasecmp ( const char *  s1,
const char *  s2 
)

Locale insensitive strcasecmp(3).

Referenced by rstreqn().

◆ rstrcat()

int char* rstrcat ( char **  dest,
const char *  src 
)

Concatenate two strings with dynamically (re)allocated memory.

Parameters
destpointer to destination string
srcsource string
Returns
realloc'd dest with src appended

Referenced by rstreqn().

◆ rstreq()

static int rstreq ( const char *  s1,
const char *  s2 
)
inlinestatic

Test for string equality.

Parameters
s1string 1
s2string 2
Returns
0 if strings differ, 1 if equal

Definition at line 113 of file rpmstring.h.

Referenced by buildForTarget(), and main().

◆ rstreqn()

static int rstreqn ( const char *  s1,
const char *  s2,
size_t  n 
)
inlinestatic

Test for string equality.

Parameters
s1string 1
s2string 2
ncompare at most n characters
Returns
0 if strings differ, 1 if equal

Definition at line 125 of file rpmstring.h.

References rasprintf(), RPM_GNUC_NULL_TERMINATED, RPM_GNUC_PRINTF, RPM_GNUC_PURE, rstrcasecmp(), rstrcat(), rstrlcpy(), rstrncasecmp(), rstrscat(), and stripTrailingChar().

◆ rstrlcpy()

size_t rstrlcpy ( char *  dest,
const char *  src,
size_t  n 
)

strlcpy() clone: Copy src to string dest of size n.

At most n-1 characters will be copied. Always zero-terminates (unless n == 0). Length of src is returned; if retval >= n, truncation occurred.

Parameters
destdestination buffer
srcstring to copy
ndestination buffer size
Returns
length of src string

Referenced by rstreqn().

◆ rstrncasecmp()

RPM_GNUC_PURE int rstrncasecmp ( const char *  s1,
const char *  s2,
size_t  n 
)

Locale insensitive strncasecmp(3).

Referenced by rstreqn().

◆ rstrscat()

char* rstrscat ( char **  dest,
const char *  arg,
  ... 
)

Concatenate multiple strings with dynamically (re)allocated memory.

Parameters
destpointer to destination string
argNULL terminated list of strings to concatenate
Returns
realloc'd dest with strings appended

Referenced by buildForTarget(), main(), and rstreqn().

◆ rtolower()

static RPM_GNUC_CONST int rtolower ( int  c)
inlinestatic

Locale insensitive tolower(3)

Definition at line 78 of file rpmstring.h.

References risupper(), and RPM_GNUC_CONST.

◆ rtoupper()

static RPM_GNUC_CONST int rtoupper ( int  c)
inlinestatic

Locale insensitive toupper(3)

Definition at line 86 of file rpmstring.h.

References rislower(), and RPM_GNUC_CONST.

◆ stripTrailingBlanksStringBuf()

void stripTrailingBlanksStringBuf ( StringBuf  sb)

◆ stripTrailingChar()

char* stripTrailingChar ( char *  s,
char  c 
)

Remove occurences of trailing character from string.

Parameters
sstring
ccharacter to strip
Returns
string

Referenced by rstreqn().

◆ truncStringBuf()

void truncStringBuf ( StringBuf  sb)