## modules/ma/bitmask.h

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. MA_eq

       1 /***************************************
       2   $Revision: 1.8 $
       3
       4   bitmask (ma) - bitmask.h - header file for bitmask library
       5
       6   Status: NOT REVUED, TESTED, INCOMPLETE
       7
       8   Design and implementation by: Marek Bukowy
       9
      10   ******************/ /******************
      11   Copyright (c) 1999                              RIPE NCC
      12
      13   All Rights Reserved
      14
      15   Permission to use, copy, modify, and distribute this software and its
      16   documentation for any purpose and without fee is hereby granted,
      17   provided that the above copyright notice appear in all copies and that
      18   both that copyright notice and this permission notice appear in
      19   supporting documentation, and that the name of the author not be
      20   used in advertising or publicity pertaining to distribution of the
      21   software without specific, written prior permission.
      22
      23   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
      24   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
      25   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
      26   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
      27   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      28   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      29   ***************************************/
      30
      31
      32 #ifndef READ_BITMASK
      33 #define READ_BITMASK
      34
      35 #define MASK_BITS_BASETYPE unsigned int
      36 #define MASK_BITS_BASESIZE (8 * sizeof (MASK_BITS_BASETYPE))
      37
      38 /* size of the mask: to keep things simple, there is only one size
      39    that must suit everybody. The requirements are listed below.
      40
      41    Marek: Aspects. Not many so far, about 30-40 possible.
      42    Chris: Query types, 78 at the moment, probably less than 128 at the end
      43 */
      44
      45
      46 #define MASK_MAX 128
      47 #define MASK_BITS_WORDS    (MASK_MAX / MASK_BITS_BASESIZE + 1)
      48
      49 typedef struct {
      50   MASK_BITS_BASETYPE  data[MASK_BITS_WORDS];
      51 } mask_t;
      52
      53
      54 #define MA_END (-1)
      55
      56 #ifdef __cplusplus
      57 extern "C" {
      58 #endif
      59
      60 void MA_free(mask_t *m);
      61 int MA_isset(mask_t d, unsigned b);
      62 void MA_set(mask_t *m_ptr, unsigned b, unsigned v);
      63 void MA_clear(mask_t *m_ptr);
      64 mask_t MA_new(int n,...);
      65 void MA_prt(mask_t m);
      66 mask_t MA_and(mask_t a, mask_t b);
      67 mask_t MA_xor(mask_t a, mask_t b);
      68 mask_t MA_or(mask_t a, mask_t b);
      69 mask_t MA_not(mask_t a);
      70 int MA_bitcount(mask_t m);
      71 char *MA_to_string(mask_t mask, char * const *tokens);
      72
      73 #define MA_eq(a,b) (memcmp( &(a), &(b), sizeof(mask_t))==0)
         /* [<][>][^][v][top][bottom][index][help] */
      74
      75 #ifdef __cplusplus
      76 }
      77
      78 #endif
      79
      80
      81 #endif /* READ_BITMASK */

/* [<][>][^][v][top][bottom][index][help] */