- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# rpmstring.h

Go to the documentation of this file.

    00001 #ifndef _RPMSTRING_H_
    00002 #define _RPMSTRING_H_
    00003
    00009 #include <stddef.h>
    00010 #include <string.h>
    00011
    00012 #include <rpm/rpmutil.h>
    00013
    00014 #ifdef __cplusplus
    00015 extern "C" {
    00016 #endif
    00017
    00021 RPM_GNUC_CONST
    00022 static inline int rislower(int c)  {
    00023     return (c >= 'a' && c <= 'z');
    00024 }
    00025
    00029 RPM_GNUC_CONST
    00030 static inline int risupper(int c)  {
    00031     return (c >= 'A' && c <= 'Z');
    00032 }
    00033
    00037 RPM_GNUC_CONST
    00038 static inline int risalpha(int c)  {
    00039     return (rislower(c) || risupper(c));
    00040 }
    00041
    00045 RPM_GNUC_CONST
    00046 static inline int risdigit(int c)  {
    00047     return (c >= '0' && c <= '9');
    00048 }
    00049
    00053 RPM_GNUC_CONST
    00054 static inline int risalnum(int c)  {
    00055     return (risalpha(c) || risdigit(c));
    00056 }
    00057
    00061 RPM_GNUC_CONST
    00062 static inline int risblank(int c)  {
    00063     return (c == ' ' || c == '\t');
    00064 }
    00065
    00069 RPM_GNUC_CONST
    00070 static inline int risspace(int c)  {
    00071     return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
    00072 }
    00073
    00077 RPM_GNUC_CONST
    00078 static inline int rtolower(int c)  {
    00079     return ((risupper(c)) ? (c | ('a' - 'A')) : c);
    00080 }
    00081
    00085 RPM_GNUC_CONST
    00086 static inline int rtoupper(int c)  {
    00087     return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
    00088 }
    00089
    00095 RPM_GNUC_CONST
    00096 static inline unsigned char rnibble(char c)
    00097 {
    00098     if (c >= '0' && c <= '9')
    00099         return (c - '0');
    00100     if (c >= 'A' && c <= 'F')
    00101         return (c - 'A') + 10;
    00102     if (c >= 'a' && c <= 'f')
    00103         return (c - 'a') + 10;
    00104     return 0;
    00105 }
    00106
    00113 static inline int rstreq(const char *s1, const char *s2)
    00114 {
    00115     return (strcmp(s1, s2) == 0);
    00116 }
    00117
    00125 static inline int rstreqn(const char *s1, const char *s2, size_t n)
    00126 {
    00127     return (strncmp(s1, s2, n) == 0);
    00128 }
    00129
    00133 RPM_GNUC_PURE
    00134 int rstrcasecmp(const char * s1, const char * s2)               ;
    00135
    00139 RPM_GNUC_PURE
    00140 int rstrncasecmp(const char *s1, const char * s2, size_t n)     ;
    00141
    00145 int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
    00146
    00153 char *rstrcat(char **dest, const char *src);
    00154
    00161 char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
    00162
    00173 size_t rstrlcpy(char *dest, const char *src, size_t n);
    00174
    00181 char * stripTrailingChar(char * s, char c);
    00182
    00185 typedef struct StringBufRec *StringBuf;
    00186
    00189 StringBuf newStringBuf(void);
    00190
    00193 StringBuf freeStringBuf( StringBuf sb);
    00194
    00197 void truncStringBuf(StringBuf sb);
    00198
    00201 char * getStringBuf(StringBuf sb);
    00202
    00205 void stripTrailingBlanksStringBuf(StringBuf sb);
    00206
    00209 #define appendStringBuf(sb, s)     appendStringBufAux(sb, s, 0)
    00210
    00213 #define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
    00214
    00217 void appendStringBufAux(StringBuf sb, const char * s, int nl);
    00218
    00219 #ifdef __cplusplus
    00220 }
    00221 #endif
    00222
    00223 #endif  /* _RPMSTRING_H_ */