My Project
Macros | Functions | Variables
feread.h File Reference

Go to the source code of this file.

Macros

#define SINGULARHIST_FILE   (char*)".singularhistory"
 

Functions

char * fe_fgets_stdin_drl (const char *pr, char *s, int size)
 
void fe_reset_input_mode ()
 
void fe_reset_fe (void)
 
char * fe_fgets_stdin_rl (const char *pr, char *s, int size)
 
char * fe_fgets_stdin_emu (const char *pr, char *s, int size)
 
char * fe_fgets (const char *pr, char *s, int size)
 
char * fe_fgets_dummy (const char *pr, char *s, int size)
 
const char * eati (const char *s, int *i)
 

Variables

EXTERN_VAR char prompt_char
 
EXTERN_VAR BOOLEAN using_history_called
 
char *(* fe_fgets_stdin )(const char *pr, char *s, int size)
 

Macro Definition Documentation

◆ SINGULARHIST_FILE

#define SINGULARHIST_FILE   (char*)".singularhistory"

Definition at line 20 of file feread.h.

Function Documentation

◆ eati()

const char * eati ( const char *  s,
int *  i 
)

Definition at line 373 of file reporter.cc.

374{
375 int l=0;
376
377 if (*s >= '0' && *s <= '9')
378 {
379 *i = 0;
380 while (*s >= '0' && *s <= '9')
381 {
382 *i *= 10;
383 *i += *s++ - '0';
384 l++;
385 if ((l>=MAX_INT_LEN)||((*i) <0))
386 {
387 s-=l;
388 Werror("`%s` greater than %d(max. integer representation)",
389 s,MAX_INT_VAL);
390 return s;
391 }
392 }
393 }
394 else *i = 1;
395 return s;
396}
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
const CanonicalForm int s
Definition: facAbsFact.cc:51
const int MAX_INT_VAL
Definition: mylimits.h:12
const int MAX_INT_LEN
Definition: mylimits.h:13
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ fe_fgets()

char * fe_fgets ( const char *  pr,
char *  s,
int  size 
)

Definition at line 309 of file feread.cc.

310{
311 if (BVERBOSE(V_PROMPT))
312 {
313 fputs(pr,stdout);
314 }
315 mflush();
316 errno=0;
317 char *line=fgets(s,size,stdin);
318 if (line!=NULL)
319 {
320 for (int i=strlen(line)-1;i>=0;i--) line[i]=line[i]&127;
321 }
322 else
323 {
324 /* NULL can mean various things... */
325 switch(errno)
326 {
327 case 0: return NULL; /*EOF */
328 case EBADF: return NULL; /* stdin got closed */
329 case EINTR: return strcpy(s,"\n"); /* CTRL-C or other signal */
330 default: /* other error */
331 {
332 int errsv = errno;
333 fprintf(stderr,"fgets() failed with errno %d\n%s\n",errsv,strerror(errsv));
334 return NULL;
335 }
336 }
337 }
338 return line;
339}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define NULL
Definition: omList.c:12
#define BVERBOSE(a)
Definition: options.h:35
#define V_PROMPT
Definition: options.h:54
#define mflush()
Definition: reporter.h:58

◆ fe_fgets_dummy()

char * fe_fgets_dummy ( const char *  pr,
char *  s,
int  size 
)

Definition at line 455 of file feread.cc.

456{
457 return NULL;
458}

◆ fe_fgets_stdin_drl()

char * fe_fgets_stdin_drl ( const char *  pr,
char *  s,
int  size 
)

Definition at line 269 of file feread.cc.

270{
271 if (!BVERBOSE(V_PROMPT))
272 {
273 pr="";
274 }
275 mflush();
276
277 char *line;
278 line = (*fe_readline) ((char*)pr);
279
280 if (line==NULL)
281 return NULL;
282
283 int l=strlen(line);
284 for (int i=l-1;i>=0;i--) line[i]=line[i]&127;
285
286 if (*line!='\0')
287 {
288 (*fe_add_history) (line);
289 }
290 if (l>=size-1)
291 {
292 strncpy(s,line,size);
293 }
294 else
295 {
296 strncpy(s,line,l);
297 s[l]='\n';
298 s[l+1]='\0';
299 }
300 free (line);
301
302 return s;
303}
#define free
Definition: omAllocFunc.c:14

◆ fe_fgets_stdin_emu()

char * fe_fgets_stdin_emu ( const char *  pr,
char *  s,
int  size 
)

Definition at line 253 of file feread.cc.

254{
255 if (!BVERBOSE(V_PROMPT))
256 {
257 pr="";
258 }
259 mflush();
260 return fe_fgets_stdin_fe(pr,s,size);
261}
char * fe_fgets_stdin_fe(const char *pr, char *s, int size)

◆ fe_fgets_stdin_rl()

char * fe_fgets_stdin_rl ( const char *  pr,
char *  s,
int  size 
)

◆ fe_reset_fe()

void fe_reset_fe ( void  )

Definition at line 83 of file fereadl.c.

86{
88 {
89 int i;
90 if (fe_is_raw_tty)
91 {
92 tcsetattr (STDIN_FILENO, TCSANOW, &fe_saved_attributes);
94 }
95 if (fe_hist!=NULL)
96 {
97 for(i=fe_hist_max-1;i>=0;i--)
98 {
99 if (fe_hist[i] != NULL) omFree((ADDRESS)fe_hist[i]);
100 }
101 omFreeSize((ADDRESS)fe_hist,fe_hist_max*sizeof(char *));
103 }
104 if (!fe_stdout_is_tty)
105 {
106 fclose(fe_echo);
107 }
108 }
109}
void * ADDRESS
Definition: auxiliary.h:119
VAR struct termios fe_saved_attributes
Definition: fereadl.c:60
VAR char ** fe_hist
Definition: fereadl.c:70
#define fe_hist_max
Definition: fereadl.c:69
VAR BOOLEAN fe_is_raw_tty
Definition: fereadl.c:72
VAR FILE * fe_echo
Definition: fereadl.c:67
STATIC_VAR BOOLEAN fe_stdin_is_tty
Definition: fereadl.c:63
STATIC_VAR BOOLEAN fe_stdout_is_tty
Definition: fereadl.c:62
#define STDIN_FILENO
Definition: fereadl.c:52
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ fe_reset_input_mode()

void fe_reset_input_mode ( )

Definition at line 831 of file fereadl.c.

832{
833#if defined(HAVE_DYN_RL)
834 char *p = getenv("SINGULARHIST");
836 if ((strlen(p) != 0) && (fe_history_total_bytes != NULL))
837 {
839 (*fe_write_history) (p);
840 }
841#elif defined(HAVE_READLINE) && !defined(HAVE_FEREAD) && !defined(HAVE_DYN_RL)
842 char *p = getenv("SINGULARHIST");
844 if (strlen(p) != 0)
845 {
848 }
849#elif defined(HAVE_FEREAD)
850 #ifndef HAVE_ATEXIT
852 #else
853 fe_reset_fe();
854 #endif
855#endif
856}
int p
Definition: cfModGcd.cc:4078
char * getenv()
VAR BOOLEAN using_history_called
Definition: feread.cc:106
int history_total_bytes()
int write_history()
#define SINGULARHIST_FILE
Definition: feread.h:20
void fe_reset_fe(void)
Definition: fereadl.c:83
VAR int(* fe_history_total_bytes)()
Definition: fereadl.c:723

Variable Documentation

◆ fe_fgets_stdin

char *(* fe_fgets_stdin) (const char *pr, char *s, int size) ( const char *  pr,
char *  s,
int  size 
)

Definition at line 25 of file feread.h.

◆ prompt_char

EXTERN_VAR char prompt_char

Definition at line 10 of file feread.h.

◆ using_history_called

EXTERN_VAR BOOLEAN using_history_called

Definition at line 15 of file feread.h.