source: git/Singular/febase.h @ 50a84c

spielwiese
Last change on this file since 50a84c was 50a84c, checked in by Hans Schönemann <hannes@…>, 25 years ago
* hannes: added ERROR, trace flag for proc git-svn-id: file:///usr/local/Singular/svn/trunk@2942 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.8 KB
Line 
1#ifndef FEBASE_H
2#define FEBASE_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: febase.h,v 1.27 1999-03-16 15:33:05 Singular Exp $ */
7/*
8* ABSTRACT: basic i/o
9*/
10#include <stdio.h>
11#include <string.h>
12#include "structs.h"
13
14
15/*
16// These are our versions of fopen and fread They are very similar to
17// the usual fopen and fread, except that on reading, they always
18// convert "\r\n" into " \n" and "\r" into "\n".
19//
20// IMPORTANT: do only use myfopen and myfread when reading text,
21// do never use fopen and fread
22*/
23#ifndef unix
24FILE *myfopen(char *path, char *mode);
25#else
26#define myfopen fopen
27#endif
28size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream);
29
30
31extern char*  feErrors;
32extern int    feErrorsLen;
33extern FILE*  feProtFile;
34extern FILE*  feFilePending; /*temp. storage for grammar.y */
35extern char   fe_promptstr[];
36extern int    si_echo, printlevel;
37extern int    pagelength, colmax;
38extern int    yy_blocklineno;
39extern int    yy_noeof;
40extern char   prompt_char;
41extern const char feNotImplemented[];
42#ifdef HAVE_TCL
43extern BOOLEAN tclmode;
44#endif
45extern BOOLEAN errorreported;
46extern BOOLEAN fe_use_fgets;
47extern BOOLEAN feBatch;
48extern BOOLEAN feProt;
49extern BOOLEAN feWarn;
50extern BOOLEAN feOut;
51
52
53#define PROT_NONE 0
54#define PROT_I    1
55#define PROT_O    2
56#define PROT_IO   3
57
58/* the C-part: */
59#define mflush() fflush(stdout)
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65void   Werror(char *fmt, ...);
66void   WerrorS(const char *s);
67void   Print(char* fmt, ...);
68void   PrintLn();
69#ifdef HAVE_TCL
70void   PrintTCLS(const char c, const char * s);
71#else
72#define PrintTCLS(A,B) Print("TCL-ErrS:%s",B)
73#endif
74void   PrintS(char* s);
75
76#ifdef __cplusplus
77}
78/* the C++-part: */
79
80enum   feBufferTypes
81{
82  BT_none  = 0,  // entry level
83  BT_break = 1,  // while, for
84  BT_proc,       // proc
85  BT_example,    // example
86  BT_file,       // <"file"
87  BT_execute,    // execute
88  BT_if,         // if
89  BT_else        // else
90};
91
92enum   feBufferInputs
93{
94  BI_stdin = 1,
95  BI_buffer,
96  BI_file
97};
98
99void    feInitPaths(const char* argv0);
100char*   feGetSearchPath();
101char*   feGetExpandedExecutable();
102char*   feGetBinDir();
103char*   feGetInfoCall(const char* index);
104char*   feGetInfoProgram();
105char*   feGetInfoFile();
106
107FILE *  feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE);
108void    fePause(void);
109#ifndef __MWERKS__
110#ifdef HAVE_TCL
111
112inline void PrintTCL(const char c, int l,const char *s)
113{
114  if (s!=NULL) printf("%c:%d:%s",c,l,s);
115  else if(l==0) printf("%c:0:",c);
116  else printf("%c:1:%c",c,'0'+l);
117  fflush(stdout);
118}
119#else
120#define PrintTCL(A,B,C) Print("TCL-Err:%s",C)
121#endif
122#endif
123
124char *  StringAppend(char *fmt, ...);
125char *  StringAppendS(char *s);
126char *  StringSet(char *fmt, ...);
127char *  StringSetS(char* s);
128const  char * VoiceName();
129void    VoiceBackTrack();
130void    WarnS(const char *s);
131void    Warn(const char *fmt, ...);
132BOOLEAN contBuffer(feBufferTypes typ);
133char *  eati(char *s, int *i);
134BOOLEAN exitBuffer(feBufferTypes typ);
135BOOLEAN exitVoice();
136void    monitor(char* s,int mode);
137BOOLEAN newFile(char* fname, FILE *f=NULL);
138void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
139void *  myynewbuffer();
140void    myyoldbuffer(void * oldb);
141
142class Voice
143{
144  public:
145    Voice  * next;
146    Voice  * prev;
147    char   * filename;    // file name or proc name
148    procinfo * pi;        // proc info
149    void   * oldb;        // internal scanner buffer
150    // for files only:
151    FILE * files;         // file handle
152    // for buffers only:
153    char * buffer;        // buffer pointer
154    long   fptr;          // current position in buffer
155
156    int    start_lineno;  // lineno, to restore in recursion
157    int    curr_lineno;   // current lineno
158    feBufferInputs   sw;  // BI_stdin: read from STDIN
159                          // BI_buffer: buffer
160                          // BI_file: files
161    char   ifsw;          // if-switch:
162            /*1 ifsw==0: no if statement, else is invalid
163            *       ==1: if (0) processed, execute else
164            *       ==2: if (1) processed, else allowed but not executed
165            */
166    feBufferTypes   typ;  // buffer type: see BT_..
167
168  Voice() { memset(this,0,sizeof(*this));}
169  feBufferTypes Typ();
170  void Next();
171} ;
172
173extern Voice  *currentVoice;
174
175Voice * feInitStdin();
176
177/* feread.cc: */
178#ifdef HAVE_FEREAD
179  //void fe_set_input_mode (void);
180  //void fe_temp_set (void);
181  //void fe_temp_reset (void);
182  char * fe_fgets_stdin(char *pr,char *s, int size);
183#else
184  #ifdef HAVE_READLINE
185    void fe_set_input_mode (void);
186    void fe_reset_input_mode (void);
187    char * fe_fgets_stdin_rl(char *pr,char *s, int size);
188    #define fe_fgets_stdin(p,A,B) fe_fgets_stdin_rl(p,A,B)
189  #else
190    #define fe_fgets_stdin(p,A,B) fgets(A,B,stdin)
191  #endif
192#endif
193#endif
194#endif
Note: See TracBrowser for help on using the repository browser.