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

Diff of /lbbs/src/bbs_net.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.38 by sysadm, Tue May 13 02:21:39 2025 UTC Revision 1.61 by sysadm, Sun Oct 5 00:49:56 2025 UTC
# Line 16  Line 16 
16    
17  #include "bbs.h"  #include "bbs.h"
18  #include "common.h"  #include "common.h"
 #include "log.h"  
19  #include "io.h"  #include "io.h"
20  #include "screen.h"  #include "log.h"
21    #include "login.h"
22  #include "menu.h"  #include "menu.h"
23  #include <stdio.h>  #include "screen.h"
 #include <stdarg.h>  
24  #include <errno.h>  #include <errno.h>
 #include <string.h>  
 #include <stdlib.h>  
25  #include <fcntl.h>  #include <fcntl.h>
26    #include <netdb.h>
27    #include <stdarg.h>
28    #include <stdio.h>
29    #include <stdlib.h>
30    #include <string.h>
31  #include <time.h>  #include <time.h>
32  #include <unistd.h>  #include <unistd.h>
33  #include <netdb.h>  #include <arpa/inet.h>
34    #include <iconv.h>
35    #include <libssh/libssh.h>
36    #include <libssh/server.h>
37    #include <libssh/callbacks.h>
38    #include <netinet/in.h>
39    #include <netinet/ip.h>
40  #include <sys/select.h>  #include <sys/select.h>
41  #include <sys/ioctl.h>  #include <sys/ioctl.h>
42  #include <sys/socket.h>  #include <sys/socket.h>
43  #include <sys/epoll.h>  #include <sys/epoll.h>
 #include <netinet/in.h>  
 #include <netinet/ip.h>  
 #include <arpa/inet.h>  
44    
45  #define MENU_CONF_DELIM " \t\r\n"  #define MENU_CONF_DELIM " \t\r\n"
46    
# Line 49  struct _bbsnet_conf Line 54  struct _bbsnet_conf
54          char host2[40];          char host2[40];
55          char ip[40];          char ip[40];
56          in_port_t port;          in_port_t port;
57            char charset[20];
58  } bbsnet_conf[MAXSTATION];  } bbsnet_conf[MAXSTATION];
59    
60  MENU_SET bbsnet_menu;  MENU_SET bbsnet_menu;
# Line 57  int load_bbsnet_conf(const char *file_co Line 63  int load_bbsnet_conf(const char *file_co
63  {  {
64          FILE *fp;          FILE *fp;
65          MENU *p_menu;          MENU *p_menu;
66          MENU_ITEM *p_menuitem;          MENU_ITEM *p_menu_item;
67          char t[256], *t1, *t2, *t3, *t4, *saveptr;          MENU_ITEM_ID menu_item_id;
68          int item_count = 0;          char t[256], *t1, *t2, *t3, *t4, *t5, *saveptr;
69    
70          fp = fopen(file_config, "r");          fp = fopen(file_config, "r");
71          if (fp == NULL)          if (fp == NULL)
# Line 67  int load_bbsnet_conf(const char *file_co Line 73  int load_bbsnet_conf(const char *file_co
73                  return -1;                  return -1;
74          }          }
75    
76          p_menu = bbsnet_menu.p_menu[0] = malloc(sizeof(MENU));          bbsnet_menu.p_menu_pool = calloc(1, sizeof(MENU));
77            if (bbsnet_menu.p_menu_pool == NULL)
78            {
79                    log_error("calloc(p_menu_pool) error\n");
80                    return -3;
81            }
82            bbsnet_menu.menu_count = 1;
83    
84            bbsnet_menu.p_menu_item_pool = calloc(MAXSTATION, sizeof(MENU_ITEM));
85            if (bbsnet_menu.p_menu_item_pool == NULL)
86            {
87                    log_error("calloc(p_menu_item_pool) error\n");
88                    return -3;
89            }
90            bbsnet_menu.menu_item_count = MAXSTATION;
91    
92            p_menu = (MENU *)get_menu_by_id(&bbsnet_menu, 0);
93    
94          strncpy(p_menu->name, "BBSNET", sizeof(p_menu->name) - 1);          strncpy(p_menu->name, "BBSNET", sizeof(p_menu->name) - 1);
95          p_menu->name[sizeof(p_menu->name) - 1] = '\0';          p_menu->name[sizeof(p_menu->name) - 1] = '\0';
96          p_menu->title.show = 0;          p_menu->title.show = 0;
97          p_menu->screen.show = 0;          p_menu->screen_show = 0;
98    
99          while (fgets(t, 255, fp) && item_count < MAXSTATION)          menu_item_id = 0;
100            while (fgets(t, 255, fp) && menu_item_id < MAXSTATION)
101          {          {
102                  t1 = strtok_r(t, MENU_CONF_DELIM, &saveptr);                  t1 = strtok_r(t, MENU_CONF_DELIM, &saveptr);
103                  t2 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);                  t2 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);
104                  t3 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);                  t3 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);
105                  t4 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);                  t4 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);
106                    t5 = strtok_r(NULL, MENU_CONF_DELIM, &saveptr);
107    
108                  if (t1 == NULL || t2 == NULL || t3 == NULL || t4 == NULL || t[0] == '#' || t[0] == '*')                  if (t1 == NULL || t2 == NULL || t3 == NULL || t4 == NULL || t5 == NULL || t[0] == '#' || t[0] == '*')
109                  {                  {
110                          continue;                          continue;
111                  }                  }
112    
113                  strncpy(bbsnet_conf[item_count].host1, t2, sizeof(bbsnet_conf[item_count].host1) - 1);                  strncpy(bbsnet_conf[menu_item_id].host1, t2, sizeof(bbsnet_conf[menu_item_id].host1) - 1);
114                  bbsnet_conf[item_count].host1[sizeof(bbsnet_conf[item_count].host1) - 1] = '\0';                  bbsnet_conf[menu_item_id].host1[sizeof(bbsnet_conf[menu_item_id].host1) - 1] = '\0';
115                  strncpy(bbsnet_conf[item_count].host2, t1, sizeof(bbsnet_conf[item_count].host2) - 1);                  strncpy(bbsnet_conf[menu_item_id].host2, t1, sizeof(bbsnet_conf[menu_item_id].host2) - 1);
116                  bbsnet_conf[item_count].host2[sizeof(bbsnet_conf[item_count].host2) - 1] = '\0';                  bbsnet_conf[menu_item_id].host2[sizeof(bbsnet_conf[menu_item_id].host2) - 1] = '\0';
117                  strncpy(bbsnet_conf[item_count].ip, t3, sizeof(bbsnet_conf[item_count].ip) - 1);                  strncpy(bbsnet_conf[menu_item_id].ip, t3, sizeof(bbsnet_conf[menu_item_id].ip) - 1);
118                  bbsnet_conf[item_count].ip[sizeof(bbsnet_conf[item_count].ip) - 1] = '\0';                  bbsnet_conf[menu_item_id].ip[sizeof(bbsnet_conf[menu_item_id].ip) - 1] = '\0';
119                  bbsnet_conf[item_count].port = (in_port_t)(t4 ? atoi(t4) : 23);                  bbsnet_conf[menu_item_id].port = (in_port_t)(t4 ? atoi(t4) : 23);
120                    strncpy(bbsnet_conf[menu_item_id].charset, t5, sizeof(bbsnet_conf[menu_item_id].charset) - 1);
121                  p_menuitem = p_menu->items[item_count] = malloc(sizeof(MENU_ITEM));                  bbsnet_conf[menu_item_id].charset[sizeof(bbsnet_conf[menu_item_id].charset) - 1] = '\0';
                 p_menuitem->row = 2 + item_count / STATION_PER_LINE;  
                 p_menuitem->col = 5 + item_count % STATION_PER_LINE * 20;  
                 snprintf(p_menuitem->action, sizeof(p_menuitem->action), "%d", item_count);  
                 p_menuitem->submenu = 0;  
                 p_menuitem->priv = 0;  
                 p_menuitem->level = 0;  
                 p_menuitem->display = 0;  
                 p_menuitem->name[0] =  
                         (char)(item_count < MAXSTATION / 2 ? 'A' + item_count : 'a' + item_count);  
                 p_menuitem->name[1] = '\0';  
                 snprintf(p_menuitem->text, sizeof(p_menuitem->text), "%c. %s",  
                                  p_menuitem->name[0], bbsnet_conf[item_count].host1);  
122    
123                  item_count++;                  p_menu_item = get_menu_item_by_id(&bbsnet_menu, menu_item_id);
124          }                  if (p_menu_item == NULL)
125          fclose(fp);                  {
126                            log_error("get_menu_item_by_id(%d) return NULL pointer\n", menu_item_id);
127                            return -1;
128                    }
129    
130          p_menu->item_count = item_count;                  p_menu_item->row = (int16_t)(2 + menu_item_id / STATION_PER_LINE);
131          p_menu->item_cur_pos = 0;                  p_menu_item->col = (int16_t)(5 + menu_item_id % STATION_PER_LINE * 20);
132                    snprintf(p_menu_item->action, sizeof(p_menu_item->action), "%d", (int16_t)menu_item_id);
133                    p_menu_item->submenu = 0;
134                    p_menu_item->priv = 0;
135                    p_menu_item->level = 0;
136                    p_menu_item->name[0] =
137                            (char)(menu_item_id < MAXSTATION / 2 ? 'A' + menu_item_id : 'a' + menu_item_id);
138                    p_menu_item->name[1] = '\0';
139                    snprintf(p_menu_item->text, sizeof(p_menu_item->text), "%c. %s",
140                                     p_menu_item->name[0], bbsnet_conf[menu_item_id].host1);
141    
142                    p_menu->items[p_menu->item_count] = menu_item_id;
143                    p_menu->item_count++;
144                    menu_item_id++;
145            }
146    
147            bbsnet_menu.menu_item_count = (int16_t)menu_item_id;
148            bbsnet_menu.menu_id_path[0] = 0;
149            bbsnet_menu.menu_item_pos[0] = 0;
150            bbsnet_menu.choose_step = 0;
151    
152          bbsnet_menu.menu_count = 1;          fclose(fp);
         bbsnet_menu.menu_select_depth = 0;  
         bbsnet_menu.p_menu_select[0] = bbsnet_menu.p_menu[0];  
153    
154          return 0;          return 0;
155  }  }
156    
157  static void process_bar(int n, int len)  void unload_bbsnet_conf(void)
158    {
159            bbsnet_menu.menu_count = 0;
160            bbsnet_menu.menu_item_count = 0;
161    
162            free(bbsnet_menu.p_menu_pool);
163            bbsnet_menu.p_menu_pool = NULL;
164            free(bbsnet_menu.p_menu_item_pool);
165            bbsnet_menu.p_menu_item_pool = NULL;
166    }
167    
168    void process_bar(int n, int len)
169  {  {
170          char buf[LINE_BUFFER_LEN];          char buf[LINE_BUFFER_LEN];
171          char buf2[LINE_BUFFER_LEN];          char buf2[LINE_BUFFER_LEN];
# Line 149  static void process_bar(int n, int len) Line 193  static void process_bar(int n, int len)
193          iflush();          iflush();
194  }  }
195    
196    int bbsnet_io_buf_conv(iconv_t cd, char *p_buf, int *p_buf_len, int *p_buf_offset, char *p_conv, size_t conv_size, int *p_conv_len)
197    {
198            char *in_buf;
199            char *out_buf;
200            size_t in_bytes;
201            size_t out_bytes;
202            int ret;
203    
204            in_buf = p_buf + *p_buf_offset;
205            in_bytes = (size_t)(*p_buf_len - *p_buf_offset);
206            out_buf = p_conv + *p_conv_len;
207            out_bytes = conv_size - (size_t)(*p_conv_len);
208    
209            while (in_bytes > 0)
210            {
211                    ret = (int)iconv(cd, &in_buf, &in_bytes, &out_buf, &out_bytes);
212                    if (ret == -1)
213                    {
214                            if (errno == EINVAL) // Incomplete
215                            {
216    #ifdef _DEBUG
217                                    log_error("iconv(inbytes=%d, outbytes=%d) error: EINVAL\n", in_bytes, out_bytes);
218    #endif
219                                    *p_buf_len = (int)(p_buf + *p_buf_len - in_buf);
220                                    *p_buf_offset = 0;
221                                    *p_conv_len = (int)(conv_size - out_bytes);
222                                    memmove(p_buf, in_buf, (size_t)(*p_buf_len));
223    
224                                    break;
225                            }
226                            else if (errno == E2BIG)
227                            {
228                                    log_error("iconv(inbytes=%d, outbytes=%d) error: E2BIG\n", in_bytes, out_bytes);
229                                    return -1;
230                            }
231                            else if (errno == EILSEQ)
232                            {
233                                    if (in_bytes > out_bytes || out_bytes <= 0)
234                                    {
235                                            log_error("iconv(inbytes=%d, outbytes=%d) error: EILSEQ and E2BIG\n", in_bytes, out_bytes);
236                                            return -2;
237                                    }
238    
239                                    *out_buf = *in_buf;
240                                    in_buf++;
241                                    out_buf++;
242                                    in_bytes--;
243                                    out_bytes--;
244    
245                                    continue;
246                            }
247                    }
248                    else
249                    {
250                            *p_buf_len = 0;
251                            *p_buf_offset = 0;
252                            *p_conv_len = (int)(conv_size - out_bytes);
253    
254                            break;
255                    }
256            }
257    
258            return 0;
259    }
260    
261  int bbsnet_connect(int n)  int bbsnet_connect(int n)
262  {  {
263          int sock, ret, loop, error;          int sock, ret, loop, error;
# Line 164  int bbsnet_connect(int n) Line 273  int bbsnet_connect(int n)
273          int output_buf_len = 0;          int output_buf_len = 0;
274          int input_buf_offset = 0;          int input_buf_offset = 0;
275          int output_buf_offset = 0;          int output_buf_offset = 0;
276            iconv_t input_cd = NULL;
277            char input_conv[LINE_BUFFER_LEN * 2];
278            char output_conv[LINE_BUFFER_LEN * 2];
279            int input_conv_len = 0;
280            int output_conv_len = 0;
281            int input_conv_offset = 0;
282            int output_conv_offset = 0;
283            iconv_t output_cd = NULL;
284          struct epoll_event ev, events[MAX_EVENTS];          struct epoll_event ev, events[MAX_EVENTS];
285          int nfds, epollfd;          int nfds, epollfd;
286          int stdin_read_wait = 0;          int stdin_read_wait = 0;
# Line 174  int bbsnet_connect(int n) Line 291  int bbsnet_connect(int n)
291          int tos;          int tos;
292          char remote_addr[IP_ADDR_LEN];          char remote_addr[IP_ADDR_LEN];
293          int remote_port;          int remote_port;
294          time_t t_used;          time_t t_used = time(NULL);
295          struct tm *tm_used;          struct tm *tm_used;
296          int ch;          int ch;
297    
298            if (user_online_update("BBS_NET") < 0)
299            {
300                    log_error("user_online_update(BBS_NET) error\n");
301            }
302    
303          clearscr();          clearscr();
304    
305          moveto(0, 0);          moveto(0, 0);
306          prints("\033[1;32mڲ %s (%s) ӣԺ... \033[m\r\n",          prints("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\r\n",
307                     bbsnet_conf[n].host1, bbsnet_conf[n].ip);                     bbsnet_conf[n].host1, bbsnet_conf[n].ip);
308          iflush();          iflush();
309    
# Line 189  int bbsnet_connect(int n) Line 311  int bbsnet_connect(int n)
311    
312          if (p_host == NULL)          if (p_host == NULL)
313          {          {
314                  prints("\033[1;31mʧܣ\033[m\r\n");                  prints("\033[1;31m查找主机名失败!\033[m\r\n");
315                  press_any_key();                  press_any_key();
316                  return -1;                  return -1;
317          }          }
# Line 198  int bbsnet_connect(int n) Line 320  int bbsnet_connect(int n)
320    
321          if (sock < 0)          if (sock < 0)
322          {          {
323                  prints("\033[1;31m޷socket\033[m\r\n");                  prints("\033[1;31m无法创建socket!\033[m\r\n");
324                  press_any_key();                  press_any_key();
325                  return -1;                  return -1;
326          }          }
327    
328          sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
329          sin.sin_addr.s_addr = (hostaddr_server[0] != '\0' ? inet_addr(hostaddr_server) : INADDR_ANY);          sin.sin_addr.s_addr = (BBS_address[0] != '\0' ? inet_addr(BBS_address) : INADDR_ANY);
330          sin.sin_port = 0;          sin.sin_port = 0;
331    
332          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)
# Line 214  int bbsnet_connect(int n) Line 336  int bbsnet_connect(int n)
336                  return -2;                  return -2;
337          }          }
338    
339          bzero(&sin, sizeof(sin));          memset(&sin, 0, sizeof(sin));
340          sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
341          sin.sin_addr = *(struct in_addr *)p_host->h_addr_list[0];          sin.sin_addr = *(struct in_addr *)p_host->h_addr_list[0];
342          sin.sin_port = htons(bbsnet_conf[n].port);          sin.sin_port = htons(bbsnet_conf[n].port);
# Line 223  int bbsnet_connect(int n) Line 345  int bbsnet_connect(int n)
345          remote_addr[sizeof(remote_addr) - 1] = '\0';          remote_addr[sizeof(remote_addr) - 1] = '\0';
346          remote_port = ntohs(sin.sin_port);          remote_port = ntohs(sin.sin_port);
347    
348          prints("\033[1;32mʾǰʹõʱ䣬\033[1;33mCtrl+C\033[1;32mжϡ\033[m\r\n");          prints("\033[1;32m穿梭进度条提示您当前已使用的时间,按\033[1;33mCtrl+C\033[1;32m中断。\033[m\r\n");
349          process_bar(0, MAX_PROCESS_BAR_LEN);          process_bar(0, MAX_PROCESS_BAR_LEN);
350    
351            // Set socket as non-blocking
352            flags_sock = fcntl(sock, F_GETFL, 0);
353            fcntl(sock, F_SETFL, flags_sock | O_NONBLOCK);
354    
355            // Set STDIN/STDOUT as non-blocking
356            flags_stdin = fcntl(STDIN_FILENO, F_GETFL, 0);
357            flags_stdout = fcntl(STDOUT_FILENO, F_GETFL, 0);
358            fcntl(STDIN_FILENO, F_SETFL, flags_stdin | O_NONBLOCK);
359            fcntl(STDOUT_FILENO, F_SETFL, flags_stdout | O_NONBLOCK);
360    
361          epollfd = epoll_create1(0);          epollfd = epoll_create1(0);
362          if (epollfd < 0)          if (epollfd < 0)
363          {          {
# Line 233  int bbsnet_connect(int n) Line 365  int bbsnet_connect(int n)
365                  return -1;                  return -1;
366          }          }
367    
368          ev.events = EPOLLOUT;          ev.events = EPOLLOUT | EPOLLET;
369          ev.data.fd = sock;          ev.data.fd = sock;
370          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &ev) == -1)
371          {          {
372                  log_error("epoll_ctl(socket) error (%d)\n", errno);                  log_error("epoll_ctl(socket) error (%d)\n", errno);
373                  return -1;                  goto cleanup;
374          }          }
375    
376          ev.events = EPOLLIN;          ev.events = EPOLLIN | EPOLLET;
377          ev.data.fd = STDIN_FILENO;          ev.data.fd = STDIN_FILENO;
378          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDIN_FILENO, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDIN_FILENO, &ev) == -1)
379          {          {
380                  log_error("epoll_ctl(STDIN_FILENO) error (%d)\n", errno);                  log_error("epoll_ctl(STDIN_FILENO) error (%d)\n", errno);
381                  return -1;                  goto cleanup;
382          }          }
383    
         // Set socket as non-blocking  
         flags_sock = fcntl(sock, F_GETFL, 0);  
         fcntl(sock, F_SETFL, flags_sock | O_NONBLOCK);  
   
384          while (!SYS_server_exit)          while (!SYS_server_exit)
385          {          {
386                  if ((ret = connect(sock, (struct sockaddr *)&sin, sizeof(sin))) < 0)                  if ((ret = connect(sock, (struct sockaddr *)&sin, sizeof(sin))) < 0)
387                  {                  {
388                          if (errno == EAGAIN || errno == EALREADY || errno == EINPROGRESS)                          if (errno == EAGAIN || errno == EALREADY || errno == EINPROGRESS)
389                          {                          {
                                 log_std("Debug: %d\n", errno);  
390                                  // Use select / epoll to check writability of the socket,                                  // Use select / epoll to check writability of the socket,
391                                  // then use getsockopt to check the status of the socket.                                  // then use getsockopt to check the status of the socket.
392                                  // See man connect(2)                                  // See man connect(2)
# Line 272  int bbsnet_connect(int n) Line 399  int bbsnet_connect(int n)
399                          else                          else
400                          {                          {
401                                  log_error("connect(socket) error (%d)\n", errno);                                  log_error("connect(socket) error (%d)\n", errno);
402                                  prints("\033[1;31mʧܣ\033[m\r\n");  
403                                    prints("\033[1;31m连接失败!\033[m\r\n");
404                                  press_any_key();                                  press_any_key();
405                                  return -1;  
406                                    goto cleanup;
407                          }                          }
408                  }                  }
409          }          }
# Line 288  int bbsnet_connect(int n) Line 417  int bbsnet_connect(int n)
417                          if (errno != EINTR)                          if (errno != EINTR)
418                          {                          {
419                                  log_error("epoll_wait() error (%d)\n", errno);                                  log_error("epoll_wait() error (%d)\n", errno);
420                                  return -1;                                  break;
421                          }                          }
422                  }                  }
423                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
# Line 305  int bbsnet_connect(int n) Line 434  int bbsnet_connect(int n)
434                                          if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) < 0)                                          if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) < 0)
435                                          {                                          {
436                                                  log_error("getsockopt() error (%d) !\n", error);                                                  log_error("getsockopt() error (%d) !\n", error);
437                                                  return -1;                                                  goto cleanup;
438                                          }                                          }
439                                          if (error == 0)                                          if (error == 0)
440                                          {                                          {
# Line 315  int bbsnet_connect(int n) Line 444  int bbsnet_connect(int n)
444                                  else if (events[i].data.fd == STDIN_FILENO)                                  else if (events[i].data.fd == STDIN_FILENO)
445                                  {                                  {
446                                          ch = igetch(0);                                          ch = igetch(0);
447                                          if (ch == Ctrl('C'))                                          if (ch == Ctrl('C') || ch == KEY_ESC)
448                                          {                                          {
449                                                  return 0;                                                  goto cleanup;
450                                          }                                          }
451                                  }                                  }
452                          }                          }
# Line 325  int bbsnet_connect(int n) Line 454  int bbsnet_connect(int n)
454          }          }
455          if (SYS_server_exit)          if (SYS_server_exit)
456          {          {
457                  return 0;                  goto cleanup;
458          }          }
459          if (!sock_connected)          if (!sock_connected)
460          {          {
461                  prints("\033[1;31mӳʱ\033[m\r\n");                  prints("\033[1;31m连接失败!\033[m\r\n");
462                  press_any_key();                  press_any_key();
463                  return -1;  
464                    goto cleanup;
465          }          }
466    
467          tos = IPTOS_LOWDELAY;          tos = IPTOS_LOWDELAY;
# Line 340  int bbsnet_connect(int n) Line 470  int bbsnet_connect(int n)
470                  log_error("setsockopt IP_TOS=%d error (%d)\n", tos, errno);                  log_error("setsockopt IP_TOS=%d error (%d)\n", tos, errno);
471          }          }
472    
473          prints("\033[1;31mӳɹ\033[m\r\n");          prints("\033[1;31m连接成功!\033[m\r\n");
474          iflush();          iflush();
475          log_std("BBSNET connect to %s:%d\n", remote_addr, remote_port);          log_common("BBSNET connect to %s:%d\n", remote_addr, remote_port);
476    
477            input_cd = iconv_open(bbsnet_conf[n].charset, "UTF-8");
478            if (input_cd == (iconv_t)(-1))
479            {
480                    log_error("iconv_open(UTF8->GBK) error: %d\n", errno);
481                    goto cleanup;
482            }
483            output_cd = iconv_open("UTF-8", bbsnet_conf[n].charset);
484            if (input_cd == (iconv_t)(-1))
485            {
486                    log_error("iconv_open(GBK->UTF-8) error: %d\n", errno);
487                    iconv_close(input_cd);
488                    goto cleanup;
489            }
490    
491          ev.events = EPOLLIN | EPOLLOUT | EPOLLET;          ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
492          ev.data.fd = sock;          ev.data.fd = sock;
493          if (epoll_ctl(epollfd, EPOLL_CTL_MOD, sock, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_MOD, sock, &ev) == -1)
494          {          {
495                  log_error("epoll_ctl(socket) error (%d)\n", errno);                  log_error("epoll_ctl(socket) error (%d)\n", errno);
496                  return -1;                  goto cleanup;
497          }          }
498    
499          ev.events = EPOLLOUT;          ev.events = EPOLLOUT | EPOLLET;
500          ev.data.fd = STDOUT_FILENO;          ev.data.fd = STDOUT_FILENO;
501          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDOUT_FILENO, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDOUT_FILENO, &ev) == -1)
502          {          {
503                  log_error("epoll_ctl(STDOUT_FILENO) error (%d)\n", errno);                  log_error("epoll_ctl(STDOUT_FILENO) error (%d)\n", errno);
504                  return -1;                  goto cleanup;
505          }          }
506    
507          // Set STDIN/STDOUT as non-blocking          BBS_last_access_tm = t_used = time(NULL);
         flags_stdin = fcntl(STDIN_FILENO, F_GETFL, 0);  
         flags_stdout = fcntl(STDOUT_FILENO, F_GETFL, 0);  
         fcntl(STDIN_FILENO, F_SETFL, flags_stdin | O_NONBLOCK);  
         fcntl(STDOUT_FILENO, F_SETFL, flags_stdout | O_NONBLOCK);  
   
         BBS_last_access_tm = t_used = time(0);  
508          loop = 1;          loop = 1;
509    
510          while (loop && !SYS_server_exit)          while (loop && !SYS_server_exit)
511          {          {
512                    if (SSH_v2 && ssh_channel_is_closed(SSH_channel))
513                    {
514                            log_error("SSH channel is closed\n");
515                            loop = 0;
516                            break;
517                    }
518    
519                  nfds = epoll_wait(epollfd, events, MAX_EVENTS, 100); // 0.1 second                  nfds = epoll_wait(epollfd, events, MAX_EVENTS, 100); // 0.1 second
520    
521                  if (nfds < 0)                  if (nfds < 0)
# Line 384  int bbsnet_connect(int n) Line 529  int bbsnet_connect(int n)
529                  }                  }
530                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
531                  {                  {
532                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
533                          {                          {
534                                  break;                                  break;
535                          }                          }
                         continue;  
536                  }                  }
537    
538                  for (int i = 0; i < nfds; i++)                  for (int i = 0; i < nfds; i++)
539                  {                  {
540                          if (events[i].data.fd == STDIN_FILENO || stdin_read_wait)                          if (events[i].data.fd == STDIN_FILENO)
541                          {                          {
542                                  stdin_read_wait = 1;                                  stdin_read_wait = 1;
543                                  while (input_buf_len < sizeof(input_buf) && !SYS_server_exit)                          }
544    
545                            if (events[i].data.fd == sock)
546                            {
547                                    if (events[i].events & EPOLLIN)
548                                  {                                  {
549                                          ret = (int)read(STDIN_FILENO, input_buf + input_buf_len, sizeof(input_buf) - (size_t)input_buf_len);                                          sock_read_wait = 1;
550                                          if (ret < 0)                                  }
551                                    if (events[i].events & EPOLLOUT)
552                                    {
553                                            sock_write_wait = 1;
554                                    }
555                            }
556    
557                            if (events[i].data.fd == STDOUT_FILENO)
558                            {
559                                    stdout_write_wait = 1;
560                            }
561                    }
562    
563                    if (stdin_read_wait)
564                    {
565                            while (input_buf_len < sizeof(input_buf) && !SYS_server_exit)
566                            {
567                                    if (SSH_v2)
568                                    {
569                                            ret = ssh_channel_read_nonblocking(SSH_channel, input_buf + input_buf_len, sizeof(input_buf) - (uint32_t)input_buf_len, 0);
570                                            if (ret == SSH_ERROR)
571                                          {                                          {
572                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));
573                                                  {                                                  loop = 0;
574                                                          stdin_read_wait = 0;                                                  break;
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("read(STDIN) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
575                                          }                                          }
576                                          else if (ret == 0) // broken pipe                                          else if (ret == SSH_EOF)
577                                          {                                          {
                                                 log_std("read(STDIN) EOF\n");  
578                                                  stdin_read_wait = 0;                                                  stdin_read_wait = 0;
579                                                  loop = 0;                                                  loop = 0;
580                                                  break;                                                  break;
581                                          }                                          }
582                                          else                                          else if (ret == 0)
583                                            {
584                                                    stdin_read_wait = 0;
585                                                    break; // Check whether channel is still open
586                                            }
587                                    }
588                                    else
589                                    {
590                                            ret = (int)read(STDIN_FILENO, input_buf + input_buf_len, sizeof(input_buf) - (size_t)input_buf_len);
591                                    }
592                                    if (ret < 0)
593                                    {
594                                            if (errno == EAGAIN || errno == EWOULDBLOCK)
595                                            {
596                                                    stdin_read_wait = 0;
597                                                    break;
598                                            }
599                                            else if (errno == EINTR)
600                                          {                                          {
                                                 input_buf_len += ret;  
                                                 BBS_last_access_tm = time(0);  
601                                                  continue;                                                  continue;
602                                          }                                          }
603                                            else
604                                            {
605                                                    log_error("read(STDIN) error (%d)\n", errno);
606                                                    loop = 0;
607                                                    break;
608                                            }
609                                    }
610                                    else if (ret == 0) // broken pipe
611                                    {
612    #ifdef _DEBUG
613                                            log_error("read(STDIN) EOF\n");
614    #endif
615                                            stdin_read_wait = 0;
616                                            loop = 0;
617                                            break;
618                                    }
619                                    else
620                                    {
621                                            input_buf_len += ret;
622                                            BBS_last_access_tm = time(NULL);
623    
624                                            // Refresh current action while user input
625                                            if (user_online_update("BBS_NET") < 0)
626                                            {
627                                                    log_error("user_online_update(BBS_NET) error\n");
628                                            }
629    
630                                            continue;
631                                    }
632                            }
633                    }
634    
635                    if (sock_write_wait)
636                    {
637                            if (input_buf_offset < input_buf_len)
638                            {
639                                    ret = bbsnet_io_buf_conv(input_cd, input_buf, &input_buf_len, &input_buf_offset, input_conv, sizeof(input_conv), &input_conv_len);
640                                    if (ret < 0)
641                                    {
642                                            log_error("bbsnet_io_buf_conv(input, %d, %d, %d) error\n", input_buf_len, input_buf_offset, input_conv_len);
643                                  }                                  }
644                          }                          }
645    
646                          if (events[i].data.fd == sock || sock_write_wait) // EPOLLOUT                          while (input_conv_offset < input_conv_len && !SYS_server_exit)
647                          {                          {
648                                  sock_write_wait = 1;                                  ret = (int)write(sock, input_conv + input_conv_offset, (size_t)(input_conv_len - input_conv_offset));
649                                  while (input_buf_offset < input_buf_len && !SYS_server_exit)                                  if (ret < 0)
650                                  {                                  {
651                                          ret = (int)write(sock, input_buf + input_buf_offset, (size_t)(input_buf_len - input_buf_offset));                                          if (errno == EAGAIN || errno == EWOULDBLOCK)
652                                          if (ret < 0)                                          {
653                                                    sock_write_wait = 0;
654                                                    break;
655                                            }
656                                            else if (errno == EINTR)
657                                          {                                          {
658                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  continue;
                                                 {  
                                                         sock_write_wait = 0;  
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("write(socket) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
659                                          }                                          }
660                                          else if (ret == 0) // broken pipe                                          else
661                                          {                                          {
662                                                  log_std("write(socket) EOF\n");                                                  log_error("write(socket) error (%d)\n", errno);
                                                 sock_write_wait = 0;  
663                                                  loop = 0;                                                  loop = 0;
664                                                  break;                                                  break;
665                                          }                                          }
666                                          else                                  }
667                                    else if (ret == 0) // broken pipe
668                                    {
669    #ifdef _DEBUG
670                                            log_error("write(socket) EOF\n");
671    #endif
672                                            sock_write_wait = 0;
673                                            loop = 0;
674                                            break;
675                                    }
676                                    else
677                                    {
678                                            input_conv_offset += ret;
679                                            if (input_conv_offset >= input_conv_len) // Output buffer complete
680                                          {                                          {
681                                                  input_buf_offset += ret;                                                  input_conv_offset = 0;
682                                                  if (input_buf_offset >= input_buf_len) // Output buffer complete                                                  input_conv_len = 0;
683                                                  {                                                  break;
                                                         input_buf_offset = 0;  
                                                         input_buf_len = 0;  
                                                         break;  
                                                 }  
                                                 continue;  
684                                          }                                          }
685                                            continue;
686                                  }                                  }
687                          }                          }
688                    }
689    
690                          if (events[i].data.fd == sock || sock_read_wait) // EPOLLIN                  if (sock_read_wait)
691                    {
692                            while (output_buf_len < sizeof(output_buf) && !SYS_server_exit)
693                          {                          {
694                                  sock_read_wait = 1;                                  ret = (int)read(sock, output_buf + output_buf_len, sizeof(output_buf) - (size_t)output_buf_len);
695                                  while (output_buf_len < sizeof(output_buf) && !SYS_server_exit)                                  if (ret < 0)
696                                  {                                  {
697                                          ret = (int)read(sock, output_buf + output_buf_len, sizeof(output_buf) - (size_t)output_buf_len);                                          if (errno == EAGAIN || errno == EWOULDBLOCK)
                                         if (ret < 0)  
698                                          {                                          {
                                                 if (errno == EAGAIN || errno == EWOULDBLOCK)  
                                                 {  
                                                         sock_read_wait = 0;  
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("read(socket) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
                                         }  
                                         else if (ret == 0) // broken pipe  
                                         {  
                                                 log_std("read(socket) EOF\n");  
699                                                  sock_read_wait = 0;                                                  sock_read_wait = 0;
                                                 loop = 0;  
700                                                  break;                                                  break;
701                                          }                                          }
702                                          else                                          else if (errno == EINTR)
703                                          {                                          {
                                                 output_buf_len += ret;  
704                                                  continue;                                                  continue;
705                                          }                                          }
706                                            else
707                                            {
708                                                    log_error("read(socket) error (%d)\n", errno);
709                                                    loop = 0;
710                                                    break;
711                                            }
712                                    }
713                                    else if (ret == 0) // broken pipe
714                                    {
715    #ifdef _DEBUG
716                                            log_error("read(socket) EOF\n");
717    #endif
718                                            sock_read_wait = 0;
719                                            loop = 0;
720                                            break;
721                                    }
722                                    else
723                                    {
724                                            output_buf_len += ret;
725                                            continue;
726                                    }
727                            }
728                    }
729    
730                    if (stdout_write_wait)
731                    {
732                            if (output_buf_offset < output_buf_len)
733                            {
734                                    ret = bbsnet_io_buf_conv(output_cd, output_buf, &output_buf_len, &output_buf_offset, output_conv, sizeof(output_conv), &output_conv_len);
735                                    if (ret < 0)
736                                    {
737                                            log_error("bbsnet_io_buf_conv(output, %d, %d, %d) error\n", output_buf_len, output_buf_offset, output_conv_len);
738                                  }                                  }
739                          }                          }
740    
741                          if (events[i].data.fd == STDOUT_FILENO || stdout_write_wait)                          while (output_conv_offset < output_conv_len && !SYS_server_exit)
742                          {                          {
743                                  stdout_write_wait = 1;                                  if (SSH_v2)
                                 while (output_buf_offset < output_buf_len && !SYS_server_exit)  
744                                  {                                  {
745                                          ret = (int)write(STDOUT_FILENO, output_buf + output_buf_offset, (size_t)(output_buf_len - output_buf_offset));                                          ret = ssh_channel_write(SSH_channel, output_conv + output_conv_offset, (uint32_t)(output_conv_len - output_conv_offset));
746                                          if (ret < 0)                                          if (ret == SSH_ERROR)
747                                          {                                          {
748                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));
749                                                  {                                                  loop = 0;
750                                                          stdout_write_wait = 0;                                                  break;
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("write(STDOUT) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
751                                          }                                          }
752                                          else if (ret == 0) // broken pipe                                  }
753                                    else
754                                    {
755                                            ret = (int)write(STDOUT_FILENO, output_conv + output_conv_offset, (size_t)(output_conv_len - output_conv_offset));
756                                    }
757                                    if (ret < 0)
758                                    {
759                                            if (errno == EAGAIN || errno == EWOULDBLOCK)
760                                          {                                          {
                                                 log_std("write(STDOUT) EOF\n");  
761                                                  stdout_write_wait = 0;                                                  stdout_write_wait = 0;
                                                 loop = 0;  
762                                                  break;                                                  break;
763                                          }                                          }
764                                          else                                          else if (errno == EINTR)
765                                          {                                          {
                                                 output_buf_offset += ret;  
                                                 if (output_buf_offset >= output_buf_len) // Output buffer complete  
                                                 {  
                                                         output_buf_offset = 0;  
                                                         output_buf_len = 0;  
                                                         break;  
                                                 }  
766                                                  continue;                                                  continue;
767                                          }                                          }
768                                            else
769                                            {
770                                                    log_error("write(STDOUT) error (%d)\n", errno);
771                                                    loop = 0;
772                                                    break;
773                                            }
774                                    }
775                                    else if (ret == 0) // broken pipe
776                                    {
777    #ifdef _DEBUG
778                                            log_error("write(STDOUT) EOF\n");
779    #endif
780                                            stdout_write_wait = 0;
781                                            loop = 0;
782                                            break;
783                                    }
784                                    else
785                                    {
786                                            output_conv_offset += ret;
787                                            if (output_conv_offset >= output_conv_len) // Output buffer complete
788                                            {
789                                                    output_conv_offset = 0;
790                                                    output_conv_len = 0;
791                                                    break;
792                                            }
793                                            continue;
794                                  }                                  }
795                          }                          }
796                  }                  }
797          }          }
798    
799            iconv_close(input_cd);
800            iconv_close(output_cd);
801    
802    cleanup:
803            if (close(epollfd) < 0)
804            {
805                    log_error("close(epoll) error (%d)\n");
806            }
807    
808          // Restore STDIN/STDOUT flags          // Restore STDIN/STDOUT flags
809          fcntl(STDIN_FILENO, F_SETFL, flags_stdin);          fcntl(STDIN_FILENO, F_SETFL, flags_stdin);
810          fcntl(STDOUT_FILENO, F_SETFL, flags_stdout);          fcntl(STDOUT_FILENO, F_SETFL, flags_stdout);
# Line 576  int bbsnet_connect(int n) Line 817  int bbsnet_connect(int n)
817                  log_error("Close socket failed\n");                  log_error("Close socket failed\n");
818          }          }
819    
820          t_used = time(0) - t_used;          t_used = time(NULL) - t_used;
821          tm_used = gmtime(&t_used);          tm_used = gmtime(&t_used);
822    
823          log_std("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n",          log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n",
824                          tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min,                             tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min,
825                          tm_used->tm_sec);                             tm_used->tm_sec);
826    
827          return 0;          return 0;
828  }  }
# Line 604  bbsnet_refresh() Line 845  bbsnet_refresh()
845          moveto(22, 0);          moveto(22, 0);
846          prints(" ----------------------------------------------------------------------------- ");          prints(" ----------------------------------------------------------------------------- ");
847          moveto(23, 0);          moveto(23, 0);
848          prints(" [\x1b[1;32mCtrl+C\x1b[m]˳");          prints(" [\x1b[1;32mCtrl+C\x1b[m]退出");
849    
850          iflush();          iflush();
851    
852          return 0;          return 0;
853  }  }
854    
855  int bbsnet_selchange(int new_pos)  int bbsnet_selchange()
856  {  {
857            int i = bbsnet_menu.menu_item_pos[0];
858    
859          moveto(20, 0);          moveto(20, 0);
860          clrtoeol();          clrtoeol();
861          prints("|\x1b[1mλ:\x1b[1;33m%-18s\x1b[m  վ:\x1b[1;33m%s\x1b[m",          prints("|\x1b[1m单位:\x1b[1;33m%-18s\x1b[m  站名:\x1b[1;33m%s\x1b[m",
862                     bbsnet_conf[new_pos].host2, bbsnet_conf[new_pos].host1);                     bbsnet_conf[i].host2, bbsnet_conf[i].host1);
863          moveto(20, 79);          moveto(20, 79);
864          prints("|");          prints("|");
865          moveto(21, 0);          moveto(21, 0);
866          clrtoeol();          clrtoeol();
867          prints("|\x1b[1m:\x1b[1;33m%-20s", bbsnet_conf[new_pos].ip);          prints("|\x1b[1m连往:\x1b[1;33m%-20s", bbsnet_conf[i].ip);
868          if (bbsnet_conf[new_pos].port != 23)          if (bbsnet_conf[i].port != 23)
869          {          {
870                  prints("  %d", bbsnet_conf[new_pos].port);                  prints("  %d", bbsnet_conf[i].port);
871          }          }
872          prints("\x1b[m");          prints("\x1b[m");
873          moveto(21, 79);          moveto(21, 79);
# Line 636  int bbsnet_selchange(int new_pos) Line 879  int bbsnet_selchange(int new_pos)
879    
880  int bbs_net()  int bbs_net()
881  {  {
882          int ch, pos, i;          int ch, i;
883    
884          load_bbsnet_conf(CONF_BBSNET);          load_bbsnet_conf(CONF_BBSNET);
885    
886          BBS_last_access_tm = time(0);          BBS_last_access_tm = time(NULL);
887    
888          clearscr();          clearscr();
889          bbsnet_refresh();          bbsnet_refresh();
890          pos = bbsnet_menu.p_menu[0]->item_cur_pos;          display_menu(&bbsnet_menu);
891          display_menu(get_menu(&bbsnet_menu, "BBSNET"));          bbsnet_selchange();
         bbsnet_selchange(pos);  
892    
893          while (!SYS_server_exit)          while (!SYS_server_exit)
894          {          {
895                  ch = igetch(0);                  ch = igetch(100);
896    
897                  switch (ch)                  switch (ch)
898                  {                  {
899                  case KEY_NULL:  // broken pipe                  case KEY_NULL: // broken pipe
900                    case KEY_ESC:
901                  case Ctrl('C'): // user cancel                  case Ctrl('C'): // user cancel
902                          return 0;                          goto cleanup;
903                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
904                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
905                          {                          {
906                                  return 0;                                  goto cleanup;
907                          }                          }
908                          continue;                          continue;
909                  case CR:                  case CR:
910                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          igetch_reset();
911                          bbsnet_connect(pos);                          bbsnet_connect(bbsnet_menu.menu_item_pos[0]);
912                          bbsnet_refresh();                          bbsnet_refresh();
913                          display_current_menu(&bbsnet_menu);                          display_menu(&bbsnet_menu);
914                          bbsnet_selchange(pos);                          bbsnet_selchange();
915                          break;                          break;
916                  case KEY_UP:                  case KEY_UP:
917                          for (i = 0; i < STATION_PER_LINE; i++)                          for (i = 0; i < STATION_PER_LINE; i++)
918                          {                          {
919                                  menu_control(&bbsnet_menu, KEY_UP);                                  menu_control(&bbsnet_menu, KEY_UP);
920                          }                          }
921                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          bbsnet_selchange();
                         bbsnet_selchange(pos);  
922                          break;                          break;
923                  case KEY_DOWN:                  case KEY_DOWN:
924                          for (i = 0; i < STATION_PER_LINE; i++)                          for (i = 0; i < STATION_PER_LINE; i++)
925                          {                          {
926                                  menu_control(&bbsnet_menu, KEY_DOWN);                                  menu_control(&bbsnet_menu, KEY_DOWN);
927                          }                          }
928                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          bbsnet_selchange();
                         bbsnet_selchange(pos);  
929                          break;                          break;
930                  case KEY_LEFT:                  case KEY_LEFT:
931                          menu_control(&bbsnet_menu, KEY_UP);                          menu_control(&bbsnet_menu, KEY_UP);
932                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          bbsnet_selchange();
                         bbsnet_selchange(pos);  
933                          break;                          break;
934                  case KEY_RIGHT:                  case KEY_RIGHT:
935                          menu_control(&bbsnet_menu, KEY_DOWN);                          menu_control(&bbsnet_menu, KEY_DOWN);
936                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          bbsnet_selchange();
937                          bbsnet_selchange(pos);                          break;
938                    case KEY_HOME:
939                    case KEY_PGUP:
940                            menu_control(&bbsnet_menu, KEY_PGUP);
941                            bbsnet_selchange();
942                            break;
943                    case KEY_END:
944                    case KEY_PGDN:
945                            menu_control(&bbsnet_menu, KEY_PGDN);
946                            bbsnet_selchange();
947                          break;                          break;
948                  default:                  default:
949                          menu_control(&bbsnet_menu, ch);                          menu_control(&bbsnet_menu, ch);
950                          pos = bbsnet_menu.p_menu[0]->item_cur_pos;                          bbsnet_selchange();
                         bbsnet_selchange(pos);  
951                          break;                          break;
952                  }                  }
953                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
954          }          }
955    
956    cleanup:
957            unload_bbsnet_conf();
958    
959          return 0;          return 0;
960  }  }


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

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