source: git/libpolys/reporter/reporter.h @ dcd92d

spielwiese
Last change on this file since dcd92d was 2c889f, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Code update corresponding to renaming findexec into resources
  • Property mode set to 100644
File size: 3.5 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 ;
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
33#define SI_PROT_I    1
34#define SI_PROT_O    2
35#define SI_PROT_IO   3
36
37/* the C-part: */
38#define mflush() fflush(stdout)
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44void    Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
45void    WerrorS_batch(const char *s);
46void    WarnS(const char *s);
47void    Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
48/* Print should not produce more than strlen(fmt)+510 characters! */
49
50void    PrintNSpaces(const int n);
51void    PrintLn();
52void    PrintS(const char* s);
53
54#ifdef __cplusplus
55}
56/* the C++-part: */
57
58void  StringAppend(const char *fmt, ...);
59void  StringAppendS(const char *s);
60void  StringSetS(const char* s);
61char * StringEndS();
62void  Warn(const char *fmt, ...);
63
64const char *  eati(const char *s, int *i);
65
66// Prints resources into string with StringAppend, etc
67void feStringAppendResources(int warn = -1);
68#endif /* c++ only */
69
70/* everything in between calls to these procedures is printed into a string
71 * which is returned by SprintEnd()
72 * Shall ONLY be used for a temporary redirection of the standard output
73 * (i.e. if Singular runs as a server)
74 */
75void SPrintStart();
76char* SPrintEnd();
77
78/* error reporting */
79#ifdef __cplusplus
80extern "C"
81{
82#endif
83extern int dReportError(const char* fmt, ...);
84#define dReportBug(s) \
85  dReportError("Bug reported: %s\n occured at %s,%d\n", s, __FILE__, __LINE__)
86
87// this is just a dummy procedure which is called after the error
88// has been reported. Within the debugger, set a breakpoint on this
89// proc.
90extern void dErrorBreak();
91#ifdef __cplusplus
92}
93#endif
94
95#ifndef HAVE_ASSUME
96#define assume(x) do {} while (0)
97#define r_assume(x) do {} while (0)
98#else /* ! HAVE_ASSUME */
99
100#define assume_violation(s,f,l) \
101  dReportError("assume violation at %s:%d condition: %s", f,l,s)
102
103#define assume(x)   _assume(x, __FILE__, __LINE__)
104#define r_assume(x) _r_assume(x, __FILE__, __LINE__)
105
106#define _assume(x, f, l)                        \
107do                                              \
108{                                               \
109  if (! (x))                                    \
110  {                                             \
111    assume_violation(#x, f, l);                 \
112  }                                             \
113}                                               \
114while (0)
115
116#define _r_assume(x, f, l)                      \
117do                                              \
118{                                               \
119  if (! (x))                                    \
120  {                                             \
121    assume_violation(#x, f, l);                 \
122    return 0;                                   \
123  }                                             \
124}                                               \
125while (0)
126#endif /* HAVE_ASSUME */
127
128#endif /* ifndef OUTPUT_H */
Note: See TracBrowser for help on using the repository browser.