summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2012-04-26 10:03:42 +0200
committerLinus Nordberg <linus@nordu.net>2012-04-26 10:08:02 +0200
commita8609e55bd16b14a888535a7e2659b3217a9d1c7 (patch)
tree7a505f73b7372895179676866ac0a5868f7ac545 /lib
parent9b9df4b9bfc3550fdcf61f173711603c27bf48f6 (diff)
Add util.h and util.c.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am5
-rw-r--r--lib/util.c19
-rw-r--r--lib/util.h4
3 files changed, 26 insertions, 2 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 294f04e..6b31435 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -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
index 0000000..3c9fef6
--- /dev/null
+++ b/lib/util.c
@@ -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
index 0000000..90c55d8
--- /dev/null
+++ b/lib/util.h
@@ -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);