2 #ifndef FVWMLIB_STRINGS_H
3 #define FVWMLIB_STRINGS_H
7 * Concatenate three strings.
9 * Parameters may be NULL to signify the empty string.
11 * Returns pointer to static storage, overwritten on the next call.
13 char *CatString3(const char *a
, const char *b
, const char *c
);
14 #define CatString2(a,b) CatString3(a,b,NULL)
18 * Copy string into newly-malloced memory, stripping leading and
19 * trailing spaces. The string is terminated by either a NUL or
20 * a newline character.
22 void CopyString(char **dest
, const char *source
);
26 * Like CopyString, but strips leading and trailing (double) quotes if any.
28 void CopyStringWithQuotes(char **dest
, const char *src
);
32 * Copy string into newly-malloced memory, stripping leading and
33 * trailing spaces. The difference between this and CopyString()
34 * is that newlines are treated as whitespace by stripcpy(), whereas
35 * CopyString() treats a newline as a string terminator (like the NUL
38 char *stripcpy( const char *source
);
42 * Return 1 if the two strings are equal. Case is ignored.
44 int StrEquals( const char *s1
, const char *s2
);
48 * Return 1 if the string has the given prefix. Case is ignored.
50 int StrHasPrefix( const char* string
, const char* prefix
);
53 * Adds single quotes arround the string and escapes single quotes with
54 * backslashes. The result is placed in the given dest, not allocated.
55 * The end of destination, i.e. pointer to '\0' is returned.
56 * You should allocate dest yourself, at least strlen(source) * 2 + 3.
58 char *QuoteString(char *dest
, const char *source
);
61 * Adds delim around the source and escapes all characters in escape with
62 * the corresponding escaper. The dest string must be preallocated.
63 * delim should be included in escape with a proper escaper.
64 * Returns a pointer to the end of dest.
66 char *QuoteEscapeString(char *dest
, const char *source
, char delim
,
67 const char *escape
, const char *escaper
);
70 * Calculates the lenght needed by a escaped by QuoteEscapeString
71 * the corresponding escaper.
73 unsigned int QuoteEscapeStringLength(const char *source
, const char *escape
);