File: error.c

package info (click to toggle)
cf-python 1.3.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,996 kB
  • sloc: python: 51,733; ansic: 2,736; makefile: 78; sh: 2
file content (68 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdarg.h>

#include "umfileint.h"

static FILE *output = NULL;

static int verbose;

static const int do_debug = 1;

void switch_bug(const char *routine)
{
  gripe("no match in switch statement in routine; "
	"may indicate coding bug in umfile or unexpected header value");
}

void gripe(const char *routine)
{
  if (verbose || do_debug)
    {
      fprintf(output, "umfile: error condition detected in routine %s\n",
	      routine);
      fflush(output);
    }
  verbose = 0;
}

void error_mesg(const char *fmt, ...)
{
  va_list args;

  if (verbose || do_debug)
    {
      va_start(args, fmt);
      vfprintf(output, fmt, args);
      fprintf(output, "\n");
      va_end(args);
      fflush(output);
    }
  verbose = 0;
}

void debug(const char *fmt, ...)
{
  va_list args;

  if (do_debug)
    {
      va_start(args, fmt);
      fprintf(output, "DEBUG: ");
      vfprintf(output, fmt, args);
      fprintf(output, "\n");
      va_end(args);
      fflush(output);
    }
}

void errorhandle_init()
{
  /* init sets verbose -- called at start of each of the interface routines --
   * then first call to error will cause a diagnostic to be printed,
   * but then unsets verbose to avoid series of knock-on messages
   */
  verbose = 1;
  if (output == NULL)
    output = stderr;
}