source: git/output/output.h @ 508610a

spielwiese
Last change on this file since 508610a was 508610a, checked in by Hans Schoenemann <hannes@…>, 14 years ago
dError etc defined in output.h
  • Property mode set to 100644
File size: 3.9 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 */
106void SPrintStart();
107char* SPrintEnd();
108
109/* error reporting */
110#ifdef __cplusplus
111extern "C"
112{
113#endif
114extern int dReportError(const char* fmt, ...);
115#define dReportBug(s) \
116  dReportError("Bug reported: %s\n occured at %s,%d\n", s, __FILE__, __LINE__)
117#endif
118
119// this is just a dummy procedure which is called after the error
120// has been reported. Within the debugger, set a breakpoint on this
121// proc.
122extern void dErrorBreak();
123#ifdef __cplusplus
124}
125#endif
126
127#ifndef HAVE_ASSUME
128#define assume(x) ((void) 0)
129#define r_assume(x) ((void) 0)
130#else /* ! HAVE_ASSUME */
131
132#define assume_violation(s,f,l) \
133  dReportError("assume violation at %s:%d condition: %s", f,l,s)
134
135#define assume(x)   _assume(x, __FILE__, __LINE__)
136#define r_assume(x) _r_assume(x, __FILE__, __LINE__)
137
138#define _assume(x, f, l)                        \
139do                                              \
140{                                               \
141  if (! (x))                                    \
142  {                                             \
143    assume_violation(#x, f, l);                 \
144  }                                             \
145}                                               \
146while (0)
147
148#define _r_assume(x, f, l)                      \
149do                                              \
150{                                               \
151  if (! (x))                                    \
152  {                                             \
153    assume_violation(#x, f, l);                 \
154    return 0;                                   \
155  }                                             \
156}                                               \
157while (0)
158#endif /* HAVE_ASSUME */
159
160#endif /* ifndef OUTPUT_H */
Note: See TracBrowser for help on using the repository browser.