bstring(3) CLIX bstring(3)
NAME
bstring: bcopy, bcmp, bzero, ffs - Provides bit/byte string operations
LIBRARY
Berkeley Software Distribution Library (libbsd.a)
SYNOPSIS
int bcopy(
char *source ,
char *destination ,
int length );
int bcmp(
char *b1 ,
char *b2 ,
int length );
int bzero(
char *b1 ,
int length );
int ffs(
int i );
PARAMETERS
source Points to a source string.
destination Points to a destination string.
length Specifies the length in bytes of strings to be copied or
compared.
b1 Points to a byte string.
b2 Points to a byte string.
i Represents a string of bits.
DESCRIPTION
The bcopy(), bcmp(), and bzero() functions operate on variable-length
strings. They do not check for null bytes as do the functions in
string(). The ffs() function operates on bit strings.
EXAMPLES
To copy one block of memory to another:
2/94 - Intergraph Corporation 1
bstring(3) CLIX bstring(3)
char a[80],b[80];
int i,bit;
extern int bcopy(),bcmp(),bzero(),ffs();
bcopy(a,b,80);
To test two blocks for equality:
if(bcmp(a,b,80)!=0)
printf("Blocks not equal.\n");
To zero out a block of memory:
bzero(a,80);
To find the location of the first set bit in an integer:
bit=ffs(i);
printf("The set bit is %d.\n",bit);
NOTES
The bcopy() function reverses parameters from strcpy().
RETURN VALUES
The bcopy() function copies length bytes from string source to the string
destination.
The bzero() function places length 0 bytes in the string b1.
The bcmp() function compares byte string b1 to byte string b2, returning 0
if they are identical, and nonzero otherwise. Both strings are assumed to
be length bytes long.
The ffs() function finds the first bit set in the argument passed and
returns the index of that bit. Bits are numbered starting with 1. A
returned value of 0 indicates the value passed is 0.
2 Intergraph Corporation - 2/94