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.

89 lines
2.0 KiB

  1. #include <stdio.h>
  2. #define BIT(n) (((unsigned long)1)<<(n))
  3. #define BITSIZE(v) (sizeof(v)*8)
  4. #define SETBIT(array,n) (array[(n)/BITSIZE(*array)] |= BIT((n)%BITSIZE(*array)))
  5. #define CLEARBIT(array,n) (array[(n)/BITSIZE(*array)] &= ~BIT((n)%BITSIZE(*array)))
  6. #define TESTBIT(array,n) (BIT((n)%BITSIZE(*array)) == (array[(n)/BITSIZE(*array)] & BIT(n%BITSIZE(*array))))
  7. __cdecl
  8. main(int argc, char *argv[])
  9. {
  10. unsigned long bitArr[32];
  11. unsigned long pictureNumber[2];
  12. int c, b, i;
  13. int lines;
  14. size_t bytes;
  15. FILE *fp;
  16. char *me;
  17. me = *argv++; --argc;
  18. while (argc-- > 0) {
  19. fp = fopen(*argv, "rb");
  20. if (fp == NULL) {
  21. fprintf(stderr, "%s: Can't open \"%s\"; ", me, *argv);
  22. perror("");
  23. continue;
  24. }
  25. b = 0;
  26. for ( ; ; ) {
  27. bytes = fread((void *)bitArr, 1, 128, fp);
  28. if (128 != bytes) {
  29. if (0 != bytes) {
  30. fprintf(stderr, "%s: Error reading bitmap; ", me);
  31. perror("");
  32. }
  33. break;
  34. }
  35. bytes = fread((void *)pictureNumber, 1, 8, fp);
  36. if (8 != bytes) {
  37. if (0 != bytes) {
  38. fprintf(stderr, "%s: Error reading pictureNumber; ", me);
  39. perror("");
  40. }
  41. break;
  42. }
  43. printf("pic# 0x%08x%08x.\n", pictureNumber[1], pictureNumber[0]);
  44. lines = 0;
  45. #if 0
  46. if (TESTBIT(bitArr, 0))
  47. printf("Odd ");
  48. else
  49. printf("Even ");
  50. #endif /*0*/
  51. printf("Lines: ");
  52. for (i = 1; i < 1024; ++i) {
  53. if (TESTBIT(bitArr, i-1)) {
  54. printf("%d, ", i);
  55. ++lines;
  56. }
  57. }
  58. printf("Total = %d.\n", lines);
  59. while (lines > 0 && (c = getc(fp)) != EOF) {
  60. ++b;
  61. if (b % 37 == 1)
  62. printf("%3d%% ", (unsigned char)(c & 0xff));
  63. else
  64. printf("%02x", (unsigned char)(c & 0xff));
  65. if (b % 37 == 4)
  66. putchar(' ');
  67. if (b % 37 == 7)
  68. putchar(' ');
  69. if (b % 37 == 0) {
  70. putchar('\n');
  71. --lines;
  72. }
  73. }
  74. if (c == EOF)
  75. break;
  76. }
  77. putchar('\n');
  78. fclose(fp);
  79. }
  80. return 0;
  81. }