/[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.3 by sysadm, Tue Oct 19 15:22:01 2004 UTC Revision 1.18 by sysadm, Sat Mar 19 13:34:20 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 17  Line 17 
17    
18  #include "bbs.h"  #include "bbs.h"
19  #include "common.h"  #include "common.h"
20    #include "io.h"
21    #include "menu.h"
22    #include <time.h>
23    #include <fcntl.h>
24    #include <unistd.h>
25    
26  //BBS enviroment  int
27  char BBS_name[50];  bbs_main ()
28  int BBS_max_client = 256;  {
29      char temp[256];
30      int ret;
31    
32      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)
42        return -1;
43      clearscr ();
44    
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      //Logout
54      bbs_exit ();
55    
56      return 0;
57    }
58    
59    int
60    bbs_info ()
61    {
62      prints ("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
63              BBS_name, BBS_server, app_version);
64    
65      iflush ();
66    
67      return 0;
68    }
69    
70  int  int
71  bbs_main()  bbs_exit ()
72  {  {
73          bbs_welcome();    char temp[256];
74            
75          return 0;    strcpy (temp, app_home_dir);
76      strcat (temp, "data/goodbye.txt");
77      display_file_ex (temp, 1, 0);
78    
79      sleep (1);
80    
81      return 0;
82    }
83    
84    int
85    bbs_center ()
86    {
87      int ch, result;
88      char action[MAX_MENUACTION_LENGTH];
89      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;
145  }  }


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

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