rpm  4.12.0.1
rpmstring.h
Go to the documentation of this file.
1 #ifndef _RPMSTRING_H_
2 #define _RPMSTRING_H_
3 
9 #include <stddef.h>
10 #include <string.h>
11 
12 #include <rpm/rpmutil.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
22 static inline int rislower(int c) {
23  return (c >= 'a' && c <= 'z');
24 }
25 
30 static inline int risupper(int c) {
31  return (c >= 'A' && c <= 'Z');
32 }
33 
38 static inline int risalpha(int c) {
39  return (rislower(c) || risupper(c));
40 }
41 
46 static inline int risdigit(int c) {
47  return (c >= '0' && c <= '9');
48 }
49 
54 static inline int risalnum(int c) {
55  return (risalpha(c) || risdigit(c));
56 }
57 
62 static inline int risblank(int c) {
63  return (c == ' ' || c == '\t');
64 }
65 
70 static inline int risspace(int c) {
71  return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
72 }
73 
78 static inline int rtolower(int c) {
79  return ((risupper(c)) ? (c | ('a' - 'A')) : c);
80 }
81 
86 static inline int rtoupper(int c) {
87  return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
88 }
89 
96 static inline unsigned char rnibble(char c)
97 {
98  if (c >= '0' && c <= '9')
99  return (c - '0');
100  if (c >= 'a' && c <= 'f')
101  return (c - 'a') + 10;
102  if (c >= 'A' && c <= 'F')
103  return (c - 'A') + 10;
104  return 0;
105 }
106 
113 static inline int rstreq(const char *s1, const char *s2)
114 {
115  return (strcmp(s1, s2) == 0);
116 }
117 
125 static inline int rstreqn(const char *s1, const char *s2, size_t n)
126 {
127  return (strncmp(s1, s2, n) == 0);
128 }
129 
134 int rstrcasecmp(const char * s1, const char * s2) ;
135 
140 int rstrncasecmp(const char *s1, const char * s2, size_t n) ;
141 
145 int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
146 
153 char *rstrcat(char **dest, const char *src);
154 
161 char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
162 
173 size_t rstrlcpy(char *dest, const char *src, size_t n);
174 
181 unsigned int rstrhash(const char * string);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* _RPMSTRING_H_ */
#define RPM_GNUC_CONST
Definition: rpmutil.h:71
static RPM_GNUC_CONST int rtolower(int c)
Locale insensitive tolower(3)
Definition: rpmstring.h:78
static RPM_GNUC_CONST int risdigit(int c)
Locale insensitive isdigit(3)
Definition: rpmstring.h:46
#define RPM_GNUC_NULL_TERMINATED
Definition: rpmutil.h:48
static RPM_GNUC_CONST int rtoupper(int c)
Locale insensitive toupper(3)
Definition: rpmstring.h:86
RPM_GNUC_PURE unsigned int rstrhash(const char *string)
String hashing function.
RPM_GNUC_PURE int rstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
static RPM_GNUC_CONST unsigned char rnibble(char c)
Convert hex to binary nibble.
Definition: rpmstring.h:96
static int rstreq(const char *s1, const char *s2)
Test for string equality.
Definition: rpmstring.h:113
static int rstreqn(const char *s1, const char *s2, size_t n)
Test for string equality.
Definition: rpmstring.h:125
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory.
static RPM_GNUC_CONST int risalpha(int c)
Locale insensitive isalpha(3)
Definition: rpmstring.h:38
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
asprintf() clone
static RPM_GNUC_CONST int risupper(int c)
Locale insensitive isupper(3)
Definition: rpmstring.h:30
static RPM_GNUC_CONST int rislower(int c)
Locale insensitive islower(3)
Definition: rpmstring.h:22
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:67
size_t rstrlcpy(char *dest, const char *src, size_t n)
strlcpy() clone: Copy src to string dest of size n.
static RPM_GNUC_CONST int risspace(int c)
Locale insensitive isspace(3)
Definition: rpmstring.h:70
int char * rstrcat(char **dest, const char *src)
Concatenate two strings with dynamically (re)allocated memory.
#define RPM_GNUC_PURE
Definition: rpmutil.h:33
static RPM_GNUC_CONST int risblank(int c)
Locale insensitive isblank(3)
Definition: rpmstring.h:62
static RPM_GNUC_CONST int risalnum(int c)
Locale insensitive isalnum(3)
Definition: rpmstring.h:54
RPM_GNUC_PURE int rstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).