rpmstring.h
Go to the documentation of this file.
#ifndef _RPMSTRING_H_
#define _RPMSTRING_H_
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <rpm/rpmutil.h>
#ifdef __cplusplus
extern "C" {
#endif
RPM_GNUC_CONST
static inline int rislower(int c) {
return (c >= 'a' && c <= 'z');
}
RPM_GNUC_CONST
static inline int risupper(int c) {
return (c >= 'A' && c <= 'Z');
}
RPM_GNUC_CONST
static inline int risalpha(int c) {
return (rislower(c) || risupper(c));
}
RPM_GNUC_CONST
static inline int risdigit(int c) {
return (c >= '0' && c <= '9');
}
RPM_GNUC_CONST
static inline int risalnum(int c) {
return (risalpha(c) || risdigit(c));
}
RPM_GNUC_CONST
static inline int risblank(int c) {
return (c == ' ' || c == '\t');
}
RPM_GNUC_CONST
static inline int risspace(int c) {
return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
}
RPM_GNUC_CONST
static inline int rtolower(int c) {
return ((risupper(c)) ? (c | ('a' - 'A')) : c);
}
RPM_GNUC_CONST
static inline int rtoupper(int c) {
return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
}
RPM_GNUC_CONST
static inline unsigned char rnibble(char c)
{
if (c >= '0' && c <= '9')
return (c - '0');
if (c >= 'a' && c <= 'f')
return (c - 'a') + 10;
if (c >= 'A' && c <= 'F')
return (c - 'A') + 10;
return 0;
}
static inline int rstreq(const char *s1, const char *s2)
{
return (strcmp(s1, s2) == 0);
}
static inline int rstreqn(const char *s1, const char *s2, size_t n)
{
return (strncmp(s1, s2, n) == 0);
}
RPM_GNUC_PURE
int rstrcasecmp(const char * s1, const char * s2) ;
RPM_GNUC_PURE
int rstrncasecmp(const char *s1, const char * s2, size_t n) ;
int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
int rvasprintf(char **strp, const char *fmt, va_list ap);
char *rstrcat(char **dest, const char *src);
char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
size_t rstrlcpy(char *dest, const char *src, size_t n);
RPM_GNUC_PURE
unsigned int rstrhash(const char * string);
#ifdef __cplusplus
}
#endif
#endif /* _RPMSTRING_H_ */
RPM_GNUC_CONST
#define RPM_GNUC_CONST
Definition: rpmutil.h:72
rtolower
static RPM_GNUC_CONST int rtolower(int c)
Locale insensitive tolower(3)
Definition: rpmstring.h:79
risdigit
static RPM_GNUC_CONST int risdigit(int c)
Locale insensitive isdigit(3)
Definition: rpmstring.h:47
RPM_GNUC_NULL_TERMINATED
#define RPM_GNUC_NULL_TERMINATED
Definition: rpmutil.h:49
rtoupper
static RPM_GNUC_CONST int rtoupper(int c)
Locale insensitive toupper(3)
Definition: rpmstring.h:87
rstrhash
RPM_GNUC_PURE unsigned int rstrhash(const char *string)
String hashing function.
rstrcasecmp
RPM_GNUC_PURE int rstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
rnibble
static RPM_GNUC_CONST unsigned char rnibble(char c)
Convert hex to binary nibble.
Definition: rpmstring.h:97
rstreq
static int rstreq(const char *s1, const char *s2)
Test for string equality.
Definition: rpmstring.h:114
rstreqn
static int rstreqn(const char *s1, const char *s2, size_t n)
Test for string equality.
Definition: rpmstring.h:126
rstrscat
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory.
risalpha
static RPM_GNUC_CONST int risalpha(int c)
Locale insensitive isalpha(3)
Definition: rpmstring.h:39
rasprintf
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
asprintf() clone
risupper
static RPM_GNUC_CONST int risupper(int c)
Locale insensitive isupper(3)
Definition: rpmstring.h:31
rislower
static RPM_GNUC_CONST int rislower(int c)
Locale insensitive islower(3)
Definition: rpmstring.h:23
RPM_GNUC_PRINTF
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:68
rstrlcpy
size_t rstrlcpy(char *dest, const char *src, size_t n)
strlcpy() clone: Copy src to string dest of size n.
risspace
static RPM_GNUC_CONST int risspace(int c)
Locale insensitive isspace(3)
Definition: rpmstring.h:71
RPM_GNUC_PURE
#define RPM_GNUC_PURE
Definition: rpmutil.h:34
risblank
static RPM_GNUC_CONST int risblank(int c)
Locale insensitive isblank(3)
Definition: rpmstring.h:63
rstrcat
char * rstrcat(char **dest, const char *src)
Concatenate two strings with dynamically (re)allocated memory.
rvasprintf
int int rvasprintf(char **strp, const char *fmt, va_list ap)
vasprintf() clone
risalnum
static RPM_GNUC_CONST int risalnum(int c)
Locale insensitive isalnum(3)
Definition: rpmstring.h:55
rstrncasecmp
RPM_GNUC_PURE int rstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).