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.

49 lines
1.3 KiB

  1. // slbcci.cpp - Utility functions
  2. //
  3. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  4. // 1999. This computer program includes Confidential, Proprietary
  5. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  6. // use, disclosure, and/or reproduction is prohibited unless authorized
  7. // in writing. All Rights Reserved.
  8. ////////////////////////////////////////////////////////////////////////////
  9. #include "NoWarning.h"
  10. #include "slbCci.h"
  11. void cci::DateStructToDateArray(Date *dStruct, BYTE *bArray)
  12. {
  13. bArray[0] = dStruct->dwYear / 64;
  14. bArray[1] = ((dStruct->dwYear % 64) << 2 ) + dStruct->bMonth / 4;
  15. bArray[2] = ((dStruct->bMonth % 4) << 6 ) + dStruct->bDay;
  16. }
  17. void cci::DateArrayToDateStruct(BYTE *bArray, Date *dStruct)
  18. {
  19. dStruct->dwYear = bArray[0] * 64 + (bArray[1] >> 2);
  20. dStruct->bMonth = (bArray[1] & 0x03) * 4 + (bArray[2] >> 6);
  21. dStruct->bDay = (bArray[2] & 0x3F);
  22. }
  23. void cci::SetBit(BYTE *Buf, unsigned int i)
  24. {
  25. BYTE Mask = 1 << (i % 8);
  26. Buf[i/8] |= Mask;
  27. return;
  28. }
  29. void cci::ResetBit(BYTE *Buf, unsigned int i)
  30. {
  31. BYTE Mask = 1 << (i % 8);
  32. Buf[i/8] &= ~Mask;
  33. return;
  34. }
  35. bool cci::BitSet(BYTE *Buf, unsigned int i)
  36. {
  37. BYTE Mask = 1 << (i % 8);
  38. return (Buf[i/8] & Mask) ? true : false;
  39. }