فهرست منبع

* Removed neterror(), replaced with strerror()

svn: 1173
Bryan Drewery 22 سال پیش
والد
کامیت
4959ff9778
7فایلهای تغییر یافته به همراه10 افزوده شده و 93 حذف شده
  1. 1 0
      src/common.h
  2. 3 5
      src/dcc.c
  3. 1 1
      src/mod/server.mod/server.c
  4. 2 4
      src/mod/server.mod/servmsg.c
  5. 2 3
      src/mod/transfer.mod/transfer.c
  6. 1 79
      src/net.c
  7. 0 1
      src/net.h

+ 1 - 0
src/common.h

@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 #ifdef HAVE_STRINGS_H
 #  include <strings.h>
 #endif

+ 3 - 5
src/dcc.c

@@ -594,8 +594,7 @@ dcc_identd_connect(int idx, char *buf, int atr)
     sock = answer(sock, s, &ip, &port, 0);
 
   if (sock < 0) {
-    neterror(s);
-    putlog(LOG_MISC, "*", DCC_FAILED, s);
+    putlog(LOG_MISC, "*", DCC_FAILED, strerror(errno));
     return;
   }
   /* changeover_dcc(idx, &DCC_IDENTD, 0); */
@@ -1209,8 +1208,7 @@ dcc_telnet(int idx, char *buf, int i)
     sock = answer(sock, s, &ip, &port, 0);
 /*. ssl_link ACCEPT_SSL should go here!!!! */
   if (sock < 0) {
-    neterror(s);
-    putlog(LOG_MISC, "*", DCC_FAILED, s);
+    putlog(LOG_MISC, "*", DCC_FAILED, strerror(errno));
     return;
   }
   /* Buffer data received on this socket.  */
@@ -1307,7 +1305,7 @@ dcc_telnet_hostresolved(int i)
     if (sock == -2)
       strcpy(s, "DNS lookup failed for ident");
     else
-      neterror(s);
+      strcpy(s, strerror(errno));
   } else {
     j = new_dcc(&DCC_IDENT, 0);
     if (j < 0) {

+ 1 - 1
src/mod/server.mod/server.c

@@ -927,7 +927,7 @@ static void dcc_chat_hostresolved(int i)
 #  endif /* IPV6_DEBUG */
 #endif /* USE_IPV6 */
   if (dcc[i].sock < 0 || open_telnet_dcc(dcc[i].sock, ip, buf) < 0) {
-    neterror(buf);
+    strcpy(buf, strerror(errno));
     if (!quiet_reject)
       dprintf(DP_HELP, "NOTICE %s :%s (%s)\n", dcc[i].nick, DCC_CONNECTFAILED1, buf);
     putlog(LOG_MISC, "*", "%s: CHAT (%s!%s)", DCC_CONNECTFAILED2, dcc[i].nick, dcc[i].host);

+ 2 - 4
src/mod/server.mod/servmsg.c

@@ -1441,7 +1441,7 @@ static void server_resolve_failure(int idx)
 
 static void server_resolve_success(int idx)
 {
-  char s[121] = "", pass[121] = "";
+  char pass[121] = "";
 
   resolvserv = 0;
   dcc[idx].addr = dcc[idx].u.dns->ip;
@@ -1454,9 +1454,7 @@ static void server_resolve_success(int idx)
   serv = open_telnet(iptostr(htonl(dcc[idx].addr)), dcc[idx].port);
 #endif /* USE_IPV6 */
   if (serv < 0) {
-    neterror(s);
-
-    putlog(LOG_SERV, "*", "Failed connect to %s (%s)", dcc[idx].host, s);
+    putlog(LOG_SERV, "*", "Failed connect to %s (%s)", dcc[idx].host, strerror(errno));
     trying_server = 0;
     lostdcc(idx);
   } else {

+ 2 - 3
src/mod/transfer.mod/transfer.c

@@ -308,7 +308,7 @@ void eof_dcc_fork_send(int idx)
     putlog(LOG_BOTS, "*", "Failed binary transfer.");
     unlink(dcc[idx].u.xfer->filename);
   } else {
-    neterror(s1);
+    strcpy(s1, strerror(errno));
     if (!quiet_reject)
       dprintf(DP_HELP, "NOTICE %s :%s (%s)\n", dcc[idx].nick,
 	      DCC_CONNECTFAILED1, s1);
@@ -1028,8 +1028,7 @@ static void dcc_get_pending(int idx, char *buf, int len)
   dcc[idx].addr = ip;
   dcc[idx].port = (int) port;
   if (dcc[idx].sock == -1) {
-    neterror(s);
-    dprintf(DP_HELP, TRANSFER_NOTICE_BAD_CONN, dcc[idx].nick, s);
+    dprintf(DP_HELP, TRANSFER_NOTICE_BAD_CONN, dcc[idx].nick, strerror(errno));
     putlog(LOG_FILES, "*", TRANSFER_LOG_BAD_CONN,
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
     fclose(dcc[idx].u.xfer->f);

+ 1 - 79
src/net.c

@@ -324,84 +324,6 @@ void cache_my_ip()
   }
 }
 
-void neterror(char *s)
-{
-  switch (errno) {
-  case EADDRINUSE:
-    strcpy(s, "Address already in use");
-    break;
-  case EADDRNOTAVAIL:
-    strcpy(s, "Cannot assign requested address");
-    break;
-  case EAFNOSUPPORT:
-    strcpy(s, "Address family not supported");
-    break;
-  case EALREADY:
-    strcpy(s, "Socket already in use");
-    break;
-  case EBADF:
-    strcpy(s, "Socket descriptor is bad");
-    break;
-  case ECONNREFUSED:
-    strcpy(s, "Connection refused");
-    break;
-  case EFAULT:
-    strcpy(s, "Bad address");
-    break;
-  case EINPROGRESS:
-    strcpy(s, "Operation in progress");
-    break;
-  case EINTR:
-    strcpy(s, "Timeout");
-    break;
-  case EINVAL:
-    strcpy(s, "Invalid argument");
-    break;
-  case EISCONN:
-    strcpy(s, "Socket already connected");
-    break;
-  case ENETUNREACH:
-    strcpy(s, "Network unreachable");
-    break;
-  case ENOTSOCK:
-    strcpy(s, "Socket operation on non-socket");
-    break;
-  case ETIMEDOUT:
-    strcpy(s, "Connection timed out");
-    break;
-  case ENOTCONN:
-    strcpy(s, "Socket is not connected");
-    break;
-  case EHOSTUNREACH:
-    strcpy(s, "No route to host");
-    break;
-  case EPIPE:
-    strcpy(s, "Broken pipe");
-    break;
-#ifdef ECONNRESET
-  case ECONNRESET:
-    strcpy(s, "Connection reset by peer");
-    break;
-#endif /* ECONNRESET */
-#ifdef EACCES
-  case EACCES:
-    strcpy(s, "Permission denied");
-    break;
-#endif /* EACCESS */
-#ifdef EMFILE
-  case EMFILE:
-    strcpy(s, "Too many open files");
-    break;
-#endif /* EMFILE */
-  case 0:
-    strcpy(s, "Error 0");
-    break;
-  default:
-    sprintf(s, "Unforseen error %d", errno);
-    break;
-  }
-}
-
 /* Sets/Unsets options for a specific socket.
  * 
  * Returns:  0   - on success
@@ -630,7 +552,7 @@ static int proxy_connect(int sock, char *host, int port, int proxy)
  * instead and then call this function with the IP address to avoid blocking.
  * 
  * returns <0 if connection refused:
- *   -1  neterror() type error
+ *   -1  strerror()/errno type error
  *   -2  can't resolve hostname
  */
 int open_telnet_raw(int sock, char *server, port_t sport)

+ 0 - 1
src/net.h

@@ -130,7 +130,6 @@ int ssl_link(int, int);
 char *myipstr(int);
 IP getmyip();
 void cache_my_ip();
-void neterror(char *);
 void setsock(int, int);
 int allocsock(int, int);