source: git/Singular/febase.h @ 1caa72

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