1 /* { dg-do compile } */
2 /* { dg-options "-O2 -g" } */
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <stdarg.h>
7
8 #define DEBUG_BUFFER_SIZE 80
9 int unifi_debug = 5;
10
11 void
unifi_trace(void * ospriv,int level,const char * fmt,...)12 unifi_trace (void* ospriv, int level, const char *fmt, ...)
13 {
14 static char s[DEBUG_BUFFER_SIZE];
15 va_list args;
16 unsigned int len;
17
18 if (!ospriv)
19 return;
20
21 if (unifi_debug >= level)
22 {
23 va_start (args, fmt);
24 len = vsnprintf (&(s)[0], (DEBUG_BUFFER_SIZE), fmt, args);
25 va_end (args);
26
27 if (len >= DEBUG_BUFFER_SIZE)
28 {
29 (s)[DEBUG_BUFFER_SIZE - 2] = '\n';
30 (s)[DEBUG_BUFFER_SIZE - 1] = 0;
31 }
32
33 printf ("%s", s);
34 }
35 }
36
37