My Project  debian-1:4.1.1-p2+ds-4build4
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 }
int l
Definition: cfEzgcd.cc:93
int i
Definition: cfEzgcd.cc:125
const CanonicalForm int s
Definition: facAbsFact.cc:55
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 310 of file feread.cc.

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

◆ fe_fgets_dummy()

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

Definition at line 451 of file feread.cc.

452 {
453  return NULL;
454 }

◆ 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 }
#define free
Definition: omAllocFunc.c:12

◆ 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 }
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 82 of file fereadl.c.

85 {
86  if (fe_stdin_is_tty)
87  {
88  int i;
89  if (fe_is_raw_tty)
90  {
91  tcsetattr (STDIN_FILENO, TCSANOW, &fe_saved_attributes);
92  fe_is_raw_tty=0;
93  }
94  if (fe_hist!=NULL)
95  {
96  for(i=fe_hist_max-1;i>=0;i--)
97  {
98  if (fe_hist[i] != NULL) omFree((ADDRESS)fe_hist[i]);
99  }
100  omFreeSize((ADDRESS)fe_hist,fe_hist_max*sizeof(char *));
101  fe_hist=NULL;
102  }
103  if (!fe_stdout_is_tty)
104  {
105  fclose(fe_echo);
106  }
107  }
108 }
void * ADDRESS
Definition: auxiliary.h:133
static BOOLEAN fe_stdin_is_tty
Definition: fereadl.c:62
static BOOLEAN fe_stdout_is_tty
Definition: fereadl.c:61
#define fe_hist_max
Definition: fereadl.c:68
struct termios fe_saved_attributes
Definition: fereadl.c:59
BOOLEAN fe_is_raw_tty
Definition: fereadl.c:71
FILE * fe_echo
Definition: fereadl.c:66
char ** fe_hist
Definition: fereadl.c:69
#define STDIN_FILENO
Definition: fereadl.c:51
#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 825 of file fereadl.c.

826 {
827 #if defined(HAVE_DYN_RL)
828  char *p = getenv("SINGULARHIST");
829  if ((p != NULL) && (fe_history_total_bytes != NULL))
830  {
831  if((*fe_history_total_bytes)()!=0)
832  (*fe_write_history) (p);
833  }
834 #endif
835 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD) && !defined(HAVE_DYN_RL)
836  char *p = getenv("SINGULARHIST");
837  if (p != NULL)
838  {
839  if(history_total_bytes()!=0)
840  write_history (p);
841  }
842 #endif
843 #if defined(HAVE_FEREAD)
844  #ifndef HAVE_ATEXIT
846  #else
847  fe_reset_fe();
848  #endif
849 #endif
850 }
int p
Definition: cfModGcd.cc:4019
char * getenv()
int history_total_bytes()
int write_history()
void fe_reset_fe(void)
Definition: fereadl.c:82
int(* fe_history_total_bytes)()
Definition: fereadl.c:722

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 17 of file feread.h.

◆ prompt_char

char prompt_char
extern

Definition at line 39 of file febase.cc.