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.

109 lines
2.6 KiB

  1. /*++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1981 - 1999
  4. Module Name:
  5. commandline.cpp
  6. Abstract:
  7. Author:
  8. Rahul Thombre (RahulTh) 4/30/1998
  9. Revision History:
  10. 4/30/1998 RahulTh
  11. Created this module.
  12. --*/
  13. // CommandLine.cpp: implementation of the CCommandLine class.
  14. //
  15. //////////////////////////////////////////////////////////////////////
  16. #include "precomp.hxx"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. //////////////////////////////////////////////////////////////////////
  23. // Construction/Destruction
  24. //////////////////////////////////////////////////////////////////////
  25. CCommandLine::CCommandLine() : m_fInvalidParams(FALSE),
  26. m_iListLen(0),
  27. m_fHideApp (FALSE),
  28. m_fShowSettings(FALSE),
  29. m_fFilesProvided (FALSE),
  30. m_lpszFilesList(NULL),
  31. m_fServerStart(FALSE)
  32. {
  33. }
  34. CCommandLine::~CCommandLine()
  35. {
  36. if (m_lpszFilesList)
  37. delete [] m_lpszFilesList;
  38. }
  39. void CCommandLine::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
  40. {
  41. TCHAR* lpszTemp;
  42. if(bFlag)
  43. {
  44. if (!lstrcmp(lpszParam, TEXT("z")) || !lstrcmp(lpszParam, TEXT("Z")))
  45. m_fServerStart=TRUE;
  46. else if (!lstrcmp(lpszParam, TEXT("h")) || !lstrcmp(lpszParam, TEXT("H")))
  47. m_fHideApp = TRUE;
  48. else if (!lstrcmp(lpszParam, TEXT("s")) || !lstrcmp(lpszParam, TEXT("S")))
  49. m_fShowSettings = TRUE;
  50. else
  51. m_fInvalidParams = TRUE;
  52. }
  53. else //lpszParam is a file/folder name.
  54. {
  55. m_fFilesProvided = TRUE;
  56. m_FileNames = m_FileNames + lpszParam + "\""; //use quotes as filename separator for now.
  57. }
  58. if (bLast && m_fFilesProvided) {
  59. if (m_fShowSettings) {
  60. m_fInvalidParams = TRUE; //invalid combination of parameters
  61. } else {
  62. m_iListLen= lstrlen((LPCTSTR)m_FileNames) + 1;
  63. m_lpszFilesList = new TCHAR[m_iListLen];
  64. if ( m_lpszFilesList != NULL) {
  65. StringCchCopy(m_lpszFilesList, m_iListLen, LPCTSTR(m_FileNames));
  66. for (lpszTemp = m_lpszFilesList; *lpszTemp; lpszTemp++) {
  67. if ('\"' == *lpszTemp) {
  68. *lpszTemp = '\0'; //create a null separated list of files
  69. }
  70. }
  71. } else {
  72. m_iListLen=0;
  73. }
  74. }
  75. }
  76. }