From: Linus Nordberg Date: Thu, 26 Apr 2012 08:03:42 +0000 (+0200) Subject: Add util.h and util.c. X-Git-Tag: libradsec-0.0.4~70 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=a8609e55bd16b14a888535a7e2659b3217a9d1c7;hp=9b9df4b9bfc3550fdcf61f173711603c27bf48f6;p=libradsec.git Add util.h and util.c. --- 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);