/[LeafOK_CVS]/lbbs/src/bbs_main.c
ViewVC logotype

Diff of /lbbs/src/bbs_main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 by sysadm, Tue Oct 19 17:11:39 2004 UTC Revision 1.31 by sysadm, Mon Apr 28 03:30:59 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            bbsd.c  -  description                                                    bbs_main.c  -  description
3                               -------------------                                                           -------------------
4      begin                : Mon Oct 18 2004          begin                : Mon Oct 18 2004
5      copyright            : (C) 2004 by Leaflet          copyright            : (C) 2004 by Leaflet
6      email                : leaflet@leafok.com          email                : leaflet@leafok.com
7   ***************************************************************************/   ***************************************************************************/
8    
9  /***************************************************************************  /***************************************************************************
# Line 17  Line 17 
17    
18  #include "bbs.h"  #include "bbs.h"
19  #include "common.h"  #include "common.h"
20    #include "io.h"
21    #include "menu.h"
22    #include "bbs_cmd.h"
23    #include <time.h>
24    #include <string.h>
25    
26  int  int bbs_main()
 bbs_main()  
27  {  {
28    bbs_welcome();          char temp[256];
29            int ret;
30    
31    return 0;          set_input_echo(0);
32    
33            bbs_info();
34    
35            // Welcome
36            bbs_welcome();
37    
38            // Login
39            ret = bbs_login();
40            if (ret < 0)
41                    return -1;
42            log_std("User \"%s\"(%ld) login from %s:%d\n",
43                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
44            clearscr();
45    
46            // BBS Top 10
47            strcpy(temp, app_home_dir);
48            strcat(temp, "data/bbs_top.txt");
49            display_file_ex(temp, 1, 1);
50    
51            // Main
52            bbs_center();
53    
54            // Logout
55            bbs_exit();
56            log_std("User logout\n");
57    
58            return 0;
59    }
60    
61    int bbs_info()
62    {
63            prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
64                       BBS_name, BBS_server, app_version);
65    
66            iflush();
67    
68            return 0;
69    }
70    
71    int bbs_exit()
72    {
73            char temp[256];
74    
75            strcpy(temp, app_home_dir);
76            strcat(temp, "data/goodbye.txt");
77            display_file_ex(temp, 1, 0);
78    
79            sleep(1);
80    
81            return 0;
82    }
83    
84    int bbs_center()
85    {
86            int ch, result, redraw;
87            char temp[256];
88            time_t t_last_action;
89    
90            BBS_last_access_tm = t_last_action = time(0);
91    
92            clearscr();
93    
94            show_top("");
95            show_active_board();
96            show_bottom("");
97            display_menu(get_menu(&bbs_menu, "TOPMENU"));
98    
99            while (!SYS_exit)
100            {
101                    ch = igetch();
102    
103                    if (time(0) - t_last_action >= 10)
104                    {
105                            t_last_action = time(0);
106                            show_active_board();
107                            show_bottom("");
108                    }
109    
110                    switch (ch)
111                    {
112                    case KEY_NULL:
113                            return 0;
114                    case KEY_TIMEOUT:
115                            if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
116                            {
117                                    return -1;
118                            }
119                            continue;
120                    default:
121                            redraw = 1;
122                            switch (menu_control(&bbs_menu, ch))
123                            {
124                            case EXITBBS:
125                                    return 0;
126                            case REDRAW:
127                                    break;
128                            case NOREDRAW:
129                            case UNKNOWN_CMD:
130                            default:
131                                    redraw = 0;
132                                    break;
133                            }
134                            if (redraw)
135                            {
136                                    clearscr();
137                                    show_top("");
138                                    show_active_board();
139                                    show_bottom("");
140                                    display_current_menu(&bbs_menu);
141                            }
142                    }
143                    BBS_last_access_tm = time(0);
144            }
145    
146            return 0;
147  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1