summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--articles.c20
-rw-r--r--articles.h1
-rw-r--r--buildinfo.h2
-rw-r--r--libterm/Makefile3
-rw-r--r--logs.c71
-rw-r--r--logs.h4
-rw-r--r--microbbs.c3
-rw-r--r--motd.h2
-rw-r--r--vote.c10
-rw-r--r--vote.h12
11 files changed, 136 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index ac8cc80..443b8ca 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,17 @@
-make:
+PROJECT=microbbs
+CC=gcc
+CFLAGS=
+SOURCES=motd.c buildinfo.c sysinfo.c articles.c logs.c vote.c
+OBJECTS=$(SOURCES:.c=.o)
+
+all: $(OBJECTS) $(PROJECT)
+
+$(PROJECT): $(SOURCES)
cd ./libterm; make
- gcc -c motd.c
- gcc -c microbbs.c
- gcc -c buildinfo.c
- gcc -c sysinfo.c
- gcc -c articles.c
- gcc -c logs.c
- gcc buildinfo.o motd.o microbbs.o sysinfo.o articles.o logs.o libterm/libterm.o -o microbbs
+ $(CC) $(OBJECTS) $(CFLAGS) libterm/libterm.o microbbs.c -o $(PROJECT)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
clean:
rm -rf *.o microbbs
diff --git a/articles.c b/articles.c
index db1d16f..b3553c0 100644
--- a/articles.c
+++ b/articles.c
@@ -20,10 +20,13 @@ int bbs_article( term_screen *ts, const char *fname )
max_y = 24;
} else
{
+ printf("Unknown mode\n");
max_x = 80;
max_y = 24;
}
+ bbs_log_article( NULL );
+
if ( fname != NULL )
{
f = fopen( fname, "r" );
@@ -48,7 +51,7 @@ int bbs_article( term_screen *ts, const char *fname )
// ((fret > 0) && (i > max_x-1)) )
if ( i >= max_y-1 )
{
- printf("(N)ext,(Q)uit:");
+ printf("(N)ext,(D)ump,(Q)uit:");
ret_len = getline( &in_buf, &in_size, stdin );
if ( ret_len > 0 )
{
@@ -63,6 +66,21 @@ int bbs_article( term_screen *ts, const char *fname )
case 'N':
i = 0;
break;
+ //dump whole file to the screen
+ case 'd':
+ case 'D':
+ {
+ char tmp_buf[81];
+ size_t tmp_size;
+ fseek( f, 0, SEEK_SET );
+ while ( (tmp_size = fread( &tmp_buf, 1, 80, f )) > 0 )
+ {
+ tmp_buf[ tmp_size ] = 0;
+ printf( "%s", tmp_buf );
+ }
+ }
+ i = 0;
+ break;
default:
printf("Try more\n");
}
diff --git a/articles.h b/articles.h
index 4f66376..25977b9 100644
--- a/articles.h
+++ b/articles.h
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include "libterm/term.h"
+#include "logs.h"
int bbs_article( term_screen*, const char* );
diff --git a/buildinfo.h b/buildinfo.h
index 1b1041d..9dcbb25 100644
--- a/buildinfo.h
+++ b/buildinfo.h
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
-#define BUILD_VERSION "0.1.7"
+#define BUILD_VERSION "0.1.8"
#define BUILD_DATE (__DATE__)
void print_build_info();
diff --git a/libterm/Makefile b/libterm/Makefile
index a592109..5cc090c 100644
--- a/libterm/Makefile
+++ b/libterm/Makefile
@@ -4,3 +4,6 @@ make:
gcc -c screen_modes.c
gcc -c print_utils.c
ld -r term.o screen_modes.o print_utils.o -o libterm.o
+
+clean:
+ rm *.o
diff --git a/logs.c b/logs.c
index 7ec8efe..697693c 100644
--- a/logs.c
+++ b/logs.c
@@ -2,7 +2,7 @@
int bbs_log( const char *syslname )
{
- int ret;
+ int ret=0;
char *term=NULL;
setlogmask (LOG_UPTO (LOG_NOTICE));
@@ -15,6 +15,7 @@ int bbs_log( const char *syslname )
openlog ( syslname, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1 );
}
+ //maybe fake visitor
term = getenv( "TERM" );
if ( term != NULL )
syslog (LOG_NOTICE, "BBS visitor with TERM=%s", term);
@@ -26,4 +27,72 @@ int bbs_log( const char *syslname )
return ret;
}
+int bbs_log_article( const char *syslname )
+{
+ int ret=0;
+
+ setlogmask (LOG_UPTO (LOG_NOTICE));
+
+ if ( syslname == NULL )
+ {
+ openlog ( BBS_DEFAULT_SYSLOG, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
+ } else
+ {
+ openlog ( syslname, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1 );
+ }
+
+ //probably not fake visitor
+ syslog( LOG_NOTICE, "BBS article" );
+
+ closelog ();
+
+
+ return ret;
+}
+
+
+int bbs_log_motd( const char *syslname )
+{
+ int ret=0;
+
+ setlogmask (LOG_UPTO (LOG_NOTICE));
+
+ if ( syslname == NULL )
+ {
+ openlog ( BBS_DEFAULT_SYSLOG, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
+ } else
+ {
+ openlog ( syslname, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1 );
+ }
+
+ syslog( LOG_NOTICE, "BBS motd" );
+
+ closelog ();
+
+
+ return ret;
+}
+
+int bbs_log_quit( const char *syslname )
+{
+ int ret=0;
+
+ setlogmask (LOG_UPTO (LOG_NOTICE));
+
+ if ( syslname == NULL )
+ {
+ openlog ( BBS_DEFAULT_SYSLOG, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
+ } else
+ {
+ openlog ( syslname, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1 );
+ }
+
+ syslog( LOG_NOTICE, "BBS quit" );
+
+ closelog ();
+
+
+ return ret;
+}
+
diff --git a/logs.h b/logs.h
index f86c0a3..9247ba6 100644
--- a/logs.h
+++ b/logs.h
@@ -8,5 +8,7 @@
#define BBS_DEFAULT_SYSLOG "microbbs"
int bbs_log( const char* );
-
+int bbs_log_article( const char* );
+int bbs_log_motd( const char* );
+int bbs_log_quit( const char* );
#endif
diff --git a/microbbs.c b/microbbs.c
index c0d94a3..3624671 100644
--- a/microbbs.c
+++ b/microbbs.c
@@ -20,7 +20,7 @@ int main( int argc, char **argv )
bbs_log( NULL ); //write to default place
bbs_motd( &ts, "art/motd.txt" );
print_build_info();
- while ( strncmp( str, "q", 1 ) )
+ while ( strncmp( str, "q", 1 ) && strncmp( str, "Q", 1 ) )
{
printf("(M)otd (Q)uit (S)ysinfo (A)rticles: ");
ret_len = getline( &str, &str_size, stdin );
@@ -48,6 +48,7 @@ int main( int argc, char **argv )
break;
case 'q':
case 'Q':
+ bbs_log_quit( NULL );
break;
default:
printf("Unknow command\n");
diff --git a/motd.h b/motd.h
index f3dfd63..f4344a6 100644
--- a/motd.h
+++ b/motd.h
@@ -8,6 +8,8 @@
#include "libterm/print_utils.h"
#include "libterm/term.h"
+#include "logs.h"
+
//get file name
//calculate current termsize and then print motd in da middle
int bbs_motd( term_screen*, const char* );
diff --git a/vote.c b/vote.c
new file mode 100644
index 0000000..9ded5cb
--- /dev/null
+++ b/vote.c
@@ -0,0 +1,10 @@
+#include "vote.h"
+
+int bbs_vote( term_screen *ts, const char *s )
+{
+ int ret=-1;
+
+
+
+ return ret;
+} \ No newline at end of file
diff --git a/vote.h b/vote.h
new file mode 100644
index 0000000..6103afc
--- /dev/null
+++ b/vote.h
@@ -0,0 +1,12 @@
+#ifndef __MICROBBS_VOTE_H
+#define __MICROBBS_VOTE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libterm/term.h"
+#include "logs.h"
+
+int bbs_vote( term_screen*, const char* );
+
+#endif \ No newline at end of file