From: hackbard Date: Wed, 3 Nov 2004 18:08:21 +0000 (+0000) Subject: minor fixes + upgrades X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebf0016d576daf024cc7a31d03ecc3c11f90cc9c;p=my-code%2Fapi.git minor fixes + upgrades --- diff --git a/display/display.c b/display/display.c index 178ec62..bb9d707 100644 --- a/display/display.c +++ b/display/display.c @@ -8,7 +8,7 @@ #define USE_NCURSES -int display_init(t_display *display) { +int display_init(t_display *display,int outfd) { struct winsize ws; @@ -20,8 +20,10 @@ int display_init(t_display *display) { 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)) @@ -110,7 +112,7 @@ int display_shutdown(t_display *display) { free(display->screen); - fprintf(stderr,"[display] shutdown\n"); + dprintf(display->outfd,"[display] shutdown\n"); return D_SUCCESS; } diff --git a/display/display.h b/display/display.h index 2184e15..30e290c 100644 --- a/display/display.h +++ b/display/display.h @@ -26,7 +26,7 @@ typedef struct s_display { } 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); @@ -35,3 +35,4 @@ int display_shutdown(t_display *display); 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); + diff --git a/input/input.c b/input/input.c index 8996866..0060f52 100644 --- a/input/input.c +++ b/input/input.c @@ -6,13 +6,21 @@ #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) { @@ -44,7 +52,7 @@ int input_shutdown(t_input *input) { free(input->content); tcsetattr(0,TCSANOW,&(input->tios)); - fprintf(stderr,"[input] shutdown\n"); + dprintf(input->outfd,"[input] shutdown\n"); return I_SUCCESS; } @@ -64,7 +72,7 @@ int input_get_event(t_input *input,int (*callback)(t_input *input,void *ptr), } 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; } diff --git a/input/input.h b/input/input.h index 6efcf6e..d7ceb4a 100644 --- a/input/input.h +++ b/input/input.h @@ -33,7 +33,8 @@ typedef struct s_input { } 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); diff --git a/network/network.c b/network/network.c index ebdbc83..1cdd38c 100644 --- a/network/network.c +++ b/network/network.c @@ -265,6 +265,11 @@ int network_send(int fd,unsigned char *data,int datasize) { 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; diff --git a/network/network.h b/network/network.h index a52d498..4f5e87e 100644 --- a/network/network.h +++ b/network/network.h @@ -81,6 +81,7 @@ int network_select(t_net *net,int channel); 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);