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.

132 lines
2.5 KiB

  1. /*++
  2. COMPARE.C
  3. Checks to see if a command line option matches a given expectation.
  4. Created, DavidCHR 6/9/1997
  5. --*/
  6. #include "private.h"
  7. /* ParseCompare:
  8. returns TRUE if the argument matches the expectation of pEntry */
  9. BOOL
  10. ParseCompare( optionStruct *pEntry,
  11. ULONG flags,
  12. PCHAR arg ) {
  13. CHAR buffer[ 255 ];
  14. switch( pEntry->flags & OPT_MUTEX_MASK ) {
  15. case OPT_CONTINUE:
  16. case OPT_PAUSE:
  17. case OPT_DUMMY:
  18. if ( pEntry->cmd ) {
  19. OPTIONS_DEBUG( "ParseCompare: skipping useless option ( %s, 0x%x)\n",
  20. pEntry->cmd,
  21. pEntry->flags & OPT_MUTEX_MASK );
  22. }
  23. return FALSE;
  24. case OPT_STRING:
  25. case OPT_INT:
  26. case OPT_STOP_PARSING:
  27. case OPT_LONG:
  28. case OPT_BOOL:
  29. case OPT_HELP:
  30. case OPT_FLOAT:
  31. case OPT_FUNC:
  32. case OPT_ENUMERATED:
  33. case OPT_FUNC2:
  34. #ifdef WINNT
  35. case OPT_USTRING:
  36. case OPT_WSTRING:
  37. #endif
  38. if ( pEntry->cmd ) {
  39. OPTIONS_DEBUG( "ParseCompare: option ( %s, 0x%x) is \"normal\".\n",
  40. pEntry->cmd,
  41. pEntry->flags & OPT_MUTEX_MASK );
  42. } else {
  43. ASSERT_NOTREACHED( "Nobody should EVER specify a NULL command field"
  44. " in an option structure. "
  45. "It's just plain dumb." );
  46. return FALSE;
  47. }
  48. break;
  49. case OPT_SUBOPTION:
  50. /* copy everything before the colon into a buffer, then
  51. string-compare the buffer-- suboptions have the form:
  52. [+|-|/]option:suboption:suboption */
  53. OPTIONS_DEBUG( "ParseCompare: Suboption... " );
  54. {
  55. ULONG i;
  56. for ( i = 0 ; arg[i] != ':' ; i++ ) {
  57. if ( arg[i] == '\0' ) {
  58. OPTIONS_DEBUG(" no colon. This cannot be a suboption.\n" );
  59. return FALSE;
  60. }
  61. OPTIONS_DEBUG("%c", arg[i] );
  62. buffer[i] = arg[i];
  63. }
  64. buffer[i] = '\0';
  65. arg = buffer;
  66. break;
  67. }
  68. default:
  69. #if (HIGHEST_OPTION_SUPPORTED != OPT_STOP_PARSING )
  70. #error "new options? update this switch statement or bad things will happen."
  71. #endif
  72. ASSERT_NOTREACHED( "unknown option type-- your COMPAT library is "
  73. "probably out of date. ssync security\\compat "
  74. "and rebuild, then relink your project." );
  75. return FALSE;
  76. }
  77. OPTIONS_DEBUG( "Comparing \"%s\" against \"%s\"...",
  78. arg, pEntry->cmd );
  79. if ( STRCASECMP( arg, pEntry->cmd ) == 0 ) {
  80. OPTIONS_DEBUG( "equal!\n" );
  81. return TRUE;
  82. } else {
  83. OPTIONS_DEBUG( "not equal\n" );
  84. return FALSE;
  85. }
  86. ASSERT_NOTREACHED( "Should never get here" );
  87. }