| 1 |
/* |
| 2 |
* errormsg.c |
| 3 |
* |
| 4 |
* This file is part of the ttf2pk package. |
| 5 |
* |
| 6 |
* Copyright 1997-1999, 2000, 2002 by |
| 7 |
* Frederic Loyer <[email protected]> |
| 8 |
* Werner Lemberg <[email protected]> |
| 9 |
*/ |
| 10 |
|
| 11 |
#ifdef HAVE_CONFIG_H |
| 12 |
#include <config.h> |
| 13 |
#endif |
| 14 |
|
| 15 |
#include <stdio.h> |
| 16 |
#include <stddef.h> /* for size_t */ |
| 17 |
#include <stdarg.h> |
| 18 |
#include <stdlib.h> |
| 19 |
|
| 20 |
#include "errormsg.h" |
| 21 |
|
| 22 |
#ifdef MIKTEX |
| 23 |
#include <miktex.h> |
| 24 |
#endif |
| 25 |
|
| 26 |
|
| 27 |
/* |
| 28 |
* Print error message and quit. |
| 29 |
*/ |
| 30 |
|
| 31 |
void |
| 32 |
oops(const char *message, |
| 33 |
...) |
| 34 |
{ |
| 35 |
va_list args; |
| 36 |
|
| 37 |
|
| 38 |
va_start(args, message); |
| 39 |
fprintf(stderr, "%s: ERROR: ", progname); |
| 40 |
vfprintf(stderr, message, args); |
| 41 |
va_end(args); |
| 42 |
putc('\n', stderr); |
| 43 |
|
| 44 |
exit(1); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
/* |
| 49 |
* Print error message, a buffer, a '^' at the buffer offset, and quit. |
| 50 |
*/ |
| 51 |
|
| 52 |
void |
| 53 |
boops(const char *buffer, |
| 54 |
size_t offset, |
| 55 |
const char *message, |
| 56 |
...) |
| 57 |
{ |
| 58 |
va_list args; |
| 59 |
|
| 60 |
|
| 61 |
va_start(args, message); |
| 62 |
fprintf(stderr, "%s: ERROR: ", progname); |
| 63 |
vfprintf(stderr, message, args); |
| 64 |
va_end(args); |
| 65 |
putc('\n', stderr); |
| 66 |
|
| 67 |
if (*buffer) |
| 68 |
{ |
| 69 |
fprintf(stderr, "%s\n", buffer); |
| 70 |
while (offset) |
| 71 |
{ |
| 72 |
fprintf(stderr, " "); |
| 73 |
offset--; |
| 74 |
} |
| 75 |
fprintf(stderr, "^\n"); |
| 76 |
} |
| 77 |
|
| 78 |
exit(1); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
/* |
| 83 |
* Print warning message and continue. |
| 84 |
*/ |
| 85 |
|
| 86 |
void |
| 87 |
warning(const char *message, |
| 88 |
...) |
| 89 |
{ |
| 90 |
va_list args; |
| 91 |
|
| 92 |
|
| 93 |
va_start(args, message); |
| 94 |
fprintf(stderr, "%s: WARNING: ", progname); |
| 95 |
vfprintf(stderr, message, args); |
| 96 |
va_end(args); |
| 97 |
putc('\n', stderr); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
/* end */ |