summaryrefslogtreecommitdiffstats
path: root/avahi-compat-libdns_sd/null-test.c
blob: 8cfb98fc4fdc295236459676878f8936b46d2a29 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***
  This file is part of avahi.

  avahi is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of the
  License, or (at your option) any later version.

  avahi is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
  Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with avahi; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  USA.
***/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <sys/types.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <avahi-common/gccmacro.h>
#include <dns_sd.h>

static void reply(
        AVAHI_GCC_UNUSED DNSServiceRef sdRef,
        AVAHI_GCC_UNUSED DNSServiceFlags flags,
        AVAHI_GCC_UNUSED uint32_t interfaceIndex,
        AVAHI_GCC_UNUSED DNSServiceErrorType errorCode,
        AVAHI_GCC_UNUSED const char *serviceName,
        AVAHI_GCC_UNUSED const char *regtype,
        AVAHI_GCC_UNUSED const char *replyDomain,
        AVAHI_GCC_UNUSED void *context) {
}

int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {

    DNSServiceRef ref1, ref2, ref3, ref4 = NULL;

    DNSServiceRegister(&ref1, 0, 0, "simple", "_simple._tcp", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    DNSServiceRegister(&ref2, 0, 0, "subtype #1", "_simple._tcp,_subtype1", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    DNSServiceRegister(&ref3, 0, 0, "subtype #2", "_simple._tcp,_subtype1,_subtype2", NULL, NULL, 4711, 0, NULL, NULL, NULL);

    DNSServiceRegister(&ref4, 0, 0, "subtype #3", "_simple._tcp,,", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    assert(!ref4);
    DNSServiceRegister(&ref4, 0, 0, "subtype #3", "", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    assert(!ref4);
    DNSServiceRegister(&ref4, 0, 0, "subtype #3", ",", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    assert(!ref4);
    DNSServiceRegister(&ref4, 0, 0, "subtype #3", ",,", NULL, NULL, 4711, 0, NULL, NULL, NULL);
    assert(!ref4);

    DNSServiceBrowse(&ref4, 0, 0, "_simple._tcp,_gurke", NULL, reply, NULL);

    sleep(20);

    DNSServiceRefDeallocate(ref1);
    DNSServiceRefDeallocate(ref2);
    DNSServiceRefDeallocate(ref3);
    DNSServiceRefDeallocate(ref4);

    return 0;
}