source: git/output/output.h @ 31cbb08

spielwiese
Last change on this file since 31cbb08 was 31cbb08, checked in by Hans Schoenemann <hannes@…>, 14 years ago
comment for SPrintStart, SPrintEnd
  • Property mode set to 100644
File size: 4.0 KB
Line 
1#ifndef OUTPUT_H
2#define OUTPUT_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7/*
8* ABSTRACT: basic output
9*/
10#include <stdio.h>
11#include <string.h>
12
13#if (SIZEOF_LONG == 8)
14typedef int BOOLEAN;
15/* testet on x86_64, gcc 3.4.6: 2 % */
16/* testet on IA64, gcc 3.4.6: 1 % */
17#else
18/* testet on athlon, gcc 2.95.4: 1 % */
19typedef short BOOLEAN;
20#endif
21
22#ifndef FALSE
23#define FALSE       0
24#endif
25
26#ifndef TRUE
27#define TRUE        1
28#endif
29
30
31
32extern char*  feErrors;
33extern int    feErrorsLen;
34extern FILE*  feProtFile;
35extern int    pagelength, colmax;
36extern int    yy_blocklineno;
37extern int    yy_noeof;
38extern const char feNotImplemented[];
39extern BOOLEAN errorreported;
40extern int     feProt;
41extern BOOLEAN feWarn;
42extern BOOLEAN feOut;
43extern int  traceit ;
44#define TRACE_SHOW_PROC   1
45#define TRACE_SHOW_LINENO 2
46#define TRACE_SHOW_LINE   4
47#define TRACE_SHOW_RINGS  8
48#define TRACE_SHOW_LINE1  16
49#define TRACE_BREAKPOINT  32
50#define TRACE_TMP_BREAKPOINT  64
51
52#define PROT_NONE 0
53#define PROT_I    1
54#define PROT_O    2
55#define 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(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();
72#ifdef HAVE_TCL
73void    PrintTCLS(const char c, const char * s);
74#else
75#define PrintTCLS(A,B) Print("TCL-ErrS:%s",B)
76#endif
77void    PrintS(const char* s);
78
79#ifdef __cplusplus
80}
81/* the C++-part: */
82
83#ifdef HAVE_TCL
84
85inline void PrintTCL(const char c, int l,const char *s)
86{
87  if (s!=NULL) printf("%c:%d:%s",c,l,s);
88  else if(l==0) printf("%c:0:",c);
89  else printf("%c:1:%c",c,'0'+l);
90  fflush(stdout);
91}
92#else
93#define PrintTCL(A,B,C) Print("TCL-Err:%s",C)
94#endif /* HAVE_TCL */
95
96char *  StringAppend(const char *fmt, ...);
97char *  StringAppendS(const char *s);
98char *  StringSetS(const char* s);
99void    Warn(const char *fmt, ...);
100
101#endif /* c++ only */
102
103/* everything in between calls to these procedures is printed into a string
104 * which is returned by SprintEnd()
105 * Shall ONLY be used for a temporary redirection of the standard output
106 * (i.e. if Singular runs as a server)
107 */
108void SPrintStart();
109char* SPrintEnd();
110
111/* error reporting */
112#ifdef __cplusplus
113extern "C"
114{
115#endif
116extern int dReportError(const char* fmt, ...);
117#define dReportBug(s) \
118  dReportError("Bug reported: %s\n occured at %s,%d\n", s, __FILE__, __LINE__)
119
120// this is just a dummy procedure which is called after the error
121// has been reported. Within the debugger, set a breakpoint on this
122// proc.
123extern void dErrorBreak();
124#ifdef __cplusplus
125}
126#endif
127
128#ifndef HAVE_ASSUME
129#define assume(x) ((void) 0)
130#define r_assume(x) ((void) 0)
131#else /* ! HAVE_ASSUME */
132
133#define assume_violation(s,f,l) \
134  dReportError("assume violation at %s:%d condition: %s", f,l,s)
135
136#define assume(x)   _assume(x, __FILE__, __LINE__)
137#define r_assume(x) _r_assume(x, __FILE__, __LINE__)
138
139#define _assume(x, f, l)                        \
140do                                              \
141{                                               \
142  if (! (x))                                    \
143  {                                             \
144    assume_violation(#x, f, l);                 \
145  }                                             \
146}                                               \
147while (0)
148
149#define _r_assume(x, f, l)                      \
150do                                              \
151{                                               \
152  if (! (x))                                    \
153  {                                             \
154    assume_violation(#x, f, l);                 \
155    return 0;                                   \
156  }                                             \
157}                                               \
158while (0)
159#endif /* HAVE_ASSUME */
160
161#endif /* ifndef OUTPUT_H */
Note: See TracBrowser for help on using the repository browser.