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.

321 lines
6.6 KiB

  1. /*
  2. Modifications:
  3. 12.05.94 Joe Holman Created to count max # of bytes in platform product(s).
  4. 03.14.95 Joe Holman Provide #s for local source in Winnt and Winnt32.
  5. xx.xx.95 Joe Holman Add code to look at value in DOSNET.INF and error
  6. out if we go over the current value.
  7. Overview:
  8. tally%platform% values are the # of bytes needed on the machine for
  9. all of the system files in their UNCOMPRESSED state.
  10. localSrc%platform% values are the # of bytes to copy the compressed
  11. and uncompressed files to the local source directories for a Winnt or
  12. Winnt32 operation.
  13. */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <windows.h>
  18. #include <time.h>
  19. #include "general.h"
  20. FILE* logFile;
  21. struct _list {
  22. char name[15]; // name of file
  23. };
  24. struct _list arrayX86[2000];
  25. struct _list arrayMips[2000];
  26. struct _list arrayAlpha[2000];
  27. struct _list arrayPpc[2000];
  28. // Tally up the # of bytes required for the system from the files included.
  29. //
  30. long tallyX86,
  31. tallyMips,
  32. tallyAlpha,
  33. tallyPpc;
  34. int iX86=0, iMips=0, iAlpha=0, iPpc=0;
  35. long localSrcX86=0, localSrcMips=0, localSrcAlpha=0, localSrcPpc=0;
  36. BOOL NotListedYetX86 ( const char * strName ) {
  37. int i;
  38. for ( i = 0; i < iX86; ++i ) {
  39. if ( !_stricmp ( arrayX86[i].name, strName ) ) {
  40. return (FALSE); // name is already in list.
  41. }
  42. }
  43. sprintf ( arrayX86[iX86].name, "%s", strName );
  44. ++iX86;
  45. return (TRUE); // not previously in list.
  46. }
  47. BOOL NotListedYetMips ( const char * strName ) {
  48. int i;
  49. for ( i = 0; i < iMips; ++i ) {
  50. if ( !_stricmp ( arrayMips[i].name, strName ) ) {
  51. return (FALSE); // name is already in list.
  52. }
  53. }
  54. sprintf ( arrayMips[iMips].name, "%s", strName );
  55. ++iMips;
  56. return (TRUE); // not previously in list.
  57. }
  58. BOOL NotListedYetAlpha ( const char * strName ) {
  59. int i;
  60. for ( i = 0; i < iAlpha; ++i ) {
  61. if ( !_stricmp ( arrayAlpha[i].name, strName ) ) {
  62. return (FALSE); // name is already in list.
  63. }
  64. }
  65. sprintf ( arrayAlpha[iAlpha].name, "%s", strName );
  66. ++iAlpha;
  67. return (TRUE); // not previously in list.
  68. }
  69. BOOL NotListedYetPpc ( const char * strName ) {
  70. int i;
  71. for ( i = 0; i < iPpc; ++i ) {
  72. if ( !_stricmp ( arrayPpc[i].name, strName ) ) {
  73. return (FALSE); // name is already in list.
  74. }
  75. }
  76. sprintf ( arrayPpc[iPpc].name, "%s", strName );
  77. ++iPpc;
  78. return (TRUE); // not previously in list.
  79. }
  80. void Msg ( const char * szFormat, ... ) {
  81. va_list vaArgs;
  82. va_start ( vaArgs, szFormat );
  83. vprintf ( szFormat, vaArgs );
  84. vfprintf ( logFile, szFormat, vaArgs );
  85. va_end ( vaArgs );
  86. }
  87. void Header(argv)
  88. char* argv[];
  89. {
  90. time_t t;
  91. Msg ("\n=========== MBYTES =============\n");
  92. Msg("Log file: %s\n", argv[1]);
  93. Msg("Input BOM: %s\n",argv[2]);
  94. Msg("Product: %s\n",argv[3]);
  95. time(&t);
  96. Msg("Time: %s",ctime(&t));
  97. Msg("================================\n\n");
  98. }
  99. void Usage()
  100. {
  101. printf("PURPOSE: Provides # of bytes in product, Workstation or Server.\n");
  102. printf("\n");
  103. printf("PARAMETERS:\n");
  104. printf("\n");
  105. printf("[LogFile] - Path to append a log of actions and errors.\n");
  106. printf("[InBom] - Path of BOM layout file to get sizes from.\n");
  107. printf("[Product] - Product to lay out.\n");
  108. printf(" NTCD = Workstation on CD\n");
  109. printf(" LMCD = Server on CD\n");
  110. }
  111. __cdecl main(argc,argv)
  112. int argc;
  113. char* argv[];
  114. {
  115. Entry *e;
  116. int records,i;
  117. char *buf;
  118. if (argc!=4) {
  119. Usage();
  120. return(1);
  121. }
  122. if ((logFile=fopen(argv[1],"a"))==NULL) {
  123. printf("ERROR Couldn't open log file %s\n",argv[1]);
  124. return(1);
  125. }
  126. Header(argv);
  127. // Get files for product, either Workstation(NTCD) or Server(ASCD).
  128. //
  129. LoadFile(argv[2],&buf,&e,&records,argv[3]);
  130. /**
  131. for ( i = 0; i < records; ++i ) {
  132. Msg ( "record #%d, %s, size=%d, csize=%d, disk=%d\n",
  133. i, e[i].name, e[i].size, e[i].csize, e[i].disk );
  134. }
  135. **/
  136. // This adds the number of bytes for x86bins, mipsbins, alphabins,
  137. // and ppcbins.
  138. // NOTE: Some files are listed more than 1 time due to multiple inf
  139. // entries in multiple inf files, so our #s we get a just a tad
  140. // bigger than actual #s.
  141. for ( i = 0; i < records; ++i ) {
  142. // Tally up the bytes.
  143. //
  144. if ( !_stricmp ( e[i].source, "ppcbins" ) ) {
  145. if ( NotListedYetPpc( e[i].name ) ) {
  146. tallyPpc += e[i].size;
  147. if ( e[i].nocompress[0] ) {
  148. localSrcPpc += e[i].size;
  149. }
  150. else {
  151. localSrcPpc += e[i].csize;
  152. }
  153. }
  154. }
  155. else if ( !_stricmp ( e[i].source, "x86bins" ) ) {
  156. if ( NotListedYetX86( e[i].name ) ) {
  157. tallyX86 += e[i].size;
  158. if ( e[i].nocompress[0] ) {
  159. localSrcX86 += e[i].size;
  160. }
  161. else {
  162. localSrcX86 += e[i].csize;
  163. }
  164. }
  165. }
  166. else if ( !_stricmp ( e[i].source, "mipsbins" ) ) {
  167. if ( NotListedYetMips( e[i].name ) ) {
  168. tallyMips += e[i].size;
  169. if ( e[i].nocompress[0] ) {
  170. localSrcMips += e[i].size;
  171. }
  172. else {
  173. localSrcMips += e[i].csize;
  174. }
  175. }
  176. }
  177. else if ( !_stricmp ( e[i].source, "alphabins" ) ){
  178. if ( NotListedYetAlpha( e[i].name ) ) {
  179. tallyAlpha += e[i].size;
  180. if ( e[i].nocompress[0] ) {
  181. localSrcAlpha += e[i].size;
  182. }
  183. else {
  184. localSrcAlpha += e[i].csize;
  185. }
  186. }
  187. }
  188. else if ( !_stricmp ( e[i].source, "ppcdbg" ) ||
  189. !_stricmp ( e[i].source, "alphadbg" ) ||
  190. !_stricmp ( e[i].source, "mipsdbg" ) ||
  191. !_stricmp ( e[i].source, "x86dbg" ) ||
  192. !_stricmp ( e[i].source, "infs" )
  193. ) {
  194. // Do nothing with these.
  195. }
  196. else {
  197. Msg ( "ERROR: source = %s\n", e[i].source );
  198. }
  199. }
  200. Msg ( "%d X86 files are %ld bytes\n", iX86, tallyX86 );
  201. Msg ( "%d Mips files are %ld bytes\n", iMips, tallyMips );
  202. Msg ( "%d Alpha files are %ld bytes\n", iAlpha,tallyAlpha );
  203. Msg ( "%d Ppc files are %ld bytes\n", iPpc, tallyPpc );
  204. Msg ( "\n\n" );
  205. // For x86 local sources, add 3M in for the boot floppies, in case
  206. // someone does a /b option.
  207. //
  208. localSrcX86 += (3*1024*1024);
  209. // Add in a fudge factor to help out people with larger cluster
  210. // sizes. We'll work with 16K clusters
  211. //
  212. localSrcX86 += (16*1024*iX86);
  213. localSrcMips += (16*1024*iMips);
  214. localSrcAlpha += (16*1024*iAlpha);
  215. localSrcPpc += (16*1024*iPpc);
  216. // Add in a for 20M pagefile we need to reserve for.
  217. //
  218. localSrcX86 += (20*1024*1024);
  219. localSrcMips += (20*1024*1024);
  220. localSrcAlpha += (20*1024*1024);
  221. localSrcPpc += (20*1024*1024);
  222. Msg ( "%d X86 local source %ld bytes\n", iX86, localSrcX86 );
  223. Msg ( "%d Mips local source %ld bytes\n", iMips, localSrcMips );
  224. Msg ( "%d Alpha local source %ld bytes\n", iAlpha,localSrcAlpha );
  225. Msg ( "%d Ppc local source %ld bytes\n", iPpc, localSrcPpc );
  226. fclose(logFile);
  227. free(e);
  228. return(0);
  229. }