Propagate Layer changes via Style command on-the-fly.
[fvwm.git] / libs / Strings.h
bloba926fecc3ba642376b2cd1354748d0badd566afb
1 /* -*-c-*- */
2 #ifndef FVWMLIB_STRINGS_H
3 #define FVWMLIB_STRINGS_H
6 /**
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.
12 **/
13 char *CatString3(const char *a, const char *b, const char *c);
14 #define CatString2(a,b) CatString3(a,b,NULL)
17 /**
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.
21 **/
22 void CopyString(char **dest, const char *source);
25 /**
26 * Like CopyString, but strips leading and trailing (double) quotes if any.
27 **/
28 void CopyStringWithQuotes(char **dest, const char *src);
31 /**
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
36 * character.
37 **/
38 char *stripcpy( const char *source );
41 /**
42 * Return 1 if the two strings are equal. Case is ignored.
43 **/
44 int StrEquals( const char *s1, const char *s2 );
47 /**
48 * Return 1 if the string has the given prefix. Case is ignored.
49 **/
50 int StrHasPrefix( const char* string, const char* prefix );
52 /**
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.
57 **/
58 char *QuoteString(char *dest, const char *source);
60 /**
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.
65 **/
66 char *QuoteEscapeString(char *dest, const char *source, char delim,
67 const char *escape, const char *escaper);
69 /**
70 * Calculates the lenght needed by a escaped by QuoteEscapeString
71 * the corresponding escaper.
72 **/
73 unsigned int QuoteEscapeStringLength(const char *source, const char *escape);
75 #endif