/*
 * strntol: Useful utility when wanting the decimal value of
 * a string which isn't null-terminated.
 */

#include <stdio.h>
#ifdef __sun__
#include <sunos.h>
#endif

long strntol(char *str, char **ptr, int base, int length) {
  char buf[20];
  if (length > 19) {
    fprintf(stderr, "strntol has a buffer of only 20, not %d.\n",length);
    exit(1);
  }
  strncpy(buf,str,length);
  buf[length]='\0';
  return strtol(buf,ptr,base);
}
