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