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.

57 lines
1.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Passport **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 2001 **/
  4. /**********************************************************************/
  5. /*
  6. keyver.h
  7. defines functions deal with key versions
  8. FILE HISTORY:
  9. */
  10. #ifndef __KEYVER_H_
  11. #define __KEYVER_H_
  12. #include "resource.h" // main symbols
  13. // Key version for admin interface
  14. const int KEY_VERSION_MIN = 1;
  15. const int KEY_VERSION_MAX = 35;
  16. // return 0: invalid range, otherwize, returns ['0' - '9', 'A' - 'Z']
  17. inline char KeyVerI2C(int i)
  18. {
  19. if (i >= KEY_VERSION_MIN && i <= 9) return (i + '0');
  20. if (i > 9 && i <= KEY_VERSION_MAX) return (i - 10 + 'A');
  21. return 0;
  22. };
  23. // return -1: invalid char, return [KEY_VERSION_MIN, KEY_VERSION_MAX]
  24. inline int KeyVerC2I(char c)
  25. {
  26. if (c > '0' && c <= '9') return (c - '0');
  27. if (c >= 'A' && c <='Z') return (c - 'A' + 10);
  28. return -1;
  29. /* lower case is not being used as key version
  30. if islower(c) return (c - 'A' + 10);
  31. */
  32. };
  33. inline int KeyVerC2I(WCHAR c)
  34. {
  35. // only ASCII is valid
  36. if (c & 0xff00) return -1;
  37. return (KeyVerC2I((char)c));
  38. };
  39. #endif // KEYVER