rpm 4.15.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 #include <stdarg.h>
12
13 #include <rpm/rpmutil.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
22 RPM_GNUC_CONST
23 static inline int rislower(int c) {
24 return (c >= 'a' && c <= 'z');
25 }
26
30 RPM_GNUC_CONST
31 static inline int risupper(int c) {
32 return (c >= 'A' && c <= 'Z');
33 }
34
38 RPM_GNUC_CONST
39 static inline int risalpha(int c) {
40 return (rislower(c) || risupper(c));
41 }
42
46 RPM_GNUC_CONST
47 static inline int risdigit(int c) {
48 return (c >= '0' && c <= '9');
49 }
50
54 RPM_GNUC_CONST
55 static inline int risalnum(int c) {
56 return (risalpha(c) || risdigit(c));
57 }
58
62 RPM_GNUC_CONST
63 static inline int risblank(int c) {
64 return (c == ' ' || c == '\t');
65 }
66
70 RPM_GNUC_CONST
71 static inline int risspace(int c) {
72 return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
73 }
74
78 RPM_GNUC_CONST
79 static inline int rtolower(int c) {
80 return ((risupper(c)) ? (c | ('a' - 'A')) : c);
81 }
82
86 RPM_GNUC_CONST
87 static inline int rtoupper(int c) {
88 return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
89 }
90
96 RPM_GNUC_CONST
97 static inline unsigned char rnibble(char c)
98 {
99 if (c >= '0' && c <= '9')
100 return (c - '0');
101 if (c >= 'a' && c <= 'f')
102 return (c - 'a') + 10;
103 if (c >= 'A' && c <= 'F')
104 return (c - 'A') + 10;
105 return 0;
106 }
107
114 static inline int rstreq(const char *s1, const char *s2)
115 {
116 return (strcmp(s1, s2) == 0);
117 }
118
126 static inline int rstreqn(const char *s1, const char *s2, size_t n)
127 {
128 return (strncmp(s1, s2, n) == 0);
129 }
130
134 RPM_GNUC_PURE
135 int rstrcasecmp(const char * s1, const char * s2) ;
136
140 RPM_GNUC_PURE
141 int rstrncasecmp(const char *s1, const char * s2, size_t n) ;
142
146 int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
147
151 int rvasprintf(char **strp, const char *fmt, va_list ap);
152
159 char *rstrcat(char **dest, const char *src);
160
167 char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
168
179 size_t rstrlcpy(char *dest, const char *src, size_t n);
180
186 RPM_GNUC_PURE
187 unsigned int rstrhash(const char * string);
188
189 #ifdef __cplusplus
190 }
191 #endif
192
193 #endif /* _RPMSTRING_H_ */
risdigit
static RPM_GNUC_CONST int risdigit(int c)
Definition: rpmstring.h:47
rstrhash
RPM_GNUC_PURE unsigned int rstrhash(const char *string)
rstrncasecmp
RPM_GNUC_PURE int rstrncasecmp(const char *s1, const char *s2, size_t n)
RPM_GNUC_NULL_TERMINATED
#define RPM_GNUC_NULL_TERMINATED
Definition: rpmutil.h:49
RPM_GNUC_PRINTF
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:68
rstrscat
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
risupper
static RPM_GNUC_CONST int risupper(int c)
Definition: rpmstring.h:31
rstrcat
char * rstrcat(char **dest, const char *src)
risblank
static RPM_GNUC_CONST int risblank(int c)
Definition: rpmstring.h:63
rstrcasecmp
RPM_GNUC_PURE int rstrcasecmp(const char *s1, const char *s2)
RPM_GNUC_PURE
#define RPM_GNUC_PURE
Definition: rpmutil.h:34
rtoupper
static RPM_GNUC_CONST int rtoupper(int c)
Definition: rpmstring.h:87
rasprintf
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
rstreqn
static int rstreqn(const char *s1, const char *s2, size_t n)
Test for string equality.
Definition: rpmstring.h:126
rtolower
static RPM_GNUC_CONST int rtolower(int c)
Definition: rpmstring.h:79
rnibble
static RPM_GNUC_CONST unsigned char rnibble(char c)
Convert hex to binary nibble.
Definition: rpmstring.h:97
risspace
static RPM_GNUC_CONST int risspace(int c)
Definition: rpmstring.h:71
risalpha
static RPM_GNUC_CONST int risalpha(int c)
Definition: rpmstring.h:39
rstreq
static int rstreq(const char *s1, const char *s2)
Test for string equality.
Definition: rpmstring.h:114
rvasprintf
int int rvasprintf(char **strp, const char *fmt, va_list ap)
rislower
static RPM_GNUC_CONST int rislower(int c)
Definition: rpmstring.h:23
rstrlcpy
size_t rstrlcpy(char *dest, const char *src, size_t n)
RPM_GNUC_CONST
#define RPM_GNUC_CONST
Definition: rpmutil.h:72
risalnum
static RPM_GNUC_CONST int risalnum(int c)
Definition: rpmstring.h:55