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.

118 lines
2.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 1997, Microsoft Corporation. All Rights Reserved.
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. #include <windows.h>
  7. #include <string.h>
  8. #include <memory.h>
  9. #include "basecore.hpp"
  10. void hugestrcpy(char *, char *);
  11. void hugememcpy(char *, char *, long);
  12. void hugememset(char *, long);
  13. void hugestrcat(char *, char *);
  14. int hugestrcmp(char *, char *);
  15. void hugestrcpy( char *dest,
  16. char *src)
  17. {
  18. while (*src) *dest++ = *src++;
  19. *dest = 0x00;
  20. }
  21. // ------------------------------------------------------------------------------------
  22. //
  23. // ------------------------------------------------------------------------------------
  24. void hugememcpy( char *dest,
  25. char *src,
  26. long cnt)
  27. {
  28. long i;
  29. i = 0L;
  30. while (i < cnt)
  31. {
  32. dest[i] = src[i];
  33. i++;
  34. }
  35. }
  36. // ------------------------------------------------------------------------------------
  37. //
  38. // ------------------------------------------------------------------------------------
  39. void hugememset( char *str,
  40. long size)
  41. {
  42. while (size--) *str++ = 0x00;
  43. }
  44. // ------------------------------------------------------------------------------------
  45. //
  46. // ------------------------------------------------------------------------------------
  47. void hugestrcat( char *dest,
  48. char *src)
  49. {
  50. while (*dest) dest++;
  51. while (*src) *dest++ = *src++;
  52. *dest = 0x00;
  53. }
  54. // ------------------------------------------------------------------------------------
  55. //
  56. // ------------------------------------------------------------------------------------
  57. int hugestrcmp(char *str1, char *str2)
  58. {
  59. while (*str1)
  60. {
  61. if (*str1 != *str2) return (*str1 - *str2);
  62. str1++;
  63. str2++;
  64. }
  65. return 0;
  66. }
  67. // ------------------------------------------------------
  68. //
  69. // ------------------------------------------------------
  70. int PrintBit(unsigned char data)
  71. {
  72. char bitstring[9];
  73. for (int i = 0; i < 8; i++) bitstring[7-i] = (GetBit(data, i) == 0) ? '0' : '1';
  74. bitstring[8] = NULLCHAR;
  75. return SUCCESS;
  76. }
  77. // ----------------------------------------------------------------------
  78. //
  79. // ----------------------------------------------------------------------
  80. BOOL GetBit( unsigned char data,
  81. int pos) // pos : 0, 1, 2, ..., 7
  82. {
  83. char mask = 0x01;
  84. return ((data & (mask << pos)) == 0) ? FALSE : TRUE;
  85. }
  86. // ----------------------------------------------------------------------
  87. //
  88. // ----------------------------------------------------------------------
  89. void SetBit( unsigned char &data,
  90. int pos,
  91. int newitem) // newitem : 0, 1
  92. {
  93. char mask = 0x01;
  94. if (newitem == 1) data = data | (mask << pos);
  95. else data = data & ~(mask << pos);
  96. }