/[LeafOK_CVS]/lbbs/src/bbs_main.c
ViewVC logotype

Contents of /lbbs/src/bbs_main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (show annotations)
Sat May 7 12:08:28 2005 UTC (20 years, 10 months ago) by sysadm
Branch: MAIN
Changes since 1.28: +1 -1 lines
Content type: text/x-csrc
*** empty log message ***

1 /***************************************************************************
2 bbs_main.c - description
3 -------------------
4 begin : Mon Oct 18 2004
5 copyright : (C) 2004 by Leaflet
6 email : leaflet@leafok.com
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "bbs.h"
19 #include "common.h"
20 #include "io.h"
21 #include "menu.h"
22 #include "bbs_cmd.h"
23 #include <time.h>
24 #include <string.h>
25
26 int
27 bbs_main ()
28 {
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 log_std ("User \"%s\"(%ld) login from %s:%d\n",
44 BBS_username, BBS_priv.uid, hostaddr_client, port_client);
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 log_std ("User logout\n");
58
59 return 0;
60 }
61
62 int
63 bbs_info ()
64 {
65 prints ("��ӭ���� \033[1;33m%s \033[32m[%s] \033[37m( %s )\r\n",
66 BBS_name, BBS_server, app_version);
67
68 iflush ();
69
70 return 0;
71 }
72
73 int
74 bbs_exit ()
75 {
76 char temp[256];
77
78 strcpy (temp, app_home_dir);
79 strcat (temp, "data/goodbye.txt");
80 display_file_ex (temp, 1, 0);
81
82 sleep (1);
83
84 return 0;
85 }
86
87 int
88 bbs_center ()
89 {
90 int ch, result, redraw;
91 char temp[256];
92 time_t t_last_action;
93
94 BBS_last_access_tm = t_last_action = time (0);
95
96 clearscr ();
97
98 show_top ("");
99 show_active_board ();
100 show_bottom ("");
101 display_menu (get_menu (&bbs_menu, "TOPMENU"));
102
103 while (!SYS_exit)
104 {
105 ch = igetch ();
106
107 if (time (0) - t_last_action >= 10)
108 {
109 t_last_action = time (0);
110 show_active_board ();
111 show_bottom ("");
112 }
113
114 switch (ch)
115 {
116 case KEY_NULL:
117 return 0;
118 case KEY_TIMEOUT:
119 if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME)
120 {
121 return -1;
122 }
123 continue;
124 default:
125 redraw = 1;
126 switch (menu_control (&bbs_menu, ch))
127 {
128 case EXITBBS:
129 return 0;
130 case REDRAW:
131 break;
132 case NOREDRAW:
133 case UNKNOWN_CMD:
134 default:
135 redraw = 0;
136 break;
137 }
138 if (redraw)
139 {
140 clearscr ();
141 show_top ("");
142 show_active_board ();
143 show_bottom ("");
144 display_current_menu (&bbs_menu);
145 }
146 }
147 BBS_last_access_tm = time (0);
148 }
149
150 return 0;
151 }

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