diff options
author | FreeArtMan <dos21h@gmail.com> | 2014-12-24 15:44:09 +0900 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2014-12-24 15:44:09 +0900 |
commit | d5ec429771a092e88015e489103e43badaef2c0d (patch) | |
tree | 598ca762ebd6186bb5dd17c6d20ceca532e86f08 | |
parent | ae9cfee6605db373e9aa8b7c054403d83a612595 (diff) | |
download | microbbs-d5ec429771a092e88015e489103e43badaef2c0d.tar.gz microbbs-d5ec429771a092e88015e489103e43badaef2c0d.zip |
Todo added into bbs shell
-rw-r--r-- | microbbs.c | 1 | ||||
-rw-r--r-- | todo.c | 78 | ||||
-rw-r--r-- | todo.h | 14 | ||||
-rw-r--r-- | todo/todo.txt | 5 |
4 files changed, 98 insertions, 0 deletions
@@ -146,6 +146,7 @@ int main( int argc, char **argv ) case 'O': { printf("Todo list\n"); + bbs_todo( &ts, NULL ); } break; #endif @@ -0,0 +1,78 @@ +#include "todo.h" + +int bbs_todo( term_screen *ts, const char *fname) +{ + int ret=-1; + + int ret_len; + size_t in_size=0; + char *in_buf=NULL; + int quit_loop=0; + + if ( ts == NULL ) + return ret; + + + if ( fname == NULL ) + fname = CONFIG_TODO_DEFAULT_FILE; + + List *todo_list = llist_new(); + f_file *file = f_file_open( fname, F_FILE_READ ); + if ( file != NULL ) + { + const int l_s = 128; + int r_v; + { + cycle0:; + char *l = malloc( l_s ); + r_v = f_file_readl( file, l_s, l ); + if ( r_v < 0 ) goto exit_cycle0; + l[r_v] = '\0'; + llist_push( todo_list, l ); + goto cycle0; + exit_cycle0:; + } + + } + f_file_close( file ); + + while( (quit_loop == 0) ) + { + + printf("(S)how tood list,(Q)uit:"); + ret_len = getline( &in_buf, &in_size, stdin ); + if ( ret_len > 0 ) + { + char ch = in_buf[0]; + switch( ch ) + { + case 'q': + case 'Q': + quit_loop = 1; + ret = 0; + break; + + case 's': + case 'S': + { + struct ListNode *iter=todo_list->first; + int cnt = 1; + while (iter != NULL) + { + printf( "[%d] -> %s\n", cnt, (char *)iter->val); + cnt += 1; + iter = iter->next; + } + } + break; + + default: + printf("Try more\n"); + } + } + } + + llist_free( todo_list ); + + return ret; +}
\ No newline at end of file @@ -0,0 +1,14 @@ +#ifndef __MICROBBS_TODO_H +#define __MICROBBS_TODO_H + +//part of libterm +#include "libterm/term.h" +#include "logs.h" +#include "file_use.h" +#include "list.h" + +#include "kconfig.h" + +int bbs_todo( term_screen *, const char *); + +#endif
\ No newline at end of file diff --git a/todo/todo.txt b/todo/todo.txt new file mode 100644 index 0000000..3a9516e --- /dev/null +++ b/todo/todo.txt @@ -0,0 +1,5 @@ +Add telnet server into binary +Add voting system +Add nice screen resolution detection, resizing +Add loging +Add messaging |