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.

151 lines
4.3 KiB

  1. // CmdLineInfo.cpp: implementation of the CCmdLineInfo class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #define __FILE_ID__ 81
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. //////////////////////////////////////////////////////////////////////
  12. // Construction/Destruction
  13. //////////////////////////////////////////////////////////////////////
  14. void
  15. CCmdLineInfo::ParseParam(
  16. LPCTSTR lpszParam,
  17. BOOL bFlag,
  18. BOOL bLast
  19. )
  20. /*++
  21. Routine name : CCmdLineInfo::ParseParam
  22. Routine description:
  23. parse/interpret individual parameters from the command line
  24. Author:
  25. Alexander Malysh (AlexMay), Apr, 2000
  26. Arguments:
  27. lpszParam [in] - parameter or flag
  28. bFlag [in] - Indicates whether lpszParam is a parameter or a flag
  29. bLast [in] - Indicates if this is the last parameter or flag on the command line
  30. Return Value:
  31. None.
  32. --*/
  33. {
  34. DWORD dwRes = ERROR_SUCCESS;
  35. DBG_ENTER(TEXT("CCmdLineInfo::ParseParam"));
  36. if(bFlag)
  37. {
  38. //
  39. // lpszParam is a flag
  40. //
  41. if(_tcsicmp(lpszParam, CONSOLE_CMD_FLAG_STR_FOLDER) == 0)
  42. {
  43. //
  44. // User asked for startup folder.
  45. // Next param is expected to be folder name.
  46. //
  47. m_cmdLastFlag = CMD_FLAG_FOLDER;
  48. }
  49. else if(_tcsicmp(lpszParam, CONSOLE_CMD_FLAG_STR_MESSAGE_ID) == 0)
  50. {
  51. //
  52. // User asked for startup message.
  53. // Next param is expected to be message id.
  54. //
  55. m_cmdLastFlag = CMD_FLAG_MESSAGE_ID;
  56. }
  57. else if(_tcsicmp(lpszParam, CONSOLE_CMD_FLAG_STR_NEW) == 0)
  58. {
  59. //
  60. // User asked for new instance.
  61. // No further params required.
  62. //
  63. m_bForceNewInstace = TRUE;
  64. m_cmdLastFlag = CMD_FLAG_NONE;
  65. }
  66. else
  67. {
  68. //
  69. // No flag
  70. //
  71. m_cmdLastFlag = CMD_FLAG_NONE;
  72. }
  73. }
  74. else
  75. {
  76. //
  77. // lpszParam is a parameter.
  78. // Let's see what was the last flag specified.
  79. //
  80. switch(m_cmdLastFlag)
  81. {
  82. case CMD_FLAG_FOLDER:
  83. if(_tcsicmp(lpszParam, CONSOLE_CMD_PRM_STR_OUTBOX) == 0)
  84. {
  85. m_FolderType = FOLDER_TYPE_OUTBOX;
  86. }
  87. else if(_tcsicmp(lpszParam, CONSOLE_CMD_PRM_STR_INCOMING) == 0)
  88. {
  89. m_FolderType = FOLDER_TYPE_INCOMING;
  90. }
  91. else if(_tcsicmp(lpszParam, CONSOLE_CMD_PRM_STR_INBOX) == 0)
  92. {
  93. m_FolderType = FOLDER_TYPE_INBOX;
  94. }
  95. else if(_tcsicmp(lpszParam, CONSOLE_CMD_PRM_STR_SENT_ITEMS) == 0)
  96. {
  97. m_FolderType = FOLDER_TYPE_SENT_ITEMS;
  98. }
  99. m_cmdLastFlag = CMD_FLAG_NONE;
  100. break;
  101. case CMD_FLAG_MESSAGE_ID:
  102. //
  103. // Try to parse the message to select
  104. //
  105. if (1 != _stscanf (lpszParam, TEXT("%I64x"), &m_dwlMessageId))
  106. {
  107. //
  108. // Can't read 64-bits message id from string
  109. //
  110. CALL_FAIL (GENERAL_ERR,
  111. TEXT("Can't read 64-bits message id from input string"),
  112. ERROR_INVALID_PARAMETER);
  113. m_dwlMessageId = 0;
  114. }
  115. m_cmdLastFlag = CMD_FLAG_NONE;
  116. break;
  117. case CMD_FLAG_NONE:
  118. try
  119. {
  120. m_cstrServerName = lpszParam;
  121. }
  122. catch (...)
  123. {
  124. CALL_FAIL (MEM_ERR, TEXT("CString::operator ="), ERROR_NOT_ENOUGH_MEMORY);
  125. return;
  126. }
  127. break;
  128. default:
  129. break;
  130. }
  131. }
  132. } // CCmdLineInfo::ParseParam