source: git/Singular/febase.h @ 97454d

spielwiese
Last change on this file since 97454d was 97454d, checked in by Olaf Bachmann <obachman@…>, 26 years ago
1998-04-07 Olaf Bachmann <obachman@mathematik.uni-kl.de> * mpsr_Put.cc (mpsr_PutDump): dump does not dump LIB string any more * extra.cc (jjSYSTEM): added System("whoami") to return full executable pathname of running Singular git-svn-id: file:///usr/local/Singular/svn/trunk@1355 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.9 KB
RevLine 
[0e1846]1#ifndef FEBASE_H
2#define FEBASE_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
[97454d]6/* $Id: febase.h,v 1.11 1998-04-07 18:35:23 obachman Exp $ */
[0e1846]7/*
8* ABSTRACT
9*/
10#include <stdio.h>
[057e93c]11#include <string.h>
[0e1846]12#include "structs.h"
13
[057e93c]14extern char*  feErrors;
15extern FILE*  feProtFile;
16extern FILE*  feFilePending; /*temp. storage for grammar.y */
17extern char   fe_promptstr[];
[0e1846]18extern int    si_echo, printlevel;
19extern int    pagelength, colmax;
[cc94b0a]20extern int    yy_blocklineno;
21extern int    yy_noeof;
[0e1846]22extern char   prompt_char;
[057e93c]23#ifdef HAVE_TCL
[0e1846]24extern BOOLEAN tclmode;
[057e93c]25#endif
[0e1846]26extern BOOLEAN errorreported;
27extern BOOLEAN fe_use_fgets;
28extern BOOLEAN feBatch;
29extern BOOLEAN feProt;
30
31#define PROT_NONE 0
32#define PROT_I    1
33#define PROT_O    2
34#define PROT_IO   3
35
36/* the C-part: */
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41void   Werror(char *fmt, ...);
[0da09b5]42void   WerrorS(char *s);
[0e1846]43
44#ifdef __cplusplus
45}
46/* the C++-part: */
47
[057e93c]48enum   feBufferTypes
[0e1846]49{
[a18fae]50  BT_none  = 0,  // entry level
[0e1846]51  BT_break = 1,  // while, for
[a18fae]52  BT_proc,       // proc
[0e1846]53  BT_example,    // example
54  BT_file,       // <"file"
55  BT_execute,    // execute
56  BT_if,         // if
57  BT_else        // else
58};
59
[057e93c]60enum   feBufferInputs
61{
62  BI_stdin = 1,
63  BI_buffer,
64  BI_file
65};
66
[1caa72]67char*   feGetSearchPath(const char* argv0 = NULL);
[97454d]68char*   feGetExpandedExecutable(const char* argv0 = NULL);
[057e93c]69FILE *  feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE);
70void    fePause(void);
71void    Print(char* fmt, ...);
72void    PrintS(char* s);
73void     PrintLn();
74void    PrintTCLS(char c, char * s);
[0e1846]75#ifndef macintosh
76inline void PrintTCL(char c, int l,char *s)
77{
78#ifdef HAVE_TCL
79  if (s!=NULL) printf("%c:%d:%s\n",c,l,s);
80  else         printf("%c:%d:\n",c,l);
81  fflush(stdout);
82#endif
83}
84#endif
85
[057e93c]86char *  StringAppend(char *fmt, ...);
87char *  StringAppendS(char *s);
88char *  StringSet(char *fmt, ...);
89char *  StringSetS(char* s);
[0e1846]90const  char * VoiceName();
[057e93c]91void    VoiceBackTrack();
92void    WarnS(char *s);
93void    Warn(char *fmt, ...);
94BOOLEAN contBuffer(feBufferTypes typ);
95char *  eati(char *s, int *i);
96BOOLEAN exitBuffer(feBufferTypes typ);
97BOOLEAN exitVoice();
[0e1846]98#define mflush() fflush(stdout)
[057e93c]99void    monitor(char* s,int mode);
100BOOLEAN newFile(char* fname, FILE *f=NULL);
101void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
102void *  myynewbuffer();
103void    myyoldbuffer(void * oldb);
104
[f92fa13]105/* assume(x) -- a handy macro for assumptions */
106#ifdef NDEBUG
107/* empty macro, if NDEBUG */
108#define assume(x) ((void*) 0)
109#else /* ! NDEBUG */
110#define assume(x) _assume(x, __FILE__, __LINE__)
111#define _assume(x, f, l)                                        \
112do                                                              \
113{                                                               \
114  if (! (x))                                                    \
115  {                                                             \
116    Warn("Internal assume violation: file %s line %d\n", f, l); \
117  }                                                             \
118}                                                               \
119while (0)
120#endif /* NDEBUG */
[057e93c]121
122class Voice
123{
124  public:
125    Voice  * next;
126    Voice  * prev;
127    char   * filename;    // file name or proc name
128    procinfo * pi;        // proc info
129    void   * oldb;        // internal scanner buffer
130    int    start_lineno;  // lineno, to restore in recursion
131    int    curr_lineno;   // current lineno
132    feBufferInputs   sw;  // BI_stdin: read from STDIN
133                          // BI_buffer: buffer
134                          // BI_file: files
135    char   ifsw;          // if-switch:
136            /*1 ifsw==0: no if statement, else is invalid
137            *       ==1: if (0) processed, execute else
138            *       ==2: if (1) processed, else allowed but not executed
139            */
140    feBufferTypes   typ;  // buffer type: see BT_..
141    // for files only:
142    FILE * files;         // file handle
143    // for buffers only:
144    char * buffer;        // buffer pointer
145    long   fptr;          // current position in buffer
146
147  Voice() { memset(this,0,sizeof(*this));}
148  feBufferTypes Typ();
149  void Next();
150} ;
151
152extern Voice  *currentVoice;
153
154Voice * feInitStdin();
[0e1846]155
156/* feread.cc: */
157#ifdef HAVE_FEREAD
158  void fe_set_input_mode (void);
159  void fe_temp_set (void);
160  void fe_temp_reset (void);
161  char * fe_fgets_stdin(char *s, int size);
162  #ifndef MSDOS
163    #ifdef HAVE_ATEXIT
164      void fe_reset_input_mode (void);
165    #else
166      void fe_reset_input_mode (int i, void *v);
167    #endif
168  #else
169    #define fe_reset_input_mode()
170  #endif
171#else
172  #ifdef HAVE_READLINE
173    void fe_set_input_mode (void);
[057e93c]174    void fe_reset_input_mode (void);
[0e1846]175    char * fe_fgets_stdin_rl(char *pr,char *s, int size);
176    #define fe_fgets_stdin(A,B) fe_fgets_stdin_rl(fe_promptstr,A,B)
177  #else
178    #define fe_fgets_stdin(A,B) fgets(A,B,stdin)
179  #endif
180#endif
181#endif
182#endif
Note: See TracBrowser for help on using the repository browser.