Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
745 B

  1. /*++
  2. Copyright (c) 1988-1999 Microsoft Corporation
  3. Module Name:
  4. hstoi.c
  5. Abstract:
  6. Low level utility
  7. --*/
  8. #include "cmd.h"
  9. /*** hstoi - convert a hex string to an integer
  10. *
  11. * Conversion stops when the first non-hex character is found. If the first
  12. * character is not a hex character, 0 is returned.
  13. *
  14. * Eric K. Evans, Microsoft
  15. */
  16. hstoi( TCHAR *s )
  17. {
  18. int result = 0 ;
  19. int digit ;
  20. if (s == NULL) {
  21. return 0;
  22. }
  23. s = SkipWhiteSpace( s );
  24. for ( ; *s && _istxdigit(*s) ; s++) {
  25. digit = (int) (*s <= TEXT('9')) ? (int)*s - (int)'0' : (int)_totlower(*s)-(int)'W' ;
  26. result = (result << 4)+digit ;
  27. } ;
  28. return (result) ;
  29. }