1 |
frodo |
2 |
/* |
2 |
|
|
parse_aux.c - Part of psiconv, a PSION 5 file formats converter |
3 |
|
|
Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> |
4 |
|
|
|
5 |
|
|
This program is free software; you can redistribute it and/or modify |
6 |
|
|
it under the terms of the GNU General Public License as published by |
7 |
|
|
the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
(at your option) any later version. |
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful, |
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
GNU General Public License for more details. |
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License |
16 |
|
|
along with this program; if not, write to the Free Software |
17 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
#include "config.h" |
21 |
|
|
#include <stdarg.h> |
22 |
|
|
#include <stdio.h> |
23 |
|
|
#include <stdlib.h> |
24 |
|
|
|
25 |
|
|
#include "parse.h" |
26 |
|
|
#include "parse_routines.h" |
27 |
|
|
#include "data.h" |
28 |
|
|
|
29 |
|
|
void psiconv_fatal(int level, psiconv_u32 off, const char *format,...) |
30 |
|
|
{ |
31 |
|
|
va_list ap; |
32 |
|
|
va_start(ap,format); |
33 |
|
|
fprintf(stderr,"Fatal error (offset %08x): ",off); |
34 |
|
|
vfprintf(stderr,format,ap); |
35 |
|
|
fputs("\n",stderr); |
36 |
|
|
va_end(ap); |
37 |
|
|
exit(1); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
void psiconv_progress(int level, psiconv_u32 off, const char *format,...) |
41 |
|
|
{ |
42 |
|
|
int i; |
43 |
|
|
va_list ap; |
44 |
|
|
va_start(ap,format); |
45 |
|
|
if (psiconv_verbosity >= PSICONV_VERB_PROGRESS) { |
46 |
|
|
fprintf(stderr,"%08x ",off); |
47 |
|
|
for (i = 0; i < level; i++) |
48 |
|
|
fputs("=",stderr); |
49 |
|
|
fprintf(stderr,"> "); |
50 |
|
|
vfprintf(stderr,format,ap); |
51 |
|
|
fputs("\n",stderr); |
52 |
|
|
} |
53 |
|
|
va_end(ap); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
void psiconv_warn(int level, psiconv_u32 off, const char *format,...) |
57 |
|
|
{ |
58 |
|
|
va_list ap; |
59 |
|
|
va_start(ap,format); |
60 |
|
|
if (psiconv_verbosity >= PSICONV_VERB_WARN) { |
61 |
|
|
fprintf(stderr,"WARNING (offset %08x): ",off); |
62 |
|
|
vfprintf(stderr,format,ap); |
63 |
|
|
fputs("\n",stderr); |
64 |
|
|
} |
65 |
|
|
va_end(ap); |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
void psiconv_debug(int level, psiconv_u32 off, const char *format,...) |
69 |
|
|
{ |
70 |
|
|
int i; |
71 |
|
|
va_list ap; |
72 |
|
|
va_start(ap,format); |
73 |
|
|
if (psiconv_verbosity >= PSICONV_VERB_DEBUG) { |
74 |
|
|
fprintf(stderr,"%08x ",off); |
75 |
|
|
for (i = 0; i < level; i++) |
76 |
|
|
fputs("-",stderr); |
77 |
|
|
fprintf(stderr,"> "); |
78 |
|
|
vfprintf(stderr,format,ap); |
79 |
|
|
fputs("\n",stderr); |
80 |
|
|
} |
81 |
|
|
va_end(ap); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
char *psiconv_make_printable(const char *s) |
85 |
|
|
{ |
86 |
|
|
int i; |
87 |
|
|
char *res = malloc(strlen(s) + 1); |
88 |
|
|
for (i = 0; i < strlen(s); i ++) |
89 |
|
|
if (s[i] < 0x20 || s[i] >= 0x7f) |
90 |
|
|
res[i] = '.'; |
91 |
|
|
else |
92 |
|
|
res[i] = s[i]; |
93 |
|
|
res[strlen(s)] = 0; |
94 |
|
|
return res; |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
|