Changeset 210e07 in git for kernel/febase.h
- Timestamp:
- Jul 14, 2011, 9:33:26 PM (13 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 76cfefe4f52ffaf7872e644c892963a5add72ce5
- Parents:
- 0f401f6dcd72827fb15dfe26d00e15981d07b550
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-07-14 21:33:26+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:16+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/febase.h
r0f401f r210e07 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> 1 // Dummy 2 #include <resources/feFopen.h> 3 #include <resources/feResource.h> 13 4 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 20 extern 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 35 extern "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 65 enum 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 76 extern char* feErrors; 77 extern char* feArgv0; 78 extern int feErrorsLen; 79 extern FILE* feProtFile; 80 extern FILE* feFilePending; /*temp. storage for grammar.y */ 81 extern char fe_promptstr[]; 82 extern int si_echo, printlevel; 83 extern int colmax; 84 extern int yy_blocklineno; 85 extern int yy_noeof; 86 extern char prompt_char; 87 extern const char feNotImplemented[]; 88 extern BOOLEAN errorreported; 89 extern int feProt; 90 extern BOOLEAN feWarn; 91 extern BOOLEAN feOut; 92 extern 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 100 extern int myynest; 101 extern int yylineno; 102 extern 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 113 extern "C" { 114 #endif 115 #ifndef __GNUC__ 116 #undef __attribute__ 117 #define __attribute__(A) 118 #endif 119 120 extern void (*WerrorS_callback)(const char *s); 121 122 void Werror(const char *fmt, ...) __attribute__((format(printf,1,2))); 123 void WerrorS(const char *s); 124 void WarnS(const char *s); 125 void Print(const char* fmt, ...) __attribute__((format(printf,1,2))); 126 /* Print should not produce more than strlen(fmt)+510 characters! */ 127 128 void PrintNSpaces(const int n); 129 void PrintLn(); 130 void PrintS(const char* s); 131 char* feGetResource(const char id); 132 133 #ifdef HAVE_FEREAD 134 extern BOOLEAN fe_is_raw_tty; 135 void fe_temp_reset (void); 136 #endif 137 138 #ifdef __cplusplus 139 } 140 /* the C++-part: */ 141 142 typedef 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 148 class proc_singular 149 { 150 public: 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 166 struct proc_object 167 { 168 //public: 169 BOOLEAN (*function)(leftv res, leftv v); 170 }; 171 union uprocinfodata 172 { 173 public: 174 proc_singular s; // data of Singular-procedure 175 struct proc_object o; // pointer to binary-function 176 }; 177 178 typedef union uprocinfodata procinfodata; 179 180 class procinfo; 181 typedef procinfo * procinfov; 182 183 class procinfo 184 { 185 public: 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 }; 195 enum 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 207 enum 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 221 void 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 229 const char* feHelpBrowser(char* browser = NULL, int warn = -1); 230 void feStringAppendBrowsers(int warn = -1); 231 232 /***************************************************************** 233 * 234 * version Id 235 * 236 *****************************************************************/ 237 /* extern unsigned long feVersionId; */ 238 239 char * StringAppend(const char *fmt, ...); 240 char * StringAppendS(const char *s); 241 char * StringSetS(const char* s); 242 const char * VoiceName(); 243 void VoiceBackTrack(); 244 void Warn(const char *fmt, ...); 245 BOOLEAN contBuffer(feBufferTypes typ); 246 BOOLEAN exitBuffer(feBufferTypes typ); 247 BOOLEAN exitVoice(); 248 void monitor(void *F, int mode); /* FILE*, int */ 249 BOOLEAN newFile(char* fname, FILE *f=NULL); 250 void newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0); 251 void * myynewbuffer(); 252 void myyoldbuffer(void * oldb); 253 254 class 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 285 extern Voice *currentVoice; 286 287 Voice * feInitStdin(Voice *pp); 288 289 /* feread.cc: */ 290 291 /* the interface for reading: */ 292 extern char * (*fe_fgets_stdin)(const char *pr,char *s, int size); 293 294 #ifdef HAVE_DYN_RL 295 char * fe_fgets_stdin_drl(const char *pr,char *s, int size); 296 #endif 297 298 extern "C" void fe_reset_input_mode(); 299 300 extern "C" { 301 #ifndef HAVE_ATEXIT 302 void fe_reset_fe (int i, void *v); 303 #else 304 void fe_reset_fe (void); 305 #endif 306 } 307 308 309 /* possible implementations: */ 310 #ifdef __cplusplus 311 extern "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 */ 334 void SPrintStart(); 335 char* SPrintEnd(); 336 337 338 #endif /* ifndef FEBASE_H */ 5
Note: See TracChangeset
for help on using the changeset viewer.