src/flb_router.c
static inline int router_match(const char *tag, int tag_len,
                               const char *match,
                               void *match_r)
{
    int ret = FLB_FALSE;
    char *pos = NULL;

#ifdef FLB_HAVE_REGEX
    struct flb_regex *match_regex = match_r;
    int n;
    if (match_regex) {
        n = onig_match(match_regex->regex,
                       (const unsigned char *) tag,
                       (const unsigned char *) tag + tag_len,
                       (const unsigned char *) tag, 0,
                       ONIG_OPTION_NONE);
        if (n > 0) {
            return 1;
        }
    }
#else
    (void) match_r;
#endif

    while (match) {
        if (*match == '*') {
            while (*++match == '*'){
                /* skip successive '*' */
            }
            if (*match == '\0') {
                /*  '*' is last of string */
                ret = 1;
                break;
            }

            while ((pos = strchr(tag, (int) *match))) {
#ifndef FLB_HAVE_REGEX
                if (router_match(pos, tag_len, match, NULL)) {
#else
                /* We don't need to pass the regex recursively,
                 * we matched in order above
                 */
                if (router_match(pos, tag_len, match, NULL)) {
#endif
                    ret = 1;
                    break;
                }
                tag = pos+1;
            }
            break;
        }
        else if (*tag != *match) {
            /* mismatch! */
            break;
        }
        else if (*tag == '\0') {
            /* end of tag. so matched! */
            ret = 1;
            break;
        }
        tag++;
        match++;
    }

    return ret;
}
/* wildcard support */
/* tag and match should be null terminated. */
wildcard support
tag and match should be null terminated.
wildcard support tag and match should be null terminated .
static inline int router_match(const char *tag, int tag_len,
                               const char *match,
                               void *match_r)
{
    int ret = FLB_FALSE;
    char *pos = NULL;
#ifdef FLB_HAVE_REGEX
    struct flb_regex *match_regex = match_r;
    int n;
    if (match_regex) {
        n = onig_match(match_regex->regex,
                       (const unsigned char *) tag,
                       (const unsigned char *) tag + tag_len,
                       (const unsigned char *) tag, 0,
                       ONIG_OPTION_NONE);
        if (n > 0) {
            return 1;
        }
    }
#else
    (void) match_r;
#endif
    while (match) {
        if (*match == '*') {
            while (*++match == '*'){
            }
            if (*match == '\0') {
                ret = 1;
                break;
            }
            while ((pos = strchr(tag, (int) *match))) {
#ifndef FLB_HAVE_REGEX
                if (router_match(pos, tag_len, match, NULL)) {
#else
                if (router_match(pos, tag_len, match, NULL)) {
#endif
                    ret = 1;
                    break;
                }
                tag = pos+1;
            }
            break;
        }
        else if (*tag != *match) {
            break;
        }
        else if (*tag == '\0') {
            ret = 1;
            break;
        }
        tag++;
        match++;
    }
    return ret;
}
static inline int router_match ( const char * tag , int tag_len , const char * match , void * match_r ) { int ret = FLB_FALSE ; char * pos = NULL ; #ifdef FLB_HAVE_REGEX struct flb_regex * match_regex = match_r ; int n ; if ( match_regex ) { n = onig_match ( match_regex -> regex , ( const unsigned char * ) tag , ( const unsigned char * ) tag + tag_len , ( const unsigned char * ) tag , 0 , ONIG_OPTION_NONE ) ; if ( n > 0 ) { return 1 ; } } #else ( void ) match_r ; #endif while ( match ) { if ( * match == ' ' ) { while ( * ++ match == ' ' ) { } if ( * match == ' \0 ' ) { ret = 1 ; break ; } while ( ( pos = strchr ( tag , ( int ) * match ) ) ) { #ifndef FLB_HAVE_REGEX if ( router_match ( pos , tag_len , match , NULL ) ) { #else 
                if (router_match(pos, tag_len, match, NULL)) { #endif 
                    ret = 1; break ; } tag = pos + 1 ; } break ; } else if ( * tag != * match ) { break ; } else if ( * tag == ' \0 ' ) { ret = 1 ; break ; } tag ++ ; match ++ ; } return ret ; }
wildcard support
tag and match should be null terminated.
wildcard support tag and match should be null terminated .
/* skip successive '*' */ /*  '*' is last of string */ 
                /* We don't need to pass the regex recursively,
                 * we matched in order above
                 */ /* mismatch! */ /* end of tag. so matched! */