bool ServerConfig::getMacAddress(const char* p,unsigned char* data) { _CONFIG* ret; char tmp[8] = "0x"; int index = 0; const char* sMac = NULL; if ((ret = find(p)) == NULL) return false; sMac = ret->value; if (strlen(sMac) != 17) return false; if ((sMac[2] == ':' && sMac[5] == ':'&& sMac[8] == ':'&& sMac[11] == ':'&& sMac[14] == ':' )|| (sMac[2] == '-' && sMac[5] == '-'&& sMac[8] == '-'&& sMac[11] == '-'&& sMac[14] == '-')) { for (int i = 0; i < 6; i++) { tmp[2] = sMac[index]; tmp[3] = sMac[index + 1]; tmp[4] = 0; data[i] = parse_int_hex(tmp) & 0xff; } return true; } return false; }
parse_result parse_int(char const * str) { parse_result r=parse_int_hex(str); if (r.result) return r; else return parse_int_dec(str); }
bool ServerConfig::getIntHex(const char* p,int* data) { _CONFIG* ret; if((ret = find(p)) == NULL) return false; *data = parse_int_hex(ret->value); if(*data == 0&&*(ret->value) != '0') { return false; } return true; }