reporter.h
Go to the documentation of this file.
1 #ifndef OUTPUT_H
2 #define OUTPUT_H
3 /****************************************
4 * Computer Algebra System SINGULAR *
5 ****************************************/
6 /*
7 * ABSTRACT: basic output
8 */
9 #include <stdio.h>
10 #include <string.h>
11 #include <misc/auxiliary.h>
12 #include <resources/feFopen.h>
13 
14 extern char* feErrors;
15 extern int feErrorsLen;
16 extern FILE* feProtFile;
17 extern int pagelength, colmax;
18 extern int yy_blocklineno;
19 extern int yy_noeof;
20 extern const char feNotImplemented[];
21 extern int feProt;
22 extern BOOLEAN feWarn;
23 extern BOOLEAN feOut;
24 extern int traceit ;
25 // show entering/leaving proc:
26 #define TRACE_SHOW_PROC 1
27 // show current line-no:
28 #define TRACE_SHOW_LINENO 2
29 // show current line and wait for <RET>:
30 #define TRACE_SHOW_LINE 4
31 // show basering for all levels of the proc-stack at enteringing/leaving proc,
32 // requires RDEBUG to be defined:
33 #define TRACE_SHOW_RINGS 8
34 // show current line and do not wait for <RET>:
35 #define TRACE_SHOW_LINE1 16
36 //
37 #define TRACE_BREAKPOINT 32
38 //
39 #define TRACE_TMP_BREAKPOINT 64
40 // show all calls to kernel routines (via iparith):
41 #define TRACE_CALL 128
42 // show all assigns (via ipassign):
43 #define TRACE_ASSIGN 256
44 // show all automtic type conversions (via ipconv):
45 #define TRACE_CONV 512
46 // profiling: print line-no to smon.out:
47 #define TRACE_PROFILING 1024
48 
49 
50 #define SI_PROT_I 1
51 #define SI_PROT_O 2
52 #define SI_PROT_IO 3
53 
54 /* the C-part: */
55 #define mflush() fflush(stdout)
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 void Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
62 void WerrorS_batch(const char *s);
63 void WarnS(const char *s);
64 void Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
65 /* Print should not produce more than strlen(fmt)+510 characters! */
66 
67 void PrintNSpaces(const int n);
68 void PrintLn();
69 void PrintS(const char* s);
70 
71 #ifdef __cplusplus
72 }
73 /* the C++-part: */
74 
75 // a new output buffer will be allocated by StringSetS,
76 // used by several calls to StringAppend/StringAppendS
77 // and closed by StringEndS:
78 // StringEndS() returns this buffer which must be freed by omFree
79 // several buffer may be active at the same time
80 // (for example in subroutines)
81 void StringAppend(const char *fmt, ...);
82 void StringAppendS(const char *s);
83 void StringSetS(const char* s);
84 char * StringEndS();
85 void Warn(const char *fmt, ...);
86 
87 const char * eati(const char *s, int *i);
88 
89 // Prints resources into string with StringAppend, etc
90 void feStringAppendResources(int warn = -1);
91 #endif /* c++ only */
92 
93 /* everything in between calls to these procedures is printed into a string
94  * which is returned by SprintEnd()
95  * Shall ONLY be used for a temporary redirection of the standard output
96  * (i.e. if Singular runs as a server)
97  */
98 // unlike the StringSet/StringEndS stuff:
99 // only one SPrintStart/SPrintEnd buffer may be active
100 // the returned string must be free via omFree
101 void SPrintStart();
102 char* SPrintEnd();
103 
104 /* error reporting */
105 #ifdef __cplusplus
106 extern "C"
107 {
108 #endif
109 extern int dReportError(const char* fmt, ...);
110 #define dReportBug(s) \
111  dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)
112 
113 // this is just a dummy procedure which is called after the error
114 // has been reported. Within the debugger, set a breakpoint on this
115 // proc.
116 extern void dErrorBreak();
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #ifndef HAVE_ASSUME
122 #define assume(x) do {} while (0)
123 #define r_assume(x) do {} while (0)
124 #else /* ! HAVE_ASSUME */
125 
126 #define assume_violation(s,f,l) \
127  dReportError("assume violation at %s:%d condition: %s", f,l,s)
128 
129 #define assume(x) _assume(x, __FILE__, __LINE__)
130 #define r_assume(x) _r_assume(x, __FILE__, __LINE__)
131 
132 #define _assume(x, f, l) \
133 do \
134 { \
135  if (! (x)) \
136  { \
137  assume_violation(#x, f, l); \
138  } \
139 } \
140 while (0)
141 
142 #define _r_assume(x, f, l) \
143 do \
144 { \
145  if (! (x)) \
146  { \
147  assume_violation(#x, f, l); \
148  return 0; \
149  } \
150 } \
151 while (0)
152 #endif /* HAVE_ASSUME */
153 
154 #endif /* ifndef OUTPUT_H */
FILE * feProtFile
Definition: reporter.cc:57
const CanonicalForm int s
Definition: facAbsFact.cc:55
BOOLEAN feOut
Definition: reporter.cc:50
int feProt
Definition: reporter.cc:56
BOOLEAN feWarn
Definition: reporter.cc:49
void void WerrorS_batch(const char *s)
Definition: reporter.cc:178
const char feNotImplemented[]
Definition: reporter.cc:54
void StringSetS(const char *s)
Definition: reporter.cc:128
int feErrorsLen
Definition: reporter.cc:48
void SPrintStart()
Definition: reporter.cc:256
int dReportError(const char *fmt,...)
Definition: dError.cc:45
int pagelength
int traceit
Definition: febase.cc:47
char * feErrors
Definition: reporter.cc:47
void PrintS(const char *s)
Definition: reporter.cc:294
void feStringAppendResources(int warn=-1)
Definition: reporter.cc:415
const char * eati(const char *s, int *i)
Definition: reporter.cc:390
void PrintLn()
Definition: reporter.cc:327
void dErrorBreak()
Definition: dError.cc:141
int yy_noeof
Definition: fevoices.cc:55
void Warn(const char *fmt,...)
Definition: reporter.cc:237
All the auxiliary stuff.
int i
Definition: cfEzgcd.cc:123
void Werror(const char *fmt,...) __attribute__((format(printf
void Print(const char *fmt,...) __attribute__((format(printf
char * SPrintEnd()
Definition: reporter.cc:283
#define __attribute__(x)
Definition: mod2.h:445
char * StringEndS()
Definition: reporter.cc:151
int yy_blocklineno
Definition: fevoices.cc:56
void WarnS(const char *s)
Definition: reporter.cc:210
void StringAppend(const char *fmt,...)
Definition: reporter.cc:61
void StringAppendS(const char *s)
Definition: reporter.cc:107
void void PrintNSpaces(const int n)
Definition: reporter.cc:381
int colmax
Definition: febase.cc:43
int BOOLEAN
Definition: auxiliary.h:131