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.

222 lines
5.7 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <malloc.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. typedef int BOOL;
  7. #define TRUE 1
  8. #define FALSE 0
  9. typedef struct _linklist
  10. {
  11. struct _linklist *Next;
  12. char data[1000];
  13. }
  14. LINKLIST;
  15. void trim( char * s )
  16. {
  17. int n;
  18. char *tmp;
  19. int i;
  20. for (n=strlen(s) -1;n>=0;n--)
  21. {
  22. if ( s[n]!=' '&&s[n]!='\t'&&s[n]!='\n') break;
  23. }
  24. s[n+1]='\0';
  25. tmp = s;
  26. for( ;isspace(*tmp); tmp++);
  27. i=0;
  28. do{
  29. s[i]=tmp[i];
  30. i++;
  31. }
  32. while (s[i]!='\0');
  33. }
  34. void AddItem( LINKLIST **ppLinkList, char * psz )
  35. {
  36. if ( *ppLinkList == NULL )
  37. {
  38. *ppLinkList = (LINKLIST *)malloc(sizeof( LINKLIST));
  39. if( *ppLinkList ) {
  40. (*ppLinkList)->Next = NULL;
  41. trim( psz );
  42. strcpy( (*ppLinkList)->data,psz );
  43. }
  44. }
  45. else
  46. AddItem ( &((*ppLinkList)->Next), psz );
  47. }
  48. void PrintItem( LINKLIST *pLinkList )
  49. {
  50. if ( pLinkList != NULL )
  51. {
  52. printf( "%s\n", pLinkList->data);
  53. PrintItem( pLinkList->Next );
  54. }
  55. }
  56. void DeleteList( LINKLIST **ppLinkList )
  57. {
  58. while ( *ppLinkList != NULL )
  59. {
  60. DeleteList (&((*ppLinkList)->Next));
  61. free (*ppLinkList);
  62. *ppLinkList = NULL;
  63. }
  64. }
  65. int
  66. __cdecl
  67. main ( int argc, char * argv[], char * envp[] )
  68. {
  69. LINKLIST *Options = NULL;
  70. LINKLIST *OptionsText = NULL;
  71. LINKLIST *LLfilename = NULL;
  72. LINKLIST *OpenFile = NULL;
  73. char buf[1000];
  74. char platbuf[1000];
  75. FILE *fp;
  76. char OptionBuf[100];
  77. sprintf(OptionBuf,"[%sOptions]",argv[2]);
  78. AddItem( &Options, OptionBuf);
  79. sprintf(OptionBuf,"[%sOptionsTextENG]",argv[2]);
  80. AddItem( &OptionsText, OptionBuf);
  81. sprintf(OptionBuf,"[%sFilename]",argv[2]);
  82. AddItem( &LLfilename, OptionBuf);
  83. if ( argc > 1 )
  84. {
  85. FILE *ffilename = fopen(argv[1],"r");
  86. LINKLIST *tmpFile;
  87. if ( ffilename != NULL)
  88. {
  89. char filename[1000];
  90. while (fgets(filename,1000,ffilename))
  91. {
  92. AddItem(&OpenFile, filename);
  93. }
  94. fclose(ffilename);
  95. }
  96. tmpFile=OpenFile;
  97. while(tmpFile!= NULL )
  98. {
  99. LINKLIST *LocOptions = NULL;
  100. LINKLIST *LocOptionsText = NULL;
  101. LINKLIST *LocPlatform = NULL;
  102. LINKLIST *tmp = NULL;
  103. BOOL ffind;
  104. trim(tmpFile->data);
  105. fp = fopen(tmpFile->data,"r");
  106. if ( fp != NULL )
  107. {
  108. BOOL fRecordPlatform = FALSE;
  109. BOOL fRecordOptions = FALSE;
  110. BOOL fRecordOptionsText = FALSE;
  111. while (fgets(buf,1000,fp))
  112. {
  113. // get the platform
  114. trim(buf);
  115. if (strcmp(buf,"")==0)
  116. {
  117. continue;
  118. }
  119. if ( strchr( buf, ';') != NULL )
  120. {
  121. continue;
  122. }
  123. if ( strchr( buf, '[') != NULL )
  124. {
  125. fRecordPlatform = FALSE;
  126. fRecordOptions = FALSE;
  127. fRecordOptionsText = FALSE;
  128. }
  129. if ( strstr( buf, "[PlatformsSupported]" ) != NULL )
  130. {
  131. fRecordPlatform = TRUE;
  132. continue;
  133. }
  134. if ( strstr( buf, "[Options]" ) != NULL )
  135. {
  136. fRecordOptions = TRUE;
  137. continue;
  138. }
  139. if ( strstr( buf, "[OptionsText" ) != NULL )
  140. {
  141. fRecordOptionsText = TRUE;
  142. continue;
  143. }
  144. if ( fRecordPlatform)
  145. {
  146. AddItem(&LocPlatform, buf );
  147. }
  148. if ( fRecordOptions)
  149. {
  150. AddItem(&LocOptions, buf );
  151. }
  152. if ( fRecordOptionsText)
  153. {
  154. AddItem(&LocOptionsText, buf );
  155. }
  156. }
  157. fclose(fp);
  158. tmp = LocPlatform;
  159. ffind = FALSE;
  160. platbuf[0]='\0';
  161. while (tmp != NULL )
  162. {
  163. if (strstr( tmp->data,argv[2]))
  164. {
  165. if ((strcmp( argv[2],"ISA")==0) && (strcmp(tmp->data,"EISA")==0))
  166. {
  167. // not mathc
  168. }
  169. else
  170. {
  171. ffind = TRUE;
  172. }
  173. }
  174. tmp=tmp->Next;
  175. }
  176. if (!ffind)
  177. goto NextFile;
  178. tmp = LocOptions;
  179. while (tmp != NULL )
  180. {
  181. AddItem(&Options,tmp->data);
  182. AddItem(&LLfilename,&(tmpFile->data[2]));
  183. tmp=tmp->Next;
  184. }
  185. tmp = LocOptionsText;
  186. while (tmp != NULL )
  187. {
  188. AddItem(&OptionsText,tmp->data);
  189. tmp=tmp->Next;
  190. }
  191. }
  192. NextFile:
  193. DeleteList(&LocOptions);
  194. DeleteList(&LocOptionsText);
  195. DeleteList(&LocPlatform);
  196. tmpFile = tmpFile->Next;
  197. }
  198. }
  199. PrintItem(Options);
  200. PrintItem(LLfilename);
  201. PrintItem(OptionsText);
  202. DeleteList (&Options);
  203. DeleteList (&OptionsText);
  204. return 0;
  205. }