/* mystricmp */ int mystricmp(char* s1, char* s2) { while( !(*s1==0 || *s2==0) && ( (*s1==*s2) || UpChar(*s1) == UpChar(*s2) ) ){ s1++; s2++; } return UpChar(*s1) - UpChar(*s2); }
BOOL CCommandParser::Option(char cOption) { BOOL fResult = FALSE; if (m_pszOptions != NULL) { fResult = strchr(m_pszOptions, UpChar(cOption)) != NULL; } return fResult; }
BOOL CCommandParser::Init(LPCSTR pszString) { BOOL fResult = FALSE; delete [] m_pszCommand; m_pszCommand = NULL; delete [] m_pszOptions; m_pszOptions = NULL; if (pszString != NULL) { // Skip white space. while (*pszString == ' ') { pszString++; } // Collect command. char szBuffer[128]; int i = 0; while ((i < sizeof(szBuffer)-1) && (*pszString != '\0') && (*pszString != ' ') && (*pszString != '/')) { szBuffer[i++] = *(pszString++); } // Save a copy of the command. if ((i > 0) && (i < sizeof(szBuffer)-1)) { szBuffer[i++] = '\0'; m_pszCommand = new char[i]; if (m_pszCommand != NULL) { lstrcpy(m_pszCommand, szBuffer); // Collect the options. i = 0; while ((i < sizeof(szBuffer)-1) && (*pszString != '\0')) { if (*pszString == '/') { if (*(pszString+1) != '\0') { szBuffer[i++] = UpChar(*(++pszString)); } } pszString++; } fResult = TRUE; // Save a copy of the options. if (i > 0) { fResult = FALSE; if (i < sizeof(szBuffer)-1) { szBuffer[i++] = '\0'; m_pszOptions = new char[i]; if (m_pszOptions != NULL) { lstrcpy(m_pszOptions, szBuffer); fResult = TRUE; } } } } } } return fResult; }