/[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.2 by sysadm, Tue Oct 19 02:08:35 2004 UTC Revision 1.42 by sysadm, Sun May 11 11:33:44 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            bbsd.c  -  description                                                    bbs_main.c  -  description
3                               -------------------                                                           -------------------
4      begin                : Mon Oct 18 2004          Copyright            : (C) 2004-2025 by Leaflet
5      copyright            : (C) 2004 by Leaflet          Email                : leaflet@leafok.com
     email                : leaflet@leafok.com  
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 3 of the License, or     *
13   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17    #include "bbs_main.h"
18    #include "bbs.h"
19    #include "welcome.h"
20    #include "login.h"
21    #include "user_priv.h"
22  #include "common.h"  #include "common.h"
23    #include "database.h"
24    #include "log.h"
25    #include "io.h"
26    #include "screen.h"
27    #include "menu.h"
28    #include "bbs_cmd.h"
29    #include <unistd.h>
30    #include <time.h>
31    #include <string.h>
32    
33  int  int bbs_info()
 bbs_main()  
34  {  {
35          log_std("bbs_main()\n");          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
36                               BBS_name, BBS_server, app_version);
37    
38            iflush();
39    
40            return 0;
41    }
42    
43    int bbs_exit()
44    {
45            display_file_ex(DATA_GOODBYE, 1, 0);
46    
47            return 0;
48    }
49    
50    int bbs_center()
51    {
52            int ch;
53            time_t t_last_action;
54    
55            BBS_last_access_tm = t_last_action = time(0);
56    
57            clearscr();
58    
59            show_top("");
60            show_active_board();
61            show_bottom("");
62            display_menu(get_menu(&bbs_menu, "TOPMENU"));
63    
64            while (!SYS_server_exit)
65            {
66                    ch = igetch(0);
67    
68                    if (time(0) - t_last_action >= 10)
69                    {
70                            t_last_action = time(0);
71                            show_active_board();
72                            show_bottom("");
73                    }
74    
75                    switch (ch)
76                    {
77                    case KEY_NULL: // broken pipe
78                            return 0;
79                    case KEY_TIMEOUT:
80                            if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
81                            {
82                                    return 0;
83                            }
84                            continue;
85                    default:
86                            switch (menu_control(&bbs_menu, ch))
87                            {
88                            case EXITBBS:
89                                    return 0;
90                            case REDRAW:
91                                    clearscr();
92                                    show_top("");
93                                    show_active_board();
94                                    show_bottom("");
95                                    display_current_menu(&bbs_menu);
96                                    break;
97                            case NOREDRAW:
98                            case UNKNOWN_CMD:
99                            default:
100                                    break;
101                            }
102                    }
103                    BBS_last_access_tm = time(0);
104            }
105    
106            return 0;
107    }
108    
109    int bbs_main()
110    {
111            int ret;
112    
113            set_input_echo(0);
114    
115            bbs_info();
116    
117            // Welcome
118            bbs_welcome();
119    
120            // Login
121            ret = bbs_login();
122            if (ret < 0)
123                    return -1;
124            log_std("User \"%s\"(%ld) login from %s:%d\n",
125                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
126            clearscr();
127    
128            // BBS Top 10
129            display_file_ex("./var/bbs_top.txt", 1, 1);
130    
131            // Main
132            bbs_center();
133    
134            // Logout
135            bbs_exit();
136            log_std("User logout\n");
137    
138            MYSQL *db = db_open();
139            if (db == NULL)
140            {
141                    return -1;
142            }
143    
144            user_online_del(db);
145    
146            mysql_close(db);
147    
148          return 0;          return 0;
149  }  }


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

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