diff options
author | FreeArtMan <dos21h@gmail.com> | 2014-08-31 08:49:53 +0900 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2014-08-31 08:49:53 +0900 |
commit | f9a751917d0dd885ba7ae6047ccf7369512ee5df (patch) | |
tree | f0d40267bbef0db583ddfe9257d28dbb75eee331 | |
parent | 56bcbaf9db3fc08b45b1065868714c58bd0d381a (diff) | |
download | microbbs-f9a751917d0dd885ba7ae6047ccf7369512ee5df.tar.gz microbbs-f9a751917d0dd885ba7ae6047ccf7369512ee5df.zip |
Case insensitive, syslog support
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | articles.c | 2 | ||||
-rw-r--r-- | buildinfo.h | 2 | ||||
-rw-r--r-- | logs.c | 29 | ||||
-rw-r--r-- | logs.h | 12 | ||||
-rw-r--r-- | microbbs.c | 7 |
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 @@ -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 @@ -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(); @@ -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; +} + + @@ -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 @@ -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"); |