initial load of upstream version 1.06.32
[xmlrpc-c] / lib / util / include / girstring.h
1 #ifndef GIRSTRING_H_INCLUDED
2 #define GIRSTRING_H_INCLUDED
3
4 #include <string.h>
5 #include "bool.h"
6
7 char
8 stripeq(const char * const comparand, const char * const comparator);
9
10 char
11 stripcaseeq(const char * const comparand, const char * const comparator);
12
13 void
14 stripcpy(char * dest, const char * source);
15
16 void
17 stripcasecpy(char * dest, const char * source);
18
19 char *
20 stripdup(const char * const input);
21
22 char *
23 strcasedup(const char input[]);
24
25 static __inline__ bool
26 streq(const char * const comparator,
27       const char * const comparand) {
28
29     return (strcmp(comparand, comparator) == 0);
30 }
31
32 static __inline__ const char *
33 sdup(const char * const input) {
34     return (const char *) strdup(input);
35 }
36
37 /* Copy string pointed by B to array A with size checking.  */
38 #define SSTRCPY(A,B) \
39         (strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
40 #define SSTRCMP(A,B) \
41         (strncmp((A), (B), sizeof(A)))
42
43 /* Concatenate string B onto string in array A with size checking */
44 #define STRSCAT(A,B) \
45     (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
46
47 #endif