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