File: error.c

package info (click to toggle)
xtrs 4.9c-3.2
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 2,236 kB
  • ctags: 1,431
  • sloc: ansic: 19,941; makefile: 248; csh: 132; sh: 129
file content (63 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (7)
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
/*
 * Copyright (C) 1992 Clarendon Hill Software.
 *
 * Permission is granted to any individual or institution to use, copy,
 * or redistribute this software, provided this copyright notice is retained. 
 *
 * This software is provided "as is" without any expressed or implied
 * warranty.  If this software brings on any sort of damage -- physical,
 * monetary, emotional, or brain -- too bad.  You've got no one to blame
 * but yourself. 
 *
 * The software may be modified for your own purposes, but modified versions
 * must retain this notice.
 */

#include "z80.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>

extern char *program_name;

void debug(const char *fmt, ...)
{
  va_list args;
  char xfmt[2048];

  strcpy(xfmt, "debug: ");
  strcat(xfmt, fmt);
  /*strcat(xfmt, "\n");*/
  va_start(args, fmt);
  vfprintf(stderr, xfmt, args);
  va_end(args);
}

void error(const char *fmt, ...)
{
  va_list args;
  char xfmt[2048];

  strcpy(xfmt, program_name);
  strcat(xfmt, " error: ");
  strcat(xfmt, fmt);
  strcat(xfmt, "\n");
  va_start(args, fmt);
  vfprintf(stderr, xfmt, args);
  va_end(args);
}

void fatal(const char *fmt, ...)
{
  va_list args;
  char xfmt[2048];

  strcpy(xfmt, program_name);
  strcat(xfmt, " fatal error: ");
  strcat(xfmt, fmt);
  strcat(xfmt, "\n");
  va_start(args, fmt);
  vfprintf(stderr, xfmt, args);
  va_end(args);
  exit(1);
}