VxWorks Reference Manual : Libraries

bLib

NAME

bLib - buffer manipulation library

ROUTINES

bcmp( ) - compare one buffer to another
binvert( ) - invert the order of bytes in a buffer
bswap( ) - swap buffers
swab( ) - swap bytes
uswab( ) - swap bytes with buffers that are not necessarily aligned
bzero( ) - zero out a buffer
bcopy( ) - copy one buffer to another
bcopyBytes( ) - copy one buffer to another one byte at a time
bcopyWords( ) - copy one buffer to another one word at a time
bcopyLongs( ) - copy one buffer to another one long word at a time
bfill( ) - fill a buffer with a specified character
bfillBytes( ) - fill buffer with a specified character one byte at a time
index( ) - find the first occurrence of a character in a string
rindex( ) - find the last occurrence of a character in a string

DESCRIPTION

This library contains routines to manipulate buffers of variable-length byte arrays. Operations are performed on long words when possible, even though the buffer lengths are specified in bytes. This occurs only when source and destination buffers start on addresses that are both odd or both even. If one buffer is even and the other is odd, operations must be done one byte at a time (because of alignment problems inherent in the MC68000), thereby slowing down the process.

Certain applications, such as byte-wide memory-mapped peripherals, may require that only byte operations be performed. For this purpose, the routines bcopyBytes( ) and bfillBytes( ) provide the same functions as bcopy( ) and bfill( ), but use only byte-at-a-time operations. These routines do not check for null termination.

INCLUDE FILES

string.h

SEE ALSO

bLib, ansiString


Libraries : Routines

bcmp( )

NAME

bcmp( ) - compare one buffer to another

SYNOPSIS

int bcmp
    (
    char * buf1,  /* pointer to first buffer */
    char * buf2,  /* pointer to second buffer */
    int    nbytes /* number of bytes to compare */
    )

DESCRIPTION

This routine compares the first nbytes characters of buf1 to buf2.

RETURNS

  0 if the first nbytes of buf1 and buf2 are identical,
  less than 0 if buf1 is less than buf2, or
  greater than 0 if buf1 is greater than buf2.

SEE ALSO

bLib


Libraries : Routines

binvert( )

NAME

binvert( ) - invert the order of bytes in a buffer

SYNOPSIS

void binvert
    (
    char * buf,   /* pointer to buffer to invert */
    int    nbytes /* number of bytes in buffer */
    )

DESCRIPTION

This routine inverts an entire buffer, byte by byte. For example, the buffer {1, 2, 3, 4, 5} would become {5, 4, 3, 2, 1}.

RETURNS

N/A

SEE ALSO

bLib


Libraries : Routines

bswap( )

NAME

bswap( ) - swap buffers

SYNOPSIS

void bswap
    (
    char * buf1,  /* pointer to first buffer */
    char * buf2,  /* pointer to second buffer */
    int    nbytes /* number of bytes to swap */
    )

DESCRIPTION

This routine exchanges the first nbytes of the two specified buffers.

RETURNS

N/A

SEE ALSO

bLib


Libraries : Routines

swab( )

NAME

swab( ) - swap bytes

SYNOPSIS

void swab
    (
    char * source,      /* pointer to source buffer */
    char * destination, /* pointer to destination buffer */
    int    nbytes       /* number of bytes to exchange */
    )

DESCRIPTION

This routine gets the specified number of bytes from source, exchanges the adjacent even and odd bytes, and puts them in destination. The buffers source and destination should not overlap.

NOTE

On some CPUs, swab( ) will cause an exception if the buffers are unaligned. In such cases, use uswab( ) for unaligned swaps.

It is an error for nbytes to be odd.

RETURNS

N/A

SEE ALSO

bLib, uswab( )


Libraries : Routines

uswab( )

NAME

uswab( ) - swap bytes with buffers that are not necessarily aligned

SYNOPSIS

void uswab
    (
    char * source,      /* pointer to source buffer */
    char * destination, /* pointer to destination buffer */
    int    nbytes       /* number of bytes to exchange */
    )

DESCRIPTION

This routine gets the specified number of bytes from source, exchanges the adjacent even and odd bytes, and puts them in destination.

NOTE

Due to speed considerations, this routine should only be used when absolutely necessary. Use swab( ) for aligned swaps.

It is an error for nbytes to be odd.

RETURNS

N/A

SEE ALSO

bLib, swab( )


Libraries : Routines

bzero( )

NAME

bzero( ) - zero out a buffer

SYNOPSIS

void bzero
    (
    char * buffer, /* buffer to be zeroed */
    int    nbytes  /* number of bytes in buffer */
    )

DESCRIPTION

This routine fills the first nbytes characters of the specified buffer with 0.

RETURNS

N/A

SEE ALSO

bLib


Libraries : Routines

bcopy( )

NAME

bcopy( ) - copy one buffer to another

SYNOPSIS

void bcopy
    (
    const char * source,      /* pointer to source buffer */
    char *       destination, /* pointer to destination buffer */
    int          nbytes       /* number of bytes to copy */
    )

DESCRIPTION

This routine copies the first nbytes characters from source to destination. Overlapping buffers are handled correctly. Copying is done in the most efficient way possible, which may include long-word, or even multiple-long-word moves on some architectures. In general, the copy will be significantly faster if both buffers are long-word aligned. (For copying that is restricted to byte, word, or long-word moves, see the manual entries for bcopyBytes( ), bcopyWords( ), and bcopyLongs( ).)

RETURNS

N/A

SEE ALSO

bLib, bcopyBytes( ), bcopyWords( ), bcopyLongs( )


Libraries : Routines

bcopyBytes( )

NAME

bcopyBytes( ) - copy one buffer to another one byte at a time

SYNOPSIS

void bcopyBytes
    (
    char * source,      /* pointer to source buffer */
    char * destination, /* pointer to destination buffer */
    int    nbytes       /* number of bytes to copy */
    )

DESCRIPTION

This routine copies the first nbytes characters from source to destination one byte at a time. This may be desirable if a buffer can only be accessed with byte instructions, as in certain byte-wide memory-mapped peripherals.

RETURNS

N/A

SEE ALSO

bLib, bcopy( )


Libraries : Routines

bcopyWords( )

NAME

bcopyWords( ) - copy one buffer to another one word at a time

SYNOPSIS

void bcopyWords
    (
    char * source,      /* pointer to source buffer */
    char * destination, /* pointer to destination buffer */
    int    nwords       /* number of words to copy */
    )

DESCRIPTION

This routine copies the first nwords words from source to destination one word at a time. This may be desirable if a buffer can only be accessed with word instructions, as in certain word-wide memory-mapped peripherals. The source and destination must be word-aligned.

RETURNS

N/A

SEE ALSO

bLib, bcopy( )


Libraries : Routines

bcopyLongs( )

NAME

bcopyLongs( ) - copy one buffer to another one long word at a time

SYNOPSIS

void bcopyLongs
    (
    char * source,      /* pointer to source buffer */
    char * destination, /* pointer to destination buffer */
    int    nlongs       /* number of longs to copy */
    )

DESCRIPTION

This routine copies the first nlongs characters from source to destination one long word at a time. This may be desirable if a buffer can only be accessed with long instructions, as in certain long-word-wide memory-mapped peripherals. The source and destination must be long-aligned.

RETURNS

N/A

SEE ALSO

bLib, bcopy( )


Libraries : Routines

bfill( )

NAME

bfill( ) - fill a buffer with a specified character

SYNOPSIS

void bfill
    (
    char * buf,    /* pointer to buffer */
    int    nbytes, /* number of bytes to fill */
    int    ch      /* char with which to fill buffer */
    )

DESCRIPTION

This routine fills the first nbytes characters of a buffer with the character ch. Filling is done in the most efficient way possible, which may be long-word, or even multiple-long-word stores, on some architectures. In general, the fill will be significantly faster if the buffer is long-word aligned. (For filling that is restricted to byte stores, see the manual entry for bfillBytes( ).)

RETURNS

N/A

SEE ALSO

bLib, bfillBytes( )


Libraries : Routines

bfillBytes( )

NAME

bfillBytes( ) - fill buffer with a specified character one byte at a time

SYNOPSIS

void bfillBytes
    (
    char * buf,    /* pointer to buffer */
    int    nbytes, /* number of bytes to fill */
    int    ch      /* char with which to fill buffer */
    )

DESCRIPTION

This routine fills the first nbytes characters of the specified buffer with the character ch one byte at a time. This may be desirable if a buffer can only be accessed with byte instructions, as in certain byte-wide memory-mapped peripherals.

RETURNS

N/A

SEE ALSO

bLib, bfill( )


Libraries : Routines

index( )

NAME

index( ) - find the first occurrence of a character in a string

SYNOPSIS

char *index
    (
    const char * s, /* string in which to find character */
    int          c  /* character to find in string */
    )

DESCRIPTION

This routine finds the first occurrence of character c in string s.

RETURNS

A pointer to the located character, or NULL if c is not found.

SEE ALSO

bLib, strchr( ).


Libraries : Routines

rindex( )

NAME

rindex( ) - find the last occurrence of a character in a string

SYNOPSIS

char *rindex
    (
    const char * s, /* string in which to find character */
    int          c  /* character to find in string */
    )

DESCRIPTION

This routine finds the last occurrence of character c in string s.

RETURNS

A pointer to c, or NULL if c is not found.

SEE ALSO

bLib