2
0

girstring.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef GIRSTRING_H_INCLUDED
  2. #define GIRSTRING_H_INCLUDED
  3. #include <string.h>
  4. #include "xmlrpc_config.h"
  5. #include "bool.h"
  6. bool
  7. stripcaseeq(const char * const comparand,
  8. const char * const comparator);
  9. static __inline__ bool
  10. streq(const char * const comparator,
  11. const char * const comparand) {
  12. return (strcmp(comparand, comparator) == 0);
  13. }
  14. static __inline__ bool
  15. memeq(const void * const comparator,
  16. const void * const comparand,
  17. size_t const size) {
  18. return (memcmp(comparator, comparand, size) == 0);
  19. }
  20. #define MEMEQ(a,b,c) (memcmp(a, b, c) == 0)
  21. #define MEMSSET(a,b) (memset(a, b, sizeof(*a)))
  22. #define MEMSCPY(a,b) (memcpy(a, b, sizeof(*a)))
  23. #define MEMSZERO(a) (MEMSSET(a, 0))
  24. static __inline__ const char *
  25. sdup(const char * const input) {
  26. return (const char *) strdup(input);
  27. }
  28. /* Copy string pointed by B to array A with size checking. */
  29. #define STRSCPY(A,B) \
  30. (strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
  31. #define STRSCMP(A,B) \
  32. (strncmp((A), (B), sizeof(A)))
  33. /* Concatenate string B onto string in array A with size checking */
  34. #define STRSCAT(A,B) \
  35. (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
  36. #endif