/[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.23 by sysadm, Mon Mar 21 13:27:00 2005 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
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #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 <fcntl.h>
25    #include <unistd.h>
26    #include <string.h>
27    
28  int  int
29  bbs_main()  bbs_main ()
30  {  {
31          log_std("bbs_main()\n");    char temp[256];
32              int ret;
33          return 0;  
34      set_input_echo (0);
35    
36      bbs_info ();
37    
38      //Welcome
39      bbs_welcome ();
40    
41      //Login
42      ret = bbs_login ();
43      if (ret < 0)
44        return -1;
45      clearscr ();
46    
47      //BBS Top 10
48      strcpy (temp, app_home_dir);
49      strcat (temp, "data/bbs_top.txt");
50      display_file_ex (temp, 1, 1);
51    
52      //Main
53      bbs_center ();
54    
55      //Logout
56      bbs_exit ();
57    
58      return 0;
59    }
60    
61    int
62    bbs_info ()
63    {
64      prints ("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
65              BBS_name, BBS_server, app_version);
66    
67      iflush ();
68    
69      return 0;
70    }
71    
72    int
73    bbs_exit ()
74    {
75      char temp[256];
76    
77      strcpy (temp, app_home_dir);
78      strcat (temp, "data/goodbye.txt");
79      display_file_ex (temp, 1, 0);
80    
81      sleep (1);
82    
83      return 0;
84    }
85    
86    int
87    bbs_center ()
88    {
89      int ch, result;
90      char action[MAX_MENUACTION_LENGTH];
91      time_t t_last_action;
92      fd_set inputs, testfds;
93      struct timeval timeout;
94    
95      FD_ZERO (&inputs);
96      FD_SET (0, &inputs);
97    
98      t_last_action = time (0);
99    
100      clearscr ();
101    
102      show_top ("");
103      show_active_board ();
104      show_bottom ("");
105      display_menu (get_menu (&bbs_menu, "TOPMENU"));
106    
107      while (1)
108        {
109          testfds = inputs;
110          timeout.tv_sec = 0;
111          timeout.tv_usec = 100000;
112    
113          result = select (FD_SETSIZE, &testfds, (fd_set *) NULL,
114                           (fd_set *) NULL, &timeout);
115    
116          switch (result)
117            {
118            case 0:
119              break;
120            case -1:
121              log_error ("select() error!\n");
122              break;
123            default:
124              if (FD_ISSET (0, &testfds))
125                {
126                  ch = igetch ();
127    
128                  switch (ch)
129                    {
130                    case KEY_NULL:
131                      return 0;
132                    default:
133                      strcpy (action, menu_control (&bbs_menu, ch));
134                      switch (get_cmd_value (action))
135                        {
136                          case EXITBBS:
137                            return 0;
138                          case BBSNET:
139                            bbs_net();
140                            clearscr ();
141                            show_top ("");
142                            show_active_board ();
143                            show_bottom ("");
144                            display_current_menu (&bbs_menu);
145                            break;
146                          case UNKNOWN_CMD:
147                            break;
148                        }
149                    }
150                }
151              break;
152            }
153          if (time (0) - t_last_action >= 10)
154            {
155              t_last_action = time (0);
156              show_top ("");
157              show_active_board ();
158              show_bottom ("");
159            }
160        }
161    
162      return 0;
163  }  }


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

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