rpm 4.19.0
The RPM Package Manager
Loading...
Searching...
No Matches
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#include <stdint.h>
13
14#include <rpm/rpmutil.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
23RPM_GNUC_CONST
24static inline int rislower(int c) {
25 return (c >= 'a' && c <= 'z');
26}
27
31RPM_GNUC_CONST
32static inline int risupper(int c) {
33 return (c >= 'A' && c <= 'Z');
34}
35
39RPM_GNUC_CONST
40static inline int risalpha(int c) {
41 return (rislower(c) || risupper(c));
42}
43
47RPM_GNUC_CONST
48static inline int risdigit(int c) {
49 return (c >= '0' && c <= '9');
50}
51
55RPM_GNUC_CONST
56static inline int risalnum(int c) {
57 return (risalpha(c) || risdigit(c));
58}
59
63RPM_GNUC_CONST
64static inline int risblank(int c) {
65 return (c == ' ' || c == '\t');
66}
67
71RPM_GNUC_CONST
72static inline int risspace(int c) {
73 return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
74}
75
79RPM_GNUC_CONST
80static inline int rtolower(int c) {
81 return ((risupper(c)) ? (c | ('a' - 'A')) : c);
82}
83
87RPM_GNUC_CONST
88static inline int rtoupper(int c) {
89 return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
90}
91
97RPM_GNUC_CONST
98static inline unsigned char rnibble(char c)
99{
100 if (c >= '0' && c <= '9')
101 return (c - '0');
102 if (c >= 'a' && c <= 'f')
103 return (c - 'a') + 10;
104 if (c >= 'A' && c <= 'F')
105 return (c - 'A') + 10;
106 return 0;
107}
108
115static inline int rstreq(const char *s1, const char *s2)
116{
117 return (strcmp(s1, s2) == 0);
118}
119
127static inline int rstreqn(const char *s1, const char *s2, size_t n)
128{
129 return (strncmp(s1, s2, n) == 0);
130}
131
135RPM_GNUC_PURE
136int rstrcasecmp(const char * s1, const char * s2) ;
137
141RPM_GNUC_PURE
142int rstrncasecmp(const char *s1, const char * s2, size_t n) ;
143
147int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
148
152int rvasprintf(char **strp, const char *fmt, va_list ap);
153
160char *rstrcat(char **dest, const char *src);
161
168char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
169
180size_t rstrlcpy(char *dest, const char *src, size_t n);
181
187RPM_GNUC_PURE
188unsigned int rstrhash(const char * string);
189
196char * rpmhex(const uint8_t *p, size_t plen);
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif /* _RPMSTRING_H_ */
RPM_GNUC_PURE unsigned int rstrhash(const char *string)
char * rstrcat(char **dest, const char *src)
int int rvasprintf(char **strp, const char *fmt, va_list ap)
RPM_GNUC_PURE int rstrcasecmp(const char *s1, const char *s2)
size_t rstrlcpy(char *dest, const char *src, size_t n)
char * rpmhex(const uint8_t *p, size_t plen)
RPM_GNUC_PURE int rstrncasecmp(const char *s1, const char *s2, size_t n)
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2