Ejemplo n.º 1
0
static int fs_wildcardPathMatch(lua_State* L) {
    int ret = wildcardMatch(luaL_checkstring(L, 1), luaL_checkstring(L, 2));
    if (ret == 1) {
        lua_pushboolean(L, 1);
    } else {
        lua_pushboolean(L, 0);
    }
    return 1;
}
Ejemplo n.º 2
0
void Router::publish(const char* dest,Cbor msg){
	Router* cursor = _first;
			while (cursor != 0) {
				INFO(" compare %s : %s ",dest,cursor->_pattern);
				if ( wildcardMatch(dest,cursor->_pattern,true,'\0')) {
					cursor->_subscriber->handle(msg);
					INFO(" match ");
				}
				cursor = cursor->_next;
			}
}
Ejemplo n.º 3
0
bool CIniFile::wildcardMatch ( const char *pattern, const char *str )
{
	while (*str) {
		switch (*pattern) 
		{
			case '?':
				if (*str == '.') return false;
				break;
			case '*':
				return !*(pattern + 1) || wildcardMatch(pattern + 1, str) || wildcardMatch(pattern, str + 1);
			default:
				if (*str != *pattern) return false;
				break;
		}
		++str;
		++pattern;
	} 
	while (*pattern == '*') ++pattern;
	return !*pattern;
}
Ejemplo n.º 4
0
const string &CIniFile::getWildcardMatchGroup ( const string &name, const string &defaultGroup )
{
	CIniFileGroupNames::iterator it = gnames.begin();
	
	while (it != gnames.end()) {
		if (wildcardMatch(it->c_str(), name.c_str())) {
			currentGroup = *it;
			return currentGroup;
		}
		++it;
	}
	
	currentGroup = defaultGroup;
	return defaultGroup;
}