1 /*******************************************************************************
2 *
3 * HEADER: cterror.h
4 *
5 ********************************************************************************
6 *
7 * DESCRIPTION: Error reporting for the ctlib
8 *
9 ********************************************************************************
10 *
11 * Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the same terms as Perl itself.
14 *
15 *******************************************************************************/
16 
17 #ifndef _CTLIB_CTERROR_H
18 #define _CTLIB_CTERROR_H
19 
20 /*===== GLOBAL INCLUDES ======================================================*/
21 
22 /*===== LOCAL INCLUDES =======================================================*/
23 
24 #include "ctparse.h"
25 #include "cppreent.h"
26 
27 
28 /*===== DEFINES ==============================================================*/
29 
30 /*===== TYPEDEFS =============================================================*/
31 
32 typedef struct {
33   void *       (*newstr)(void);
34   void         (*destroy)(void *);
35   void         (*scatf)(void *, const char *, ...);
36   void         (*vscatf)(void *, const char *, va_list *);
37   const char * (*cstring)(void *, size_t *);
38   void         (*fatalerr)(void *);
39 } PrintFunctions;
40 
41 enum CTErrorSeverity {
42   CTES_INFORMATION,
43   CTES_WARNING,
44   CTES_ERROR
45 };
46 
47 typedef struct {
48   enum CTErrorSeverity severity;
49   char *string;
50 } CTLibError;
51 
52 
53 /*===== FUNCTION PROTOTYPES ==================================================*/
54 
55 #define set_print_functions CTlib_set_print_functions
56 void set_print_functions(PrintFunctions *pPF);
57 
58 #define pop_all_errors CTlib_pop_all_errors
59 void pop_all_errors(CParseInfo *pCPI);
60 
61 #define push_error CTlib_push_error
62 void push_error(CParseInfo *pCPI, const char *fmt, ...);
63 
64 #define push_warning CTlib_push_warning
65 void push_warning(CParseInfo *pCPI, const char *fmt, ...);
66 
67 #define fatal_error CTlib_fatal_error
68 void fatal_error(const char *fmt, ...);
69 
70 #define my_ucpp_ouch CTlib_my_ucpp_ouch
71 void my_ucpp_ouch(pUCPP_ char *fmt, ...);
72 
73 #define my_ucpp_error CTlib_my_ucpp_error
74 void my_ucpp_error(pUCPP_ long line, char *fmt, ...);
75 
76 #define my_ucpp_warning CTlib_my_ucpp_warning
77 void my_ucpp_warning(pUCPP_ long line, char *fmt, ...);
78 
79 #endif
80