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.
 
 
 
 

41 lines
1.4 KiB

  1. #ifndef BYTE_H
  2. #define BYTE_H
  3. #ifdef __dietlibc__
  4. #include <sys/cdefs.h>
  5. #endif
  6. #ifndef __pure__
  7. #define __pure__
  8. #endif
  9. /* byte_chr returns the smallest integer i between 0 and len-1
  10. * inclusive such that one[i] equals needle, or len if not found. */
  11. unsigned long byte_chr(const void* haystack, unsigned long len, char needle) __pure__;
  12. /* byte_rchr returns the largest integer i between 0 and len-1 inclusive
  13. * such that one[i] equals needle, or len if not found. */
  14. unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) __pure__;
  15. /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
  16. * to out[len-1]. */
  17. void byte_copy(void* out, unsigned long len, const void* in);
  18. /* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2],
  19. * ... and in[0] to out[0] */
  20. void byte_copyr(void* out, unsigned long len, const void* in);
  21. /* byte_diff returns negative, 0, or positive, depending on whether the
  22. * string a[0], a[1], ..., a[len-1] is lexicographically smaller
  23. * than, equal to, or greater than the string b[0], b[1], ...,
  24. * b[len-1]. When the strings are different, byte_diff does not read
  25. * bytes past the first difference. */
  26. int byte_diff(const void* a, unsigned long len, const void* b) __pure__;
  27. /* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
  28. void byte_zero(void* out, unsigned long len);
  29. #define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
  30. #endif