/[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.14 by sysadm, Mon Apr 28 03:30:59 2025 UTC Revision 1.19 by sysadm, Mon May 5 05:43:36 2025 UTC
# Line 17  Line 17 
17    
18  #include "bbs.h"  #include "bbs.h"
19  #include "common.h"  #include "common.h"
20    #include "log.h"
21  #include "io.h"  #include "io.h"
22    #include "screen.h"
23  #include "menu.h"  #include "menu.h"
24  #include "tcplib.h"  #include "tcplib.h"
25  #include <stdio.h>  #include <stdio.h>
# Line 50  int load_bbsnet_conf(const char *file_co Line 52  int load_bbsnet_conf(const char *file_co
52          FILE *fp;          FILE *fp;
53          MENU *p_menu;          MENU *p_menu;
54          MENU_ITEM *p_menuitem;          MENU_ITEM *p_menuitem;
55          char t[256], *t1, *t2, *t3, *t4;          char t[256], *t1, *t2, *t3, *t4, *saveptr;
56          int item_count = 0;          int item_count = 0;
57    
58          fp = fopen(file_config, "r");          fp = fopen(file_config, "r");
# Line 64  int load_bbsnet_conf(const char *file_co Line 66  int load_bbsnet_conf(const char *file_co
66    
67          while (fgets(t, 255, fp) && item_count < MAXSTATION)          while (fgets(t, 255, fp) && item_count < MAXSTATION)
68          {          {
69                  t1 = strtok(t, " \t");                  if (t[0] == '#' || t[0] == '*')
70                  t2 = strtok(NULL, " \t\n");                  {
71                  t3 = strtok(NULL, " \t\n");                          continue;
72                  t4 = strtok(NULL, " \t\n");                  }
73    
74                    t1 = strtok_r(t, " \t", &saveptr);
75                    t2 = strtok_r(NULL, " \t\n", &saveptr);
76                    t3 = strtok_r(NULL, " \t\n", &saveptr);
77                    t4 = strtok_r(NULL, " \t\n", &saveptr);
78    
79                  if (t1[0] == '#' || t1[0] == '*' || t1 == NULL || t2 == NULL || t3 == NULL)                  if (t1 == NULL || t2 == NULL || t3 == NULL)
80                    {
81                          continue;                          continue;
82                  strncpy(bbsnet_conf[item_count].host1, t2, 18);                  }
83                  bbsnet_conf[item_count].host1[18] = 0;  
84                  strncpy(bbsnet_conf[item_count].host2, t1, 36);                  strncpy(bbsnet_conf[item_count].host1, t2, sizeof(bbsnet_conf[item_count].host1));
85                  bbsnet_conf[item_count].host2[36] = 0;                  strncpy(bbsnet_conf[item_count].host2, t1, sizeof(bbsnet_conf[item_count].host2));
86                  strncpy(bbsnet_conf[item_count].ip, t3, 36);                  strncpy(bbsnet_conf[item_count].ip, t3, sizeof(bbsnet_conf[item_count].ip));
                 bbsnet_conf[item_count].ip[36] = 0;  
87                  bbsnet_conf[item_count].port = t4 ? atoi(t4) : 23;                  bbsnet_conf[item_count].port = t4 ? atoi(t4) : 23;
88    
89                  p_menuitem = p_menu->items[item_count] = malloc(sizeof(MENU_ITEM));                  p_menuitem = p_menu->items[item_count] = malloc(sizeof(MENU_ITEM));
# Line 90  int load_bbsnet_conf(const char *file_co Line 97  int load_bbsnet_conf(const char *file_co
97                  p_menuitem->name[0] =                  p_menuitem->name[0] =
98                          (item_count < MAXSTATION / 2 ? 'A' + item_count : 'a' + item_count);                          (item_count < MAXSTATION / 2 ? 'A' + item_count : 'a' + item_count);
99                  p_menuitem->name[1] = '\0';                  p_menuitem->name[1] = '\0';
100                  sprintf(p_menuitem->text, "%c. %s",                  snprintf(p_menuitem->text, sizeof(p_menuitem->text), "%c. %s",
101                                  p_menuitem->name[0], bbsnet_conf[item_count].host1);                                   p_menuitem->name[0], t2);
102    
103                  item_count++;                  item_count++;
104          }          }
# Line 117  process_bar(int n, int len) Line 124  process_bar(int n, int len)
124          char *ptr3;          char *ptr3;
125    
126          moveto(4, 0);          moveto(4, 0);
127          prints("©°©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©´\r\n");          prints("©°©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©´\r\n");
128          sprintf(buf2, "            %3d%%              ", n * 100 / len);          sprintf(buf2, "            %3d%%              ", n * 100 / len);
129          ptr = buf;          ptr = buf;
130          ptr2 = buf2;          ptr2 = buf2;
# Line 133  process_bar(int n, int len) Line 140  process_bar(int n, int len)
140                  *ptr++ = *ptr2++;                  *ptr++ = *ptr2++;
141          *ptr++ = '\0';          *ptr++ = '\0';
142          prints("©¦\033[46m%s\033[m©¦\r\n", buf);          prints("©¦\033[46m%s\033[m©¦\r\n", buf);
143          prints("©¸©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¼\r\n");          prints("©¸©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¼\r\n");
144          iflush();          iflush();
145  }  }
146    
147  int bbsnet_connect(int n)  int bbsnet_connect(int n)
148  {  {
149          int sock, ch, result, len, loop;          int sock, result, len, loop;
150          struct sockaddr_in sin;          struct sockaddr_in sin;
151          char buf[256];          char buf[256];
152          fd_set inputs, testfds;          fd_set inputs, testfds;
153          struct timeval timeout;          struct timeval timeout;
154          struct hostent *pHost = NULL;          struct hostent *pHost = NULL;
155          int rc, rv, tos = 020, i;          int rv, tos = 020, i;
156          char remote_addr[256];          char remote_addr[256];
157          int remote_port;          int remote_port;
158          time_t t_used;          time_t t_used;
# Line 310  bbsnet_refresh() Line 317  bbsnet_refresh()
317    
318          clearscr();          clearscr();
319          moveto(1, 0);          moveto(1, 0);
320          prints("¨q¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨r");          prints("¨q¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨r");
321          for (i = 2; i < 19; i++)          for (i = 2; i < 19; i++)
322          {          {
323                  moveto(i, 0);                  moveto(i, 0);
# Line 319  bbsnet_refresh() Line 326  bbsnet_refresh()
326                  prints("¨U");                  prints("¨U");
327          }          }
328          moveto(19, 0);          moveto(19, 0);
329          prints("¨U¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨U");          prints("¨U¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨U");
330          moveto(22, 0);          moveto(22, 0);
331          prints("¨t¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨s");          prints("¨t¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨s");
332          moveto(23, 0);          moveto(23, 0);
333          prints(" [\x1b[1;32mCtrl+C\x1b[m]Í˳ö");          prints(" [\x1b[1;32mCtrl+C\x1b[m]Í˳ö");
334    
# Line 354  int bbsnet_selchange(int new_pos) Line 361  int bbsnet_selchange(int new_pos)
361  int bbs_net()  int bbs_net()
362  {  {
363          int ch, pos, i;          int ch, pos, i;
         char file_config[256];  
   
         strcpy(file_config, app_home_dir);  
         strcat(file_config, "conf/bbsnet.conf");  
364    
365          load_bbsnet_conf(file_config);          load_bbsnet_conf(CONF_BBSNET);
366    
367          BBS_last_access_tm = time(0);          BBS_last_access_tm = time(0);
368    
# Line 371  int bbs_net() Line 374  int bbs_net()
374    
375          while (1)          while (1)
376          {          {
377                  ch = igetch();                  ch = igetch(0);
378                  switch (ch)                  switch (ch)
379                  {                  {
380                  case KEY_NULL:                  case KEY_NULL:


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

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