2007-11-23 14:11:42 +08:00
|
|
|
#ifndef _RPMSTRING_H_
|
|
|
|
#define _RPMSTRING_H_
|
1995-12-14 00:01:36 +08:00
|
|
|
|
2007-11-23 14:11:42 +08:00
|
|
|
/** \file rpmio/rpmstring.h
|
2000-08-28 03:27:03 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-11-23 14:32:08 +08:00
|
|
|
static inline int xislower(int c) {
|
|
|
|
return (c >= 'a' && c <= 'z');
|
|
|
|
}
|
|
|
|
static inline int xisupper(int c) {
|
|
|
|
return (c >= 'A' && c <= 'Z');
|
|
|
|
}
|
|
|
|
static inline int xisalpha(int c) {
|
|
|
|
return (xislower(c) || xisupper(c));
|
|
|
|
}
|
|
|
|
static inline int xisdigit(int c) {
|
|
|
|
return (c >= '0' && c <= '9');
|
|
|
|
}
|
|
|
|
static inline int xisalnum(int c) {
|
|
|
|
return (xisalpha(c) || xisdigit(c));
|
|
|
|
}
|
|
|
|
static inline int xisblank(int c) {
|
|
|
|
return (c == ' ' || c == '\t');
|
|
|
|
}
|
|
|
|
static inline int xisspace(int c) {
|
|
|
|
return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int xtolower(int c) {
|
|
|
|
return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
|
|
|
|
}
|
|
|
|
static inline int xtoupper(int c) {
|
|
|
|
return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \ingroup rpmio
|
|
|
|
* Locale insensitive strcasecmp(3).
|
|
|
|
*/
|
|
|
|
int xstrcasecmp(const char * s1, const char * s2) ;
|
|
|
|
|
|
|
|
/** \ingroup rpmio
|
|
|
|
* Locale insensitive strncasecmp(3).
|
|
|
|
*/
|
|
|
|
int xstrncasecmp(const char *s1, const char * s2, size_t n) ;
|
|
|
|
|
2007-11-23 14:21:23 +08:00
|
|
|
/**
|
|
|
|
* Split string into fields separated by a character.
|
|
|
|
* @param str string
|
|
|
|
* @param length length of string
|
|
|
|
* @param sep separator character
|
|
|
|
* @return (malloc'd) argv array
|
|
|
|
*/
|
|
|
|
char ** splitString(const char * str, int length, char sep);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free split string argv array.
|
|
|
|
* @param list argv array
|
|
|
|
*/
|
|
|
|
void freeSplitString( char ** list);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove occurences of trailing character from string.
|
|
|
|
* @param s string
|
|
|
|
* @param c character to strip
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
char * stripTrailingChar(char * s, char c);
|
|
|
|
|
2007-10-08 16:05:06 +08:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
typedef struct StringBufRec *StringBuf;
|
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
StringBuf newStringBuf(void);
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
StringBuf freeStringBuf( StringBuf sb);
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
void truncStringBuf(StringBuf sb);
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
char * getStringBuf(StringBuf sb);
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
void stripTrailingBlanksStringBuf(StringBuf sb);
|
1995-12-14 00:01:36 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/**
|
|
|
|
*/
|
1995-12-14 00:01:36 +08:00
|
|
|
#define appendStringBuf(sb, s) appendStringBufAux(sb, s, 0)
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
1995-12-14 00:01:36 +08:00
|
|
|
#define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
|
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
void appendStringBufAux(StringBuf sb, const char * s, int nl);
|
1995-12-14 00:01:36 +08:00
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-11-23 14:11:42 +08:00
|
|
|
#endif /* _RPMSTRING_H_ */
|