/[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.35 by sysadm, Sun May 4 14:54:55 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 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #include "bbs_main.h"
19  #include "bbs.h"  #include "bbs.h"
20    #include "welcome.h"
21    #include "login.h"
22    #include "user_priv.h"
23  #include "common.h"  #include "common.h"
24    #include "database.h"
25    #include "log.h"
26    #include "io.h"
27    #include "screen.h"
28    #include "menu.h"
29    #include "bbs_cmd.h"
30    #include <unistd.h>
31    #include <time.h>
32    #include <string.h>
33    
34  int  int bbs_info()
 bbs_main()  
35  {  {
36    bbs_welcome();          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
37                       BBS_name, BBS_server, app_version);
38    
39    return 0;          iflush();
40    
41            return 0;
42    }
43    
44    int bbs_exit()
45    {
46            display_file_ex(DATA_GOODBYE, 1, 0);
47    
48            sleep(1);
49    
50            return 0;
51    }
52    
53    int bbs_center()
54    {
55            int ch, redraw;
56            time_t t_last_action;
57    
58            BBS_last_access_tm = t_last_action = time(0);
59    
60            clearscr();
61    
62            show_top("");
63            show_active_board();
64            show_bottom("");
65            display_menu(get_menu(&bbs_menu, "TOPMENU"));
66    
67            while (!SYS_exit)
68            {
69                    ch = igetch(0);
70    
71                    if (time(0) - t_last_action >= 10)
72                    {
73                            t_last_action = time(0);
74                            show_active_board();
75                            show_bottom("");
76                    }
77    
78                    switch (ch)
79                    {
80                    case KEY_NULL:
81                            return 0;
82                    case KEY_TIMEOUT:
83                            if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
84                            {
85                                    return -1;
86                            }
87                            continue;
88                    default:
89                            redraw = 1;
90                            switch (menu_control(&bbs_menu, ch))
91                            {
92                            case EXITBBS:
93                                    return 0;
94                            case REDRAW:
95                                    break;
96                            case NOREDRAW:
97                            case UNKNOWN_CMD:
98                            default:
99                                    redraw = 0;
100                                    break;
101                            }
102                            if (redraw)
103                            {
104                                    clearscr();
105                                    show_top("");
106                                    show_active_board();
107                                    show_bottom("");
108                                    display_current_menu(&bbs_menu);
109                            }
110                    }
111                    BBS_last_access_tm = time(0);
112            }
113    
114            return 0;
115    }
116    
117    int bbs_main()
118    {
119            int ret;
120    
121            set_input_echo(0);
122    
123            bbs_info();
124    
125            // Welcome
126            bbs_welcome();
127    
128            // Login
129            ret = bbs_login();
130            if (ret < 0)
131                    return -1;
132            log_std("User \"%s\"(%ld) login from %s:%d\n",
133                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
134            clearscr();
135    
136            // BBS Top 10
137            display_file_ex("./var/bbs_top.txt", 1, 1);
138    
139            // Main
140            bbs_center();
141    
142            // Logout
143            bbs_exit();
144            log_std("User logout\n");
145    
146            MYSQL *db = db_open();
147            if (db == NULL)
148            {
149                    return -1;
150            }
151    
152            user_online_del(db);
153    
154            mysql_close(db);
155    
156            return 0;
157  }  }


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

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