#include <assert.h>
-#include <howl.h>
-
#include <avahi-common/strlst.h>
#include <avahi-common/malloc.h>
#include <avahi-common/domain.h>
+#include "howl.h"
#include "warn.h"
struct _sw_text_record {
int buffer_valid;
};
+#ifndef HAVE_STRLCPY
+
+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);
+}
+
+#endif
+
sw_result sw_text_record_init(sw_text_record *self) {
assert(self);
sw_result sw_text_record_iterator_next(
sw_text_record_iterator self,
- char key[255],
- sw_uint8 val[255],
+ char key[SW_TEXT_RECORD_MAX_LEN],
+ sw_uint8 val[SW_TEXT_RECORD_MAX_LEN],
sw_uint32 * val_len) {
char *mkey = NULL, *mvalue = NULL;
if (avahi_string_list_get_pair(self->index, &mkey, &mvalue, &msize) < 0)
return SW_E_UNKNOWN;
- avahi_strlcpy(key, mkey, 255);
+ strlcpy(key, mkey, SW_TEXT_RECORD_MAX_LEN);
+ memset(val, 0, SW_TEXT_RECORD_MAX_LEN);
memcpy(val, mvalue, msize);
*val_len = msize;