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.

144 lines
3.4 KiB

  1. #include <mytypes.h>
  2. #include <misclib.h>
  3. #include <diskio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <memory.h>
  7. #include <ctype.h>
  8. BOOL
  9. ParseArgs(
  10. IN int argc,
  11. IN FPCHAR argv[],
  12. IN BOOL Strict,
  13. IN FPCHAR AllowedSwitchChars,
  14. OUT FPCMD_LINE_ARGS CmdLineArgs
  15. )
  16. {
  17. char *arg;
  18. char c;
  19. memset(CmdLineArgs,0,sizeof(CmdLineArgs));
  20. if(!argc) {
  21. return(TRUE);
  22. }
  23. while(--argc) {
  24. arg = *(++argv);
  25. if((*arg == '-') || (*arg == '/')) {
  26. c = (char)toupper(arg[1]);
  27. if(strchr(AllowedSwitchChars,c)) {
  28. switch(c) {
  29. case 'D':
  30. case 'Y': // to match requested behavior
  31. if((arg[2] == ':') && arg[3]) {
  32. _LogStart(&arg[3]);
  33. } else {
  34. if(Strict) {
  35. return(FALSE);
  36. }
  37. }
  38. break;
  39. case 'F':
  40. if((arg[2] == ':') && arg[3] && !CmdLineArgs->FileListFile) {
  41. CmdLineArgs->FileListFile = &arg[3];
  42. } else {
  43. if(Strict) {
  44. return(FALSE);
  45. }
  46. }
  47. break;
  48. case 'I':
  49. if((arg[2] == ':') && arg[3] && !CmdLineArgs->ImageFile) {
  50. CmdLineArgs->ImageFile = &arg[3];
  51. } else {
  52. if(Strict) {
  53. return(FALSE);
  54. }
  55. }
  56. break;
  57. case 'L':
  58. if(arg[2] == ':') {
  59. CmdLineArgs->LanguageCount = atoi(&arg[3]);
  60. } else {
  61. if(Strict) {
  62. return(FALSE);
  63. }
  64. }
  65. break;
  66. case 'M':
  67. if(arg[2] == ':') {
  68. CmdLineArgs->MasterDiskInt13Unit = (BYTE)strtoul(&arg[3],NULL,0);
  69. } else {
  70. if(Strict) {
  71. return(FALSE);
  72. }
  73. }
  74. break;
  75. case 'Q':
  76. CmdLineArgs->Quiet = TRUE;
  77. break;
  78. case 'R':
  79. CmdLineArgs->Reinit = TRUE;
  80. break;
  81. case 'T':
  82. CmdLineArgs->Test = TRUE;
  83. break;
  84. case 'X':
  85. if(arg[2] == ':') {
  86. DisableExtendedInt13((BYTE)strtoul(&arg[3],NULL,0));
  87. } else {
  88. //
  89. // Disable xint13 for all devices
  90. //
  91. DisableExtendedInt13(0);
  92. }
  93. break;
  94. default:
  95. if(Strict) {
  96. return(FALSE);
  97. }
  98. break;
  99. }
  100. } else {
  101. if(Strict) {
  102. return(FALSE);
  103. }
  104. }
  105. } else {
  106. if(Strict) {
  107. return(FALSE);
  108. }
  109. }
  110. }
  111. return(TRUE);
  112. }