#include "motd.h" #ifdef CONFIG_MOTD //TODO merge 2 functions in one proper //TODO complcations with libterm int bbs_motd_draw( term_screen *ts, const char *fname ) { int posc=0, posr=0; int ret=0; const int buf_size=80*25+1; char buf[buf_size]; int x=0,y=0; int row=0,column=0; FILE *f = fopen( fname, "r" ); if ( f == NULL ) { printf("Cannot open file %s\n", fname); return -1; } term_clr_scr( ts ); row = term_get_maxrow( ts ); column = term_get_maxcol( ts ); term_cur_set_r( ts, ++posr ); term_cur_set_c( ts, 0 ); memset( buf, 0, buf_size ); ret = fread( buf, 1, buf_size, f ); if (ret > 0) { { int i=0; while ( i < ret ) { if ( buf[i] != '\n' ) { printf("%c",buf[i] ); } else if ( buf[i] == '\n') { posr += 1; fflush( stdout ); term_cur_set_r( ts, posr ); term_cur_set_c( ts, 0 ); } i++; } } } fclose( f ); return 0; } #endif