Author: adrian.chadd
Date: Tue Apr 21 01:54:09 2009
New Revision: 13959
Added:
branches/LUSCA_HEAD/libsqtlv/Makefile.am
branches/LUSCA_HEAD/libsqtlv/tlv.c
branches/LUSCA_HEAD/libsqtlv/tlv.h
Log:
Actually commit the new school TLV code..
Added: branches/LUSCA_HEAD/libsqtlv/Makefile.am
==============================================================================
--- (empty file)
+++ branches/LUSCA_HEAD/libsqtlv/Makefile.am Tue Apr 21 01:54:09 2009
@@ -0,0 +1,7 @@
+## Process this file with automake to produce Makefile.in
+
+libsqtlv_a_SOURCES = \
+ tlv.c
+
+noinst_LIBRARIES = \
+ libsqtlv.a
Added: branches/LUSCA_HEAD/libsqtlv/tlv.c
==============================================================================
--- (empty file)
+++ branches/LUSCA_HEAD/libsqtlv/tlv.c Tue Apr 21 01:54:09 2009
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "../include/util.h"
+
+#include "tlv.h"
+
+#if 0
+MemPool * pool_swap_tlv = NULL;
+#endif
+
+void
+tlv_init(void)
+{
+#if 0
+ pool_swap_tlv = memPoolCreate("storeSwapTLV", sizeof(tlv));
+#endif
+}
+
+tlv **
+tlv_add(int type, const void *ptr, size_t len, tlv ** tail)
+{
+/* tlv *t = memPoolAlloc(pool_swap_tlv); */
+ tlv *t = xmalloc(sizeof(tlv));
+ t->type = (char) type;
+ t->length = (int) len;
+ t->value = xmalloc(len);
+ xmemcpy(t->value, ptr, len);
+ *tail = t;
+ return &t->next; /* return new tail pointer */
+}
+
+void
+tlv_free(tlv * n)
+{
+ tlv *t;
+ while ((t = n) != NULL) {
+ n = t->next;
+ xfree(t->value);
+/* memPoolFree(pool_swap_tlv, t); */
+ xfree(t);
+ }
+}
Added: branches/LUSCA_HEAD/libsqtlv/tlv.h
==============================================================================
--- (empty file)
+++ branches/LUSCA_HEAD/libsqtlv/tlv.h Tue Apr 21 01:54:09 2009
@@ -0,0 +1,17 @@
+#ifndef __LIBSQTLV_TLV_H__
+#define __LIBSQTLV_TLV_H__
+
+struct _tlv;
+typedef struct _tlv tlv;
+struct _tlv {
+ char type;
+ int length;
+ void *value;
+ tlv *next;
+};
+
+extern void tlv_init(void);
+extern tlv ** tlv_add(int type, const void *ptr, size_t len, tlv ** tail);
+extern void tlv_free(tlv *);
+
+#endif
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---