/* Simple routine to convert an ASCII hex string to binary data Requires ASCII hex data and buffer to populate with binary data  */
static gboolean iseries_parse_hex_string(const char *ascii, guint8 *buf, size_t len)
/* Simple routine to convert an ASCII hex string to binary data Requires ASCII hex data and buffer to populate with binary data  */
static gboolean iseries_parse_hex_string(const char *ascii, guint8 *buf, size_t len)
{
  size_t i;
  int byte;
  gint   hexvalue;
  guint8 bytevalue;
  byte = 0;
  for (i = 0; i < len; i++)
    {
      hexvalue = g_ascii_xdigit_value(ascii[i]);
      i++;
      if (hexvalue == -1)
        return FALSE;
      bytevalue = (guint8)(hexvalue << 4);
      if (i >= len)
        return FALSE;
      hexvalue = g_ascii_xdigit_value(ascii[i]);
      if (hexvalue == -1)
        return FALSE;
      bytevalue |= (guint8) hexvalue;
      buf[byte] = bytevalue;
      byte++;
    }
  return TRUE;
}