… | |
… | |
35 | const char *message) |
35 | const char *message) |
36 | { |
36 | { |
37 | fprintf(stderr,"%s\n",message); |
37 | fprintf(stderr,"%s\n",message); |
38 | } |
38 | } |
39 | |
39 | |
40 | psiconv_error_handler_t psiconv_error_handler = psiconv_default_error_handler; |
|
|
41 | |
|
|
42 | |
|
|
43 | #define MAX_MESSAGE 160 |
40 | #define MAX_MESSAGE 160 |
44 | |
41 | |
45 | void psiconv_fatal(psiconv_config config, int level, psiconv_u32 off, |
42 | void psiconv_fatal(psiconv_config config, int level, psiconv_u32 off, |
46 | const char *format,...) |
43 | const char *format,...) |
47 | { |
44 | { |
… | |
… | |
52 | va_start(ap,format); |
49 | va_start(ap,format); |
53 | snprintf(buffer,MAX_MESSAGE,"Fatal error (offset %08x): ",off); |
50 | snprintf(buffer,MAX_MESSAGE,"Fatal error (offset %08x): ",off); |
54 | curlen = strlen(buffer); |
51 | curlen = strlen(buffer); |
55 | |
52 | |
56 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
53 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
|
|
54 | if (config->error_handler) |
|
|
55 | config->error_handler(PSICONV_VERB_FATAL,off,buffer); |
|
|
56 | else |
57 | psiconv_error_handler(PSICONV_VERB_FATAL,off,buffer); |
57 | psiconv_default_error_handler(PSICONV_VERB_FATAL,off,buffer); |
58 | va_end(ap); |
58 | va_end(ap); |
59 | |
59 | |
60 | exit(1); |
60 | exit(1); |
61 | } |
61 | } |
62 | |
62 | |
… | |
… | |
72 | if (config->verbosity >= PSICONV_VERB_WARN) { |
72 | if (config->verbosity >= PSICONV_VERB_WARN) { |
73 | snprintf(buffer,MAX_MESSAGE,"WARNING (offset %08x): ",off); |
73 | snprintf(buffer,MAX_MESSAGE,"WARNING (offset %08x): ",off); |
74 | curlen = strlen(buffer); |
74 | curlen = strlen(buffer); |
75 | |
75 | |
76 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
76 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
|
|
77 | if (config->error_handler) |
|
|
78 | config->error_handler(PSICONV_VERB_WARN,off,buffer); |
|
|
79 | else |
77 | psiconv_error_handler(PSICONV_VERB_WARN,off,buffer); |
80 | psiconv_default_error_handler(PSICONV_VERB_WARN,off,buffer); |
78 | } |
81 | } |
79 | va_end(ap); |
82 | va_end(ap); |
80 | } |
83 | } |
81 | |
84 | |
82 | void psiconv_progress(psiconv_config config,int level, psiconv_u32 off, |
85 | void psiconv_progress(psiconv_config config,int level, psiconv_u32 off, |
… | |
… | |
101 | buffer[curlen+2] = '\0'; |
104 | buffer[curlen+2] = '\0'; |
102 | curlen += 2; |
105 | curlen += 2; |
103 | |
106 | |
104 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
107 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
105 | |
108 | |
|
|
109 | if (config->error_handler) |
|
|
110 | config->error_handler(PSICONV_VERB_PROGRESS,off,buffer); |
|
|
111 | else |
106 | psiconv_error_handler(PSICONV_VERB_PROGRESS,off,buffer); |
112 | psiconv_default_error_handler(PSICONV_VERB_PROGRESS,off,buffer); |
107 | } |
113 | } |
108 | |
114 | |
109 | va_end(ap); |
115 | va_end(ap); |
110 | } |
116 | } |
111 | |
117 | |
… | |
… | |
132 | buffer[curlen+2] = '\0'; |
138 | buffer[curlen+2] = '\0'; |
133 | curlen += 2; |
139 | curlen += 2; |
134 | |
140 | |
135 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
141 | vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap); |
136 | |
142 | |
|
|
143 | if (config->error_handler) |
|
|
144 | config->error_handler(PSICONV_VERB_DEBUG,off,buffer); |
|
|
145 | else |
137 | psiconv_error_handler(PSICONV_VERB_DEBUG,off,buffer); |
146 | psiconv_default_error_handler(PSICONV_VERB_DEBUG,off,buffer); |
138 | } |
147 | } |
139 | va_end(ap); |
148 | va_end(ap); |
140 | } |
149 | } |