[ebcfee3] | 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> |
---|
[f093ba] | 11 | #include <misc/auxiliary.h> |
---|
[854405] | 12 | #include <findexec/feFopen.h> |
---|
[3a4bda] | 13 | |
---|
[ebcfee3] | 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 | |
---|
| 33 | #define PROT_NONE 0 |
---|
| 34 | #define PROT_I 1 |
---|
| 35 | #define PROT_O 2 |
---|
| 36 | #define PROT_IO 3 |
---|
| 37 | |
---|
| 38 | /* the C-part: */ |
---|
| 39 | #define mflush() fflush(stdout) |
---|
| 40 | |
---|
| 41 | #ifdef __cplusplus |
---|
| 42 | extern "C" { |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | void Werror(const char *fmt, ...) __attribute__((format(printf,1,2))); |
---|
[854405] | 46 | void WerrorS_batch(const char *s); |
---|
[ebcfee3] | 47 | void WarnS(const char *s); |
---|
| 48 | void Print(const char* fmt, ...) __attribute__((format(printf,1,2))); |
---|
| 49 | /* Print should not produce more than strlen(fmt)+510 characters! */ |
---|
| 50 | |
---|
| 51 | void PrintNSpaces(const int n); |
---|
| 52 | void PrintLn(); |
---|
| 53 | void PrintS(const char* s); |
---|
| 54 | |
---|
| 55 | #ifdef __cplusplus |
---|
| 56 | } |
---|
| 57 | /* the C++-part: */ |
---|
| 58 | |
---|
| 59 | char * StringAppend(const char *fmt, ...); |
---|
| 60 | char * StringAppendS(const char *s); |
---|
| 61 | char * StringSetS(const char* s); |
---|
| 62 | void Warn(const char *fmt, ...); |
---|
| 63 | |
---|
[9c83f2] | 64 | const char * eati(const char *s, int *i); |
---|
| 65 | |
---|
[f323dd1] | 66 | // Prints resources into string with StringAppend, etc |
---|
| 67 | void feStringAppendResources(int warn = -1); |
---|
[ebcfee3] | 68 | #endif /* c++ only */ |
---|
| 69 | |
---|
| 70 | /* everything in between calls to these procedures is printed into a string |
---|
| 71 | * which is returned by SprintEnd() |
---|
[31cbb08] | 72 | * Shall ONLY be used for a temporary redirection of the standard output |
---|
| 73 | * (i.e. if Singular runs as a server) |
---|
[ebcfee3] | 74 | */ |
---|
| 75 | void SPrintStart(); |
---|
| 76 | char* SPrintEnd(); |
---|
| 77 | |
---|
[508610a] | 78 | /* error reporting */ |
---|
| 79 | #ifdef __cplusplus |
---|
| 80 | extern "C" |
---|
| 81 | { |
---|
| 82 | #endif |
---|
| 83 | extern 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. |
---|
| 90 | extern void dErrorBreak(); |
---|
| 91 | #ifdef __cplusplus |
---|
| 92 | } |
---|
| 93 | #endif |
---|
| 94 | |
---|
[8948da] | 95 | #ifndef HAVE_ASSUME |
---|
| 96 | #define assume(x) ((void) 0) |
---|
| 97 | #define r_assume(x) ((void) 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) \ |
---|
| 107 | do \ |
---|
| 108 | { \ |
---|
| 109 | if (! (x)) \ |
---|
| 110 | { \ |
---|
| 111 | assume_violation(#x, f, l); \ |
---|
| 112 | } \ |
---|
| 113 | } \ |
---|
| 114 | while (0) |
---|
| 115 | |
---|
| 116 | #define _r_assume(x, f, l) \ |
---|
| 117 | do \ |
---|
| 118 | { \ |
---|
| 119 | if (! (x)) \ |
---|
| 120 | { \ |
---|
| 121 | assume_violation(#x, f, l); \ |
---|
| 122 | return 0; \ |
---|
| 123 | } \ |
---|
| 124 | } \ |
---|
| 125 | while (0) |
---|
| 126 | #endif /* HAVE_ASSUME */ |
---|
[ebcfee3] | 127 | |
---|
| 128 | #endif /* ifndef OUTPUT_H */ |
---|