Source code of Windows XP (NT5)
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.

94 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ASCII.c
  5. Abstract:
  6. This module contains code for Remote Admin Protocol use.
  7. Author:
  8. David Treadwell (davidtr) 07-Jan-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Revision History:
  12. 27-Feb-1991 JohnRo
  13. Converted from Xs routines to Rap routines.
  14. 14-Apr-1991 JohnRo
  15. Reduce recompiles.
  16. 17-Apr-1991 JohnRo
  17. Make it clear that "input" pointer is updated.
  18. 19-Aug-1991 JohnRo
  19. Improve UNICODE handling.
  20. Reduce recompiles.
  21. 07-Sep-1991 JohnRo
  22. Use DESC_DIGIT_TO_NUM(). Made changes suggested by PC-LINT.
  23. --*/
  24. // These must be included first:
  25. #include <windef.h> // IN, LPDWORD, NULL, OPTIONAL, DWORD, etc.
  26. #include <lmcons.h> // NET_API_STATUS
  27. // These may be included in any order:
  28. #include <rap.h> // My prototype, LPDESC, DESC_CHAR_IS_DIGIT().
  29. DWORD
  30. RapAsciiToDecimal (
  31. IN OUT LPDESC *Number
  32. )
  33. /*++
  34. Routine Description:
  35. This routine converts an ASCII string to decimal and updates the
  36. input pointer to point the last character of the number. The string is
  37. parm of a descriptor.
  38. Arguments:
  39. Number - points to a LPDESC pointing to a number in ASCII format. The
  40. pointer is updated to point to the next location after the number.
  41. Return Value:
  42. The decimal value of the string.
  43. --*/
  44. {
  45. LPDESC s;
  46. DWORD actualNumber = 0;
  47. //
  48. // Walk through the number, multiplying the current value by ten to
  49. // update place, and adding the next digit.
  50. //
  51. for ( s = *Number; DESC_CHAR_IS_DIGIT( *s ); s++ ) {
  52. actualNumber = actualNumber * 10 + DESC_DIGIT_TO_NUM( *s );
  53. }
  54. //
  55. // Set up the output pointer to point to the character after the last
  56. // digit of the number.
  57. //
  58. *Number = s;
  59. return actualNumber;
  60. } // RapAsciiToDecimal