/[public]/psiconv/trunk/lib/psiconv/error.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/error.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 173 Revision 217
1/* 1/*
2 error.c - Part of psiconv, a PSION 5 file formats converter 2 error.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
23#include <stdio.h> 23#include <stdio.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <string.h> 25#include <string.h>
26 26
27#include "error.h" 27#include "error.h"
28#include "config.h"
29 28
30#ifdef DMALLOC 29#ifdef DMALLOC
31#include <dmalloc.h> 30#include <dmalloc.h>
32#endif 31#endif
33 32
35 const char *message) 34 const char *message)
36{ 35{
37 fprintf(stderr,"%s\n",message); 36 fprintf(stderr,"%s\n",message);
38} 37}
39 38
40#define MAX_MESSAGE 160 39#define MAX_MESSAGE 1024
41 40
42void psiconv_fatal(psiconv_config config, int level, psiconv_u32 off, 41void psiconv_fatal(psiconv_config config, int level, psiconv_u32 off,
43 const char *format,...) 42 const char *format,...)
44{ 43{
45 char buffer[MAX_MESSAGE]; 44 char buffer[MAX_MESSAGE];
56 else 55 else
57 psiconv_default_error_handler(PSICONV_VERB_FATAL,off,buffer); 56 psiconv_default_error_handler(PSICONV_VERB_FATAL,off,buffer);
58 va_end(ap); 57 va_end(ap);
59 58
60 exit(1); 59 exit(1);
60}
61
62void psiconv_error(psiconv_config config, int level, psiconv_u32 off,
63 const char *format,...)
64{
65 char buffer[MAX_MESSAGE];
66 va_list ap;
67 size_t curlen;
68
69 va_start(ap,format);
70
71 if (config->verbosity >= PSICONV_VERB_ERROR) {
72 snprintf(buffer,MAX_MESSAGE,"ERROR (offset %08x): ",off);
73 curlen = strlen(buffer);
74
75 vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
76 if (config->error_handler)
77 config->error_handler(PSICONV_VERB_ERROR,off,buffer);
78 else
79 psiconv_default_error_handler(PSICONV_VERB_ERROR,off,buffer);
80 }
81 va_end(ap);
61} 82}
62 83
63void psiconv_warn(psiconv_config config, int level, psiconv_u32 off, 84void psiconv_warn(psiconv_config config, int level, psiconv_u32 off,
64 const char *format,...) 85 const char *format,...)
65{ 86{

Legend:
Removed from v.173  
changed lines
  Added in v.217

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26