Follow API change in tests.
[radsecproxy.git] / lib / attr.c
1 /* Copyright 2010, 2011 NORDUnet A/S. All rights reserved.
2    See LICENSE for licensing information.  */
3
4 /* NOTE: This file is not in use at the moment (libradsec-0.0.1).  */
5
6 #if defined HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9
10 #include <radius/client.h>
11 #include <radsec/radsec.h>
12 #include <radsec/radsec-impl.h>
13
14 int
15 rs_attr_create(struct rs_connection *conn,
16                struct rs_attr **attr,
17                const char *type,
18                const char *val)
19 {
20   VALUE_PAIR *vp;
21   struct rs_attr *a;
22
23   *attr = NULL;
24   a = (struct rs_attr *) malloc (sizeof(struct rs_attr));
25   if (!a)
26     return rs_err_conn_push_fl (conn, RSE_NOMEM, __FILE__, __LINE__, NULL);
27   memset (a, 0, sizeof(struct rs_attr));
28
29   vp = pairmake (type, val, T_OP_EQ);
30   if (!vp)
31     {
32       rs_attr_destroy (a);
33       return rs_err_conn_push_fl (conn, RSE_FR, __FILE__, __LINE__,
34                                   "pairmake: %s", fr_strerror ());
35     }
36
37   a->vp = vp;
38   *attr = a;
39   return RSE_OK;
40 }
41
42 void
43 rs_attr_destroy (struct rs_attr *attr)
44 {
45   if (attr->vp)
46     pairfree (&attr->vp);
47   free (attr);
48 }