Functions | Variables
feread.h File Reference
#include <kernel/structs.h>

Go to the source code of this file.

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

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

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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const int MAX_INT_LEN
Definition: mylimits.h:13
const int MAX_INT_VAL
Definition: mylimits.h:12
int i
Definition: cfEzgcd.cc:123
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94

§ fe_fgets()

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

Definition at line 310 of file feread.cc.

311 {
312  if (BVERBOSE(V_PROMPT))
313  {
314  fprintf(stdout,"%s",pr);
315  }
316  mflush();
317  char *line=fgets(s,size,stdin);
318  if (line!=NULL)
319  for (int i=strlen(line)-1;i>=0;i--) line[i]=line[i]&127;
320  return line;
321 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define mflush()
Definition: reporter.h:57
int i
Definition: cfEzgcd.cc:123
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define BVERBOSE(a)
Definition: options.h:33
#define V_PROMPT
Definition: options.h:52
#define NULL
Definition: omList.c:10

§ fe_fgets_dummy()

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

Definition at line 432 of file feread.cc.

433 {
434  return NULL;
435 }
#define NULL
Definition: omList.c:10

§ fe_fgets_stdin_drl()

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

Definition at line 270 of file feread.cc.

271 {
272  if (!BVERBOSE(V_PROMPT))
273  {
274  pr="";
275  }
276  mflush();
277 
278  char *line;
279  line = (*fe_readline) ((char*)pr);
280 
281  if (line==NULL)
282  return NULL;
283 
284  int l=strlen(line);
285  for (int i=l-1;i>=0;i--) line[i]=line[i]&127;
286 
287  if (*line!='\0')
288  {
289  (*fe_add_history) (line);
290  }
291  if (l>=size-1)
292  {
293  strncpy(s,line,size);
294  }
295  else
296  {
297  strncpy(s,line,l);
298  s[l]='\n';
299  s[l+1]='\0';
300  }
301  free (line);
302 
303  return s;
304 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define mflush()
Definition: reporter.h:57
#define free
Definition: omAllocFunc.c:12
int i
Definition: cfEzgcd.cc:123
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define BVERBOSE(a)
Definition: options.h:33
#define V_PROMPT
Definition: options.h:52
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94

§ fe_fgets_stdin_emu()

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

Definition at line 254 of file feread.cc.

255 {
256  if (!BVERBOSE(V_PROMPT))
257  {
258  pr="";
259  }
260  mflush();
261  return fe_fgets_stdin_fe(pr,s,size);
262 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * fe_fgets_stdin_fe(const char *pr, char *s, int size)
#define mflush()
Definition: reporter.h:57
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define BVERBOSE(a)
Definition: options.h:33
#define V_PROMPT
Definition: options.h:52

§ 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 86 of file fereadl.c.

89 {
90  if (fe_stdin_is_tty)
91  {
92  int i;
93  if (fe_is_raw_tty)
94  {
95  tcsetattr (STDIN_FILENO, TCSANOW, &fe_saved_attributes);
96  fe_is_raw_tty=0;
97  }
98  if (fe_hist!=NULL)
99  {
100  for(i=fe_hist_max-1;i>=0;i--)
101  {
102  if (fe_hist[i] != NULL) omFree((ADDRESS)fe_hist[i]);
103  }
104  omFreeSize((ADDRESS)fe_hist,fe_hist_max*sizeof(char *));
105  fe_hist=NULL;
106  }
107  if (!fe_stdout_is_tty)
108  {
109  fclose(fe_echo);
110  }
111  }
112 }
BOOLEAN fe_is_raw_tty
Definition: fereadl.c:75
FILE * fe_echo
Definition: fereadl.c:70
static BOOLEAN fe_stdin_is_tty
Definition: fereadl.c:65
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define STDIN_FILENO
Definition: fereadl.c:54
static BOOLEAN fe_stdout_is_tty
Definition: fereadl.c:64
void * ADDRESS
Definition: auxiliary.h:118
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
char ** fe_hist
Definition: fereadl.c:73
#define NULL
Definition: omList.c:10
struct termios fe_saved_attributes
Definition: fereadl.c:62
#define fe_hist_max
Definition: fereadl.c:72

§ fe_reset_input_mode()

void fe_reset_input_mode ( )

Definition at line 826 of file fereadl.c.

827 {
828 #if defined(HAVE_DYN_RL)
829  char *p = getenv("SINGULARHIST");
830  if ((p != NULL) && (fe_history_total_bytes != NULL))
831  {
832  if((*fe_history_total_bytes)()!=0)
833  (*fe_write_history) (p);
834  }
835 #endif
836 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD) && !defined(HAVE_DYN_RL)
837  char *p = getenv("SINGULARHIST");
838  if (p != NULL)
839  {
840  if(history_total_bytes()!=0)
841  write_history (p);
842  }
843 #endif
844 #if defined(HAVE_FEREAD)
845  #ifndef HAVE_ATEXIT
847  #else
848  fe_reset_fe();
849  #endif
850 #endif
851 }
return P p
Definition: myNF.cc:203
char * getenv()
void fe_reset_fe(void)
Definition: fereadl.c:86
int write_history()
int history_total_bytes()
int(* fe_history_total_bytes)()
Definition: fereadl.c:723
#define NULL
Definition: omList.c:10

Variable Documentation

§ fe_fgets_stdin

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

Definition at line 17 of file feread.h.

§ prompt_char

char prompt_char

Definition at line 44 of file febase.cc.