summaryrefslogtreecommitdiffstats
path: root/client/util.c
blob: 9f1a16b6473b025f2fddb49f4f74ae6b1386dd15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 *	BIRD Client -- Utility Functions
 *
 *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

#include "nest/bird.h"
#include "lib/string.h"
#include "client/client.h"

/* Client versions of logging functions */

static void
vlog(char *msg, va_list args)
{
  char buf[1024];

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

void
bug(char *msg, ...)
{
  va_list args;

  va_start(args, msg);
  cleanup();
  fputs("Internal error: ", stderr);
  vlog(msg, args);
  vfprintf(stderr, msg, args);
  exit(1);
}

void
die(char *msg, ...)
{
  va_list args;

  va_start(args, msg);
  cleanup();
  vlog(msg, args);
  exit(1);
}