Statistics
| Branch: | Revision:

iof-bird-daemon / client / util.c @ e598853e

History | View | Annotate | Download (875 Bytes)

1
/*
2
 *        BIRD Client -- Utility Functions
3
 *
4
 *        (c) 1999--2000 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <stdarg.h>
12

    
13
#include "nest/bird.h"
14
#include "lib/string.h"
15
#include "client/client.h"
16

    
17
/* Client versions of logging functions */
18

    
19
static void
20
vlog(const char *msg, va_list args)
21
{
22
  char buf[1024];
23

    
24
  if (bvsnprintf(buf, sizeof(buf)-1, msg, args) < 0)
25
    bsprintf(buf + sizeof(buf) - 100, " ... <too long>");
26
  fputs(buf, stderr);
27
  fputc('\n', stderr);
28
}
29

    
30
void
31
bug(const char *msg, ...)
32
{
33
  va_list args;
34

    
35
  va_start(args, msg);
36
  cleanup();
37
  fputs("Internal error: ", stderr);
38
  vlog(msg, args);
39
  vfprintf(stderr, msg, args);
40
  exit(1);
41
}
42

    
43
void
44
die(const char *msg, ...)
45
{
46
  va_list args;
47

    
48
  va_start(args, msg);
49
  cleanup();
50
  vlog(msg, args);
51
  exit(1);
52
}