1 | #ifndef OUTPUT_H |
---|
2 | #define OUTPUT_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: basic output |
---|
9 | */ |
---|
10 | #include <stdio.h> |
---|
11 | #include <string.h> |
---|
12 | |
---|
13 | #if (SIZEOF_LONG == 8) |
---|
14 | typedef int BOOLEAN; |
---|
15 | /* testet on x86_64, gcc 3.4.6: 2 % */ |
---|
16 | /* testet on IA64, gcc 3.4.6: 1 % */ |
---|
17 | #else |
---|
18 | /* testet on athlon, gcc 2.95.4: 1 % */ |
---|
19 | typedef short BOOLEAN; |
---|
20 | #endif |
---|
21 | |
---|
22 | #ifndef FALSE |
---|
23 | #define FALSE 0 |
---|
24 | #endif |
---|
25 | |
---|
26 | #ifndef TRUE |
---|
27 | #define TRUE 1 |
---|
28 | #endif |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | extern char* feErrors; |
---|
33 | extern int feErrorsLen; |
---|
34 | extern FILE* feProtFile; |
---|
35 | extern int pagelength, colmax; |
---|
36 | extern int yy_blocklineno; |
---|
37 | extern int yy_noeof; |
---|
38 | extern const char feNotImplemented[]; |
---|
39 | extern BOOLEAN errorreported; |
---|
40 | extern int feProt; |
---|
41 | extern BOOLEAN feWarn; |
---|
42 | extern BOOLEAN feOut; |
---|
43 | extern int traceit ; |
---|
44 | #define TRACE_SHOW_PROC 1 |
---|
45 | #define TRACE_SHOW_LINENO 2 |
---|
46 | #define TRACE_SHOW_LINE 4 |
---|
47 | #define TRACE_SHOW_RINGS 8 |
---|
48 | #define TRACE_SHOW_LINE1 16 |
---|
49 | #define TRACE_BREAKPOINT 32 |
---|
50 | #define TRACE_TMP_BREAKPOINT 64 |
---|
51 | |
---|
52 | #define PROT_NONE 0 |
---|
53 | #define PROT_I 1 |
---|
54 | #define PROT_O 2 |
---|
55 | #define PROT_IO 3 |
---|
56 | |
---|
57 | /* the C-part: */ |
---|
58 | #define mflush() fflush(stdout) |
---|
59 | |
---|
60 | #ifdef __cplusplus |
---|
61 | extern "C" { |
---|
62 | #endif |
---|
63 | |
---|
64 | void Werror(const char *fmt, ...) __attribute__((format(printf,1,2))); |
---|
65 | void WerrorS(const char *s); |
---|
66 | void WarnS(const char *s); |
---|
67 | void Print(const char* fmt, ...) __attribute__((format(printf,1,2))); |
---|
68 | /* Print should not produce more than strlen(fmt)+510 characters! */ |
---|
69 | |
---|
70 | void PrintNSpaces(const int n); |
---|
71 | void PrintLn(); |
---|
72 | #ifdef HAVE_TCL |
---|
73 | void PrintTCLS(const char c, const char * s); |
---|
74 | #else |
---|
75 | #define PrintTCLS(A,B) Print("TCL-ErrS:%s",B) |
---|
76 | #endif |
---|
77 | void PrintS(const char* s); |
---|
78 | |
---|
79 | #ifdef __cplusplus |
---|
80 | } |
---|
81 | /* the C++-part: */ |
---|
82 | |
---|
83 | #ifdef HAVE_TCL |
---|
84 | |
---|
85 | inline void PrintTCL(const char c, int l,const char *s) |
---|
86 | { |
---|
87 | if (s!=NULL) printf("%c:%d:%s",c,l,s); |
---|
88 | else if(l==0) printf("%c:0:",c); |
---|
89 | else printf("%c:1:%c",c,'0'+l); |
---|
90 | fflush(stdout); |
---|
91 | } |
---|
92 | #else |
---|
93 | #define PrintTCL(A,B,C) Print("TCL-Err:%s",C) |
---|
94 | #endif /* HAVE_TCL */ |
---|
95 | |
---|
96 | char * StringAppend(const char *fmt, ...); |
---|
97 | char * StringAppendS(const char *s); |
---|
98 | char * StringSetS(const char* s); |
---|
99 | void Warn(const char *fmt, ...); |
---|
100 | |
---|
101 | #endif /* c++ only */ |
---|
102 | |
---|
103 | /* everything in between calls to these procedures is printed into a string |
---|
104 | * which is returned by SprintEnd() |
---|
105 | * Shall ONLY be used for a temporary redirection of the standard output |
---|
106 | * (i.e. if Singular runs as a server) |
---|
107 | */ |
---|
108 | void SPrintStart(); |
---|
109 | char* SPrintEnd(); |
---|
110 | |
---|
111 | /* error reporting */ |
---|
112 | #ifdef __cplusplus |
---|
113 | extern "C" |
---|
114 | { |
---|
115 | #endif |
---|
116 | extern int dReportError(const char* fmt, ...); |
---|
117 | #define dReportBug(s) \ |
---|
118 | dReportError("Bug reported: %s\n occured at %s,%d\n", s, __FILE__, __LINE__) |
---|
119 | |
---|
120 | // this is just a dummy procedure which is called after the error |
---|
121 | // has been reported. Within the debugger, set a breakpoint on this |
---|
122 | // proc. |
---|
123 | extern void dErrorBreak(); |
---|
124 | #ifdef __cplusplus |
---|
125 | } |
---|
126 | #endif |
---|
127 | |
---|
128 | #ifndef HAVE_ASSUME |
---|
129 | #define assume(x) ((void) 0) |
---|
130 | #define r_assume(x) ((void) 0) |
---|
131 | #else /* ! HAVE_ASSUME */ |
---|
132 | |
---|
133 | #define assume_violation(s,f,l) \ |
---|
134 | dReportError("assume violation at %s:%d condition: %s", f,l,s) |
---|
135 | |
---|
136 | #define assume(x) _assume(x, __FILE__, __LINE__) |
---|
137 | #define r_assume(x) _r_assume(x, __FILE__, __LINE__) |
---|
138 | |
---|
139 | #define _assume(x, f, l) \ |
---|
140 | do \ |
---|
141 | { \ |
---|
142 | if (! (x)) \ |
---|
143 | { \ |
---|
144 | assume_violation(#x, f, l); \ |
---|
145 | } \ |
---|
146 | } \ |
---|
147 | while (0) |
---|
148 | |
---|
149 | #define _r_assume(x, f, l) \ |
---|
150 | do \ |
---|
151 | { \ |
---|
152 | if (! (x)) \ |
---|
153 | { \ |
---|
154 | assume_violation(#x, f, l); \ |
---|
155 | return 0; \ |
---|
156 | } \ |
---|
157 | } \ |
---|
158 | while (0) |
---|
159 | #endif /* HAVE_ASSUME */ |
---|
160 | |
---|
161 | #endif /* ifndef OUTPUT_H */ |
---|