Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.8 KiB

  1. #ifndef STR_H
  2. #define STR_H
  3. #ifdef __dietlibc__
  4. #include <sys/cdefs.h>
  5. #endif
  6. #ifndef __pure__
  7. #define __pure__
  8. #endif
  9. /* str_copy copies leading bytes from in to out until \0.
  10. * return number of copied bytes. */
  11. extern unsigned long str_copy(char *out,const char *in);
  12. /* str_diff returns negative, 0, or positive, depending on whether the
  13. * string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than,
  14. * equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'.
  15. * If the strings are different, str_diff does not read bytes past the
  16. * first difference. */
  17. extern int str_diff(const char *a,const char *b) __pure__;
  18. /* str_diffn returns negative, 0, or positive, depending on whether the
  19. * string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than,
  20. * equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'.
  21. * If the strings are different, str_diffn does not read bytes past the
  22. * first difference. The strings will be considered equal if the first
  23. * limit characters match. */
  24. extern int str_diffn(const char *a,const char *b,unsigned long limit) __pure__;
  25. #ifdef __dietlibc__
  26. #include <string.h>
  27. #define str_len(foo) strlen(foo)
  28. #else
  29. /* str_len returns the index of \0 in s */
  30. extern unsigned long str_len(const char *s) __pure__;
  31. #endif
  32. /* str_chr returns the index of the first occurance of needle or \0 in haystack */
  33. extern unsigned long str_chr(const char *haystack,char needle) __pure__;
  34. /* str_rchr returns the index of the last occurance of needle or \0 in haystack */
  35. extern unsigned long str_rchr(const char *haystack,char needle) __pure__;
  36. /* str_start returns 1 if the b is a prefix of a, 0 otherwise */
  37. extern int str_start(const char *a,const char *b) __pure__;
  38. /* convenience shortcut to test for string equality */
  39. #define str_equal(s,t) (!str_diff((s),(t)))
  40. #endif