#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 posr=0; int ret=0; const int buf_size=80*26+1; char buf[buf_size]; int row=0,column=0; FILE *f = fopen( fname, "r" ); if ( f == NULL ) { term_printf( ts, "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' ) { term_printf( ts, "%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++; } fflush( stdout ); } } fclose( f ); return 0; } #endif