Manual Pages for UNIX Darwin command on man bit_nset
MyWebUniversity

Manual Pages for UNIX Darwin command on man bit_nset

BITSTRING(3) BSD Library Functions Manual BITSTRING(3)

NAME

bbiittaalllloocc, bbiittcclleeaarr, bbiittddeeccll, bbiittffffss, bbiittnncclleeaarr, bbiittnnsseett,, bbiittsseett,

bbiittssttrrssiizzee, bbiitttteesstt - bit-string manipulation macros

SYNOPSIS

##iinncclluuddee <>

bitstrt * bbiittaalllloocc(int nbits); bbiittddeeccll(bitstr name, int nbits); bbiittcclleeaarr(bitstr name, int bit); bbiittffffcc(bitstr name, int nbits, int *value); bbiittffffss(bitstr name, int nbits, int *value); bbiittnncclleeaarr(bitstr name, int start, int stop); bbiittnnsseett(bitstr name, int start, int stop); bbiittsseett(bitstr name, int bit); bbiittssttrrssiizzee(int nbits); bbiitttteesstt(bitstr name, int bit);

DESCRIPTION

These macros operate on strings of bits.

The macro bbiittaalllloocc() returns a pointer of type ``bitstrt *'' to suffi-

cient space to store nbits bits, or NULL if no space is available. The macro bbiittddeeccll() allocates sufficient space to store nbits bits on the stack. The macro bbiittssttrrssiizzee() returns the number of elements of type bitstrt necessary to store nbits bits. This is useful for copying bit strings.

The macros bbiittcclleeaarr() and bbiittsseett() clear or set the zero-based numbered

bit bit, in the bit string name.

The bbiittnnsseett() and bbiittnncclleeaarr() macros set or clear the zero-based num-

bered bits from start to stop in the bit string name.

The bbiitttteesstt() macro evaluates to non-zero if the zero-based numbered bit

bit of bit string name is set, and zero otherwise.

The bbiittffffss() macro stores in the location referenced by value the zero-

based number of the first bit set in the array of nbits bits referenced by name. If no bits are set, the location referenced by value is set to

-1.

The macro bbiittffffcc() stores in the location referenced by value the zero-

based number of the first bit not set in the array of nbits bits refer-

enced by name. If all bits are set, the location referenced by value is

set to -1.

The arguments to these macros are evaluated only once and may safely have side effects. EEXXAAMMPPLLEE

#include

#include

#define LPRBUSYBIT 0

#define LPRFORMATBIT 1

#define LPRDOWNLOADBIT 2

#define LPRAVAILABLEBIT 9

#define LPRMAXBITS 10

makelpravailable() { bitstrt bitdecl(bitlist, LPRMAXBITS); ...

bitnclear(bitlist, 0, LPRMAXBITS - 1);

... if (!bittest(bitlist, LPRBUSYBIT)) { bitclear(bitlist, LPRFORMATBIT); bitclear(bitlist, LPRDOWNLOADBIT); bitset(bitlist, LPRAVAILABLEBIT); } }

SEE ALSO

malloc(3) HISTORY The bbiittssttrriinngg functions first appeared in 4.4BSD. 4th Berkeley Distribution July 19, 1993 4th Berkeley Distribution




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™