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


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

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