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.

98 lines
1.7 KiB

  1. #include "utils.h"
  2. #include "struct.h"
  3. #include "Readfile.h"
  4. ULONG ahextoi( TCHAR *s)
  5. {
  6. int len;
  7. ULONG num, base, hex;
  8. len = _tcslen(s);
  9. hex = 0; base = 1; num = 0;
  10. while (--len >= 0) {
  11. if ( (s[len] == 'x' || s[len] == 'X') &&
  12. (s[len-1] == '0') )
  13. break;
  14. if (s[len] >= '0' && s[len] <= '9')
  15. num = s[len] - '0';
  16. else if (s[len] >= 'a' && s[len] <= 'f')
  17. num = (s[len] - 'a') + 10;
  18. else if (s[len] >= 'A' && s[len] <= 'F')
  19. num = (s[len] - 'A') + 10;
  20. else
  21. continue;
  22. hex += num * base;
  23. base = base * 16;
  24. }
  25. return hex;
  26. }
  27. void RemoveComment( TCHAR *String)
  28. {
  29. ULONG i = 0;
  30. while( String[i] != 0 )
  31. {
  32. if( String[i] == '/' )
  33. {
  34. String[i] = 0;
  35. break;
  36. }
  37. i++;
  38. }
  39. }
  40. void
  41. ConvertAsciiToGuid( TCHAR* arg, LPGUID Guid)
  42. {
  43. ULONG i;
  44. TCHAR Temp[MAX_STR];
  45. _tcsncpy(Temp, arg, 37);
  46. Temp[8] = 0;
  47. Guid->Data1 = ahextoi(Temp);
  48. _tcsncpy(Temp, &arg[9], 4);
  49. Temp[4] = 0;
  50. Guid->Data2 = (USHORT) ahextoi(Temp);
  51. _tcsncpy(Temp, &arg[14], 4);
  52. Temp[4] = 0;
  53. Guid->Data3 = (USHORT) ahextoi(Temp);
  54. for (i=0; i<2; i++)
  55. {
  56. _tcsncpy(Temp, &arg[19 + (i*2)], 2);
  57. Temp[2] = 0;
  58. Guid->Data4[i] = (UCHAR) ahextoi(Temp);
  59. }
  60. for (i=2; i<8; i++)
  61. {
  62. _tcsncpy(Temp, &arg[20 + (i*2)], 2);
  63. Temp[2] = 0;
  64. Guid->Data4[i] = (UCHAR) ahextoi(Temp);
  65. }
  66. }
  67. void
  68. SplitCommandLine(
  69. LPTSTR CommandLine,
  70. LPTSTR* pArgv
  71. )
  72. {
  73. LPTSTR arg;
  74. int i = 0;
  75. arg = _tcstok( CommandLine, _T(" \t"));
  76. while( arg != NULL ){
  77. _tcscpy(pArgv[i++], arg);
  78. arg = _tcstok(NULL, _T(" \t"));
  79. }
  80. }