Restructure code, moving most code out of packet.c
[radsecproxy.git] / lib / debug.c
1 /* Copyright 2011 NORDUnet A/S. All rights reserved.
2    See the file COPYING for licensing information.  */
3
4 #if defined HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <stdio.h>
9 #include <assert.h>
10 #include <freeradius/libradius.h>
11 #include <radsec/radsec.h>
12 #include <radsec/radsec-impl.h>
13 #include "debug.h"
14
15 void
16 rs_dump_packet (const struct rs_packet *pkt)
17 {
18   const RADIUS_PACKET *p = NULL;
19
20   if (!pkt || !pkt->rpkt)
21     return;
22   p = pkt->rpkt;
23
24   fprintf (stderr, "\tCode: %u, Identifier: %u, Lenght: %u\n",
25            p->code,
26            p->id,
27            p->data_len);
28   fflush (stderr);
29 }
30
31 void
32 rs_dump_attr (const struct rs_attr *attr)
33 {
34   vp_printlist (stderr, attr->vp);
35 }
36
37 #if defined DEBUG
38 int
39 _rs_debug (const char *fmt, ...)
40 {
41   int n;
42   va_list args;
43
44   va_start (args, fmt);
45   n = vfprintf (stderr, fmt, args);
46   va_end (args);
47   fflush (stderr);
48
49   return n;
50 }
51 #endif