From c1e6c1341ace1f61569e6d1d0dbfb36cb192113c Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Tue, 17 Feb 2015 15:15:26 +0900 Subject: Updated libterm. Updated config headers --- articles.c | 8 +++++++- bbsconfig.c | 3 ++- bbsconfig.h | 42 ++++++++++++++++++++++++++++++++++++++++++ libterm/term.c | 23 +++++++++++++++++------ libterm/term.h | 2 +- libterm/term_gui.c | 31 +++++++++++++++++++++++++++++++ libterm/term_gui.h | 24 ++++++++++++++++++++++++ microbbs.c | 2 ++ 8 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 libterm/term_gui.c create mode 100644 libterm/term_gui.h diff --git a/articles.c b/articles.c index 7db8b39..a5c196b 100644 --- a/articles.c +++ b/articles.c @@ -135,6 +135,7 @@ int bbs_article_list( term_screen *ts, const char *dir_name ) int cnt; for ( cnt=0; cntd_name ); sds pathname = sds_new( dir_name ); pathname = sds_cat( pathname, d_name ); @@ -199,8 +200,13 @@ int bbs_article_list( term_screen *ts, const char *dir_name ) int cnt = 1; while (iter != NULL) { + struct stat art_stat; + term_cur_set_c( ts, 0 ); - printf( "[%02d] %s\n", cnt, (char *)iter->val); + //get stat structure and get filesize + + stat( iter->val, &art_stat );//no err check + printf( "[%02d] %s ( %ld bytes)\n", cnt, (char *)iter->val, art_stat.st_size ); cnt += 1; iter = iter->next; } diff --git a/bbsconfig.c b/bbsconfig.c index 53267b8..5ad6a58 100644 --- a/bbsconfig.c +++ b/bbsconfig.c @@ -1 +1,2 @@ -#include "bbsconfig.h" \ No newline at end of file +#include "bbsconfig.h" + diff --git a/bbsconfig.h b/bbsconfig.h index c1eb80f..55be15a 100644 --- a/bbsconfig.h +++ b/bbsconfig.h @@ -4,4 +4,46 @@ #include #include +#include "list.h" +#include "sds.h" +#include "file_use.h" +#include "ini.h" + +//there should be many ways how to config stuff +//from commandline some basic things +//from config files more complicated + +typedef struct bbs_config +{ + //todo configs + //list of filenames that considered to be todos + List *todo_files; + + //directories where could be articles + List *article_dirs; + + //directory with all user inis + char *user_dir; + + //show motd messages? + int motd; + + //write syslogs? + int syslog; + + //debug mode outputs more stuff + int debug; +} bbs_config; + +//GLOBAL USER +#ifdef __MICROBBS_MAIN +bbs_config g_config; +#else +extern bbs_config g_config; +#endif + +int config_from_ini( const char *config_file ); +int config_from_argv( int argc, char **argv ); + + #endif \ No newline at end of file diff --git a/libterm/term.c b/libterm/term.c index 412253b..532dc92 100644 --- a/libterm/term.c +++ b/libterm/term.c @@ -37,6 +37,23 @@ exit_error: return -1; } +//set terminal speed return 0 if OK and 1 if not +//im trust to input arguments that they are ok +int term_set_speed( term_screen *ts, speed_t speed) +{ + int ret = cfsetospeed( &ts->raw_i, speed ); + if ( ret != 0 ) + return 1; + + //if baudrate set to there then input speed same as + //output speed + cfsetispeed( &ts->raw_i, B0); + ret = tcsetattr(1, TCSANOW, &ts->raw_i ); + if ( ret != 0 ) + return 1; + return 0; +} + //get maximal number of columns setting up cursor to 999 column //and getting on with place terminal have placed cursor and getting //column on with terminal putted cursor @@ -233,12 +250,6 @@ exit_error: } -int term_set_speed( term_screen *ts ) -{ - int ret = -1; - return ret; -} - //clean terminal with escape command int term_clr_scr( term_screen *ts ) diff --git a/libterm/term.h b/libterm/term.h index b399cd6..51af31d 100644 --- a/libterm/term.h +++ b/libterm/term.h @@ -52,6 +52,7 @@ typedef struct term_screen } term_screen; int term_init( term_screen *ts ); +int term_set_speed( term_screen *ts, speed_t speed); int term_get_maxcol( term_screen *ts ); int term_get_maxrow( term_screen *ts ); int term_cur_get_c( term_screen *ts ); @@ -59,7 +60,6 @@ int term_cur_get_r( term_screen *ts ); int term_cur_set_c( term_screen *ts, unsigned int pc ); int term_cur_set_r( term_screen *ts, unsigned int pr ); int term_cur_set_cr( term_screen *ts, unsigned int pc , unsigned int pr ); -int term_set_speed( term_screen *ts ); int term_clr_scr( term_screen *ts ); int term_set_raw_mode( term_screen *ts ); int term_mode_rows( term_screen *ts ); diff --git a/libterm/term_gui.c b/libterm/term_gui.c new file mode 100644 index 0000000..dcdc840 --- /dev/null +++ b/libterm/term_gui.c @@ -0,0 +1,31 @@ +#include "term_gui.h" + +int term_gui_init( term_gui *tg, term_screen *ts ) +{ + return 0; +} + + +int term_set_wh( term_screen *tg, int width, int height ) +{ + return 0; +} + + +int term_gui_input_box( term_gui *ts, int x, int y, int w, int h, char *prompt, + char *str, size_t sz ) +{ + return 0; +} + + +int term_gui_draw( term_gui *tg ) +{ + return 0; +} + + +int term_gui_destroy( term_gui *tg ) +{ + return 0; +} \ No newline at end of file diff --git a/libterm/term_gui.h b/libterm/term_gui.h new file mode 100644 index 0000000..408382e --- /dev/null +++ b/libterm/term_gui.h @@ -0,0 +1,24 @@ +#ifndef __LIBTERM_TERM_GUI_H +#define __LIBTERM_TERM_GUI_H + +#include "term.h" +#include "term_io.h" + +typedef struct term_gui +{ + term_screen *ts; + int w; + int h; + int abs_x; + int abs_y; +} term_gui; + +int term_gui_init( term_gui *tg, term_screen *ts ); +int term_set_wh( term_screen *tg, int width, int height ); +int term_gui_input_box( term_gui *ts, int x, int y, int w, int h, char *prompt, + char *str, size_t sz ); +int term_gui_draw( term_gui *tg ); +int term_gui_destroy( term_gui *tg ); + + +#endif \ No newline at end of file diff --git a/microbbs.c b/microbbs.c index 1cb1888..92aa1ed 100644 --- a/microbbs.c +++ b/microbbs.c @@ -10,6 +10,7 @@ #include "sysinfo.h" #include "articles.h" #include "user.h" +#include "bbsconfig.h" #include "libterm/term.h" #include "libterm/term_io.h" @@ -27,6 +28,7 @@ int main( int argc, char **argv ) term_screen ts; memset( (void *)&ts, 0, sizeof(ts) ); term_init( &ts ); term_set_raw_mode( &ts ); + term_set_speed( &ts, B38400 ); term_clr_scr( &ts ); //init global variable of bbs user -- cgit v1.2.3