source: git/kernel/old.febase.h @ 320f1c

spielwiese
Last change on this file since 320f1c was 210e07, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
ADD: testing headers with "make test.o" FIX: cleaning up headers in kernel: TODO: kutil.h?! FIX: febase.h -> old.febase.h (remove later on) ADD: dummy headers instead of some splited or moved: febase.h, modulop.h (for later fixing) FIX: renamed various obsolette files into "old.*"
  • Property mode set to 100644
File size: 8.1 KB
Line 
1#ifndef FEBASE_H
2#define FEBASE_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7/*
8* ABSTRACT: basic i/o
9*/
10#include <stdio.h>
11#include <string.h>
12#include <kernel/structs.h>
13
14/* define DIR_SEPP, etc */
15/* unix , WINNT */
16#  define  DIR_SEP '/'
17#  define  DIR_SEPP "/"
18#  define  UP_DIR ".."
19// this might still get reset by feInitResources
20extern char fePathSep;
21
22/* define MAXPATHLEN */
23#ifdef HAVE_SYS_PARAM_H
24#include <sys/param.h>
25#endif
26
27/* the are versions of limits.h with incorrect values (IRIX_6)
28* let's include our own */
29
30#include <omalloc/mylimits.h>
31
32/* OSF/1 and AIX_4 are missing the header for setenv, but the proc exists */
33#if defined(DecAlpha_OSF1) || defined(AIX_4)
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38  int setenv(const char *name, const char *value, int overwrite);
39#ifdef __cplusplus
40}
41#endif
42#endif
43
44#ifndef MAXPATHLEN
45#define MAXPATHLEN 1024
46#endif
47
48#ifdef HAVE_LIBREADLINE
49  #define HAVE_READLINE 1
50#endif
51
52#ifdef HAVE_DYN_RL
53  #undef HAVE_READLINE
54  #define HAVE_FEREAD 1
55#elif ! defined(HAVE_READLINE)
56#ifndef ix86_Win
57  #define HAVE_FEREAD 1
58#endif
59#endif
60#ifdef ix86_Linux
61  // FEREAD stuff does not work with glibc2
62  #undef HAVE_FEREAD
63#endif
64
65enum noeof_t
66{
67  noeof_brace = 1,
68  noeof_asstring,
69  noeof_block,
70  noeof_bracket,
71  noeof_comment,
72  noeof_procname,
73  noeof_string
74};  /* for scanner.l */
75
76extern char*  feErrors;
77extern char*  feArgv0;
78extern int    feErrorsLen;
79extern FILE*  feProtFile;
80extern FILE*  feFilePending; /*temp. storage for grammar.y */
81extern char   fe_promptstr[];
82extern int    si_echo, printlevel;
83extern int    colmax;
84extern int    yy_blocklineno;
85extern int    yy_noeof;
86extern char   prompt_char;
87extern const char feNotImplemented[];
88extern BOOLEAN errorreported;
89extern int     feProt;
90extern BOOLEAN feWarn;
91extern BOOLEAN feOut;
92extern int  traceit ;
93#define TRACE_SHOW_PROC   1
94#define TRACE_SHOW_LINENO 2
95#define TRACE_SHOW_LINE   4
96#define TRACE_SHOW_RINGS  8
97#define TRACE_SHOW_LINE1  16
98#define TRACE_BREAKPOINT  32
99#define TRACE_TMP_BREAKPOINT  64
100extern int myynest;
101extern int yylineno;
102extern char     my_yylinebuf[80];
103
104#define PROT_NONE 0
105#define PROT_I    1
106#define PROT_O    2
107#define PROT_IO   3
108
109/* the C-part: */
110#define mflush() fflush(stdout)
111
112#ifdef __cplusplus
113extern "C" {
114#endif
115#ifndef __GNUC__
116#undef __attribute__
117#define __attribute__(A)
118#endif
119
120extern void (*WerrorS_callback)(const char *s);
121
122void    Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
123void    WerrorS(const char *s);
124void    WarnS(const char *s);
125void    Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
126/* Print should not produce more than strlen(fmt)+510 characters! */
127
128void    PrintNSpaces(const int n);
129void    PrintLn();
130void    PrintS(const char* s);
131char*   feGetResource(const char id);
132
133#ifdef HAVE_FEREAD
134extern BOOLEAN fe_is_raw_tty;
135void           fe_temp_reset (void);
136#endif
137
138#ifdef __cplusplus
139}
140/* the C++-part: */
141
142typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
143// LANG_TOP     : Toplevel package only
144// LANG_SINGULAR:
145// LANG_C       :
146//
147
148class proc_singular
149{
150public:
151  long   proc_start;       // position where proc is starting
152  long   def_end;          // position where proc header is ending
153  long   help_start;       // position where help is starting
154  long   help_end;         // position where help is starting
155  long   body_start;       // position where proc-body is starting
156  long   body_end;         // position where proc-body is ending
157  long   example_start;    // position where example is starting
158  long   proc_end;         // position where proc is ending
159  int    proc_lineno;
160  int    body_lineno;
161  int    example_lineno;
162  char   *body;
163  long help_chksum;
164};
165
166struct proc_object
167{
168//public:
169  BOOLEAN (*function)(leftv res, leftv v);
170};
171union uprocinfodata
172{
173public:
174  proc_singular  s;        // data of Singular-procedure
175  struct proc_object    o; // pointer to binary-function
176};
177
178typedef union uprocinfodata procinfodata;
179
180class procinfo;
181typedef procinfo *         procinfov;
182
183class procinfo
184{
185public:
186  char          *libname;
187  char          *procname;
188  package       pack;
189  language_defs language;
190  short         ref;
191  char          is_static;        // if set, proc not accessible for user
192  char          trace_flag;
193  procinfodata  data;
194};
195enum   feBufferTypes
196{
197  BT_none  = 0,  // entry level
198  BT_break = 1,  // while, for
199  BT_proc,       // proc
200  BT_example,    // example
201  BT_file,       // <"file"
202  BT_execute,    // execute
203  BT_if,         // if
204  BT_else        // else
205};
206
207enum   feBufferInputs
208{
209  BI_stdin = 1,
210  BI_buffer,
211  BI_file
212};
213
214/*****************************************************************
215 *
216 * help system (fehelp.cc)
217 *
218 *****************************************************************/
219// if str != NULL display help for str
220// display general help, otherwise
221void feHelp(char* str = NULL);
222// if browser != NULL or feOpt("browser") != NULL
223//    set HelpBrowser to browser
224// otherwise, if browser was already set, leave as is,
225//            if not, choose first available browser
226// return string identifying current browser
227// keeps feOpt("browser") up-to-date
228// Optional warn argument is as in feResource
229const char* feHelpBrowser(char* browser = NULL, int warn = -1);
230void feStringAppendBrowsers(int warn = -1);
231
232/*****************************************************************
233 *
234 * version Id
235 *
236 *****************************************************************/
237/* extern unsigned long feVersionId; */
238
239char *  StringAppend(const char *fmt, ...);
240char *  StringAppendS(const char *s);
241char *  StringSetS(const char* s);
242const  char * VoiceName();
243void    VoiceBackTrack();
244void    Warn(const char *fmt, ...);
245BOOLEAN contBuffer(feBufferTypes typ);
246BOOLEAN exitBuffer(feBufferTypes typ);
247BOOLEAN exitVoice();
248void    monitor(void *F, int mode); /* FILE*, int */
249BOOLEAN newFile(char* fname, FILE *f=NULL);
250void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
251void *  myynewbuffer();
252void    myyoldbuffer(void * oldb);
253
254class Voice
255{
256  public:
257    Voice  * next;
258    Voice  * prev;
259    char   * filename;    // file name or proc name
260    procinfo * pi;        // proc info
261    void   * oldb;        // internal scanner buffer
262    // for files only:
263    FILE * files;         // file handle
264    // for buffers only:
265    char * buffer;        // buffer pointer
266    long   fptr;          // current position in buffer
267
268    int    start_lineno;  // lineno, to restore in recursion
269    int    curr_lineno;   // current lineno
270    feBufferInputs   sw;  // BI_stdin: read from STDIN
271                          // BI_buffer: buffer
272                          // BI_file: files
273    char   ifsw;          // if-switch:
274            /*1 ifsw==0: no if statement, else is invalid
275            *       ==1: if (0) processed, execute else
276            *       ==2: if (1) processed, else allowed but not executed
277            */
278    feBufferTypes   typ;  // buffer type: see BT_..
279
280  Voice() { memset(this,0,sizeof(*this));}
281  feBufferTypes Typ();
282  void Next();
283} ;
284
285extern Voice  *currentVoice;
286
287Voice * feInitStdin(Voice *pp);
288
289/* feread.cc: */
290
291/* the interface for reading: */
292extern  char * (*fe_fgets_stdin)(const char *pr,char *s, int size);
293
294#ifdef HAVE_DYN_RL
295char * fe_fgets_stdin_drl(const char *pr,char *s, int size);
296#endif
297
298extern "C" void fe_reset_input_mode();
299
300extern "C" {
301#ifndef HAVE_ATEXIT
302void fe_reset_fe (int i, void *v);
303#else
304void fe_reset_fe (void);
305#endif
306}
307
308
309/* possible implementations: */
310#ifdef __cplusplus
311extern "C"
312{
313#endif
314  /* readline, linked in: */
315  char * fe_fgets_stdin_rl(const char *pr,char *s, int size);
316
317  /* emulated readline: */
318  char * fe_fgets_stdin_emu(const char *pr,char *s, int size);
319
320  /* fgets: */
321  char * fe_fgets(const char *pr,char *s, int size);
322
323  /* dummy (for batch mode): */
324  char * fe_fgets_dummy(const char *pr,char *s, int size);
325
326#ifdef __cplusplus
327}
328#endif
329#endif /* c++ only */
330
331/* everything in between calls to these procedures is printed into a string
332 * which is returned by SprintEnd()
333 */
334void SPrintStart();
335char* SPrintEnd();
336
337
338#endif /* ifndef FEBASE_H */
Note: See TracBrowser for help on using the repository browser.