Просмотр исходного кода

* Undid sockt_t/size_t patches

svn: 1375
Bryan Drewery 21 лет назад
Родитель
Сommit
1413abcd5d
19 измененных файлов с 139 добавлено и 180 удалено
  1. 1 1
      src/botmsg.c
  2. 11 11
      src/botnet.c
  3. 25 25
      src/dcc.c
  4. 4 5
      src/dcc.h
  5. 4 4
      src/dccutil.c
  6. 1 1
      src/debug.c
  7. 1 1
      src/dns.c
  8. 6 8
      src/main.c
  9. 3 3
      src/misc_file.c
  10. 1 1
      src/mod/dns.mod/dns.c
  11. 1 1
      src/mod/server.mod/server.c
  12. 1 2
      src/mod/server.mod/server.h
  13. 1 2
      src/mod/share.mod/share.c
  14. 8 8
      src/mod/transfer.mod/transfer.c
  15. 49 83
      src/net.c
  16. 20 21
      src/net.h
  17. 1 1
      src/shell.c
  18. 1 1
      src/tandem.h
  19. 0 1
      src/types.h

+ 1 - 1
src/botmsg.c

@@ -553,7 +553,7 @@ int add_note(char *to, char *from, char *msg, int idx, int echo)
     if ((idx >= 0) && (echo))
       dprintf(idx, "-> %s@%s: %s\n", x, p, msg);
     if (idx >= 0) {
-      sprintf(ssf, "%lu:%s", dcc[idx].sock, botf);
+      sprintf(ssf, "%d:%s", dcc[idx].sock, botf);
       botnet_send_priv(i, ssf, x, p, "%s", msg);
     } else
       botnet_send_priv(i, botf, x, p, "%s", msg);

+ 11 - 11
src/botnet.c

@@ -1020,7 +1020,7 @@ static void failed_tandem_relay(int idx)
 	(dcc[i].u.relay->sock == dcc[idx].sock))
       uidx = i;
   if (uidx < 0) {
-    putlog(LOG_MISC, "*", "%s  %li -> %li", BOT_CANTFINDRELAYUSER,
+    putlog(LOG_MISC, "*", "%s  %d -> %d", BOT_CANTFINDRELAYUSER,
 	   dcc[idx].sock, dcc[idx].u.relay->sock);
     killsock(dcc[idx].sock);
     lostdcc(idx);
@@ -1150,7 +1150,7 @@ static void tandem_relay_resolve_failure(int idx)
       break;
     }
   if (uidx < 0) {
-    putlog(LOG_MISC, "*", "%s  %li -> %li", BOT_CANTFINDRELAYUSER,
+    putlog(LOG_MISC, "*", "%s  %d -> %d", BOT_CANTFINDRELAYUSER,
 	   dcc[idx].sock, dcc[idx].u.relay->sock);
     killsock(dcc[idx].sock);
     lostdcc(idx);
@@ -1197,7 +1197,7 @@ static void tandem_relay_resolve_success(int i)
 
 /* Input from user before connect is ready
  */
-static void pre_relay(int idx, char *buf, register size_t len)
+static void pre_relay(int idx, char *buf, register int len)
 {
   register int tidx = (-1), i;
 
@@ -1217,7 +1217,7 @@ static void pre_relay(int idx, char *buf, register size_t len)
       }
   }
   if (tidx < 0) {
-    putlog(LOG_MISC, "*", "%s  %li -> %li", BOT_CANTFINDRELAYUSER,
+    putlog(LOG_MISC, "*", "%s  %d -> %d", BOT_CANTFINDRELAYUSER,
 	   dcc[idx].sock, dcc[idx].u.relay->sock);
     killsock(dcc[idx].sock);
     lostdcc(idx);
@@ -1263,7 +1263,7 @@ static void failed_pre_relay(int idx)
       }
   }
   if (tidx < 0) {
-    putlog(LOG_MISC, "*", "%s  %li -> %li", BOT_CANTFINDRELAYUSER,
+    putlog(LOG_MISC, "*", "%s  %d -> %d", BOT_CANTFINDRELAYUSER,
 	   dcc[idx].sock, dcc[idx].u.relay->sock);
     killsock(dcc[idx].sock);
     lostdcc(idx);
@@ -1288,7 +1288,7 @@ static void failed_pre_relay(int idx)
   lostdcc(idx);
 }
 
-static void cont_tandem_relay(int idx, char *buf, register size_t len)
+static void cont_tandem_relay(int idx, char *buf, register int len)
 {
   register int uidx = (-1), i;
 
@@ -1297,7 +1297,7 @@ static void cont_tandem_relay(int idx, char *buf, register size_t len)
 	(dcc[i].u.relay->sock == dcc[idx].sock))
       uidx = i;
   if (uidx < 0) {
-    putlog(LOG_MISC, "*", "%s  %li -> %li", BOT_CANTFINDRELAYUSER,
+    putlog(LOG_MISC, "*", "%s  %d -> %d", BOT_CANTFINDRELAYUSER,
 	   dcc[i].sock, dcc[i].u.relay->sock);
     killsock(dcc[i].sock);
     lostdcc(i);
@@ -1376,7 +1376,7 @@ static void eof_dcc_relaying(int idx)
   lostdcc(j);			/* Drop connection to the bot */
 }
 
-static void dcc_relay(int idx, char *buf, size_t j)
+static void dcc_relay(int idx, char *buf, int j)
 {
   unsigned char *p = (unsigned char *) buf;
   int mark;
@@ -1415,7 +1415,7 @@ static void dcc_relay(int idx, char *buf, size_t j)
     dprintf(-dcc[idx].u.relay->sock, "%s\r\n", buf);
 }
 
-static void dcc_relaying(int idx, char *buf, size_t j)
+static void dcc_relaying(int idx, char *buf, int j)
 {
   if (egg_strcasecmp(buf, "*bye*")) {
     dprintf(-dcc[idx].u.relay->sock, "%s\n", buf);
@@ -1450,12 +1450,12 @@ static void dcc_relaying(int idx, char *buf, size_t j)
 
 static void display_relay(int i, char *other)
 {
-  sprintf(other, "rela  -> sock %li", dcc[i].u.relay->sock);
+  sprintf(other, "rela  -> sock %d", dcc[i].u.relay->sock);
 }
 
 static void display_relaying(int i, char *other)
 {
-  sprintf(other, ">rly  -> sock %li", dcc[i].u.relay->sock);
+  sprintf(other, ">rly  -> sock %d", dcc[i].u.relay->sock);
 }
 
 static void display_tandem_relay(int i, char *other)

+ 25 - 25
src/dcc.c

@@ -60,10 +60,10 @@ static time_t flood_telnet_time = 5;       /* In how many seconds?
 
 static void dcc_telnet_hostresolved(int);
 static void dcc_telnet_got_ident(int, char *);
-static void dcc_telnet_pass(int, size_t);
+static void dcc_telnet_pass(int, int);
 
 static void
-strip_telnet(sock_t sock, char *buf, size_t *len)
+strip_telnet(int sock, char *buf, int *len)
 {
   unsigned char *p = (unsigned char *) buf, *o = (unsigned char *) buf;
   int mark;
@@ -273,11 +273,11 @@ failed_link(int idx)
 }
 
 static void
-cont_link(int idx, char *buf, size_t ii)
+cont_link(int idx, char *buf, int ii)
 {
   /* Now set the initial link key (incoming only, we're not sending more until we get an OK)... */
 
-  sock_t snum = findanysnum(dcc[idx].sock);
+  int snum = findanysnum(dcc[idx].sock);
 
   if (snum >= 0) {
     struct sockaddr_in sa;
@@ -320,7 +320,7 @@ cont_link(int idx, char *buf, size_t ii)
 }
 
 static void
-dcc_bot_new(int idx, char *buf, size_t x)
+dcc_bot_new(int idx, char *buf, int x)
 {
 /*  struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick); */
   char *code = NULL;
@@ -332,7 +332,7 @@ dcc_bot_new(int idx, char *buf, size_t x)
   } else if (!egg_strcasecmp(code, "v")) {
     bot_version(idx, buf);
   } else if (!egg_strcasecmp(code, "elink")) {
-    sock_t snum = findanysnum(dcc[idx].sock);
+    int snum = findanysnum(dcc[idx].sock);
 
     /* putlog(LOG_DEBUG, "*", "Got elink: %s %s", code, buf); */
     /* Set the socket key and we're linked */
@@ -414,7 +414,7 @@ struct dcc_table DCC_BOT_NEW = {
 extern botcmd_t C_bot[];
 
 static void
-dcc_bot(int idx, char *code, size_t i)
+dcc_bot(int idx, char *code, int i)
 {
   char *msg = NULL;
   int f;
@@ -524,7 +524,7 @@ struct dcc_table DCC_FORK_BOT = {
 };
 
 static void
-dcc_identd(int idx, char *buf, size_t atr)
+dcc_identd(int idx, char *buf, int atr)
 {
   char outbuf[1024] = "";
 
@@ -563,11 +563,11 @@ struct dcc_table DCC_IDENTD = {
 };
 
 static void
-dcc_identd_connect(int idx, char *buf, size_t atr)
+dcc_identd_connect(int idx, char *buf, int atr)
 {
   in_addr_t ip;
   port_t port;
-  sock_t j, sock;
+  int j, sock;
   char s[UHOSTLEN + 1] = "";
 
   if (dcc_total + 1 > max_dcc) {
@@ -612,7 +612,7 @@ struct dcc_table DCC_IDENTD_CONNECT = {
 };
 
 static void
-dcc_chat_secpass(int idx, char *buf, size_t atr)
+dcc_chat_secpass(int idx, char *buf, int atr)
 {
   int badauth = 0;
 
@@ -885,7 +885,7 @@ static struct dcc_table DCC_CHAT_SECPASS = {
 };
 
 static void
-dcc_chat_pass(int idx, char *buf, size_t atr)
+dcc_chat_pass(int idx, char *buf, int atr)
 {
   if (!atr)
     return;
@@ -998,7 +998,7 @@ eof_dcc_chat(int idx)
 }
 
 static void
-dcc_chat(int idx, char *buf, size_t len)
+dcc_chat(int idx, char *buf, int len)
 {
   int i = 0;
 
@@ -1192,14 +1192,14 @@ detect_telnet_flood(char *floodhost)
 }
 
 static void
-dcc_telnet(int idx, char *buf, size_t ii)
+dcc_telnet(int idx, char *buf, int ii)
 {
   in_addr_t ip;
   port_t port;
   char s[UHOSTLEN + 1] = "";
 
   if (dcc_total + 1 > max_dcc) {
-    sock_t j;
+    int j;
 
     j = answer(dcc[idx].sock, s, &ip, &port, 0);
     if (j != -1) {
@@ -1209,7 +1209,7 @@ dcc_telnet(int idx, char *buf, size_t ii)
     return;
   }
 
-  sock_t sock = answer(dcc[idx].sock, s, &ip, &port, 0);
+  int sock = answer(dcc[idx].sock, s, &ip, &port, 0);
 
   while ((sock == -1) && (errno == EAGAIN))
     sock = answer(sock, s, &ip, &port, 0);
@@ -1269,7 +1269,7 @@ static void
 dcc_telnet_hostresolved(int i)
 {
   int idx;
-  sock_t j = 0, sock;
+  int j = 0, sock;
   char s2[UHOSTLEN + 20] = "";
 
 #ifdef USE_IPV6
@@ -1385,7 +1385,7 @@ eof_dcc_dupwait(int idx)
 }
 
 static void
-dcc_dupwait(int idx, char *buf, size_t i)
+dcc_dupwait(int idx, char *buf, int i)
 {
   /* We just ignore any data at this point. */
   return;
@@ -1458,7 +1458,7 @@ dupwait_notify(const char *who)
 }
 
 static void
-dcc_telnet_id(int idx, char *buf, size_t atr)
+dcc_telnet_id(int idx, char *buf, int atr)
 {
   strip_telnet(dcc[idx].sock, buf, &atr);
   buf[HANDLEN] = 0;
@@ -1521,7 +1521,7 @@ dcc_telnet_id(int idx, char *buf, size_t atr)
 }
 
 static void
-dcc_telnet_pass(int idx, size_t atr)
+dcc_telnet_pass(int idx, int atr)
 {
   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0 };
 
@@ -1568,7 +1568,7 @@ dcc_telnet_pass(int idx, size_t atr)
   }
 
   if (glob_bot(fr)) {
-    sock_t snum = findanysnum(dcc[idx].sock);
+    int snum = findanysnum(dcc[idx].sock);
 
     if (snum >= 0) {
       char initkey[33] = "", *tmp2 = NULL;
@@ -1651,7 +1651,7 @@ struct dcc_table DCC_TELNET_ID = {
 };
 
 static void
-dcc_socket(int idx, char *buf, size_t len)
+dcc_socket(int idx, char *buf, int len)
 {
 }
 
@@ -1701,7 +1701,7 @@ struct dcc_table DCC_LOST = {
 };
 
 void
-dcc_identwait(int idx, char *buf, size_t len)
+dcc_identwait(int idx, char *buf, int len)
 {
   /* Ignore anything now */
 }
@@ -1742,7 +1742,7 @@ struct dcc_table DCC_IDENTWAIT = {
 };
 
 void
-dcc_ident(int idx, char *buf, size_t len)
+dcc_ident(int idx, char *buf, int len)
 {
   char ident_response[512] = "", uid[512] = "", buf1[UHOSTLEN] = "";
 
@@ -1783,7 +1783,7 @@ eof_dcc_ident(int idx)
 static void
 display_dcc_ident(int idx, char *buf)
 {
-  sprintf(buf, "idnt  (sock %li)", dcc[idx].u.ident_sock);
+  sprintf(buf, "idnt  (sock %d)", dcc[idx].u.ident_sock);
 }
 
 struct dcc_table DCC_IDENT = {

+ 4 - 5
src/dcc.h

@@ -15,7 +15,7 @@ struct dcc_table {
   char *name;
   int flags;
   void (*eof) (int);
-  void (*activity) (int, char *, size_t);
+  void (*activity) (int, char *, int);
   time_t *timeout_val;
   void (*timeout) (int);
   void (*display) (int, char *);
@@ -36,7 +36,7 @@ struct dcc_t {
     struct relay_info *relay;
     struct dns_info *dns;
     struct dupwait_info *dupwait;
-    sock_t ident_sock;
+    int ident_sock;
     void *other;
   } u;                          /* Special use depending on type        */
 
@@ -47,8 +47,7 @@ struct dcc_t {
   time_t pingtime;
   unsigned long status;         /* A LOT of dcc types have status
                                    thingos, this makes it more avaliabe */
-  sock_t sock;                    /* This should be a long to keep 64-bit
-                                   machines sane                         */
+  int sock;
   int ssl;                      /* use ssl on this dcc? */
   int simul;                    /* this will hold the idx on the remote bot to return result. */
   int msgc;			/* forward the output back to irc? */
@@ -115,7 +114,7 @@ struct bot_info {
 
 struct relay_info {
   struct chat_info *chat;
-  sock_t sock;
+  int sock;
   int old_status;
   port_t port;
 };

+ 4 - 4
src/dccutil.c

@@ -269,7 +269,7 @@ void chanout_but(int x, int chan, const char *format, ...)
 void dcc_chatter(int idx)
 {
   int i;
-  sock_t j;
+  int j;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0 };
 
   strcpy(dcc[idx].u.chat->con_chan, "***");
@@ -633,9 +633,9 @@ port_t listen_all(port_t lport, bool off)
   int idx = (-1);
   port_t port, realport;
 #ifdef USE_IPV6
-  sock_t i6 = 0;
+  int i6 = 0;
 #endif /* USE_IPV6 */
-  sock_t i;
+  int i;
   struct portmap *pmap = NULL, *pold = NULL;
 
   port = realport = lport;
@@ -739,7 +739,7 @@ port_t listen_all(port_t lport, bool off)
 void identd_open()
 {
   int idx;
-  sock_t i = -1;
+  int i = -1;
   port_t port = 113;
 
   for (idx = 0; idx < dcc_total; idx++)

+ 1 - 1
src/debug.c

@@ -109,7 +109,7 @@ void sdprintf (char *format, ...)
 
 static void write_debug()
 {
-  sock_t x;
+  int x;
   char s[25] = "", tmpout[150] = "", buf[DIRMAX] = "";
   int y;
 

+ 1 - 1
src/dns.c

@@ -27,7 +27,7 @@ devent_t	*dns_events = NULL;
  *   DCC functions
  */
 
-void dcc_dnswait(int idx, char *buf, size_t len)
+void dcc_dnswait(int idx, char *buf, int len)
 {
   /* Ignore anything now. */
 }

+ 6 - 8
src/main.c

@@ -949,10 +949,10 @@ printf("out: %s\n", out);
 
   debug0("main: entering loop");
 
-  while (1) {
-    int socket_cleanup = 0, status = 0, xx, i = 0;
-    char buf[SGRAB + 10] = "";
+  int socket_cleanup = 0, status = 0, xx, i = 0, idx = 0;
+  char buf[SGRAB + 10] = "";
 
+  while (1) {
 #ifndef CYGWIN_HACKS
     if (conf.watcher && waitpid(watcher, &status, WNOHANG))
       fatal("watcher PID died/stopped", 0);
@@ -981,7 +981,7 @@ printf("out: %s\n", out);
     xx = sockgets(buf, &i);
 
     if (xx >= 0) {		/* Non-error */
-      for (int idx = 0; idx < dcc_total; idx++) {
+      for (idx = 0; idx < dcc_total; idx++) {
 	if (dcc[idx].sock == xx) {
 	  if (dcc[idx].type && dcc[idx].type->activity) {
 	    /* Traffic stats */
@@ -1004,14 +1004,12 @@ printf("out: %s\n", out);
 	    dcc[idx].type->activity(idx, buf, i);
 	  } else
 	    putlog(LOG_MISC, "*",
-		   "!!! untrapped dcc activity: type %s, sock %li",
+		   "!!! untrapped dcc activity: type %s, sock %d",
 		   dcc[idx].type->name, dcc[idx].sock);
 	  break;
 	}
       }
     } else if (xx == -1) {	/* EOF from someone */
-      int idx;
-
       if (i == STDOUT && !backgrd)
 	fatal("END OF FILE ON TERMINAL", 0);
       for (idx = 0; idx < dcc_total; idx++) {
@@ -1038,7 +1036,7 @@ printf("out: %s\n", out);
       for (i = 0; i < dcc_total; i++) {
 	if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno = EBADF)) {
 	  putlog(LOG_MISC, "*",
-		 "DCC socket %li (type %s, name '%s') expired -- pfft",
+		 "DCC socket %d (type %s, name '%s') expired -- pfft",
 		 dcc[i].sock, dcc[i].type->name, dcc[i].nick);
 	  killsock(dcc[i].sock);
 	  lostdcc(i);

+ 3 - 3
src/misc_file.c

@@ -24,7 +24,7 @@
  */
 int copyfile(const char *oldpath, const char *newpath)
 {
-  sock_t fi;
+  int fi;
 
 #ifndef CYGWIN_HACKS
   fi = open(oldpath, O_RDONLY, 0);
@@ -40,7 +40,7 @@ int copyfile(const char *oldpath, const char *newpath)
   if (!(st.st_mode & S_IFREG))
     return 3;
 
-  sock_t fo;
+  int fo;
 
   fo = creat(newpath, (int) (st.st_mode & 0600));
   if (fo < 0) {
@@ -50,7 +50,7 @@ int copyfile(const char *oldpath, const char *newpath)
 
   char buf[512] = "";
 
-  for (ssize_t x = 1; x > 0;) {
+  for (int x = 1; x > 0;) {
     x = read(fi, buf, 512);
     if (x > 0) {
       if (write(fo, buf, x) < x) {	/* Couldn't write */

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

@@ -75,7 +75,7 @@ static void eof_dns_socket(int idx)
     lostdcc(idx);
 }
 
-static void dns_socket(int idx, char *buf, size_t len)
+static void dns_socket(int idx, char *buf, int len)
 {
   dns_ack();
 }

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

@@ -29,7 +29,7 @@
 bool strict_servernames;
 bool checked_hostmask;	/* Used in request_op()/check_hostmask() cleared on connect */
 int ctcp_mode;
-sock_t serv;		/* sock # of server currently */
+int serv;		/* sock # of server currently */
 int servidx;		/* idx of server */
 char newserver[121] = "";	/* new server? */
 port_t newserverport;		/* new server port? */

+ 1 - 2
src/mod/server.mod/server.h

@@ -41,10 +41,9 @@ enum {
 #endif		/* _EGG_MOD_SERVER_SERVER_H */
 
 extern bind_table_t	*BT_ctcp, *BT_ctcr, *BT_msgc;
-extern sock_t		serv;
 extern size_t		nick_len;
 extern bool		checked_hostmask, quiet_reject, trigger_on_ignore;
-extern int 		servidx, ctcp_mode, flud_thr, flud_ctcp_thr, answer_ctcp;
+extern int 		servidx, ctcp_mode, flud_thr, flud_ctcp_thr, answer_ctcp, serv;
 extern port_t		default_port, newserverport;
 extern time_t		server_online, cycle_time, flud_time, flud_ctcp_time;
 extern char		cursrvname[], botrealname[], botuserhost[], ctcp_reply[],

+ 1 - 2
src/mod/share.mod/share.c

@@ -1038,8 +1038,7 @@ share_ufsend(int idx, char *par)
 {
   char *ip = NULL, *port = NULL;
   char s[1024] = "";
-  int i;
-  sock_t sock;
+  int i, sock;
   FILE *f = NULL;
 
   egg_snprintf(s, sizeof s, "%s.share.%s.%li.users", tempdir, conf.bot->nick, now);

+ 8 - 8
src/mod/transfer.mod/transfer.c

@@ -48,7 +48,7 @@ static bool quiet_reject = 1;        /* Quietly reject dcc chat or sends from
 #ifdef HUB
 static void wipe_tmp_filename(char *, int);
 static int at_limit(char *);
-static void dcc_get_pending(int, char *, size_t);
+static void dcc_get_pending(int, char *, int);
 #endif /* HUB */
 
 static fileq_t *fileq = NULL;
@@ -501,7 +501,7 @@ inline static void handle_resend_packet(int idx, transfer_reget *reget_data)
  * Note: The first received packet during reget is a special 8 bit packet
  *       containing special information.
  */
-void dcc_get(int idx, char *buf, size_t len)
+void dcc_get(int idx, char *buf, int len)
 {
   char xnick[NICKLEN] = "";
   unsigned char bbuf[4] = "";
@@ -723,7 +723,7 @@ void eof_dcc_get(int idx)
 }
 #endif /* HUB */
 
-void dcc_send(int idx, char *buf, size_t len)
+void dcc_send(int idx, char *buf, int len)
 {
   char s[SGRAB + 2] = "", *b = NULL;
   unsigned long sent;
@@ -952,7 +952,7 @@ struct dcc_table DCC_SEND =
   NULL
 };
 
-void dcc_fork_send(int idx, char *x, size_t y);
+void dcc_fork_send(int idx, char *x, int y);
 
 struct dcc_table DCC_FORK_SEND =
 {
@@ -968,7 +968,7 @@ struct dcc_table DCC_FORK_SEND =
   NULL
 };
 
-void dcc_fork_send(int idx, char *x, size_t y)
+void dcc_fork_send(int idx, char *x, int y)
 {
   if (dcc[idx].type != &DCC_FORK_SEND)
     return;
@@ -1012,11 +1012,11 @@ struct dcc_table DCC_GET_PENDING =
   NULL
 };
 
-static void dcc_get_pending(int idx, char *buf, size_t len)
+static void dcc_get_pending(int idx, char *buf, int len)
 {
   in_addr_t ip;
   port_t port;
-  sock_t i;
+  int i;
   char s[UHOSTLEN] = "";
 
   i = answer(dcc[idx].sock, s, &ip, &port, 1);
@@ -1087,7 +1087,7 @@ static void dcc_get_pending(int idx, char *buf, size_t len)
 
 static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir, int resend)
 {
-  sock_t zz = -1;
+  int zz = -1;
   int i;
   port_t port;
   char *nfn = NULL, *buf = NULL;

+ 49 - 83
src/net.c

@@ -104,7 +104,7 @@ int hostprotocol(char *host)
 }
 
 /* get the protocol used on a socket */
-int sockprotocol(sock_t sock)
+int sockprotocol(int sock)
 {
   struct sockaddr sa;
   socklen_t socklen = sizeof(sa);
@@ -324,7 +324,7 @@ void cache_my_ip()
  *           -1  - socket not found
  *           -2  - illegal operation
  */
-int sockoptions(sock_t sock, int operation, int sock_options)
+int sockoptions(int sock, int operation, int sock_options)
 {
   for (int i = 0; i < MAXSOCKS; i++) {
     if ((socklist[i].sock == sock) && !(socklist[i].flags & SOCK_UNUSED)) {
@@ -342,9 +342,9 @@ int sockoptions(sock_t sock, int operation, int sock_options)
 
 /* Return a free entry in the socket entry
  */
-sock_t allocsock(sock_t sock, int options)
+int allocsock(int sock, int options)
 {
-  for (sock_t i = 0; i < MAXSOCKS; i++) {
+  for (int i = 0; i < MAXSOCKS; i++) {
     if (socklist[i].flags & SOCK_UNUSED) {
       /* yay!  there is table space */
       socklist[i].inbuf = socklist[i].outbuf = NULL;
@@ -369,9 +369,9 @@ sock_t allocsock(sock_t sock, int options)
 
 /* Request a normal socket for i/o
  */
-void setsock(sock_t sock, int options)
+void setsock(int sock, int options)
 {
-  sock_t i = allocsock(sock, options);
+  int i = allocsock(sock, options);
   bool parm;
 
   if (((sock != STDOUT) || backgrd) && !(socklist[i].flags & SOCK_NONSOCK)) {
@@ -391,14 +391,14 @@ void setsock(sock_t sock, int options)
 }
 
 #ifdef USE_IPV6
-sock_t real_getsock(int options, int af_def, char *fname, int line)
+int real_getsock(int options, int af_def, char *fname, int line)
 {
 #else
-sock_t real_getsock(int options, char *fname, int line)
+int real_getsock(int options, char *fname, int line)
 {
   int af_def = AF_INET;
 #endif /* USE_IPV6 */
-  sock_t sock = socket(af_def, SOCK_STREAM, 0);
+  int sock = socket(af_def, SOCK_STREAM, 0);
 
   if (sock >= 0)
     setsock(sock, options);
@@ -410,11 +410,11 @@ sock_t real_getsock(int options, char *fname, int line)
 }
 
 #ifdef HAVE_SSL
-void dropssl(register sock_t sock)
+void dropssl(register int sock)
 {
   if (sock < 0)
     return;
-  sock_t i;
+  int i;
 
   for (i = 0; (i < MAXSOCKS); i++)
     if (socklist[i].sock == sock) break;
@@ -432,7 +432,7 @@ void dropssl(register sock_t sock)
 
 /* Done with a socket
  */
-void real_killsock(register sock_t sock, const char *file, int line)
+void real_killsock(register int sock, const char *file, int line)
 {
   if (sock < 0) {
     putlog(LOG_ERRORS, "*", "Attempt to kill socket -1 %s:%d", file, line);
@@ -461,12 +461,12 @@ void real_killsock(register sock_t sock, const char *file, int line)
       return;
     }
   }
-  putlog(LOG_MISC, "*", "Attempt to kill un-allocated socket %lu %s:%d !!", sock, file, line);
+  putlog(LOG_MISC, "*", "Attempt to kill un-allocated socket %d %s:%d !!", sock, file, line);
 }
 
 /* Send connection request to proxy
  */
-static sock_t proxy_connect(sock_t sock, char *host, int port, int proxy)
+static int proxy_connect(int sock, char *host, int port, int proxy)
 {
 #ifdef USE_IPV6
   unsigned char x[32] = "";
@@ -545,7 +545,7 @@ static sock_t proxy_connect(sock_t sock, char *host, int port, int proxy)
  *   -1  strerror()/errno type error
  *   -2  can't resolve hostname
  */
-sock_t open_telnet_raw(sock_t sock, char *server, port_t sport)
+int open_telnet_raw(int sock, char *server, port_t sport)
 {
   static port_t port = 0;
   union sockaddr_union so;
@@ -613,6 +613,7 @@ sock_t open_telnet_raw(sock_t sock, char *server, port_t sport)
   }
 
   int rc = connect(sock, &so.sa, SIZEOF_SOCKADDR(so));
+
   if (rc < 0) {    if (errno == EINPROGRESS) {
       /* Firewall?  announce connect attempt to proxy */
       if (firewall[0])
@@ -631,9 +632,9 @@ sock_t open_telnet_raw(sock_t sock, char *server, port_t sport)
 }
 
 /* Ordinary non-binary connection attempt */
-sock_t open_telnet(char *server, port_t port)
+int open_telnet(char *server, port_t port)
 {
-  sock_t sock = -1;
+  int sock = -1;
 
 #ifdef USE_IPV6
   sock = getsock(0, hostprotocol(server));
@@ -651,9 +652,9 @@ sock_t open_telnet(char *server, port_t port)
  * 'addr' is ignored if af_def is AF_INET6 -poptix (02/03/03)
  */
 #ifdef USE_IPV6
-sock_t open_address_listen(in_addr_t addr, int af_def, port_t *port)
+int open_address_listen(in_addr_t addr, int af_def, port_t *port)
 #else
-sock_t open_address_listen(in_addr_t addr, port_t *port)
+intt open_address_listen(in_addr_t addr, port_t *port)
 #endif /* USE_IPV6 */
  {
   if (firewall[0]) {
@@ -662,7 +663,7 @@ sock_t open_address_listen(in_addr_t addr, port_t *port)
     return -1;
   }
 
-  sock_t sock = 0;
+  int sock = 0;
   socklen_t addrlen;
   struct sockaddr_in name;
 
@@ -674,7 +675,7 @@ sock_t open_address_listen(in_addr_t addr, port_t *port)
     if (sock < 1)
       return -1;
 
-    debug2("Opening listen socket on port %d with AF_INET6, sock: %lu", *port, sock);
+    debug2("Opening listen socket on port %d with AF_INET6, sock: %d", *port, sock);
     egg_bzero((char *) &name6, sizeof(name6));
     name6.sin6_family = af_def;
     name6.sin6_port = htons(*port); /* 0 = just assign us a port */
@@ -703,7 +704,7 @@ sock_t open_address_listen(in_addr_t addr, port_t *port)
     if (sock < 1)
       return -1;
 
-    debug2("Opening listen socket on port %d with AF_INET, sock: %lu", *port, sock);
+    debug2("Opening listen socket on port %d with AF_INET, sock: %d", *port, sock);
     egg_bzero((char *) &name, sizeof(struct sockaddr_in));
     name.sin_family = AF_INET;
     name.sin_port = htons(*port); /* 0 = just assign us a port */
@@ -727,7 +728,7 @@ sock_t open_address_listen(in_addr_t addr, port_t *port)
   }
 #endif /* USE_IPV6 */
 
-  debug2("Opened listen socket on port %d with AF_INET, sock: %lu", *port, sock);
+  debug2("Opened listen socket on port %d with AF_INET, sock: %d", *port, sock);
 
   return sock;
 }
@@ -735,7 +736,7 @@ sock_t open_address_listen(in_addr_t addr, port_t *port)
 /* Returns a socket number for a listening socket that will accept any
  * connection -- port # is returned in port
  */
-sock_t open_listen(port_t *port)
+int open_listen(port_t *port)
 {
 #ifdef USE_IPV6
   return open_address_listen(getmyip(), AF_INET, port);
@@ -748,7 +749,7 @@ sock_t open_listen(port_t *port)
  * the above is being left in for compatibility, and should NOT LONGER BE USED IN THE CORE CODE.
  */
 
-sock_t open_listen_by_af(port_t *port, int af_def)
+int open_listen_by_af(port_t *port, int af_def)
 {
 #ifdef USE_IPV6
   return open_address_listen(getmyip(), af_def, port);
@@ -758,7 +759,7 @@ sock_t open_listen_by_af(port_t *port, int af_def)
 }
 
 #ifdef HAVE_SSL
-int ssl_link(register sock_t sock, int state)
+int ssl_link(register int sock, int state)
 {
   int err = 0, i = 0, errs = 0;
 
@@ -840,9 +841,9 @@ char *iptostr(in_addr_t ip)
  * by open_listen ... returns hostname of the caller & the new socket
  * does NOT dispose of old "public" socket!
  */
-sock_t answer(sock_t sock, char *caller, in_addr_t *ip, port_t *port, int binary)
+int answer(int sock, char *caller, in_addr_t *ip, port_t *port, int binary)
 {
-  sock_t new_sock;
+  int new_sock;
   socklen_t addrlen;
   struct sockaddr_in from;
 #ifdef USE_IPV6
@@ -908,7 +909,7 @@ sock_t answer(sock_t sock, char *caller, in_addr_t *ip, port_t *port, int binary
 
 /* Like open_telnet, but uses server & port specifications of dcc
  */
-sock_t open_telnet_dcc(sock_t sock, char *server, char *port)
+int open_telnet_dcc(int sock, char *server, char *port)
 {
   port_t p;
   unsigned long addr;
@@ -946,7 +947,7 @@ sock_t open_telnet_dcc(sock_t sock, char *server, char *port)
     }
   /* strcpy(sv,hostnamefromip(addr)); */
 #  ifdef DEBUG_IPV6
-  debug3("open_telnet_raw %s %lu %d", sv, sock, p);
+  debug3("open_telnet_raw %s %d %d", sv, sock, p);
 #  endif /* DEBUG_IPV6 */
 #endif /* USE_IPV6 */
   return open_telnet_raw(sock, sv, p);
@@ -964,7 +965,7 @@ static int sockread(char *s, int *len)
   fd_set fd;
   int fds = 0, i, fdtmp, x;
   struct timeval t;
-  size_t grab = SGRAB + 1;
+  int grab = SGRAB + 1;
   egg_timeval_t howlong;
 
   if (timer_get_shortest(&howlong)) {
@@ -1012,7 +1013,7 @@ static int sockread(char *s, int *len)
 	    /* Hang around to get the return code from proxy */
 	    grab = 10;
 	  } else if (!(socklist[i].flags & SOCK_STRONGCONN)) {
-	    debug1("net: connect! sock %lu", socklist[i].sock);
+	    debug1("net: connect! sock %d", socklist[i].sock);
 	    s[0] = 0;
 	    *len = 0;
 #ifdef HAVE_SSL
@@ -1060,17 +1061,17 @@ static int sockread(char *s, int *len)
 				    to die, it will die later, otherwise it will connect */
 	    *len = socklist[i].sock;
 	    socklist[i].flags &= ~SOCK_CONNECT;
-	    debug1("net: eof!(read) socket %lu", socklist[i].sock);
+	    debug1("net: eof!(read) socket %d", socklist[i].sock);
 	    return -1;
 	  } else {
-	    debug3("sockread EAGAIN: %lu %d (%s)", socklist[i].sock, errno, strerror(errno));
+	    debug3("sockread EAGAIN: %d %d (%s)", socklist[i].sock, errno, strerror(errno));
 	    continue; /* EAGAIN */
 	  }
 	}
 	s[x] = 0;
 	*len = x;
 	if (socklist[i].flags & SOCK_PROXYWAIT) {
-	  debug2("net: socket: %lu proxy errno: %d", socklist[i].sock, s[1]);
+	  debug2("net: socket: %d proxy errno: %d", socklist[i].sock, s[1]);
 	  socklist[i].flags &= ~(SOCK_CONNECT | SOCK_PROXYWAIT);
 	  switch (s[1]) {
 	  case 90:		/* Success */
@@ -1113,7 +1114,7 @@ prand(int *seed, int range)
   return ((i1 * range) >> 32);
 }
 
-char *botlink_decrypt(sock_t snum, char *src)
+char *botlink_decrypt(int snum, char *src)
 {
   char *line = decrypt_string(socklist[snum].ikey, src);
 
@@ -1131,7 +1132,7 @@ char *botlink_decrypt(sock_t snum, char *src)
   return src;
 }
 
-char *botlink_encrypt(sock_t snum, char *src, size_t *len)
+char *botlink_encrypt(int snum, char *src, size_t *len)
 {
   char *srcbuf = NULL, *buf = NULL, *line = NULL, *eol = NULL, *eline = NULL;
   size_t bufpos = 0;
@@ -1391,7 +1392,7 @@ int sockgets(char *s, int *len)
  * 
  * NOTE: Do NOT put Contexts in here if you want DEBUG to be meaningful!!
  */
-void tputs(register sock_t z, char *s, size_t len)
+void tputs(register int z, char *s, size_t len)
 {
   if (z < 0)			/* um... HELLO?!  sanity check please! */
     return;			
@@ -1401,8 +1402,7 @@ void tputs(register sock_t z, char *s, size_t len)
     return;
   }
 
-  register ssize_t x;
-  register int idx;
+  register int x, idx;
   char *p = NULL;
 
   for (register int i = 0; i < MAXSOCKS; i++) {
@@ -1492,7 +1492,7 @@ void tputs(register sock_t z, char *s, size_t len)
   if (!inhere) {
     inhere = 1;
 
-    putlog(LOG_MISC, "*", "!!! writing to nonexistent socket: %lu", z);
+    putlog(LOG_MISC, "*", "!!! writing to nonexistent socket: %d", z);
     s[strlen(s) - 1] = 0;
     putlog(LOG_MISC, "*", "!-> '%s'", s);
 
@@ -1504,17 +1504,17 @@ void tputs(register sock_t z, char *s, size_t len)
 */
 }
 
-sock_t findanysnum(register sock_t sock)
+int findanysnum(register int sock)
 {
   if (sock != -1)
-    for (sock_t i = 0; i < MAXSOCKS; i++)
+    for (int i = 0; i < MAXSOCKS; i++)
       if ((socklist[i].sock == sock) && !(socklist[i].flags & SOCK_UNUSED))
         return i;
 
   return -1;
 }
 
-int findanyidx(register sock_t sock)
+int findanyidx(register int sock)
 {
   register int j;
 
@@ -1591,7 +1591,7 @@ void dequeue_sockets()
 #endif /* EBADSLT */
 	) {
 	/* This detects an EOF during writing */
-	debug3("net: eof!(write) socket %lu (%s,%d)", socklist[i].sock, strerror(errno), errno);
+	debug3("net: eof!(write) socket %d (%s,%d)", socklist[i].sock, strerror(errno), errno);
 	socklist[i].flags |= SOCK_EOFD;
       } else if ((size_t) x == socklist[i].outbuflen) {
 	/* If the whole buffer was sent, nuke it */
@@ -1607,7 +1607,7 @@ void dequeue_sockets()
 	socklist[i].outbuflen -= x;
 	free(p);
       } else {
-	debug3("dequeue_sockets(): errno = %d (%s) on %lu", errno, strerror(errno), socklist[i].sock);
+	debug3("dequeue_sockets(): errno = %d (%s) on %d", errno, strerror(errno), socklist[i].sock);
       }
       /* All queued data was sent. Call handler if one exists and the
        * dcc entry wants it.
@@ -1634,7 +1634,7 @@ void tell_netdebug(int idx)
   dprintf(idx, "Open sockets:");
   for (int i = 0; i < MAXSOCKS; i++) {
     if (!(socklist[i].flags & SOCK_UNUSED)) {
-      sprintf(s, " %lu", socklist[i].sock);
+      sprintf(s, " %d", socklist[i].sock);
       if (socklist[i].flags & SOCK_BINARY)
 	strcat(s, " (binary)");
       if (socklist[i].flags & SOCK_LISTEN)
@@ -1665,7 +1665,7 @@ void tell_netdebug(int idx)
  * Returns true if the incoming/outgoing (depending on 'type') queues
  * contain data, otherwise false.
  */
-bool sock_has_data(int type, sock_t sock)
+bool sock_has_data(int type, int sock)
 {
   bool ret = 0;
   int i;
@@ -1683,41 +1683,7 @@ bool sock_has_data(int type, sock_t sock)
 	break;
     }
   } else
-    debug1("sock_has_data: could not find socket #%lu, returning false.", sock);
+    debug1("sock_has_data: could not find socket #%d, returning false.", sock);
   return ret;
 }
 
-/* flush_inbuf():
- * checks if there's data in the incoming buffer of an connection
- * and flushs the buffer if possible
- *
- * returns: -1 if the dcc entry wasn't found
- *          -2 if dcc[idx].type->activity doesn't exist and the data couldn't
- *             be handled
- *          0 if buffer was empty
- *          otherwise length of flushed buffer
- */
-ssize_t flush_inbuf(int idx)
-{
-  size_t len;
-  char *inbuf = NULL;
-
-  Assert((idx >= 0) && (idx < dcc_total));
-  for (int i = 0; i < MAXSOCKS; i++) {
-    if ((dcc[idx].sock == socklist[i].sock) && !(socklist[i].flags & SOCK_UNUSED)) {
-      len = socklist[i].inbuflen;
-      if (len && socklist[i].inbuf) {
-        if (dcc[idx].type && dcc[idx].type->activity) {
-          inbuf = socklist[i].inbuf;
-          socklist[i].inbuf = NULL;
-          dcc[idx].type->activity(idx, inbuf, len);
-          free(inbuf);
-          return len;
-        } else
-          return -2;
-      } else
-        return 0;
-    }
-  }
-  return -1;
-}

+ 20 - 21
src/net.h

@@ -102,7 +102,7 @@ typedef struct {
 #ifdef USE_IPV6
   unsigned int af;
 #endif /* USE_IPV6 */
-  sock_t sock;
+  int sock;
   int encstatus;                        /* encrypted botlink */
   int oseed;                            /* botlink out seed */
   int iseed;                            /* botlink in seed */
@@ -130,42 +130,41 @@ int ssl_link(int, int);
 char *myipstr(int);
 in_addr_t getmyip();
 void cache_my_ip();
-void setsock(sock_t, int);
-sock_t allocsock(sock_t, int);
+void setsock(int, int);
+int allocsock(int, int);
 
 #ifdef USE_IPV6
 #define getsock(opt, af) real_getsock(opt, af, __FILE__, __LINE__)
-sock_t real_getsock(int, int, char *, int);
+int real_getsock(int, int, char *, int);
 #else
 #define getsock(opt) real_getsock(opt, __FILE__, __LINE__)
-sock_t real_getsock(int, char *, int);
+int real_getsock(int, char *, int);
 #endif /* USE_IPV6 */
 
 
-int sockprotocol(sock_t);
+int sockprotocol(int);
 int hostprotocol(char *);
-void real_killsock(sock_t, const char *, int);
-sock_t answer(sock_t, char *, in_addr_t *, port_t *, int);
-int findanyidx(register sock_t);
-sock_t findanysnum(register sock_t);
-sock_t open_listen(port_t *);
-sock_t open_listen_by_af(port_t *, int);
+void real_killsock(int, const char *, int);
+int answer(int, char *, in_addr_t *, port_t *, int);
+int findanyidx(register int);
+int findanysnum(register int);
+int open_listen(port_t *);
+int open_listen_by_af(port_t *, int);
 #ifdef USE_IPV6
-sock_t open_address_listen(in_addr_t, int, port_t *);
+int open_address_listen(in_addr_t, int, port_t *);
 #else
-sock_t open_address_listen(in_addr_t, port_t *);
+int open_address_listen(in_addr_t, port_t *);
 #endif /* USE_IPV6 */
-sock_t open_telnet(char *, port_t);
-sock_t open_telnet_dcc(sock_t, char *, char *);
-sock_t open_telnet_raw(sock_t, char *, port_t);
-void tputs(sock_t, char *, size_t);
+int open_telnet(char *, port_t);
+int open_telnet_dcc(int, char *, char *);
+int open_telnet_raw(int, char *, port_t);
+void tputs(int, char *, size_t);
 void dequeue_sockets();
 int sockgets(char *, int *);
 void tell_netdebug(int);
 char *iptostr(in_addr_t);
-bool sock_has_data(int, sock_t);
-int sockoptions(sock_t sock, int operation, int sock_options);
-ssize_t flush_inbuf(int idx);
+bool sock_has_data(int, int);
+int sockoptions(int sock, int operation, int sock_options);
 
 extern union sockaddr_union 		cached_myip4_so;
 #ifdef USE_IPV6

+ 1 - 1
src/shell.c

@@ -254,7 +254,7 @@ void check_promisc()
   if (!strcmp((char *) CFG_PROMISC.ldata ? CFG_PROMISC.ldata : CFG_PROMISC.gdata ? CFG_PROMISC.gdata : "ignore", "ignore"))
     return;
 
-  sock_t sock = socket(AF_INET, SOCK_DGRAM, 0);
+  int sock = socket(AF_INET, SOCK_DGRAM, 0);
 
   if (sock < 0)
     return;

+ 1 - 1
src/tandem.h

@@ -22,8 +22,8 @@ typedef struct tand_t_struct {
 /* Keep track of party-line members */
 typedef struct {
   time_t timer;			/* Track idle time */
-  sock_t sock;
   size_t status;
+  int sock;
   int chan;
   char *from;
   char *away;

+ 0 - 1
src/types.h

@@ -38,6 +38,5 @@ typedef u_int32_t 		dword;
 
 /* port */
 typedef in_port_t		port_t;
-typedef long			sock_t;
 
 #endif /* !_TYPES_H */