2001-02-02 17:54:47 +00:00
|
|
|
#ifndef BYTE_H
|
|
|
|
#define BYTE_H
|
|
|
|
|
2002-09-16 01:09:56 +00:00
|
|
|
#ifdef __dietlibc__
|
2001-02-02 17:54:47 +00:00
|
|
|
#include <sys/cdefs.h>
|
2002-09-16 01:09:56 +00:00
|
|
|
#endif
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
#ifndef __pure__
|
|
|
|
#define __pure__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* byte_chr returns the smallest integer i between 0 and len-1
|
2002-09-15 22:45:51 +00:00
|
|
|
* inclusive such that one[i] equals needle, or len if not found. */
|
2003-08-26 17:58:14 +00:00
|
|
|
unsigned long byte_chr(const void* haystack, unsigned long len, char needle) __pure__;
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
/* byte_rchr returns the largest integer i between 0 and len-1 inclusive
|
|
|
|
* such that one[i] equals needle, or len if not found. */
|
2003-08-26 17:58:14 +00:00
|
|
|
unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) __pure__;
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
/* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
|
|
|
|
* to out[len-1]. */
|
2003-08-26 17:58:14 +00:00
|
|
|
void byte_copy(void* out, unsigned long len, const void* in);
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
/* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2],
|
|
|
|
* ... and in[0] to out[0] */
|
2003-08-26 17:58:14 +00:00
|
|
|
void byte_copyr(void* out, unsigned long len, const void* in);
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
/* byte_diff returns negative, 0, or positive, depending on whether the
|
|
|
|
* string a[0], a[1], ..., a[len-1] is lexicographically smaller
|
|
|
|
* than, equal to, or greater than the string b[0], b[1], ...,
|
|
|
|
* b[len-1]. When the strings are different, byte_diff does not read
|
|
|
|
* bytes past the first difference. */
|
2003-08-26 17:58:14 +00:00
|
|
|
int byte_diff(const void* a, unsigned long len, const void* b) __pure__;
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
/* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
|
2003-08-26 17:58:14 +00:00
|
|
|
void byte_zero(void* out, unsigned long len);
|
2001-02-02 17:54:47 +00:00
|
|
|
|
|
|
|
#define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
|
|
|
|
|
|
|
|
#endif
|