Loading...
Searching...
No Matches
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 377 of file reporter.cc.

{
int l=0;
if (*s >= '0' && *s <= '9')
{
*i = 0;
while (*s >= '0' && *s <= '9')
{
*i *= 10;
*i += *s++ - '0';
l++;
if ((l>=MAX_INT_LEN)||((*i) <0))
{
s-=l;
Werror("`%s` greater than %d(max. integer representation)",
s,MAX_INT_VAL);
return s;
}
}
}
else *i = 1;
return s;
}
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51
MAX_INT_VAL
const int MAX_INT_VAL
Definition mylimits.h:12
MAX_INT_LEN
const int MAX_INT_LEN
Definition mylimits.h:13
Werror
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.

{
if (BVERBOSE(V_PROMPT))
{
fputs(pr,stdout);
}
mflush();
errno=0;
char *line=fgets(s,size,stdin);
if (line!=NULL)
{
for (int i=strlen(line)-1;i>=0;i--) line[i]=line[i]&127;
}
else
{
/* NULL can mean various things... */
switch(errno)
{
case 0: return NULL; /*EOF */
case EBADF: return NULL; /* stdin got closed */
case EINTR: return strcpy(s,"\n"); /* CTRL-C or other signal */
default: /* other error */
{
int errsv = errno;
fprintf(stderr,"fgets() failed with errno %d\n%s\n",errsv,strerror(errsv));
return NULL;
}
}
}
return line;
}
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
NULL
#define NULL
Definition omList.c:12
BVERBOSE
#define BVERBOSE(a)
Definition options.h:35
V_PROMPT
#define V_PROMPT
Definition options.h:54
mflush
#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.

{
return NULL;
}

## fe_fgets_stdin_drl()

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

Definition at line 269 of file feread.cc.

{
if (!BVERBOSE(V_PROMPT))
{
pr="";
}
mflush();
char *line;
line = (*fe_readline) ((char*)pr);
if (line==NULL)
return NULL;
int l=strlen(line);
for (int i=l-1;i>=0;i--) line[i]=line[i]&127;
if (*line!='\0')
{
(*fe_add_history) (line);
}
if (l>=size-1)
{
strncpy(s,line,size);
}
else
{
strncpy(s,line,l);
s[l]='\n';
s[l+1]='\0';
}
free (line);
return s;
}
free
#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.

{
if (!BVERBOSE(V_PROMPT))
{
pr="";
}
mflush();
return fe_fgets_stdin_fe(pr,s,size);
}
fe_fgets_stdin_fe
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.

{
if (fe_stdin_is_tty)
{
int i;
if (fe_is_raw_tty)
{
tcsetattr (STDIN_FILENO, TCSANOW, &fe_saved_attributes);
fe_is_raw_tty=0;
}
if (fe_hist!=NULL)
{
for(i=fe_hist_max-1;i>=0;i--)
{
if (fe_hist[i] != NULL) omFree((ADDRESS)fe_hist[i]);
}
omFreeSize((ADDRESS)fe_hist,fe_hist_max*sizeof(char *));
fe_hist=NULL;
}
if (!fe_stdout_is_tty)
{
fclose(fe_echo);
}
}
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
fe_saved_attributes
VAR struct termios fe_saved_attributes
Definition fereadl.c:60
fe_hist
VAR char ** fe_hist
Definition fereadl.c:70
fe_hist_max
#define fe_hist_max
Definition fereadl.c:69
fe_is_raw_tty
VAR BOOLEAN fe_is_raw_tty
Definition fereadl.c:72
fe_echo
VAR FILE * fe_echo
Definition fereadl.c:67
fe_stdin_is_tty
STATIC_VAR BOOLEAN fe_stdin_is_tty
Definition fereadl.c:63
fe_stdout_is_tty
STATIC_VAR BOOLEAN fe_stdout_is_tty
Definition fereadl.c:62
STDIN_FILENO
#define STDIN_FILENO
Definition fereadl.c:52
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omFree
#define omFree(addr)
Definition omAllocDecl.h:261

## fe_reset_input_mode()

void fe_reset_input_mode | ( |  | ) |

Definition at line 831 of file fereadl.c.

{
#if defined(HAVE_DYN_RL)
char *p = getenv("SINGULARHIST");
if (p==NULL) p=SINGULARHIST_FILE;
if ((strlen(p) != 0) && (fe_history_total_bytes != NULL))
{
if((using_history_called && (*fe_history_total_bytes)()!=0))
(*fe_write_history) (p);
}
#elif defined(HAVE_READLINE) && !defined(HAVE_FEREAD) && !defined(HAVE_DYN_RL)
char *p = getenv("SINGULARHIST");
if (p==NULL) p=SINGULARHIST_FILE;
if (strlen(p) != 0)
{
if(using_history_called &&(history_total_bytes()!=0))
write_history (p);
}
#elif defined(HAVE_FEREAD)
#ifndef HAVE_ATEXIT
fe_reset_fe(NULL,NULL);
#else
fe_reset_fe();
#endif
#endif
}
p
int p
Definition cfModGcd.cc:4086
getenv
char * getenv()
using_history_called
VAR BOOLEAN using_history_called
Definition feread.cc:106
fe_history_total_bytes
VAR int(* fe_history_total_bytes)()
Definition feread.cc:172
history_total_bytes
int history_total_bytes()
write_history
int write_history()
SINGULARHIST_FILE
#define SINGULARHIST_FILE
Definition feread.h:20
fe_reset_fe
void fe_reset_fe(void)
Definition fereadl.c:83

## 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.