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