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 #define TRACE_SHOW_PROC 1
26 #define TRACE_SHOW_LINENO 2
27 #define TRACE_SHOW_LINE 4
28 #define TRACE_SHOW_RINGS 8
29 #define TRACE_SHOW_LINE1 16
30 #define TRACE_BREAKPOINT 32
31 #define TRACE_TMP_BREAKPOINT 64
32 #define TRACE_CALL 128
33 #define TRACE_ASSIGN 256
34 #define TRACE_CONV 512
35 
36 
37 #define SI_PROT_I 1
38 #define SI_PROT_O 2
39 #define SI_PROT_IO 3
40 
41 /* the C-part: */
42 #define mflush() fflush(stdout)
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 void Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
49 void WerrorS_batch(const char *s);
50 void WarnS(const char *s);
51 void Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
52 /* Print should not produce more than strlen(fmt)+510 characters! */
53 
54 void PrintNSpaces(const int n);
55 void PrintLn();
56 void PrintS(const char* s);
57 
58 #ifdef __cplusplus
59 }
60 /* the C++-part: */
61 
62 // a new output buffer will be allocated by StringSetS,
63 // used by several calls to StringAppend/StringAppendS
64 // and closed by StringEndS:
65 // StringEndS() returns this buffer which must be freed by omFree
66 // several buffer may be active at the same time
67 // (for example in subroutines)
68 void StringAppend(const char *fmt, ...);
69 void StringAppendS(const char *s);
70 void StringSetS(const char* s);
71 char * StringEndS();
72 void Warn(const char *fmt, ...);
73 
74 const char * eati(const char *s, int *i);
75 
76 // Prints resources into string with StringAppend, etc
77 void feStringAppendResources(int warn = -1);
78 #endif /* c++ only */
79 
80 /* everything in between calls to these procedures is printed into a string
81  * which is returned by SprintEnd()
82  * Shall ONLY be used for a temporary redirection of the standard output
83  * (i.e. if Singular runs as a server)
84  */
85 // unlike the StringSet/StringEndS stuff:
86 // only one SPrintStart/SPrintEnd buffer may be active
87 // the returned string must be free via omFree
88 void SPrintStart();
89 char* SPrintEnd();
90 
91 /* error reporting */
92 #ifdef __cplusplus
93 extern "C"
94 {
95 #endif
96 extern int dReportError(const char* fmt, ...);
97 #define dReportBug(s) \
98  dReportError("Bug reported: %s\n occured at %s,%d\n", s, __FILE__, __LINE__)
99 
100 // this is just a dummy procedure which is called after the error
101 // has been reported. Within the debugger, set a breakpoint on this
102 // proc.
103 extern void dErrorBreak();
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #ifndef HAVE_ASSUME
109 #define assume(x) do {} while (0)
110 #define r_assume(x) do {} while (0)
111 #else /* ! HAVE_ASSUME */
112 
113 #define assume_violation(s,f,l) \
114  dReportError("assume violation at %s:%d condition: %s", f,l,s)
115 
116 #define assume(x) _assume(x, __FILE__, __LINE__)
117 #define r_assume(x) _r_assume(x, __FILE__, __LINE__)
118 
119 #define _assume(x, f, l) \
120 do \
121 { \
122  if (! (x)) \
123  { \
124  assume_violation(#x, f, l); \
125  } \
126 } \
127 while (0)
128 
129 #define _r_assume(x, f, l) \
130 do \
131 { \
132  if (! (x)) \
133  { \
134  assume_violation(#x, f, l); \
135  return 0; \
136  } \
137 } \
138 while (0)
139 #endif /* HAVE_ASSUME */
140 
141 #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
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:410
const char * eati(const char *s, int *i)
Definition: reporter.cc:385
void PrintLn()
Definition: reporter.cc:322
void dErrorBreak()
Definition: dError.cc:141
int yy_noeof
Definition: fevoices.cc:53
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:54
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:376
int colmax
Definition: febase.cc:43
int BOOLEAN
Definition: auxiliary.h:131