コード例 #1
0
ファイル: sflbits.c プロジェクト: cookrn/openamq
int
bits_clear (
    BITS *bits,
    long bit)
{
    int
        index,                          /*  Number of index block            */
        section;                        /*  Number of section in index       */
    dbyte
        bit_nbr;                        /*  Number of bit in section         */
    int
        feedback = 0;


    ASSERT (bits);

    if (bit >= 0 && bit < BIT_MAXBITS)
      {
        locate_bit  (bits, bit, &index, &section, &bit_nbr);
        get_section (bits, index, section, section_data, TRUE);
        section_data [bit_nbr / 8] &= 255 - (1 << (bit_nbr % 8));
        put_section (bits, index, section, section_data);
      }
    else
        feedback = -1;
    return (feedback);
}
コード例 #2
0
ファイル: sflbits.c プロジェクト: imatix-legacy/xitami
int
bits_test (
    const BITS *bits,
    long bit)
{
    int
        index,                          /*  Number of index block            */
        section;                        /*  Number of section in index       */
    dbyte
        bit_nbr;                        /*  Number of bit in section         */

    ASSERT (bits);

    locate_bit  (bits, bit, &index, &section, &bit_nbr);
    get_section ((BITS *) bits, index, section, section_data, FALSE);
    if ((section_data [bit_nbr / 8]) & (1 << (bit_nbr % 8)))
        return (1);
    else
        return (0);
}
コード例 #3
0
ファイル: sflbits.c プロジェクト: imatix-legacy/xitami
int
bits_clear (
    BITS *bits,
    long bit)
{
    int
        index,                          /*  Number of index block            */
        section;                        /*  Number of section in index       */
    dbyte
        bit_nbr;                        /*  Number of bit in section         */

    ASSERT (bits);

    locate_bit  (bits, bit, &index, &section, &bit_nbr);
    get_section (bits, index, section, section_data, TRUE);
    section_data [bit_nbr / 8] &= 255 - (1 << (bit_nbr % 8));
    put_section (bits, index, section, section_data);

    return 0;
}
コード例 #4
0
ファイル: sflbits.c プロジェクト: cookrn/openamq
long  
bits_search_set (const BITS *bits, long bit, Bool reverse)
{
    long
         current_bit,
         feedback = -1;
    int
        index,                          /*  Number of index block            */
        section,                        /*  Number of section in index       */
        data_index, 
        bit_index;
    dbyte
        bit_nbr;                        /*  Number of bit in section         */

    BITBLOCK
        *index_block;                   /*  Points to index block            */
    dbyte
        section_head;                   /*  Section block list head          */

    ASSERT (bits);

    if (reverse == FALSE)
      {
        current_bit = bit + 1;
        locate_bit (bits, current_bit, &index, &section, &bit_nbr);
        index_block = bits-> block [index];
        FOREVER
          {
            section_head = index_block-> block.index [section];
            if (section_head == 0x0000)         /*  All 0's                          */
              {
                while (   index_block-> block.index [section] == 0x0000
                       && section < BIT_INDEXSIZE)
                    section++;
                if (section == BIT_INDEXSIZE)
                    break;
                else
                    section_head = index_block-> block.index [section];
              }

            if (section_head == 0xFFFF)     /*  All 1's                          */
              {
                feedback = current_bit;
                break;
              }
            else
              {
                get_section ((BITS *)bits, index, section, section_data, FALSE);
                data_index = bit_nbr / 8;
                for (bit_index = bit_nbr % 8; bit_index < 8; bit_index++, bit_nbr++)
                  {
                    if ((section_data [data_index]) & (1 << bit_index))
                      {
                         feedback = (((long) BIT_SECTSIZE * 8) * section) + bit_nbr;
                         break;
                      }
                  }

                if (feedback != -1)
                    break;

                data_index++;
                while (   section_data [data_index] == 0x00
                       && data_index < BIT_SECTSIZE)
                    data_index++;
                if (data_index == BIT_SECTSIZE)
                  {
                    section++;
                    bit_nbr = 0;
                  }
                else
                  {
                    for (bit_index = 0; bit_index < 8; bit_index++, bit_nbr++)
                      {
                        if ((section_data [data_index]) & (1 << bit_index))
                          {
                             feedback = (((long) BIT_SECTSIZE * 8) * section) + 
                                        ( 8 * data_index) + bit_index;
                             break;
                          }
                      }
                  }
                if (feedback != -1)
                    break;
                current_bit = (((long) BIT_SECTSIZE * 8) * section) + bit_nbr;
             }
          }
       }