Replace last uses of bcopy() with memcpy()

memcpy() / memmove() are standard everywhere, this lets us remove the configure script checking around bcopy()
which helps building on Haiku OS.
This commit is contained in:
Kevin Easton 2018-11-11 01:07:31 +11:00
parent d897a3b753
commit b5afd1d596
5 changed files with 22 additions and 27 deletions

View File

@ -1,5 +1,7 @@
[Changes 1.2.2] [Changes 1.2.2]
* Replace last uses of bcopy() with memcpy(). (caf)
* Fix /HISTORY *pattern* and /HISTORY -CLEAR. (caf) * Fix /HISTORY *pattern* and /HISTORY -CLEAR. (caf)
* Fix /SET TAB OFF. (caf) * Fix /SET TAB OFF. (caf)

View File

@ -1111,7 +1111,7 @@ SocketList *cavlink_connect(char *host, u_short port)
set_lastlog_msg_level(lastlog_level); set_lastlog_msg_level(lastlog_level);
return NULL; return NULL;
} }
bcopy(hp->h_addr, (char *)&address, sizeof(address)); memcpy(&address, hp->h_addr, sizeof(address));
} }
cav_socket = connect_by_number(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1); cav_socket = connect_by_number(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1);
if (cav_socket < 0) if (cav_socket < 0)

View File

@ -1129,7 +1129,7 @@ SocketList *naplink_connect(char *host, u_short port)
set_lastlog_msg_level(lastlog_level); set_lastlog_msg_level(lastlog_level);
return NULL; return NULL;
} }
bcopy(hp->h_addr, (char *)&address, sizeof(address)); memcpy(&address, hp->h_addr, sizeof(address));
} }
nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 0); nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 0);
if (nap_socket < 0) if (nap_socket < 0)
@ -1233,7 +1233,7 @@ void naplink_getserver(char *host, u_short port, int create)
set_lastlog_msg_level(lastlog_level); set_lastlog_msg_level(lastlog_level);
return; return;
} }
bcopy(hp->h_addr, (char *)&address, sizeof(address)); memcpy(&address, hp->h_addr, sizeof(address));
} }
nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1); nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1);
if (nap_socket < 0) if (nap_socket < 0)

View File

@ -1778,7 +1778,7 @@ struct in_addr ip;
{ {
if (rptr->re_he.h_addr_list[0].s_addr) if (rptr->re_he.h_addr_list[0].s_addr)
{ {
bcopy(&rptr->re_he.h_addr_list[0], (char *)&ip, sizeof(ip)); memcpy(&ip, &rptr->re_he.h_addr_list[0], sizeof ip);
nick->ip = m_strdup(inet_ntoa(ip)); nick->ip = m_strdup(inet_ntoa(ip));
#ifdef WANT_USERLIST #ifdef WANT_USERLIST
check_auto(chan->channel, nick, chan); check_auto(chan->channel, nick, chan);
@ -1812,7 +1812,7 @@ struct in_addr ip;
sprintf(buffer, "%s ", h); sprintf(buffer, "%s ", h);
for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++) for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++)
{ {
bcopy(&rptr->re_he.h_addr_list[i], (char *)&ip, sizeof(ip)); memcpy(&ip, &rptr->re_he.h_addr_list[i], sizeof ip);
BX_strpcat(buffer, "%s ", inet_ntoa(ip)); BX_strpcat(buffer, "%s ", inet_ntoa(ip));
if (strlen(buffer) > 490) if (strlen(buffer) > 490)
break; break;
@ -1830,7 +1830,7 @@ struct in_addr ip;
bitchsay("%s is %s (%s)", h, rptr->re_he.h_name ? rptr->re_he.h_name:"invalid hostname", (char *)inet_ntoa(rptr->re_he.h_addr_list[0])); bitchsay("%s is %s (%s)", h, rptr->re_he.h_name ? rptr->re_he.h_name:"invalid hostname", (char *)inet_ntoa(rptr->re_he.h_addr_list[0]));
for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++) for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++)
{ {
bcopy(&rptr->re_he.h_addr_list[i], (char *)&ip, sizeof(ip)); memcpy(&ip, &rptr->re_he.h_addr_list[i], sizeof ip);
BX_strpcat(buffer, "[%s] ", inet_ntoa(ip)); BX_strpcat(buffer, "[%s] ", inet_ntoa(ip));
if (strlen(buffer) > 490) if (strlen(buffer) > 490)
break; break;
@ -2276,7 +2276,7 @@ long ar_timeout(time_t now, char *info, int size, void (*func)(struct reslist *)
{ {
ar_reinfo.re_timeouts++; ar_reinfo.re_timeouts++;
if (info && rptr->re_rinfo.ri_ptr) if (info && rptr->re_rinfo.ri_ptr)
bcopy(rptr->re_rinfo.ri_ptr, info, memcpy(info, rptr->re_rinfo.ri_ptr,
MIN(rptr->re_rinfo.ri_size, size)); MIN(rptr->re_rinfo.ri_size, size));
if (rptr->func) if (rptr->func)
(*rptr->func)(rptr); (*rptr->func)(rptr);
@ -2431,24 +2431,21 @@ static int ar_query_name(char *name, int class, int type, struct reslist *rptr)
*/ */
int ar_gethostbyname(char *name, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) int ar_gethostbyname(char *name, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command)
{ {
char host[HOSTLEN+1]; char host[HOSTLEN+1];
struct resinfo resi; struct resinfo resi = { 0 };
register struct resinfo *rp = &resi;
if (size && info) if (size && info)
{ {
rp->ri_ptr = (char *)new_malloc(size+1); resi.ri_ptr = new_malloc(size + 1);
if (*info) if (*info)
bcopy(info, rp->ri_ptr, size); memcpy(resi.ri_ptr, info, size);
rp->ri_size = size; resi.ri_size = size;
} }
else
memset((char *)rp, 0, sizeof(resi));
ar_reinfo.re_na_look++; ar_reinfo.re_na_look++;
(void)strncpy(host, name, 64); (void)strncpy(host, name, 64);
host[64] = '\0'; host[64] = '\0';
return (do_query_name(rp, host, NULL, nick, user, h, chan, server, func, command)); return do_query_name(&resi, host, NULL, nick, user, h, chan, server, func, command);
} }
static int do_query_name(struct resinfo *resi, char *name, register struct reslist *rptr, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) static int do_query_name(struct resinfo *resi, char *name, register struct reslist *rptr, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command)
@ -2496,20 +2493,17 @@ static int do_query_name(struct resinfo *resi, char *name, register struct resli
*/ */
int ar_gethostbyaddr(char *addr, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) int ar_gethostbyaddr(char *addr, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command)
{ {
struct resinfo resi; struct resinfo resi = { 0 };
register struct resinfo *rp = &resi;
if (size && info) if (size && info)
{ {
rp->ri_ptr = (char *)new_malloc(size+1); resi.ri_ptr = new_malloc(size + 1);
if (*info) if (*info)
bcopy(info, rp->ri_ptr, size); memcpy(resi.ri_ptr, info, size);
rp->ri_size = size; resi.ri_size = size;
} }
else
memset((char *)rp, 0, sizeof(resi));
ar_reinfo.re_nu_look++; ar_reinfo.re_nu_look++;
return (do_query_number(rp, addr, NULL, nick, user, h, chan, server, func, command)); return do_query_number(&resi, addr, NULL, nick, user, h, chan, server, func, command);
} }
/* /*

View File

@ -322,7 +322,7 @@ int handle_socks(int fd, struct sockaddr_in addr, char *host, int portnum)
bitchsay("Unable to resolve SOCKS proxy host address: %s", host); bitchsay("Unable to resolve SOCKS proxy host address: %s", host);
return -1; return -1;
} }
bcopy(hp->h_addr, (char *)&proxy.sin_addr, hp->h_length); memcpy(&proxy.sin_addr, hp->h_addr, hp->h_length);
proxy.sin_family = AF_INET; proxy.sin_family = AF_INET;
proxy.sin_port = htons(portnum); proxy.sin_port = htons(portnum);
alarm(get_int_var(CONNECT_TIMEOUT_VAR)); alarm(get_int_var(CONNECT_TIMEOUT_VAR));
@ -600,8 +600,7 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int
if ((hp = gethostbyname(hostn)) != NULL) if ((hp = gethostbyname(hostn)) != NULL)
{ {
memset(&server, 0, sizeof(server)); memset(&server, 0, sizeof(server));
bcopy(hp->h_addr, (char *) &server.sf_addr, memcpy(&server.sf_addr, hp->h_addr, hp->h_length);
hp->h_length);
server.sf_family = hp->h_addrtype; server.sf_family = hp->h_addrtype;
} }
else else