flxStringList *a = NULL, *b;
guint size, n;
+ a = flx_string_list_add(a, "start");
a = flx_string_list_add(a, "foo");
a = flx_string_list_add(a, "bar");
- a = flx_string_list_add(a, "baz");
+ a = flx_string_list_add(a, "quux");
+ a = flx_string_list_add_arbitrary(a, "null\0null", 9);
+ a = flx_string_list_add(a, "end");
t = flx_string_list_to_string(a);
printf("--%s--\n", t);
printf("--%s--\n", t);
g_free(t);
+ flx_string_list_free(b);
+
+ b = flx_string_list_copy(a);
+
+ g_assert(flx_string_list_equal(a, b));
+ t = flx_string_list_to_string(b);
+ printf("--%s--\n", t);
+ g_free(t);
+
flx_string_list_free(a);
flx_string_list_free(b);
#include "strlst.h"
-static flxStringList *string_list_add_internal(flxStringList *l, const gchar *text, guint size) {
+flxStringList *flx_string_list_add_arbitrary(flxStringList *l, const guint8*text, guint size) {
flxStringList *n;
g_assert(text);
n = g_malloc(sizeof(flxStringList) + size);
n->next = l;
- strncpy(n->text, text, size);
- n->text[size] = 0;
+ memcpy(n->text, text, n->size = size);
return n;
}
flxStringList *flx_string_list_add(flxStringList *l, const gchar *text) {
g_assert(text);
- return string_list_add_internal(l, text, strlen(text));
+ return flx_string_list_add_arbitrary(l, (const guint8*) text, strlen(text));
}
flxStringList *flx_string_list_parse(gconstpointer data, guint size) {
break;
k = *(c++);
- r = string_list_add_internal(r, (const gchar*) c, k);
+ r = flx_string_list_add_arbitrary(r, c, k);
c += k;
size -= 1 + k;
}
}
-
static flxStringList* string_list_reverse(flxStringList *l) {
flxStringList *r = NULL, *n;
if (n != l)
s ++;
- s += strlen(n->text)+2;
+ s += n->size+3;
}
- t = e = g_new(gchar, s+1);
+ t = e = g_new(gchar, s);
for (n = l; n; n = n->next) {
if (n != l)
*(e++) = ' ';
*(e++) = '"';
- strcpy(e, n->text);
- e += strlen(n->text);
+ strncpy(e, n->text, n->size);
+ e[n->size] = 0;
+ e = strchr(e, 0);
*(e++) = '"';
}
if (size < 1)
break;
- k = strlen(n->text);
+ k = n->size;
if (k > 255)
k = 255;
for (n = l; n; n = n->next) {
guint k;
- k = strlen(n->text);
+ k = n->size;
if (k > 255)
k = 255;
if (!a || !b)
return FALSE;
- if (strcmp(a->text, b->text) != 0)
+ if (a->size != b->size)
+ return FALSE;
+
+ if (a->size != 0 && memcmp(a->text, b->text, a->size) != 0)
return FALSE;
a = a->next;
return r;
}
+
flxStringList *flx_string_list_new(const gchar *txt, ...) {
va_list va;
flxStringList *r = NULL;
flxStringList *r = NULL;
for (; l; l = l->next)
- r = flx_string_list_add(r, l->text);
+ r = flx_string_list_add_arbitrary(r, l->text, l->size);
return string_list_reverse(r);
}
struct _flxStringList {
flxStringList *next;
- gchar text[1];
+ guint size;
+ guint8 text[1];
};
flxStringList *flx_string_list_new(const gchar *txt, ...);
void flx_string_list_free(flxStringList *l);
flxStringList *flx_string_list_add(flxStringList *l, const gchar *text);
+flxStringList *flx_string_list_add_arbitrary(flxStringList *l, const guint8 *text, guint size);
flxStringList *flx_string_list_add_many(flxStringList *r, ...);
flxStringList *flx_string_list_add_many_va(flxStringList *r, va_list va);
* add SRV and TXT records referenced from PTR records automatically to packet
* add A and AAAA records referenced from SRV records automatically to packet
-* allow NULL bytes in TXT records
-
done:
* Probing/Conflict resolution
* uniqueness
* name compression
* remove expression "rrset" from source files
* defend our entries on incoming goodbye
-
-
+* allow NULL bytes in TXT records