summaryrefslogtreecommitdiffstats
path: root/motd.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2014-11-16 15:20:30 +0900
committerFreeArtMan <dos21h@gmail.com>2014-11-16 15:20:30 +0900
commitdc4bbe5366d6c733f9f77b7c9fee0cbba3e0d92b (patch)
tree59335ea751ae3e3cbedfd227e4c9c92237b1d6de /motd.c
parentc0adc26b6e1b9c07b144798fb3b5de27a2e36e0c (diff)
downloadmicrobbs-dc4bbe5366d6c733f9f77b7c9fee0cbba3e0d92b.tar.gz
microbbs-dc4bbe5366d6c733f9f77b7c9fee0cbba3e0d92b.zip
New version bumped. Article list and list read added. Quit motd added
Diffstat (limited to 'motd.c')
-rw-r--r--motd.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/motd.c b/motd.c
index 21d6246..ce68f77 100644
--- a/motd.c
+++ b/motd.c
@@ -1,6 +1,8 @@
#include "motd.h"
-int bbs_motd( term_screen *ts, const char *fname )
+//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;
@@ -50,3 +52,52 @@ int bbs_motd( term_screen *ts, const char *fname )
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<posy;i++)
+ printf("\n");
+ ret = 1;
+ while ( ret > 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;
+} \ No newline at end of file