-/* $Id$ */
-
/***
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
static size_t strlcpy(char *dest, const char *src, size_t n) {
assert(dest);
assert(src);
-
+
if (n > 0) {
strncpy(dest, src, n-1);
dest[n-1] = 0;
}
-
+
return strlen(src);
}
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (!(*self = avahi_new(struct _sw_text_record, 1))) {
*self = NULL;
return SW_E_UNKNOWN;
}
-
+
(*self)->strlst = NULL;
(*self)->buffer = NULL;
(*self)->buffer_size = 0;
(*self)->buffer_valid = 0;
-
+
return SW_OKAY;
}
sw_const_string string) {
AvahiStringList *n;
-
+
assert(self);
assert(string);
AVAHI_WARN_LINKAGE;
-
+
if (!(n = avahi_string_list_add(self->strlst, string)))
return SW_E_UNKNOWN;
assert(self);
assert(key);
-
+
AVAHI_WARN_LINKAGE;
if (!(n = avahi_string_list_add_pair(self->strlst, key, val)))
assert(self);
assert(key);
assert(len || !val);
-
+
AVAHI_WARN_LINKAGE;
if (!(n = avahi_string_list_add_pair_arbitrary(self->strlst, key, val, len)))
return 0;
self->buffer_size = avahi_string_list_serialize(self->strlst, NULL, 0);
-
+
if (!(self->buffer = avahi_realloc(self->buffer, self->buffer_size + 1)))
return -1;
-
+
avahi_string_list_serialize(self->strlst, self->buffer, self->buffer_size);
self->buffer_valid = 1;
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (rebuild(self) < 0)
return (uint32_t) -1;
struct _sw_text_record_iterator {
AvahiStringList *strlst, *index;
-
+
};
sw_result sw_text_record_iterator_init(
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (!(*self = avahi_new(struct _sw_text_record_iterator, 1))) {
*self = NULL;
return SW_E_UNKNOWN;
}
(*self)->index = (*self)->strlst = avahi_string_list_reverse(txt);
-
+
return SW_OKAY;
}
avahi_string_list_free(self->strlst);
avahi_free(self);
-
+
return SW_OKAY;
}
char *mkey = NULL, *mvalue = NULL;
size_t msize = 0;
-
+
assert(self);
assert(key);
-
+
AVAHI_WARN_LINKAGE;
if (!self->index)
memset(val, 0, SW_TEXT_RECORD_MAX_LEN);
memcpy(val, mvalue, msize);
*val_len = msize;
-
+
avahi_free(mkey);
avahi_free(mvalue);