• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/avahi-0.6.25/avahi-compat-libdns_sd/

Lines Matching defs:*

0 /* $Id$ */
4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include <sys/types.h>
27 #include <assert.h>
28 #include <stdio.h>
30 #include <avahi-common/gccmacro.h>
31 #include <dns_sd.h>
33 static void hexdump(const void* p, size_t size) {
34 const uint8_t *c = p;
35 assert(p);
37 printf("Dumping %u bytes from %p:\n", size, p);
39 while (size > 0) {
40 unsigned i;
42 for (i = 0; i < 16; i++) {
43 if (i < size)
44 printf("%02x ", c[i]);
45 else
46 printf(" ");
49 for (i = 0; i < 16; i++) {
50 if (i < size)
51 printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.');
52 else
53 printf(" ");
56 printf("\n");
58 c += 16;
60 if (size <= 16)
61 break;
63 size -= 16;
68 int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
69 const char *r;
70 TXTRecordRef ref;
71 uint8_t l;
72 const void *p;
73 char k[256];
75 TXTRecordCreate(&ref, 0, NULL);
77 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
79 TXTRecordSetValue(&ref, "foo", 7, "lennart");
80 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
82 TXTRecordSetValue(&ref, "waldo", 5, "rocks");
83 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
85 TXTRecordSetValue(&ref, "quux", 9, "the_house");
86 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
88 TXTRecordSetValue(&ref, "yeah", 0, NULL);
89 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
91 TXTRecordSetValue(&ref, "waldo", 6, "rocked");
92 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
94 TXTRecordRemoveValue(&ref, "foo");
95 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
97 TXTRecordRemoveValue(&ref, "waldo");
98 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
100 TXTRecordSetValue(&ref, "kawumm", 6, "bloerb");
101 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
103 TXTRecordSetValue(&ref, "one", 1, "1");
104 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
106 TXTRecordSetValue(&ref, "two", 1, "2");
107 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
109 TXTRecordSetValue(&ref, "three", 1, "3");
110 hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
112 assert(TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "two"));
113 assert(!TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "four"));
115 r = TXTRecordGetValuePtr(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "kawumm", &l);
117 hexdump(r, l);
119 assert(TXTRecordGetCount(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref)) == 6);
121 TXTRecordGetItemAtIndex(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), 2, sizeof(k), k, &l, &p);
123 fprintf(stderr, "key=<%s>\n", k);
125 hexdump(p, l);
127 assert(TXTRecordGetItemAtIndex(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), 20, sizeof(k), k, &l, &p) == kDNSServiceErr_Invalid);
129 TXTRecordDeallocate(&ref);