From a8609e55bd16b14a888535a7e2659b3217a9d1c7 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Thu, 26 Apr 2012 10:03:42 +0200 Subject: Add util.h and util.c. --- lib/Makefile.am | 5 +++-- lib/util.c | 19 +++++++++++++++++++ lib/util.h | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 lib/util.c create mode 100644 lib/util.h (limited to 'lib') 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 +#include +#include +#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); -- cgit v1.1