#define USE_NCURSES
-int display_init(t_display *display) {
+int display_init(t_display *display,int outfd) {
struct winsize ws;
display->max_x=ws.ws_col;
display->max_y=ws.ws_row;
- fprintf(stderr,"[display] initializing display, width: %02d / height: %02d \n"
- ,ws.ws_col,ws.ws_row);
+ display->outfd=outfd;
+
+ dprintf(display->outfd,"[display] initializing display, w: %02d / h: %02d\n",
+ ws.ws_col,ws.ws_row);
/* allocating 'screen' buffer */
if((display->screen=(char *)malloc(display->max_x*display->max_y))
free(display->screen);
- fprintf(stderr,"[display] shutdown\n");
+ dprintf(display->outfd,"[display] shutdown\n");
return D_SUCCESS;
}
} t_display;
/* function prototypes */
-int display_init(t_display *display);
+int display_init(t_display *display,int outfd);
int display_draw(t_display *display);
int display_draw_until_line(t_display *display,int line);
int display_set_cursor(t_display *display,int x,int y);
int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym);
int display_string(t_display *display,int x,int y,char *string,int len);
int display_string_vert(t_display *display,int x,int y,char *string,int len);
+
#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;
- fprintf(stderr,"[input] initializing input system ...\n");
-
size=((input->mode&CONTENT_BUFFER)?MAX_CONTENT:1);
if((input->content=(char *)malloc(size))==NULL) {
free(input->content);
tcsetattr(0,TCSANOW,&(input->tios));
- fprintf(stderr,"[input] shutdown\n");
+ dprintf(input->outfd,"[input] shutdown\n");
return I_SUCCESS;
}
}
if(input->c_count>=MAX_CONTENT) {
- fprintf(stderr,"[input] max input length reached\n");
+ dprintf(input->outfd,"[input] max input length reached\n");
return I_ERROR;
}
} t_input;
/* function prototypes */
-int input_init(t_input *input);
+int input_init(t_input *input,int outfd);
+int input_ios_init(t_input *input);
int input_shutdown(t_input *input);
int input_get_event(t_input *input,int (*callback)(t_input *input,void *ptr),
void *ptr);
return N_SUCCESS;
}
+int network_send_chan(t_net *net,int chan,unsigned char *data,int datasize) {
+
+ return(network_send(net->connection[chan].fd,data,datasize));
+}
+
int network_receive(int fd,unsigned char *data,int datasize) {
int count,left;
int network_deselect(t_net *net,int channel);
int network_manage_incoming(t_net *net);
int network_send(int fd,unsigned char *data,int datasize);
+int network_send_chan(t_net *net,int chan,unsigned char *data,int datasize);
int network_receive(int fd,unsigned char *data,int datasize);
int network_receive_chan(t_net *net,int chan,unsigned char *data,int datasize);
int network_udp_listen_init(t_net *net);