home *** CD-ROM | disk | FTP | other *** search
-
- BITSTRING(3) UNIX Programmer's Manual BITSTRING(3)
-
- NNAAMMEE
- bbiitt__aalllloocc, bbiitt__cclleeaarr, bbiitt__ddeeccll, bbiitt__ffffss, bbiitt__nncclleeaarr, bbiitt__nnsseett,, bbiitt__sseett,
- bbiittssttrr__ssiizzee, bbiitt__tteesstt - bit-string manipulation macros
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<bbiittssttrriinngg..hh>>
-
- _b_i_t_s_t_r___t _*
- bbiitt__aalllloocc(_i_n_t _n_b_i_t_s)
-
- bbiitt__ddeeccll(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s)
-
- bbiitt__cclleeaarr(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
-
- bbiitt__ffffcc(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s, _i_n_t _*_v_a_l_u_e)
-
- bbiitt__ffffss(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s, _i_n_t _*_v_a_l_u_e)
-
- bbiitt__nncclleeaarr(_b_i_t___s_t_r _n_a_m_e, _i_n_t _s_t_a_r_t, _i_n_t _s_t_o_p)
-
- bbiitt__nnsseett(_b_i_t___s_t_r _n_a_m_e, _i_n_t _s_t_a_r_t, _i_n_t _s_t_o_p)
-
- bbiitt__sseett(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
-
- bbiittssttrr__ssiizzee(_i_n_t _n_b_i_t_s)
-
- bbiitt__tteesstt(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
-
- DDEESSCCRRIIPPTTIIOONN
- These macros operate on strings of bits.
-
- The macro bbiitt__aalllloocc() returns a pointer of type ``_b_i_t_s_t_r___t _*'' to suffi-
- cient space to store _n_b_i_t_s bits, or NULL if no space is available.
-
- The macro bbiitt__ddeeccll() allocates sufficient space to store _n_b_i_t_s bits on
- the stack.
-
- The macro bbiittssttrr__ssiizzee() returns the number of elements of type _b_i_t_s_t_r___t
- necessary to store _n_b_i_t_s bits. This is useful for copying bit strings.
-
- The macros bbiitt__cclleeaarr() and bbiitt__sseett() clear or set the zero-based numbered
- bit _b_i_t, in the bit string _n_a_m_e.
-
- The bbiitt__nnsseett() and bbiitt__nncclleeaarr() macros set or clear the zero-based num-
- bered bits from _s_t_a_r_t to _s_t_o_p in the bit string _n_a_m_e.
-
- The bbiitt__tteesstt() macro evaluates to non-zero if the zero-based numbered bit
- _b_i_t of bit string _n_a_m_e is set, and zero otherwise.
-
- The bbiitt__ffffss() macro stores in the location referenced by _v_a_l_u_e the zero-
- based number of the first bit set in the array of _n_b_i_t_s bits referenced
- by _n_a_m_e. If no bits are set, the location referenced by _v_a_l_u_e is set to
- -1.
-
- The macro bbiitt__ffffcc() stores in the location referenced by _v_a_l_u_e the zero-
- based number of the first bit not set in the array of _n_b_i_t_s bits refer-
- enced by _n_a_m_e. If all bits are set, the location referenced by _v_a_l_u_e is
- set to -1.
-
- The arguments to these macros are evaluated only once and may safely have
- side effects.
-
- EEXXAAMMPPLLEE
- #include <limits.h>
- #include <bitstring.h>
-
- #define LPR_BUSY_BIT 0
- #define LPR_FORMAT_BIT 1
- #define LPR_DOWNLOAD_BIT 2
- #define LPR_AVAILABLE_BIT 9
- #define LPR_MAX_BITS 10
-
- make_lpr_available()
- {
- bitstr_t bit_decl(bitlist, LPR_MAX_BITS);
- ...
- bit_nclear(bitlist, 0, LPR_MAX_BITS - 1);
- ...
- if (!bit_test(bitlist, LPR_BUSY_BIT)) {
- bit_clear(bitlist, LPR_FORMAT_BIT);
- bit_clear(bitlist, LPR_DOWNLOAD_BIT);
- bit_set(bitlist, LPR_AVAILABLE_BIT);
- }
- }
-
- SSEEEE AALLSSOO
- malloc(3)
-
- HHIISSTTOORRYY
- The bbiittssttrriinngg functions first appeared in 4.4BSD.
-
- 4th Berkeley Distribution July 19, 1993 2
-