#include "motd.h" //TODO merge 2 functions in one proper //TODO complcations with libterm int bbs_login_motd( term_screen *ts, const char *fname ) { int posx=0, posy=0; int i; FILE *f = fopen( fname, "r" ); if ( f == NULL ) { printf("Cannot open file %s\n", fname); return -1; } int ret; const int buf_size=160; char buf[buf_size]; int x=0,y=0; if ( ts->term_row > 24 ) { posy = (ts->term_row-24)/2; } for (i=0;i 0 ) { memset( buf, 0, buf_size ); ret = fread( buf, 1, buf_size, f ); if (ret > 0) { //printf("%d %d",x,y); x = term_print( ts, buf, ret, x, y ); y = (x&0xffff0000)>>16; x = x&0x0000ffff; } } fclose( f ); //printf("->posy=%d y=%d x=%d\n",posy,y,x); //printf("-->%d\n",ts->term_row-posy-(24-y)); for (i=0;i<(ts->term_row-posy-y);i++) printf("\n"); //for (i=0;i < ts->term_row-(ts->term_row-posy-24+y);i++) // printf("\n"); //printf("%d\n",i); //printf("%d %d %d\n",y,posy,ts->term_row); return 0; } int bbs_quit_motd( term_screen *ts, const char *fname ) { int posx=0, posy=0; int i; FILE *f = fopen( fname, "r" ); if ( f == NULL ) { printf("Cannot open file %s\n", fname); return -1; } int ret; const int buf_size=160; char buf[buf_size]; int x=0,y=0; if ( ts->term_row > 24 ) { posy = (ts->term_row-24)/2; } for (i=0;i 0 ) { memset( buf, 0, buf_size ); ret = fread( buf, 1, buf_size, f ); if (ret > 0) { //printf("%d %d",x,y); x = term_print( ts, buf, ret, x, y ); y = (x&0xffff0000)>>16; x = x&0x0000ffff; } } fclose( f ); //printf("->posy=%d y=%d x=%d\n",posy,y,x); //printf("-->%d\n",ts->term_row-posy-(24-y)); for (i=0;i<(ts->term_row-posy-y);i++) printf("\n"); //for (i=0;i < ts->term_row-(ts->term_row-posy-24+y);i++) // printf("\n"); //printf("%d\n",i); //printf("%d %d %d\n",y,posy,ts->term_row); return 0; }