Sha256: c4e3ecbd2818ef9bb7610d1df37aab115021a5299dfc3562bf4947e2545626d2

Contents?: true

Size: 558 Bytes

Versions: 3

Compression:

Stored size: 558 Bytes

Contents

#include "hexparse.h"

static int hexdigit(char x)
{
  if (x >= '0' && x <= '9') return x - '0';
  if (x >= 'a' && x <= 'f') return 10 + (x - 'a');
  if (x >= 'A' && x <= 'F') return 10 + (x - 'A');
  return -1;
}

int hexparse(unsigned char *y,long long len,const char *x)
{
  if (!x) return 0;
  while (len > 0) {
    int digit0;
    int digit1;
    digit0 = hexdigit(x[0]); if (digit0 == -1) return 0;
    digit1 = hexdigit(x[1]); if (digit1 == -1) return 0;
    *y++ = digit1 + 16 * digit0;
    --len;
    x += 2;
  }
  if (x[0]) return 0;
  return 1;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_nacl-0.1.2 ext/ruby_nacl/NaCl/curvecp/hexparse.c
ruby_nacl-0.1.1 ext/ruby_nacl/NaCl/curvecp/hexparse.c
ruby_nacl-0.1.0 ext/ruby_nacl/NaCl/curvecp/hexparse.c