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

# rpmstring.h

Go to the documentation of this file.

    00001 #ifndef _RPMSTRING_H_
    00002 #define _RPMSTRING_H_
    00003
    00009 #include <stddef.h>
    00010
    00011 #include <rpm/rpmutil.h>
    00012
    00013 #ifdef __cplusplus
    00014 extern "C" {
    00015 #endif
    00016
    00020 static inline int rislower(int c)  {
    00021     return (c >= 'a' && c <= 'z');
    00022 }
    00023
    00027 static inline int risupper(int c)  {
    00028     return (c >= 'A' && c <= 'Z');
    00029 }
    00030
    00034 static inline int risalpha(int c)  {
    00035     return (rislower(c) || risupper(c));
    00036 }
    00037
    00041 static inline int risdigit(int c)  {
    00042     return (c >= '0' && c <= '9');
    00043 }
    00044
    00048 static inline int risalnum(int c)  {
    00049     return (risalpha(c) || risdigit(c));
    00050 }
    00051
    00055 static inline int risblank(int c)  {
    00056     return (c == ' ' || c == '\t');
    00057 }
    00058
    00062 static inline int risspace(int c)  {
    00063     return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
    00064 }
    00065
    00069 static inline int rtolower(int c)  {
    00070     return ((risupper(c)) ? (c | ('a' - 'A')) : c);
    00071 }
    00072
    00076 static inline int rtoupper(int c)  {
    00077     return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
    00078 }
    00079
    00085 static inline unsigned char rnibble(char c)
    00086 {
    00087     if (c >= '0' && c <= '9')
    00088         return (c - '0');
    00089     if (c >= 'A' && c <= 'F')
    00090         return (c - 'A') + 10;
    00091     if (c >= 'a' && c <= 'f')
    00092         return (c - 'a') + 10;
    00093     return 0;
    00094 }
    00095
    00099 int rstrcasecmp(const char * s1, const char * s2)               ;
    00100
    00104 int rstrncasecmp(const char *s1, const char * s2, size_t n)     ;
    00105
    00109 int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
    00110
    00117 char *rstrcat(char **dest, const char *src);
    00118
    00125 char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
    00126
    00137 size_t rstrlcpy(char *dest, const char *src, size_t n);
    00138
    00145 char * stripTrailingChar(char * s, char c);
    00146
    00149 typedef struct StringBufRec *StringBuf;
    00150
    00153 StringBuf newStringBuf(void);
    00154
    00157 StringBuf freeStringBuf( StringBuf sb);
    00158
    00161 void truncStringBuf(StringBuf sb);
    00162
    00165 char * getStringBuf(StringBuf sb);
    00166
    00169 void stripTrailingBlanksStringBuf(StringBuf sb);
    00170
    00173 #define appendStringBuf(sb, s)     appendStringBufAux(sb, s, 0)
    00174
    00177 #define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
    00178
    00181 void appendStringBufAux(StringBuf sb, const char * s, int nl);
    00182
    00183 #ifdef __cplusplus
    00184 }
    00185 #endif
    00186
    00187 #endif  /* _RPMSTRING_H_ */