/[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.8 by sysadm, Tue Mar 22 08:59:31 2005 UTC Revision 1.9 by sysadm, Tue Mar 22 12:12:33 2005 UTC
# Line 119  process_bar (int n, int len) Line 119  process_bar (int n, int len)
119    char *ptr3;    char *ptr3;
120    
121    moveto (4, 0);    moveto (4, 0);
122    prints ("┌───────────────┐\n");    prints ("┌───────────────┐\r\n");
123    sprintf (buf2, "            %3d%%              ", n * 100 / len);    sprintf (buf2, "            %3d%%              ", n * 100 / len);
124    ptr = buf;    ptr = buf;
125    ptr2 = buf2;    ptr2 = buf2;
# Line 134  process_bar (int n, int len) Line 134  process_bar (int n, int len)
134    while (*ptr2 != '\0')    while (*ptr2 != '\0')
135      *ptr++ = *ptr2++;      *ptr++ = *ptr2++;
136    *ptr++ = '\0';    *ptr++ = '\0';
137    prints ("│\033[46m%s\033[m│\n", buf);    prints ("│\033[46m%s\033[m│\r\n", buf);
138    prints ("└───────────────┘\n");    prints ("└───────────────┘\r\n");
139      iflush ();
140  }  }
141    
142  int  int
# Line 153  bbsnet_connect (int n) Line 154  bbsnet_connect (int n)
154    time_t t_used;    time_t t_used;
155    struct tm * tm_used;    struct tm * tm_used;
156    
157    prints ("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\n",    clearscr ();
158            bbsnet_conf[n].host1, bbsnet_conf[n].ip);  
159    prints ("\033[1;32m如果在 %d 秒内无法连上,穿梭程序将放弃连接。\033[m\n",    moveto (0, 0);
160            TIME_OUT);    prints ("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\r\n",
161        bbsnet_conf[n].host1, bbsnet_conf[n].ip);
162      prints ("\033[1;32m如果在 %d 秒内无法连上,穿梭程序将放弃连接。\033[m\r\n",
163        TIME_OUT);
164      iflush ();
165    
166    pHost = gethostbyname (bbsnet_conf[n].ip);    pHost = gethostbyname (bbsnet_conf[n].ip);
167    
168    if (pHost == NULL)    if (pHost == NULL)
169      {      {
170        prints ("\033[1;31m查找主机名失败!\033[m\n");        prints ("\033[1;31m查找主机名失败!\033[m\r\n");
171        press_any_key ();        press_any_key ();
172        return -1;        return -1;
173      }      }
# Line 171  bbsnet_connect (int n) Line 176  bbsnet_connect (int n)
176    
177    if (sock < 0)    if (sock < 0)
178      {      {
179        prints ("\033[1;31m无法创建socket!\033[m\n");        prints ("\033[1;31m无法创建socket!\033[m\r\n");
180        press_any_key ();        press_any_key ();
181        return -1;        return -1;
182      }      }
# Line 196  bbsnet_connect (int n) Line 201  bbsnet_connect (int n)
201    strcpy (remote_addr, inet_ntoa (sin.sin_addr));    strcpy (remote_addr, inet_ntoa (sin.sin_addr));
202    remote_port = ntohs (sin.sin_port);    remote_port = ntohs (sin.sin_port);
203    
204    prints ("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\n");    prints ("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\r\n");
205    process_bar (0, MAX_PROCESS_BAR_LEN);    process_bar (0, MAX_PROCESS_BAR_LEN);
206    for (i = 0; i < MAX_PROCESS_BAR_LEN; i++)    for (i = 0; i < MAX_PROCESS_BAR_LEN; i++)
207      {      {
# Line 217  bbsnet_connect (int n) Line 222  bbsnet_connect (int n)
222          break;          break;
223        else        else
224          {          {
225            prints ("\033[1;31m连接失败!\033[m\n");            prints ("\033[1;31m连接失败!\033[m\r\n");
226            press_any_key ();            press_any_key ();
227            return -1;            return -1;
228          }          }
229      }      }
230    if (i == MAX_PROCESS_BAR_LEN)    if (i == MAX_PROCESS_BAR_LEN)
231      {      {
232        prints ("\033[1;31m连接超时!\033[m\n");        prints ("\033[1;31m连接超时!\033[m\r\n");
233        press_any_key ();        press_any_key ();
234        return -1;        return -1;
235      }      }
236    setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (int));    setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (int));
237    
238    prints ("\033[1;31m连接成功!\033[m\n");    prints ("\033[1;31m连接成功!\033[m\r\n");
239    log_std ("BBSNET connect to %s:%d\n",    log_std ("BBSNET connect to %s:%d\n",
240      remote_addr, remote_port);      remote_addr, remote_port);
241    


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

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