/[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.21 by sysadm, Sun Mar 20 07:39:28 2005 UTC Revision 1.35 by sysadm, Sun May 4 14:54:55 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            bbs_main.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"  #include "io.h"
27    #include "screen.h"
28  #include "menu.h"  #include "menu.h"
29  #include <time.h>  #include "bbs_cmd.h"
 #include <fcntl.h>  
30  #include <unistd.h>  #include <unistd.h>
31    #include <time.h>
32  #include <string.h>  #include <string.h>
33    
34  int  int bbs_info()
 bbs_main ()  
35  {  {
36    char temp[256];          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
37    int ret;                     BBS_name, BBS_server, app_version);
38    
39    set_input_echo (0);          iflush();
40    
41    bbs_info ();          return 0;
42    }
43    
44    //Welcome  int bbs_exit()
45    bbs_welcome ();  {
46            display_file_ex(DATA_GOODBYE, 1, 0);
47    
48    //Login          sleep(1);
   ret = bbs_login ();  
   if (ret < 0)  
     return -1;  
   clearscr ();  
49    
50    //BBS Top 10          return 0;
51    strcpy (temp, app_home_dir);  }
   strcat (temp, "data/bbs_top.txt");  
   display_file_ex (temp, 1, 1);  
52    
53    //Main  int bbs_center()
54    bbs_center ();  {
55            int ch, redraw;
56            time_t t_last_action;
57    
58    //Logout          BBS_last_access_tm = t_last_action = time(0);
   bbs_exit ();  
59    
60    return 0;          clearscr();
 }  
61    
62  int          show_top("");
63  bbs_info ()          show_active_board();
64  {          show_bottom("");
65    prints ("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",          display_menu(get_menu(&bbs_menu, "TOPMENU"));
           BBS_name, BBS_server, app_version);  
66    
67    iflush ();          while (!SYS_exit)
68            {
69                    ch = igetch(0);
70    
71    return 0;                  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  int bbs_main()
 bbs_exit ()  
118  {  {
119    char temp[256];          int ret;
120    
121    strcpy (temp, app_home_dir);          set_input_echo(0);
   strcat (temp, "data/goodbye.txt");  
   display_file_ex (temp, 1, 0);  
122    
123    sleep (1);          bbs_info();
124    
125    return 0;          // Welcome
126  }          bbs_welcome();
127    
128  int          // Login
129  bbs_center ()          ret = bbs_login();
130  {          if (ret < 0)
131    int ch, result;                  return -1;
132    char action[MAX_MENUACTION_LENGTH];          log_std("User \"%s\"(%ld) login from %s:%d\n",
133    time_t t_last_action;                          BBS_username, BBS_priv.uid, hostaddr_client, port_client);
134    fd_set inputs, testfds;          clearscr();
   struct timeval timeout;  
   
   FD_ZERO (&inputs);  
   FD_SET (0, &inputs);  
   
   t_last_action = time (0);  
   
   clearscr ();  
   
   show_top ("");  
   show_active_board ();  
   display_menu (get_menu (&bbs_menu, "TOPMENU"));  
   show_bottom ("");  
   
   while (1)  
     {  
       testfds = inputs;  
       timeout.tv_sec = 0;  
       timeout.tv_usec = 100000;  
135    
136        result = select (FD_SETSIZE, &testfds, (fd_set *) NULL,          // BBS Top 10
137                         (fd_set *) NULL, &timeout);          display_file_ex("./var/bbs_top.txt", 1, 1);
138    
139        switch (result)          // Main
140          {          bbs_center();
         case 0:  
           break;  
         case -1:  
           log_error ("select() error!\n");  
           break;  
         default:  
           if (FD_ISSET (0, &testfds))  
             {  
               ch = igetch ();  
141    
142                switch (ch)          // Logout
143                  {          bbs_exit();
144                  case 0:          log_std("User logout\n");
145                    return 0;  
146                  default:          MYSQL *db = db_open();
147                    strcpy (action, menu_control (&bbs_menu, ch));          if (db == NULL)
                   if (strcmp (action, "EXITBBS") == 0)  
                     return 0;  
                 }  
             }  
           break;  
         }  
       if (time (0) - t_last_action >= 10)  
148          {          {
149            t_last_action = time (0);                  return -1;
           show_active_board ();  
150          }          }
     }  
151    
152    return 0;          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