source: git/libpolys/reporter/reporter.h @ 3e4cb1

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