summaryrefslogtreecommitdiffstats
path: root/motd.c
diff options
context:
space:
mode:
authorArtur Artamonov <freeartman@wechall.net>2014-08-17 19:40:06 +0100
committerArtur Artamonov <freeartman@wechall.net>2014-08-17 19:40:06 +0100
commitaca4b1ad122434458125b4f25ea2d99a80370ee4 (patch)
tree7664e9e1f454e702c5ad2f557c06882a12ab42de /motd.c
downloadmicrobbs-aca4b1ad122434458125b4f25ea2d99a80370ee4.tar.gz
microbbs-aca4b1ad122434458125b4f25ea2d99a80370ee4.zip
Initial commit
Diffstat (limited to 'motd.c')
-rw-r--r--motd.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/motd.c b/motd.c
new file mode 100644
index 0000000..21d6246
--- /dev/null
+++ b/motd.c
@@ -0,0 +1,52 @@
+#include "motd.h"
+
+int bbs_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;
+}
+