File: Strings.h

package info (click to toggle)
fvwm 1%3A2.5.18-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,084 kB
  • ctags: 14,319
  • sloc: ansic: 160,604; perl: 10,958; sh: 9,922; makefile: 1,109; yacc: 683; lex: 169; sed: 11
file content (75 lines) | stat: -rw-r--r-- 2,189 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* -*-c-*- */
#ifndef FVWMLIB_STRINGS_H
#define FVWMLIB_STRINGS_H


/**
 * Concatenate three strings.
 *
 * Parameters may be NULL to signify the empty string.
 *
 * Returns pointer to static storage, overwritten on the next call.
 **/
char *CatString3(const char *a, const char *b, const char *c);
#define CatString2(a,b) CatString3(a,b,NULL)


/**
 * Copy string into newly-malloced memory, stripping leading and
 * trailing spaces.  The string is terminated by either a NUL or
 * a newline character.
 **/
void CopyString(char **dest, const char *source);


/**
 * Like CopyString, but strips leading and trailing (double) quotes if any.
 **/
void CopyStringWithQuotes(char **dest, const char *src);


/**
 * Copy string into newly-malloced memory, stripping leading and
 * trailing spaces.  The difference between this and CopyString()
 * is that newlines are treated as whitespace by stripcpy(), whereas
 * CopyString() treats a newline as a string terminator (like the NUL
 * character.
 **/
char *stripcpy( const char *source );


/**
 * Return 1 if the two strings are equal.  Case is ignored.
 **/
int StrEquals( const char *s1, const char *s2 );


/**
 * Return 1 if the string has the given prefix.  Case is ignored.
 **/
int StrHasPrefix( const char* string, const char* prefix );

/**
 * Adds single quotes arround the string and escapes single quotes with
 * backslashes.  The result is placed in the given dest, not allocated.
 * The end of destination, i.e. pointer to '\0' is returned.
 * You should allocate dest yourself, at least strlen(source) * 2 + 3.
 **/
char *QuoteString(char *dest, const char *source);

/**
 * Adds delim around the source and escapes all characters in escape with
 * the corresponding escaper. The dest string must be preallocated.
 * delim should be included in escape with a proper escaper.
 * Returns a pointer to the end of dest.
 **/
char *QuoteEscapeString(char *dest, const char *source, char delim,
			const char *escape, const char *escaper);

/**
 * Calculates the lenght needed by a escaped by QuoteEscapeString
 * the corresponding escaper.
 **/
unsigned int QuoteEscapeStringLength(const char *source, const char *escape);

#endif