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.

233 lines
9.9 KiB

  1. #include <windows.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <process.h>
  5. #include <tchar.h>
  6. #include <ctype.h>
  7. int main(void)
  8. {
  9. HANDLE hFile, hFindFile, hExistingFile, hDir;
  10. CHAR *pbuff = NULL, szHtmlLine[MAX_PATH], szRoot[MAX_PATH], szDate[9], *pdirs, *pDirsTmp, delBuff[MAX_PATH];
  11. DWORD dwSize, i, dw;
  12. BY_HANDLE_FILE_INFORMATION FileInfo;
  13. SYSTEMTIME SystemTime;
  14. FILETIME FileTime;
  15. // open file that contains the list of files to process
  16. hFile = CreateFile( "\\\\iitdev\\builds\\sapi5\\Web.Files\\headera.html", GENERIC_READ,
  17. FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY, NULL );
  18. if( hFile != INVALID_HANDLE_VALUE )
  19. {
  20. dwSize = GetFileSize( hFile, NULL );
  21. if( dwSize != 0xffffff )
  22. {
  23. pbuff = new CHAR [dwSize];
  24. }
  25. if( pbuff )
  26. {
  27. // read the .html header
  28. ReadFile( hFile, pbuff, dwSize, &dw, NULL );
  29. CloseHandle( hFile );
  30. hFile = CreateFile( "\\\\iitdev\\builds\\sapi5\\Web.Files\\alphabuild.html",
  31. GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
  32. NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
  33. if( hFile != INVALID_HANDLE_VALUE )
  34. {
  35. WriteFile( hFile, pbuff, dwSize, &dw, NULL );
  36. }
  37. else
  38. {
  39. return -1;
  40. }
  41. system( "dir /b /o-d \\\\iitdev\\builds\\sapi5\\*. > dirs.txt" );
  42. hFindFile = CreateFile( _T("dirs.txt"), GENERIC_READ | GENERIC_WRITE,
  43. FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  44. if( hFindFile != INVALID_HANDLE_VALUE )
  45. {
  46. dwSize = GetFileSize( hFindFile, NULL );
  47. if( dwSize != 0xffffff )
  48. {
  49. pdirs = new CHAR [dwSize];
  50. }
  51. if( pdirs )
  52. {
  53. pDirsTmp = pdirs;
  54. ReadFile( hFindFile, pdirs, dwSize, &dw, NULL );
  55. CloseHandle( hFindFile );
  56. }
  57. else
  58. {
  59. return -1;
  60. }
  61. CHAR *pTmp, *pEnd = pdirs + dwSize;
  62. int count = 0;
  63. strcpy( szRoot, "\\\\iitdev\\builds\\sapi5\\" );
  64. do
  65. {
  66. pTmp = szRoot + 22;
  67. while( *pdirs != 13 )
  68. {
  69. *pTmp++ = *pdirs++;
  70. }
  71. *pTmp = 0;
  72. pdirs += 2;
  73. if( (++count > 10) && isdigit(szRoot[22]) )
  74. {
  75. i = sprintf( delBuff, "del /F /Q %s", szRoot );
  76. delBuff[i] = '\0';
  77. system( delBuff );
  78. continue;
  79. }
  80. hDir = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  81. OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
  82. if( hDir != INVALID_HANDLE_VALUE )
  83. {
  84. if( GetFileInformationByHandle( hDir, &FileInfo ) )
  85. {
  86. // Write date
  87. if( FileTimeToLocalFileTime( &FileInfo.ftCreationTime, &FileTime ) )
  88. {
  89. if( FileTimeToSystemTime( &FileTime, &SystemTime ) )
  90. {
  91. sprintf( szDate, "%02d/%02d/%02d", SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear % 100 );
  92. i = sprintf( szHtmlLine, "<TR>\x0d\x0a <TD ><FONT FACE=Arial ><B>%s</B>\x0d\x0a", szDate );
  93. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  94. }
  95. }
  96. }
  97. CloseHandle( hDir );
  98. }
  99. else
  100. {
  101. return -1;
  102. }
  103. // Write status line
  104. WriteFile( hFile, " <TD ><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 60, &dw, NULL );
  105. // Write Build number
  106. i = sprintf(szHtmlLine," <TD ><CENTER><B>%s</B></CENTER>\n", &szRoot[22] );
  107. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  108. // check for existence of the SAPI5 runtime and fill table entry
  109. strcpy( &szRoot[26], "\\release\\cab\\alpha\\sapi5.EXE" );
  110. szRoot[54] = '\0';
  111. hExistingFile = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  112. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  113. if( hExistingFile != INVALID_HANDLE_VALUE )
  114. {
  115. i = sprintf( szHtmlLine,
  116. " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><A HREF=FILE://%s><B>Runtime</B></A>\x0d\x0a", szRoot );
  117. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  118. CloseHandle( hExistingFile );
  119. }
  120. else
  121. {
  122. WriteFile( hFile, " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 77, &dw, NULL );
  123. }
  124. // check for existence of the SAPI5 runtime and symbols (retail)
  125. strcpy( &szRoot[26], "\\release\\cab\\alpha\\sapi5sym.EXE" );
  126. szRoot[57] = '\0';
  127. hExistingFile = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  128. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  129. if( hExistingFile != INVALID_HANDLE_VALUE )
  130. {
  131. i = sprintf( szHtmlLine,
  132. " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><A HREF=FILE://%s><B>Runtime/Symbols</B></A>\x0d\x0a",
  133. szRoot );
  134. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  135. CloseHandle( hExistingFile );
  136. }
  137. else
  138. {
  139. WriteFile( hFile, " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 77, &dw, NULL );
  140. }
  141. // check for existence of the SAPI5 retail SDK
  142. strcpy( &szRoot[26], "\\release\\cab\\alpha\\sapi5sdk.EXE" );
  143. szRoot[57] = '\0';
  144. hExistingFile = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  145. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  146. if( hExistingFile != INVALID_HANDLE_VALUE )
  147. {
  148. i = sprintf( szHtmlLine,
  149. " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><A HREF=FILE://%s><CENTER><B>SDK</B></CENTER></A>\x0d\x0a", szRoot );
  150. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  151. CloseHandle( hExistingFile );
  152. }
  153. else
  154. {
  155. WriteFile( hFile, " <TD BGCOLOR=\"#aaaaaa\"><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 77, &dw, NULL );
  156. }
  157. // check for existence of the SAPI5 runtime and symbols (debug)
  158. strcpy( &szRoot[26], "\\debug\\cab\\alpha\\sapi5sym.EXE" );
  159. szRoot[55] = '\0';
  160. hExistingFile = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  161. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  162. if( hExistingFile != INVALID_HANDLE_VALUE )
  163. {
  164. i = sprintf( szHtmlLine,
  165. " <TD BGCOLOR=\"#ffff00\"><FONT FACE=Arial ><A HREF=FILE://%s><B>Runtime/Symbols</B></A>\x0d\x0a", szRoot );
  166. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  167. CloseHandle( hExistingFile );
  168. }
  169. else
  170. {
  171. WriteFile( hFile, " <TD BGCOLOR=\"#ffff00\"><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 77, &dw, NULL );
  172. }
  173. // check for existence of the SAPI5 debug SDK
  174. strcpy( &szRoot[26], "\\debug\\cab\\alpha\\sapi5sdk.EXE" );
  175. szRoot[55] = '\0';
  176. hExistingFile = CreateFile( szRoot, GENERIC_READ, FILE_SHARE_READ, NULL,
  177. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  178. if( hExistingFile != INVALID_HANDLE_VALUE )
  179. {
  180. i = sprintf( szHtmlLine,
  181. " <TD BGCOLOR=\"#ffff00\"><FONT FACE=Arial ><A HREF=FILE://%s><CENTER><B>SDK</B></CENTER></A>\x0d\x0a", szRoot );
  182. WriteFile( hFile, szHtmlLine, i, &dw, NULL );
  183. CloseHandle( hExistingFile );
  184. }
  185. else
  186. {
  187. WriteFile( hFile, " <TD BGCOLOR=\"#ffff00\"><FONT FACE=Arial ><CENTER><B>N/A</B></CENTER>\x0d\x0a", 77, &dw, NULL );
  188. }
  189. } while( pdirs < pEnd );
  190. delete [] pDirsTmp;
  191. system( "del dirs.txt" );
  192. WriteFile( hFile, "</TABLE>\x0d\x0a<BR>\x0d\x0a\x0d\x0a</CENTER>\x0d\x0a</BODY></HTML>\x0d\x0a",
  193. 45, &dw, NULL );
  194. CloseHandle( hFile );
  195. }
  196. else
  197. {
  198. return -1;
  199. }
  200. }
  201. else
  202. {
  203. return -1;
  204. }
  205. }
  206. return 0;
  207. }