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.

110 lines
2.1 KiB

  1. #include "brian.h"
  2. VOID
  3. PrintLargeInteger (
  4. IN PLARGE_INTEGER LargeInt
  5. )
  6. {
  7. printf( "%08lx:%08lx", LargeInt->HighPart, LargeInt->LowPart );
  8. return;
  9. }
  10. ULONG
  11. AsciiToInteger (
  12. IN PCHAR Ascii
  13. )
  14. {
  15. BOOLEAN DoHex = FALSE;
  16. LONG Integer = 0;
  17. PCHAR c;
  18. while (*Ascii) {
  19. if (Integer == 0 &&
  20. (*Ascii == 'x' || *Ascii == 'X')) {
  21. DoHex = TRUE;
  22. } else {
  23. if (DoHex) {
  24. *Ascii = (CHAR) toupper( *Ascii );
  25. if (*Ascii < '0' ||
  26. (*Ascii > '9' &&
  27. (*Ascii < 'A' || *Ascii > 'F'))) {
  28. break;
  29. }
  30. Integer *= 16;
  31. Integer += ( *Ascii - ( *Ascii > '9' ? ('A' - 10) : '0' ));
  32. } else {
  33. if (*Ascii < '0' || *Ascii > '9') {
  34. break;
  35. }
  36. Integer *= 10;
  37. Integer += (*Ascii - '0');
  38. }
  39. }
  40. Ascii++;
  41. }
  42. return Integer;
  43. }
  44. ULONGLONG
  45. AsciiToLargeInteger (
  46. IN PCHAR Ascii
  47. )
  48. {
  49. BOOLEAN DoHex = FALSE;
  50. ULONGLONG Integer = 0;
  51. PCHAR c;
  52. while (*Ascii) {
  53. if (Integer == 0 &&
  54. (*Ascii == 'x' || *Ascii == 'X')) {
  55. DoHex = TRUE;
  56. } else {
  57. if (DoHex) {
  58. *Ascii = (CHAR) toupper( *Ascii );
  59. if (*Ascii < '0' ||
  60. (*Ascii > '9' &&
  61. (*Ascii < 'A' || *Ascii > 'F'))) {
  62. break;
  63. }
  64. Integer *= 16;
  65. Integer += ( *Ascii - ( *Ascii > '9' ? ('A' - 10) : '0' ));
  66. } else {
  67. if (*Ascii < '0' || *Ascii > '9') {
  68. break;
  69. }
  70. Integer *= 10;
  71. Integer += (*Ascii - '0');
  72. }
  73. }
  74. Ascii++;
  75. }
  76. return Integer;
  77. }