Debian Codegraph @

lib/ast/error.h

raw
1 /*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11 #pragma once
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /*
18 * standalone mini error interface
19 */
20
21 #include <stdarg.h>
22 #include <errno.h>
23
24 typedef struct Error_info_s {
25 int errors;
26 int indent;
27 int line;
28 int warnings;
29 int trace;
30 char *file;
31 char *id;
32 } Error_info_t;
33
34 #define ERROR_INFO 0 /* info message -- no err_id */
35 #define ERROR_WARNING 1 /* warning message */
36 #define ERROR_ERROR 2 /* error message -- no err_exit */
37 #define ERROR_FATAL 3 /* error message with err_exit */
38 #define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
39
40 #define ERROR_LEVEL 0x00ff /* level portion of status */
41 #define ERROR_USAGE 0x0800 /* usage message */
42
43 /* support for extra API misuse warnings if available */
44 #ifdef __GNUC__
45 #define PRINTF_LIKE(index, first) __attribute__((format(printf, index, first)))
46 #else
47 #define PRINTF_LIKE(index, first) /* nothing */
48 #endif
49
50 extern Error_info_t error_info;
51
52 extern void setTraceLevel (int);
53 extern void setErrorLine (int);
54 extern void setErrorFileLine (char*, int);
55 extern void setErrorId (char*);
56 extern void setErrorErrors (int);
57 extern int getErrorErrors (void);
58
59 extern void error(int, const char *, ...) PRINTF_LIKE(2, 3);
60 extern void errorf(void *, void *, int, const char *, ...) PRINTF_LIKE(4, 5);
61 extern void errorv(const char *, int, const char *, va_list);
62
63 #undef PRINTF_LIKE
64
65 #ifdef __cplusplus
66 }
67 #endif