- 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
    00011 #include <rpm/rpmutil.h>
    00012
    00013 #ifdef __cplusplus
    00014 extern "C" {
    00015 #endif
    00016
    00020 RPM_GNUC_CONST
    00021 static inline int rislower(int c)  {
    00022     return (c >= 'a' && c <= 'z');
    00023 }
    00024
    00028 RPM_GNUC_CONST
    00029 static inline int risupper(int c)  {
    00030     return (c >= 'A' && c <= 'Z');
    00031 }
    00032
    00036 RPM_GNUC_CONST
    00037 static inline int risalpha(int c)  {
    00038     return (rislower(c) || risupper(c));
    00039 }
    00040
    00044 RPM_GNUC_CONST
    00045 static inline int risdigit(int c)  {
    00046     return (c >= '0' && c <= '9');
    00047 }
    00048
    00052 RPM_GNUC_CONST
    00053 static inline int risalnum(int c)  {
    00054     return (risalpha(c) || risdigit(c));
    00055 }
    00056
    00060 RPM_GNUC_CONST
    00061 static inline int risblank(int c)  {
    00062     return (c == ' ' || c == '\t');
    00063 }
    00064
    00068 RPM_GNUC_CONST
    00069 static inline int risspace(int c)  {
    00070     return (risblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
    00071 }
    00072
    00076 RPM_GNUC_CONST
    00077 static inline int rtolower(int c)  {
    00078     return ((risupper(c)) ? (c | ('a' - 'A')) : c);
    00079 }
    00080
    00084 RPM_GNUC_CONST
    00085 static inline int rtoupper(int c)  {
    00086     return ((rislower(c)) ? (c & ~('a' - 'A')) : c);
    00087 }
    00088
    00094 RPM_GNUC_CONST
    00095 static inline unsigned char rnibble(char c)
    00096 {
    00097     if (c >= '0' && c <= '9')
    00098         return (c - '0');
    00099     if (c >= 'A' && c <= 'F')
    00100         return (c - 'A') + 10;
    00101     if (c >= 'a' && c <= 'f')
    00102         return (c - 'a') + 10;
    00103     return 0;
    00104 }
    00105
    00109 RPM_GNUC_PURE
    00110 int rstrcasecmp(const char * s1, const char * s2)               ;
    00111
    00115 RPM_GNUC_PURE
    00116 int rstrncasecmp(const char *s1, const char * s2, size_t n)     ;
    00117
    00121 int rasprintf(char **strp, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
    00122
    00129 char *rstrcat(char **dest, const char *src);
    00130
    00137 char *rstrscat(char **dest, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
    00138
    00149 size_t rstrlcpy(char *dest, const char *src, size_t n);
    00150
    00157 char * stripTrailingChar(char * s, char c);
    00158
    00161 typedef struct StringBufRec *StringBuf;
    00162
    00165 StringBuf newStringBuf(void);
    00166
    00169 StringBuf freeStringBuf( StringBuf sb);
    00170
    00173 void truncStringBuf(StringBuf sb);
    00174
    00177 char * getStringBuf(StringBuf sb);
    00178
    00181 void stripTrailingBlanksStringBuf(StringBuf sb);
    00182
    00185 #define appendStringBuf(sb, s)     appendStringBufAux(sb, s, 0)
    00186
    00189 #define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
    00190
    00193 void appendStringBufAux(StringBuf sb, const char * s, int nl);
    00194
    00195 #ifdef __cplusplus
    00196 }
    00197 #endif
    00198
    00199 #endif  /* _RPMSTRING_H_ */