summaryrefslogtreecommitdiffstats
path: root/falgproto/falgproto-match-hostname.c
blob: 9957df803815dd72edfe5183ca88dde50cee603d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* vim: set sw=4 ts=4 sts=4 et: */

#include "config.h"
#include "falgproto.h"

#include <ctype.h>
#include <stdbool.h>


FALGPROTO_MATCHER_DECL (hostname) {

    const char *big_end = big + big_len;
    const char *little_end = little + little_len;

    for (; big_end >= big && little_end >= little &&
           toupper (*big_end) == toupper (*little_end);
           big_end--, little_end--);

    if (little_end < little) {
        if (big_end >= big) {
            if (*big_end == '.') {
                return true;
            } else {
                return false;
            }
        } else {
            return true;
        }
    }

    return false;
}