/*
  util.c

  Copyright 20-Nov-2002 MBARI
  Written: 20-Nov-2002 Mark Sibenac
  Last mod: 20-Nov-2002 sib - creation

  Utility functions
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _QNX
#include <unistd.h>
#else
#include <sys/unistd.h>
#endif

void msleep (int milliseconds)
{
  usleep ((unsigned int)(milliseconds * 1000));
}

int ahextoi (char *str)
{
  int n, x = 0;

  for (; *str; ++str)
    {
      n = 0;
      if (*str >= '0' && *str <= '9')
	n += *str - '0';
      else if (*str >= 'A' && *str <= 'F')
	n += *str - 'A' + 10;
      else if (*str >= 'a' && *str <= 'f')
	n += *str - 'a' + 10;
      else break;
      x = (x << 4) + n;
    }
  return x;
}

