Add util.h and util.c.
authorLinus Nordberg <linus@nordu.net>
Thu, 26 Apr 2012 08:03:42 +0000 (10:03 +0200)
committerLinus Nordberg <linus@nordu.net>
Thu, 26 Apr 2012 08:08:02 +0000 (10:08 +0200)
lib/Makefile.am
lib/util.c [new file with mode: 0644]
lib/util.h [new file with mode: 0644]

index 294f04e..6b31435 100644 (file)
@@ -37,7 +37,8 @@ libradsec_la_SOURCES = \
        request.c \
        send.c \
        tcp.c \
-       udp.c
+       udp.c \
+       util.c
 
 libradsec_la_SOURCES += \
        rsp_debug.c \
@@ -52,4 +53,4 @@ libradsec_la_SOURCES += \
 endif
 
 libradsec_la_LDFLAGS = -version-info 0:0:0 -export-symbols radsec.sym
-libradsec_la_CFLAGS = $(AM_CFLAGS) -Werror # -DDEBUG -DDEBUG_LEVENT 
+libradsec_la_CFLAGS = $(AM_CFLAGS) -DDEBUG -DDEBUG_LEVENT 
diff --git a/lib/util.c b/lib/util.c
new file mode 100644 (file)
index 0000000..3c9fef6
--- /dev/null
@@ -0,0 +1,19 @@
+/* Copyright 2012 NORDUnet A/S. All rights reserved.
+   See the file COPYING for licensing information.  */
+
+#include <string.h>
+#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
+#include "util.h"
+
+char *
+rs_strdup (struct rs_context *ctx, const char *s)
+{
+  char *buf = rs_calloc (ctx, 1, strlen (s) + 1);
+
+  if (buf != NULL)
+    return strcpy (buf, s);
+
+  rs_err_ctx_push (ctx, RSE_NOMEM, NULL);
+  return NULL;
+}
diff --git a/lib/util.h b/lib/util.h
new file mode 100644 (file)
index 0000000..90c55d8
--- /dev/null
@@ -0,0 +1,4 @@
+/* Copyright 2012 NORDUnet A/S. All rights reserved.
+   See the file COPYING for licensing information.  */
+
+char *rs_strdup (struct rs_context *ctx, const char *s);