诸暨麻将添加redis
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.
 
 
 
 
 
 

61 lines
1.8 KiB

  1. #include "StdAfx.h"
  2. #include "WHCommandLine.h"
  3. //////////////////////////////////////////////////////////////////////////////////
  4. //构造函数
  5. CWHCommandLine::CWHCommandLine()
  6. {
  7. }
  8. //析构函数
  9. CWHCommandLine::~CWHCommandLine()
  10. {
  11. }
  12. //查询命令
  13. bool CWHCommandLine::SearchCommandItem(LPCTSTR pszCommandLine, LPCTSTR pszCommand, TCHAR szParameter[], WORD wParameterLen)
  14. {
  15. //效验参数
  16. ASSERT((pszCommandLine != NULL) && (pszCommand != NULL));
  17. if ((pszCommandLine == NULL) || (pszCommand == NULL)) return false;
  18. //参数处理
  19. if (pszCommandLine[0] != 0)
  20. {
  21. //变量定义
  22. UINT nCommandLen = lstrlen(pszCommand);
  23. LPCTSTR lpszBeginString = pszCommandLine;
  24. //提取参数
  25. while (true)
  26. {
  27. //参数分析
  28. LPCTSTR lpszEndString = _tcschr(lpszBeginString, TEXT(' '));
  29. UINT nStringLength = (lpszEndString == NULL) ? lstrlen(lpszBeginString) : (UINT)(lpszEndString - lpszBeginString);
  30. //命令分析
  31. if ((nStringLength >= nCommandLen) && (memcmp(lpszBeginString, pszCommand, nCommandLen*sizeof(TCHAR)) == 0))
  32. {
  33. //长度效验
  34. ASSERT(wParameterLen > (nStringLength - nCommandLen));
  35. if ((wParameterLen <= (nStringLength - nCommandLen))) return false;
  36. //提取参数
  37. szParameter[nStringLength - nCommandLen] = 0;
  38. CopyMemory(szParameter, lpszBeginString + nCommandLen, (nStringLength - nCommandLen)*sizeof(TCHAR));
  39. return true;
  40. }
  41. //设置变量
  42. if (lpszEndString == NULL) break;
  43. lpszBeginString = (lpszEndString + 1);
  44. }
  45. }
  46. return false;
  47. }
  48. //////////////////////////////////////////////////////////////////////////////////