home *** CD-ROM | disk | FTP | other *** search
- /*********
- *
- * _TR_HTOI.C
- *
- * by Ralph Davis
- *
- * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
- *
- * SYNTAX: _tr_htoi(cp)
- * char *cp;
- *
- * RETURN: integer equivalent of cp
- *
- *********/
-
- #include "trlib.h"
-
- _tr_htoi(s) /* dec() internal function */
- char *s;
- {
- int hexdigit, i, n;
-
- n = 0;
- for (i = 0; i < _tr_strlen(s); i++)
- {
- if (s[i] >= '0' && s[i] <= '9')
- hexdigit = s[i] - '0';
- else if (s[i] >= 'a' && s[i] <= 'f')
- hexdigit = s[i] - 'a' + 10;
- else if (s[i] >= 'A' && s[i] <= 'F')
- hexdigit = s[i] - 'A' + 10;
- else
- return(0);
- n = 16 * n + hexdigit;
- }
- return(n);
- }
-
-