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.

220 lines
6.3 KiB

  1. // comptest.cpp : Defines the entry point for the console application.
  2. //
  3. #pragma warning( disable:4786 )
  4. #include <iostream>
  5. #include <compfile.h>
  6. #include "media.h"
  7. using namespace std;
  8. extern "C" {
  9. WCHAR NativeSourcePaths[MAX_SOURCE_COUNT][MAX_PATH];
  10. }
  11. char *NativeSourcePathsA = NULL;
  12. /*extern "C" {
  13. WCHAR *NativeSourcePaths[] = {0};
  14. }*/
  15. //
  16. // main() entry point
  17. //
  18. bool bUITest = FALSE;
  19. bool bVerbose = FALSE;
  20. bool bDebug = FALSE;
  21. int
  22. __cdecl
  23. main(
  24. int argc,
  25. char * argv[]
  26. )
  27. {
  28. bool bOutputFile = FALSE;
  29. char *pCompFileName = NULL;
  30. ComplianceFile *pCompFile;
  31. ofstream *pOutFile;
  32. if (argc > 1) {
  33. try {
  34. int count = 1;
  35. while ( count < argc) {
  36. if( argv[count] && (sizeof(argv[count]) > 3) && (*argv[count] == '-')) {
  37. switch ( *(argv[count]+1)) {
  38. case 's':
  39. case 'S':
  40. NativeSourcePathsA = argv[count]+3;
  41. MultiByteToWideChar( CP_ACP, 0, NativeSourcePathsA, -1, NativeSourcePaths[0],
  42. sizeof(NativeSourcePaths[0])/sizeof(NativeSourcePaths[0][0]));
  43. wprintf( L"NativeSourcePaths %s\n",NativeSourcePaths[0]);
  44. if ( NativeSourcePaths[0][0]) {
  45. ReadMediaData();
  46. }
  47. break;
  48. case 'i':
  49. case 'I':
  50. pCompFileName = argv[count]+3;
  51. break;
  52. case 'o':
  53. case 'O':
  54. cerr << "outFile " << argv[count]+3 <<endl;
  55. pOutFile = new ofstream(argv[count]+3);
  56. if (!(pOutFile)->good()) {
  57. throw ComplianceFile::InvalidFileName(argv[count]+3);
  58. }
  59. bOutputFile = TRUE;
  60. break;
  61. case 'u':
  62. case 'U':
  63. bUITest = TRUE;
  64. break;
  65. case 'd':
  66. case 'D':
  67. bDebug = TRUE;
  68. break;
  69. case 'v':
  70. case 'V':
  71. bVerbose = TRUE;
  72. break;
  73. default:
  74. break;
  75. }
  76. }
  77. count++;
  78. }
  79. if ( !pCompFileName) {
  80. cerr << "-i:inputfile must be specified" << endl;
  81. } else {
  82. pCompFile = new ComplianceFile(pCompFileName);
  83. if ( bOutputFile) {
  84. (pCompFile)->executeTestCases(*pOutFile);
  85. } else {
  86. (pCompFile)->executeTestCases(cerr);
  87. }
  88. MediaDataCleanUp();
  89. }
  90. } catch (ComplianceFile::InvalidFileFormat iff) {
  91. cerr << iff;
  92. } catch (ComplianceFile::InvalidFileName ifn) {
  93. cerr << ifn;
  94. } catch (ComplianceFile::MissingSection ms) {
  95. cerr << ms;
  96. } catch (Section::InvalidSectionFormat isf) {
  97. cerr << isf;
  98. } catch (Section::InvalidSectionName isn) {
  99. cerr << isn;
  100. } catch (ValueSection::ValueNotFound vnf) {
  101. cerr << vnf;
  102. } catch (TestCase::InvalidFormat itf) {
  103. cerr << itf;
  104. } catch (...) {
  105. cerr << "Unknown Exception caught... :(" << endl;
  106. }
  107. } else {
  108. cerr << "illegal usage :(" << endl;
  109. }
  110. return 0;
  111. }
  112. /*
  113. namespace Compliance {
  114. //
  115. // static data initialization
  116. //
  117. const string UpgradeTestCase::m_szDelimiters = ":#";
  118. //
  119. // utility function to tokenize a given line based on the delimiters
  120. // specified
  121. //
  122. template< class T >
  123. unsigned Tokenize(const T &szInput, const T & szDelimiters, vector<T>& tokens) {
  124. unsigned uDelimiterCount = 0;
  125. tokens.clear();
  126. if(!szInput.empty()){
  127. if(!szDelimiters.empty()){
  128. T::const_iterator inputIter = szInput.begin();
  129. T::const_iterator copyIter = szInput.begin();
  130. while(inputIter != szInput.end()){
  131. if(szDelimiters.find(*inputIter) != string::npos){
  132. if (copyIter < inputIter) {
  133. tokens.push_back(szInput.substr(copyIter - szInput.begin(),
  134. inputIter - copyIter));
  135. }
  136. uDelimiterCount++;
  137. inputIter++;
  138. copyIter = inputIter;
  139. continue;
  140. }
  141. inputIter++;
  142. }
  143. if(copyIter != inputIter){
  144. tokens.push_back(szInput.substr(copyIter - szInput.begin(),
  145. inputIter - szInput.begin()));
  146. }
  147. }
  148. else
  149. tokens.push_back(szInput);
  150. }
  151. return uDelimiterCount;
  152. }
  153. //
  154. // debug output for section
  155. //
  156. ostream& operator<<(ostream &os, const Section &section){
  157. os << "Section Name: " << section.name() << endl;
  158. os << "Number of child sections : " << section.childSections().size() << endl;
  159. os << "Section content : " << endl;
  160. vector<string>::const_iterator liter = section.lines().begin();
  161. while (liter != section.lines().end())
  162. os << *liter++ << endl;
  163. // dump all the child sections
  164. vector<Section>::const_iterator iter = section.childSections().begin();
  165. while (iter != section.childSections().end()) {
  166. os << (const Section &)(*iter) << endl;
  167. iter++;
  168. }
  169. return os;
  170. }
  171. //
  172. // debug output for compliance file
  173. //
  174. ostream& operator<<(ostream& os, const ComplianceFile &cf){
  175. os << "------------------------------------------------------------" << endl;
  176. os << "Compliance File State - Dump" << endl;
  177. os << "Name : " << cf.name() << endl;
  178. os << "Num Lines : " << cf.lines().size() << endl;
  179. os << "Section Dump : " << endl;
  180. if (cf.topLevelSection())
  181. os << *(cf.topLevelSection()) << endl;
  182. os << "------------------------------------------------------------" << endl;
  183. return os;
  184. }
  185. }
  186. */