MCPcopy Create free account
hub / github.com/Singular/Singular / fe_init

Function fe_init

kernel/oswrapper/fereadl.c:140–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 return c;
139}
140static void fe_init (void)
141{
142 fe_is_initialized=TRUE;
143 if ((!fe_use_fgets) && (isatty (STDIN_FILENO)))
144 {
145 /* Make sure stdin is a terminal. */
146 char *term=getenv("TERM");
147
148 /*setup echo*/
149 if(isatty(STDOUT_FILENO))
150 {
151 fe_stdout_is_tty=1;
152 fe_echo=stdout;
153 }
154 else
155 {
156 fe_stdout_is_tty=0;
157 char *tty_name=ttyname(fileno(stdin));
158 if (tty_name!=NULL)
159 fe_echo = fopen( tty_name, "w" );
160 else
161 fe_echo = NULL;
162 if (fe_echo==NULL)
163 {
164 fe_echo=stdout;
165 printf("stdin is a tty, but ttyname fails\n");
166 return;
167 }
168 }
169 /* Save the terminal attributes so we can restore them later. */
170 {
171 struct termios tattr;
172 tcgetattr (STDIN_FILENO, &fe_saved_attributes);
173 #ifdef HAVE_FEREAD
174 #ifdef HAVE_ATEXIT
175 atexit(fe_reset_fe);
176 #else
177 on_exit(fe_reset_fe,NULL);
178 #endif
179 #endif
180
181 /* Set the funny terminal modes. */
182 tcgetattr (STDIN_FILENO, &tattr);
183 tattr.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO. */
184 tattr.c_cc[VMIN] = 1;
185 tattr.c_cc[VTIME] = 0;
186 tcsetattr (STDIN_FILENO, TCSAFLUSH, &tattr);
187 /*ospeed=cfgetospeed(&tattr);*/
188 }
189 if(term==NULL)
190 {
191 printf("need TERM\n");
192 }
193 else if(tgetent(termcap_buff,term)<=0)
194 {
195 printf("could not access termcap data base\n");
196 }
197 else

Callers 1

fe_fgets_stdin_feFunction · 0.85

Calls 2

omAlloc0Function · 0.85
omMarkAsStaticAddrFunction · 0.85

Tested by

no test coverage detected