Logo Search packages:      
Sourcecode: aimage version File versions  Download package

template<typename T>
static int hash__< T >::hex2bin ( uint8_t *  binbuf,
size_t  binbuf_size,
const char *  hex 
) [inline, static]

Convert a hex representation to binary, and return the number of bits converted.

Parameters:
binbufoutput buffer
binbuf_sizesize of output buffer in bytes.
hexinput buffer (in hex)
Returns:
the number of converted bits.

Definition at line 109 of file hash_t.h.

    {
      int bits = 0;
      if(hexcharvals_init__==0){
          /* Need to initialize this */
          int i;
          for(i=0;i<10;i++){
            hexcharvals__['0'+i] = i;
          }
          for(i=10;i<16;i++){
            hexcharvals__['A'+i-10] = i;
            hexcharvals__['a'+i-10] = i;
          }
          hexcharvals_init__ = 1;
      }
      while(hex[0] && hex[1] && binbuf_size>0){
          *binbuf++ = ((hexcharvals__[(uint8_t)hex[0]]<<4) |
                   hexcharvals__[(uint8_t)hex[1]]);
          hex  += 2;
          bits += 8;
          binbuf_size -= 1;
      }
      return bits;
    }

Generated by  Doxygen 1.6.0   Back to index