simplified message type detection
This commit is contained in:
@@ -80,7 +80,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
{
|
{
|
||||||
// [type];[class];name;[comment];[QQ];ZZ;id;fields...
|
// [type];[class];name;[comment];[QQ];ZZ;id;fields...
|
||||||
result_t result;
|
result_t result;
|
||||||
bool isSet = false, isPassive = true;
|
bool isSet = false, isPassive = false;
|
||||||
char defaultsChar;
|
char defaultsChar;
|
||||||
unsigned int pollPriority = 0;
|
unsigned int pollPriority = 0;
|
||||||
size_t defaultPos = 1;
|
size_t defaultPos = 1;
|
||||||
@@ -90,15 +90,12 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
const char* str = (*it++).c_str();
|
const char* str = (*it++).c_str();
|
||||||
if (it == end)
|
if (it == end)
|
||||||
return RESULT_ERR_EOF;
|
return RESULT_ERR_EOF;
|
||||||
if (str[0] == 0 || strcasecmp(str, "R") == 0) { // default: active get
|
if (str[0] == 0 || strncasecmp(str, "R", 1) == 0) { // default: active get
|
||||||
isPassive = false;
|
|
||||||
defaultsChar = 'r';
|
defaultsChar = 'r';
|
||||||
} else if (strcasecmp(str, "W") == 0) { // active set
|
} else if (strncasecmp(str, "W", 1) == 0) { // active set
|
||||||
isPassive = false;
|
|
||||||
isSet = true;
|
isSet = true;
|
||||||
defaultsChar = 'w';
|
defaultsChar = 'w';
|
||||||
} else if (str[0] == 'P' || str[0] == 'p') { // poll (=active get)
|
} else if (strncasecmp(str, "P", 1) == 0) { // poll (=active get)
|
||||||
isPassive = false;
|
|
||||||
if (str[1] == 0)
|
if (str[1] == 0)
|
||||||
pollPriority = 1;
|
pollPriority = 1;
|
||||||
else {
|
else {
|
||||||
@@ -109,14 +106,14 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
}
|
}
|
||||||
defaultsChar = 'r';
|
defaultsChar = 'r';
|
||||||
} else if (str[0] >= '0' && str[0] <= '9') { // poll priority (=active get)
|
} else if (str[0] >= '0' && str[0] <= '9') { // poll priority (=active get)
|
||||||
isPassive = false;
|
|
||||||
result_t result;
|
result_t result;
|
||||||
pollPriority = parseInt(str, 10, 1, 9, result);
|
pollPriority = parseInt(str, 10, 1, 9, result);
|
||||||
if (result != RESULT_OK)
|
if (result != RESULT_OK)
|
||||||
return result;
|
return result;
|
||||||
defaultsChar = 'r';
|
defaultsChar = 'r';
|
||||||
} else { // any other: passive set/get
|
} else { // any other: passive set/get
|
||||||
isSet = str[1] == 'W' || str[1] == 'w';
|
isPassive = true;
|
||||||
|
isSet = strncasecmp(str+1, "R", 1) == 0;
|
||||||
defaultsChar = str[0];
|
defaultsChar = str[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user