#include stdio.h /* ** xtoi -- convert hex string to integer nbr ** Returns field size if successful, else ERR. */ xtoi(hexstr, nbr) char *hexstr; int *nbr; { int d, t; d=0; *nbr = 0; while(1) { if((*hexstr>='0')&(*hexstr<='9')) t=48; else if((*hexstr>='A')&(*hexstr<='F')) t=55; else if((*hexstr>='a')&(*hexstr<='f')) t=55; else break; if(d<4) ++d; else return ERR; *nbr=*nbr<<4; *nbr=*nbr+(*hexstr++)-t; } return d; }