summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2014-08-31 08:49:53 +0900
committerFreeArtMan <dos21h@gmail.com>2014-08-31 08:49:53 +0900
commitf9a751917d0dd885ba7ae6047ccf7369512ee5df (patch)
treef0d40267bbef0db583ddfe9257d28dbb75eee331
parent56bcbaf9db3fc08b45b1065868714c58bd0d381a (diff)
downloadmicrobbs-f9a751917d0dd885ba7ae6047ccf7369512ee5df.tar.gz
microbbs-f9a751917d0dd885ba7ae6047ccf7369512ee5df.zip
Case insensitive, syslog support
-rw-r--r--.gitignore2
-rw-r--r--Makefile3
-rw-r--r--articles.c2
-rw-r--r--buildinfo.h2
-rw-r--r--logs.c29
-rw-r--r--logs.h12
-rw-r--r--microbbs.c7
7 files changed, 55 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3789978
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.o
+microbbs
diff --git a/Makefile b/Makefile
index e8cd73f..ac8cc80 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ make:
gcc -c buildinfo.c
gcc -c sysinfo.c
gcc -c articles.c
- gcc buildinfo.o motd.o microbbs.o sysinfo.o articles.o libterm/libterm.o -o microbbs
+ gcc -c logs.c
+ gcc buildinfo.o motd.o microbbs.o sysinfo.o articles.o logs.o libterm/libterm.o -o microbbs
clean:
rm -rf *.o microbbs
diff --git a/articles.c b/articles.c
index b5c5ea3..db1d16f 100644
--- a/articles.c
+++ b/articles.c
@@ -56,9 +56,11 @@ int bbs_article( term_screen *ts, const char *fname )
switch( ch )
{
case 'q':
+ case 'Q':
quit_loop = 1;
break;
case 'n':
+ case 'N':
i = 0;
break;
default:
diff --git a/buildinfo.h b/buildinfo.h
index d831b5e..1b1041d 100644
--- a/buildinfo.h
+++ b/buildinfo.h
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
-#define BUILD_VERSION "0.1.4"
+#define BUILD_VERSION "0.1.7"
#define BUILD_DATE (__DATE__)
void print_build_info();
diff --git a/logs.c b/logs.c
new file mode 100644
index 0000000..7ec8efe
--- /dev/null
+++ b/logs.c
@@ -0,0 +1,29 @@
+#include "logs.h"
+
+int bbs_log( const char *syslname )
+{
+ int ret;
+ char *term=NULL;
+
+ 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 );
+ }
+
+ term = getenv( "TERM" );
+ if ( term != NULL )
+ syslog (LOG_NOTICE, "BBS visitor with TERM=%s", term);
+ else
+ syslog( LOG_NOTICE, "BBS visitor" );
+
+ closelog ();
+
+ return ret;
+}
+
+
diff --git a/logs.h b/logs.h
new file mode 100644
index 0000000..f86c0a3
--- /dev/null
+++ b/logs.h
@@ -0,0 +1,12 @@
+#ifndef __MICROBBS_LOGS_H
+#define __MICROBBS_LOGS_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+
+#define BBS_DEFAULT_SYSLOG "microbbs"
+
+int bbs_log( const char* );
+
+#endif
diff --git a/microbbs.c b/microbbs.c
index af22958..c0d94a3 100644
--- a/microbbs.c
+++ b/microbbs.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "logs.h"
#include "motd.h"
#include "libterm/term.h"
@@ -15,6 +16,8 @@ int main( int argc, char **argv )
term_init_data( &ts );
//printf("%d %d\n", ts.term_col, ts.term_row);
+ //write to log that some user have accesed bbs
+ bbs_log( NULL ); //write to default place
bbs_motd( &ts, "art/motd.txt" );
print_build_info();
while ( strncmp( str, "q", 1 ) )
@@ -26,21 +29,25 @@ int main( int argc, char **argv )
switch ( str[0] )
{
case 'm':
+ case 'M':
{
bbs_motd( &ts, "art/motd.txt" );
}
break;
case 's':
+ case 'S':
{
bbs_sysinfo( &ts );
}
break;
case 'a':
+ case 'A':
{
bbs_article( &ts, "article/post1.txt" );
}
break;
case 'q':
+ case 'Q':
break;
default:
printf("Unknow command\n");