4.3BSD-Reno/share/man/cat3/bitstring.0

Compare this file to the similar file:
Show the results in this format:




BITSTRING(3)		      1990		     BITSTRING(3)



NNAAMMEE
     bit_alloc, bit_clear, bit_decl, bit_ffs, bit_nclear,
     bit_nset, bit_set, bitstr_size, bit_test - bit-string mani-
     pulation macros

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<bbiittssttrriinngg..hh>>

     nnaammee == bbiitt__aalllloocc((nnbbiittss))
     bbiittssttrr__tt **nnaammee;;
     iinntt nnbbiittss;;

     bbiitt__ddeeccll((nnaammee,, nnbbiittss))
     bbiittssttrr__tt nnaammee;;
     iinntt nnbbiittss;;

     bbiitt__cclleeaarr((nnaammee,, bbiitt))
     bbiittssttrr__tt nnaammee;;
     iinntt bbiitt;;

     bbiitt__ffffcc((nnaammee,, nnbbiittss,, vvaalluuee))
     bbiittssttrr__tt nnaammee;;
     iinntt nnbbiittss,, **vvaalluuee;;

     bbiitt__ffffss((nnaammee,, nnbbiittss,, vvaalluuee))
     bbiittssttrr__tt nnaammee;;
     iinntt nnbbiittss,, **vvaalluuee;;

     bbiitt__nncclleeaarr((nnaammee,, ssttaarrtt,, ssttoopp))
     bbiittssttrr__tt nnaammee;;
     iinntt ssttaarrtt,, ssttoopp;;

     bbiitt__nnsseett((nnaammee,, ssttaarrtt,, ssttoopp))
     bbiittssttrr__tt nnaammee;;
     iinntt ssttaarrtt,, ssttoopp;;

     bbiitt__sseett((nnaammee,, bbiitt))
     bbiittssttrr__tt nnaammee;;
     iinntt bbiitt;;

     bbiittssttrr__ssiizzee((nnbbiittss))
     iinntt nnbbiittss;;

     bbiitt__tteesstt((nnaammee,, bbiitt))
     bbiittssttrr__tt nnaammee;;
     iinntt bbiitt;;

DDEESSCCRRIIPPTTIIOONN
     These macros operate on strings of bits.

     _B_i_t__a_l_l_o_c returns a pointer of type _b_i_t_s_t_r__t * to sufficient
     space to store _n_b_i_t_s bits, or NULL if no space is available.



Printed 7/27/90               June				1






BITSTRING(3)		      1990		     BITSTRING(3)



     _B_i_t__d_e_c_l is a macro for allocating sufficient space to store
     _n_b_i_t_s bits on the stack.

     _B_i_t_s_t_r__s_i_z_e 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.

     _B_i_t__c_l_e_a_r and _b_i_t__s_e_t clear or set the zero-based numbered
     bit _b_i_t, in the bit string _n_a_m_e.

     _B_i_t__n_s_e_t and _b_i_t__n_c_l_e_a_r set or clear the zero-based numbered
     bits from _s_t_a_r_t to _s_t_o_p in the bit string _n_a_m_e.

     _B_i_t__t_e_s_t evaluates to zero if the zero-based numbered bit
     _b_i_t of bit string _n_a_m_e is set, and non-zero otherwise.

     _B_i_t__f_f_s 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.

     _B_i_t__f_f_c 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 referenced 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);
	       }
	  }




Printed 7/27/90               June				2






BITSTRING(3)		      1990		     BITSTRING(3)



SSEEEE AALLSSOO
     malloc(3)





















































Printed 7/27/90               June				3