#include "input.h"
-int input_init(t_input *input) {
+int input_init(t_input *input,int outfd) {
+
+ dprintf(outfd,"[input] initializing input system ...\n");
+
+ input->outfd=outfd;
+ input->mode=0;
+
+ return I_SUCCESS;
+}
+
+int input_ios_init(t_input *input) {
struct termios tios;
int size;
- puts("[input] initializing input system ...");
-
- // size=((input->mode&CONTENT_BUFFER)?MAX_CONTENT:1); <- ???
- size=MAX_CONTENT;
+ size=((input->mode&CONTENT_BUFFER)?MAX_CONTENT:1);
if((input->content=(char *)malloc(size))==NULL) {
perror("[input] malloc call");
tios.c_cc[VMIN]=1; /* 1 char for non-can. mode */
/* depending on used modes */
+ tios.c_lflag|=ICANON;
+ tios.c_lflag|=ECHO;
if(!(input->mode&LINE_BUFFERED)) tios.c_lflag&=(~ICANON);
if(!(input->mode&INPUT_ECHO)) tios.c_lflag&=(~ECHO);
free(input->content);
tcsetattr(0,TCSANOW,&(input->tios));
- puts("[input] shutdown");
+ dprintf(input->outfd,"[input] shutdown\n");
return I_SUCCESS;
}
}
if(input->c_count>=MAX_CONTENT) {
- puts("[input] max input length reached");
+ dprintf(input->outfd,"[input] max input length reached\n");
return I_ERROR;
}