From 55290e53567293cdd3a6753444d0f62968936a7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Remco=20R=C4=B3nders?= Date: Sat, 7 Mar 2026 12:17:36 -0500 Subject: [PATCH] CLEANUP: Modernize C idioms (register, bzero/bcopy/bcmp, index/rindex, errno) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Remove 'register' keyword (33 occurrences) — modern compilers ignore it - Replace bzero/bcopy/bcmp with memset/memcpy/memcmp (110 occurrences) - Replace index/rindex with strchr/strrchr (85 occurrences) - Remove 'extern int errno' declarations (3 files) — provided by errno.h Co-Authored-By: Claude Opus 4.6 --- src/bsd.c | 2 -- src/channel.c | 30 +++++++++++++------------- src/chkconf.c | 18 ++++++++-------- src/dbuf.c | 12 +++++------ src/hash.c | 20 ++++++++--------- src/ircd.c | 4 ++-- src/list.c | 20 ++++++++--------- src/packet.c | 6 +++--- src/parse.c | 14 ++++++------ src/res.c | 51 ++++++++++++++++++++------------------------ src/s_bsd.c | 54 +++++++++++++++++++--------------------------- src/s_conf.c | 38 ++++++++++++++++----------------- src/s_misc.c | 22 +++++++++---------- src/s_ping.c | 20 +++++++---------- src/s_serv.c | 28 ++++++++++++------------ src/s_user.c | 40 +++++++++++++++++----------------- src/s_zip.c | 8 +++---- src/send.c | 8 +++---- src/support.c | 58 ++++++++++++++++++++++++-------------------------- src/userload.c | 22 +++++++++---------- src/whowas.c | 4 ++-- 21 files changed, 228 insertions(+), 251 deletions(-) diff --git a/src/bsd.c b/src/bsd.c index c6ee069..c292457 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -28,8 +28,6 @@ #include #include -extern int errno; - #ifdef DEBUGMODE int writecalls = 0, writeb[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #endif diff --git a/src/channel.c b/src/channel.c index e6bba4e..2cbc90f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -138,7 +138,7 @@ static int add_banid (cptr, chptr, banid) } ban = make_ban (); - bzero ((char *) ban, sizeof (Ban)); + memset ((char *) ban, 0, sizeof (Ban)); /* ban->flags = CHFL_BAN; They're all bans!! */ ban->next = chptr->banlist; ban->banstr = (char *) MyMalloc (strlen (banid) + 1); @@ -225,7 +225,7 @@ static int add_exbanid (cptr, chptr, banid) } ban = make_ban (); - bzero ((char *) ban, sizeof (Ban)); + memset ((char *) ban, 0, sizeof (Ban)); /* ban->flags = CHFL_BAN; They're all bans!! */ ban->next = chptr->exbanlist; ban->banstr = (char *) MyMalloc (strlen (banid) + 1); @@ -306,7 +306,7 @@ static int add_hostrestrictid (cptr, chptr, banid) } ban = make_ban (); - bzero ((char *) ban, sizeof (Ban)); + memset ((char *) ban, 0, sizeof (Ban)); /* ban->flags = CHFL_BAN; They're all bans!! */ ban->next = chptr->hostrestrictlist; ban->banstr = (char *) MyMalloc (strlen (banid) + 1); @@ -1202,14 +1202,14 @@ char *pretty_mask (mask) char *user; char *host; - if ((user = index ((cp = mask), '!'))) + if ((user = strchr ((cp = mask), '!'))) *user++ = '\0'; - if ((host = rindex (user ? user : cp, '@'))) { + if ((host = strrchr (user ? user : cp, '@'))) { *host++ = '\0'; if (!user) return make_nick_user_host (NULL, cp, host); } - else if (!user && index (cp, '.')) + else if (!user && strchr (cp, '.')) return make_nick_user_host (NULL, NULL, cp); return make_nick_user_host (cp, user, host); } @@ -1260,7 +1260,7 @@ static int set_mode (cptr, sptr, chptr, parc, parv, mbuf, pbuf, badop, sadmin) if (parc < 1) return 0; mode = &(chptr->mode); - bcopy ((char *) mode, (char *) &oldm, sizeof (Mode)); + memcpy ((char *) &oldm, (char *) mode, sizeof (Mode)); /* Mode is accepted when sptr is a channel operator * but also when the mode is received from a server. --Run */ @@ -1687,7 +1687,7 @@ static int set_mode (cptr, sptr, chptr, parc, parv, mbuf, pbuf, badop, sadmin) } *bmbuf++ = 'l'; (void) sprintf (numeric, "%-15d", mode->limit); - if ((cp = index (numeric, ' '))) + if ((cp = strchr (numeric, ' '))) *cp = '\0'; (void) strcat (bpbuf, numeric); blen += strlen (numeric); @@ -1767,7 +1767,7 @@ static int set_mode (cptr, sptr, chptr, parc, parv, mbuf, pbuf, badop, sadmin) case MODE_LIMIT: c = 'l'; (void) sprintf (numeric, "%-15d", nusers); - if ((cp = index (numeric, ' '))) + if ((cp = strchr (numeric, ' '))) *cp = '\0'; cp = numeric; break; @@ -1838,7 +1838,7 @@ static int set_mode (cptr, sptr, chptr, parc, parv, mbuf, pbuf, badop, sadmin) bwhatt = MODE_ADD; } (void) sprintf (numeric, "%-15d", mode->limit); - if ((cp = index (numeric, ' '))) + if ((cp = strchr (numeric, ' '))) *cp = '\0'; (void) strcat (bpbuf, numeric); blen += strlen (numeric); @@ -2152,7 +2152,7 @@ static int check_channelmask (sptr, cptr, chname) if (*chname == '&' && IsServer (cptr)) return -1; - s = rindex (chname, ':'); + s = strrchr (chname, ':'); if (!s) return 0; @@ -2190,7 +2190,7 @@ static aChannel *get_channel (cptr, chname, flag) return (chptr); if (flag == CREATE) { chptr = (aChannel *) MyMalloc (sizeof (aChannel) + len); - bzero ((char *) chptr, sizeof (aChannel)); + memset ((char *) chptr, 0, sizeof (aChannel)); strncpyzt (chptr->chname, chname, len + 1); if (channel) channel->prevch = chptr; @@ -3953,7 +3953,7 @@ int m_list (cptr, sptr, parc, parv) * Changed to default to ignoring channels with only * 1 person on, to decrease floods... -Donwulff */ - bzero (lopt, sizeof (LOpts)); /* To be sure! */ + memset (lopt, 0, sizeof (LOpts)); /* To be sure! */ lopt->next = (LOpts *) NULL; lopt->yeslist = lopt->nolist = (Link *) NULL; lopt->usermin = 0; /* Default */ @@ -4224,7 +4224,7 @@ int m_names (cptr, sptr, parc, parv) cptr->flags2 |= FLAGS2_HTC; /* To prevent a dead socket */ if (!BadPtr (para)) { - s = index (para, ','); + s = strchr (para, ','); if (s) { parv[1] = ++s; (void) m_names (cptr, sptr, parc, parv); @@ -4373,7 +4373,7 @@ void send_user_joins (cptr, user) for (lp = user->user->channel; lp; lp = lp->next) { chptr = lp->value.chptr; - if ((mask = index (chptr->chname, ':'))) + if ((mask = strchr (chptr->chname, ':'))) if (match (++mask, cptr->name)) continue; if (*chptr->chname == '&') diff --git a/src/chkconf.c b/src/chkconf.c index 79eb84a..0ad7f77 100644 --- a/src/chkconf.c +++ b/src/chkconf.c @@ -27,7 +27,7 @@ #undef free #define MyMalloc(x) malloc(x) -#define Reg register +#define Reg static void new_class (); static char *getfield (), confchar (); @@ -147,11 +147,11 @@ static aConfItem *initconf (opt) aconf->passwd = (char *) NULL; aconf->name = (char *) NULL; aconf->class = (aClass *) NULL; - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = 0; else while (dgets (fd, c, sizeof (c) - 1)) - if ((tmp = (char *) index (c, '\n'))) { + if ((tmp = (char *) strchr (c, '\n'))) { *tmp = 0; break; } @@ -388,7 +388,7 @@ static aConfItem *initconf (opt) if (!aconf->host) (void) fprintf (stderr, "\tERROR: %s\n", "null host field in P-line"); - else if (index (aconf->host, '/')) + else if (strchr (aconf->host, '/')) (void) fprintf (stderr, "%u:\tWARNING: / present in P-line " "UNIXPORT configuration no longer supported\n", @@ -397,8 +397,8 @@ static aConfItem *initconf (opt) goto print_confline; } if (aconf->status & CONF_SERVER_MASK && - (!aconf->host || index (aconf->host, '*') || - index (aconf->host, '?'))) { + (!aconf->host || strchr (aconf->host, '*') || + strchr (aconf->host, '?'))) { (void) fprintf (stderr, "\tERROR: bad host field\n"); continue; } @@ -411,7 +411,7 @@ static aConfItem *initconf (opt) continue; } if (aconf->status & (CONF_SERVER_MASK | CONF_OPS)) - if (!index (aconf->host, '@')) { + if (!strchr (aconf->host, '@')) { char *newhost; int len = 3; /* *@\0 = 3 */ @@ -500,9 +500,9 @@ static char *getfield (newline) return (NULL); field = line; - if ((end = (char *) index (line, ':')) == NULL) { + if ((end = (char *) strchr (line, ':')) == NULL) { line = NULL; - if ((end = (char *) index (field, '\n')) == NULL) + if ((end = (char *) strchr (field, '\n')) == NULL) end = field + strlen (field); } else diff --git a/src/dbuf.c b/src/dbuf.c index 12cf515..813beda 100644 --- a/src/dbuf.c +++ b/src/dbuf.c @@ -136,7 +136,7 @@ int dbuf_put (dyn, buf, length) } if (chunk > length) chunk = length; - bcopy (buf, d->data + off, chunk); + memcpy (d->data + off, buf, chunk); length -= chunk; buf += chunk; off = 0; @@ -204,7 +204,7 @@ int dbuf_get (dyn, buf, length) while (length > 0 && (b = dbuf_map (dyn, &chunk)) != NULL) { if (chunk > length) chunk = length; - bcopy (b, buf, (int) chunk); + memcpy (buf, b, (int) chunk); (void) dbuf_delete (dyn, chunk); buf += chunk; length -= chunk; @@ -223,12 +223,12 @@ int dbuf_get (dyn, buf, length) int dbuf_getmsg (dyn, buf, length) dbuf *dyn; char *buf; - register int length; + int length; { dbufbuf *d; - register char *s; - register int dlen; - register int i; + char *s; + int dlen; + int i; int copy; getmsg_init: diff --git a/src/hash.c b/src/hash.c index c816831..3d7aed9 100644 --- a/src/hash.c +++ b/src/hash.c @@ -28,7 +28,7 @@ /* Quick & dirty inline version of mycmp for hash-tables -Donwulff */ #define thecmp(str1, str2, where) { \ - register char *st1=str1, *st2=str2; \ + char *st1=str1, *st2=str2; \ while (tolower(*st1)==tolower(*st2)) \ { \ if (!*st1) goto where; \ @@ -137,7 +137,7 @@ void clear_client_hash_table () (aHashEntry *) MyMalloc (HASHSIZE * sizeof (aHashEntry)); #endif /* DEBUGMODE */ - bzero ((char *) clientTable, sizeof (aHashEntry) * HASHSIZE); + memset ((char *) clientTable, 0, sizeof (aHashEntry) * HASHSIZE); } void clear_channel_hash_table () @@ -149,12 +149,12 @@ void clear_channel_hash_table () channelTable = (aHashEntry *) MyMalloc (CHANNELHASHSIZE * sizeof (aHashEntry)); #endif /* DEBUGMODE */ - bzero ((char *) channelTable, sizeof (aHashEntry) * CHANNELHASHSIZE); + memset ((char *) channelTable, 0, sizeof (aHashEntry) * CHANNELHASHSIZE); } void clear_notify_hash_table (void) { - bzero ((char *) notifyTable, sizeof (notifyTable)); + memset ((char *) notifyTable, 0, sizeof (notifyTable)); } /* @@ -722,7 +722,7 @@ aClient *hash_find_nickserver (name, cptr) int hashv; char *serv; - serv = index (name, '@'); + serv = strchr (name, '@'); *serv++ = '\0'; hashv = hash_nn_name (name) % HASHSIZE; @@ -909,7 +909,7 @@ aChannel *hash_find_channel (name, chptr) c_move_to_top: chhits++; if (prv) { - register aChannel *tmp2; + aChannel *tmp2; tmp2 = (aChannel *) tmp3->list; tmp3->list = (void *) tmp; @@ -923,7 +923,7 @@ aChannel *hash_find_channel (name, chptr) return chptr; c_move_to_top: if (prv) { - register aChannel *tmp2; + aChannel *tmp2; tmp2 = (aChannel *) channelTable[hashv]; channelTable[hashv] = (void *) tmp; @@ -948,8 +948,8 @@ int m_hash (cptr, sptr, parc, parv) char *parv[]; { #ifdef DEBUGMODE - register int l, i; - register aHashEntry *tab; + int l, i; + aHashEntry *tab; int deepest = 0, deeplink = 0, showlist = 0, tothits = 0; int mosthit = 0, mosthits = 0, used = 0, used_now = 0, totlink = 0; int link_pop[10], size = HASHSIZE; @@ -1024,7 +1024,7 @@ int m_hash (cptr, sptr, parc, parv) case 'V': case 'v': { - register aClient *acptr; + aClient *acptr; int bad = 0, listlength = 0; for (acptr = client; acptr; acptr = acptr->next) { diff --git a/src/ircd.c b/src/ircd.c index 33fd9fd..cd6ceab 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -94,7 +94,7 @@ void s_die () int fd; char buff[20]; if ((fd = open (LUSERS, O_CREAT | O_WRONLY, 0600)) >= 0) { - bzero (buff, sizeof (buff)); + memset (buff, 0, sizeof (buff)); (void) sprintf (buff, "%i %i\n", lu_mglobalu, lu_mlu); if (write (fd, buff, strlen (buff)) == -1) (void) close (fd); @@ -445,7 +445,7 @@ int main (argc, argv) myargv = argv; (void) umask (077); /* better safe than sorry --SRB */ - bzero ((char *) &me, sizeof (me)); + memset ((char *) &me, 0, sizeof (me)); setup_signals (); initload (); diff --git a/src/list.c b/src/list.c index e29c5ab..9402650 100644 --- a/src/list.c +++ b/src/list.c @@ -48,13 +48,13 @@ int numclients = 0; void initlists () { #ifdef DEBUGMODE - bzero ((char *) &cloc, sizeof (cloc)); - bzero ((char *) &crem, sizeof (crem)); - bzero ((char *) &users, sizeof (users)); - bzero ((char *) &servs, sizeof (servs)); - bzero ((char *) &links, sizeof (links)); - bzero ((char *) &classs, sizeof (classs)); - bzero ((char *) &aconfs, sizeof (aconfs)); + memset ((char *) &cloc, 0, sizeof (cloc)); + memset ((char *) &crem, 0, sizeof (crem)); + memset ((char *) &users, 0, sizeof (users)); + memset ((char *) &servs, 0, sizeof (servs)); + memset ((char *) &links, 0, sizeof (links)); + memset ((char *) &classs, 0, sizeof (classs)); + memset ((char *) &aconfs, 0, sizeof (aconfs)); #endif } @@ -90,7 +90,7 @@ aClient *make_client (from, servr) if (!(cptr = (aClient *) MyMalloc (size))) outofmemory (); - bzero ((char *) cptr, (int) size); + memset ((char *) cptr, 0, (int) size); #ifdef DEBUGMODE if (size == CLIENT_LOCAL_SIZE) @@ -483,7 +483,7 @@ aConfItem *make_conf () #ifdef DEBUGMODE aconfs.inuse++; #endif - bzero ((char *) &aconf->ipnum, sizeof (struct in_addr)); + memset ((char *) &aconf->ipnum, 0, sizeof (struct in_addr)); aconf->next = NULL; aconf->host = aconf->passwd = aconf->name = NULL; aconf->status = CONF_ILLEGAL; @@ -533,7 +533,7 @@ void free_conf (aconf) del_queries ((char *) aconf); MyFree (aconf->host); if (aconf->passwd) - bzero (aconf->passwd, strlen (aconf->passwd)); + memset (aconf->passwd, 0, strlen (aconf->passwd)); MyFree (aconf->passwd); MyFree (aconf->name); MyFree ((char *) aconf); diff --git a/src/packet.c b/src/packet.c index 35abaf6..c844ffb 100644 --- a/src/packet.c +++ b/src/packet.c @@ -62,8 +62,8 @@ int dopacket (cptr, buffer, length) char *buffer; int length; { - register char *ch1; - register char *ch2; + char *ch1; + char *ch2; int zipped = 0; int unzipped_length = 0; @@ -121,7 +121,7 @@ int dopacket (cptr, buffer, length) #endif while (--length >= 0 && ch2) { - register char g = (*ch1 = *ch2++); + char g = (*ch1 = *ch2++); /* * Yuck. Stuck. To make sure we stay backward compatible, * we must assume that either CR or LF terminates the message diff --git a/src/parse.c b/src/parse.c index 548fcdc..66823d3 100644 --- a/src/parse.c +++ b/src/parse.c @@ -94,14 +94,14 @@ aClient *find_name (char *name, aClient *cptr) if ((c2ptr = hash_find_server (name, cptr))) return (c2ptr); - if (!index (name, '*')) + if (!strchr (name, '*')) return c2ptr; for (c2ptr = client; c2ptr; c2ptr = c2ptr->next) { if (!IsServer (c2ptr) && !IsMe (c2ptr)) continue; if (match (name, c2ptr->name) == 0) break; - if (index (c2ptr->name, '*')) + if (strchr (c2ptr->name, '*')) if (match (c2ptr->name, name) == 0) break; } @@ -188,7 +188,7 @@ int parse (aClient *cptr, char *buffer, char *bufend, struct Message *mptr) from = find_client (sender, (aClient *) NULL); if (!from || match (from->name, sender)) from = find_server (sender, (aClient *) NULL); - else if (!from && index (sender, '@')) + else if (!from && strchr (sender, '@')) from = find_nickserv (sender, (aClient *) NULL); para[0] = sender; @@ -232,7 +232,7 @@ int parse (aClient *cptr, char *buffer, char *bufend, struct Message *mptr) ** numerics must have paramters and thus a space after the command ** code. -avalon */ - s = (char *) index (ch, ' '); /* s -> End of the command code */ + s = (char *) strchr (ch, ' '); /* s -> End of the command code */ len = (s) ? (s - ch) : 0; if (len == 3 && isdigit (*ch) && isdigit (*(ch + 1)) && isdigit (*(ch + 2))) { @@ -394,9 +394,9 @@ char *getfield (char *newline) return (NULL); field = line; - if ((end = (char *) index (line, ':')) == NULL) { + if ((end = (char *) strchr (line, ':')) == NULL) { line = NULL; - if ((end = (char *) index (field, '\n')) == NULL) + if ((end = (char *) strchr (field, '\n')) == NULL) end = field + strlen (field); } else @@ -449,7 +449,7 @@ static void remove_unknown (aClient *cptr, char *sender) * Do kill if it came from a server because it means there is a ghost * user on the other server which needs to be removed. -avalon */ - if (!index (sender, '.')) + if (!strchr (sender, '.')) sendto_one (cptr, ":%s KILL %s :%s (%s(?) <- %s)", me.name, sender, me.name, sender, get_client_name (cptr, FALSE)); diff --git a/src/res.c b/src/res.c index 5f83e55..bd2a80e 100644 --- a/src/res.c +++ b/src/res.c @@ -23,7 +23,6 @@ #undef DEBUG /* because there is a lot of debug code in here :-) */ -extern int errno, h_errno; extern int highest_fd; extern aClient *local[]; @@ -82,7 +81,7 @@ int init_resolver (op) int ret = 0; if (op & RES_INITLIST) { - bzero ((char *) &reinfo, sizeof (reinfo)); + memset ((char *) &reinfo, 0, sizeof (reinfo)); first = last = NULL; } if (op & RES_CALLINIT) { @@ -104,8 +103,8 @@ int init_resolver (op) _res.options |= RES_DEBUG; #endif if (op & RES_INITCACH) { - bzero ((char *) &cainfo, sizeof (cainfo)); - bzero ((char *) hashtable, sizeof (hashtable)); + memset ((char *) &cainfo, 0, sizeof (cainfo)); + memset ((char *) hashtable, 0, sizeof (hashtable)); } if (op == 0) ret = resfd; @@ -171,16 +170,16 @@ static ResRQ *make_request (Link *lp) ResRQ *nreq; nreq = (ResRQ *) MyMalloc (sizeof (ResRQ)); - bzero ((char *) nreq, sizeof (ResRQ)); + memset ((char *) nreq, 0, sizeof (ResRQ)); nreq->next = NULL; /* where NULL is non-zero ;) */ nreq->sentat = time (NULL); nreq->retries = 3; nreq->resend = 1; nreq->srch = -1; if (lp) - bcopy ((char *) lp, (char *) &nreq->cinfo, sizeof (Link)); + memcpy ((char *) &nreq->cinfo, (char *) lp, sizeof (Link)); else - bzero ((char *) &nreq->cinfo, sizeof (Link)); + memset ((char *) &nreq->cinfo, 0, sizeof (Link)); nreq->timeout = 4; /* start at 4 and exponential inc. */ nreq->he.h_addrtype = AF_INET; nreq->he.h_name = NULL; @@ -348,7 +347,7 @@ static int do_query_name (Link *lp, char *name, ResRQ *rptr) (void) strncpy (hname, name, sizeof (hname) - 1); len = strlen (hname); - if (rptr && !index (hname, '.') && _res.options & RES_DEFNAMES) { + if (rptr && !strchr (hname, '.') && _res.options & RES_DEFNAMES) { (void) strncat (hname, dot, sizeof (hname) - len - 1); len++; (void) strncat (hname, _res.defdname, sizeof (hname) - len - 1); @@ -382,8 +381,7 @@ static int do_query_number (Link *lp, struct in_addr *numb, ResRQ *rptr) rptr = make_request (lp); rptr->type = T_PTR; rptr->addr.s_addr = numb->s_addr; - bcopy ((char *) &numb->s_addr, - (char *) &rptr->he.h_addr, sizeof (struct in_addr)); + memcpy ((char *) &rptr->he.h_addr, (char *) &numb->s_addr, sizeof (struct in_addr)); rptr->he.h_length = sizeof (struct in_addr); } return (query_name (ipbuf, C_IN, T_PTR, rptr)); @@ -400,7 +398,7 @@ static int query_name (char *name, int class, int type, ResRQ *rptr) HEADER *hptr; Debug ((DEBUG_DNS, "query_name: na %s cl %d ty %d", name, class, type)); - bzero (buf, sizeof (buf)); + memset (buf, 0, sizeof (buf)); r = res_mkquery (QUERY, name, class, type, NULL, 0, NULL, buf, sizeof (buf)); if (r <= 0) { @@ -487,7 +485,7 @@ static int proc_answer (ResRQ *rptr, HEADER *hptr, char *buf, char *eob) len = strlen (hostbuf); /* name server never returns with trailing '.' */ - if (!index (hostbuf, '.') && (_res.options & RES_DEFNAMES)) { + if (!strchr (hostbuf, '.') && (_res.options & RES_DEFNAMES)) { (void) strcat (hostbuf, dot); len++; (void) strncat (hostbuf, _res.defdname, @@ -499,7 +497,7 @@ static int proc_answer (ResRQ *rptr, HEADER *hptr, char *buf, char *eob) hp->h_length = dlen; if (ans == 1) hp->h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; - bcopy (cp, (char *) &dr, dlen); + memcpy ((char *) &dr, cp, dlen); adr->s_addr = dr.s_addr; Debug ((DEBUG_INFO, "got ip # %s for %s", inetntoa ((char *) adr), hostbuf)); @@ -605,9 +603,7 @@ struct hostent *get_res (char *lp) for (a = 0; a < max; a++) if (!_res.nsaddr_list[a].sin_addr.s_addr || - !bcmp ((char *) &sin.sin_addr, - (char *) &_res.nsaddr_list[a].sin_addr, - sizeof (struct in_addr))) + !memcmp ((char *) &sin.sin_addr, (char *) &_res.nsaddr_list[a].sin_addr, sizeof (struct in_addr))) break; if (a == max) { reinfo.re_unkrep++; @@ -673,7 +669,7 @@ struct hostent *get_res (char *lp) */ if ((hp2 = gethost_byname (rptr->he.h_name, &rptr->cinfo))) if (lp) - bcopy ((char *) &rptr->cinfo, lp, sizeof (Link)); + memcpy (lp, (char *) &rptr->cinfo, sizeof (Link)); /* * If name wasn't found, a request has been queued and it will * be the last one queued. This is rather nasty way to keep @@ -691,7 +687,7 @@ struct hostent *get_res (char *lp) } if (a > 0) { if (lp) - bcopy ((char *) &rptr->cinfo, lp, sizeof (Link)); + memcpy (lp, (char *) &rptr->cinfo, sizeof (Link)); cp = make_cache (rptr); #ifdef DEBUG Debug ((DEBUG_INFO, "get_res:cp=%#x rptr=%#x (made)", cp, rptr)); @@ -723,7 +719,7 @@ struct hostent *get_res (char *lp) resend_query (rptr); } else if (lp) - bcopy ((char *) &rptr->cinfo, lp, sizeof (Link)); + memcpy (lp, (char *) &rptr->cinfo, sizeof (Link)); } return (struct hostent *) NULL; } @@ -876,7 +872,7 @@ static void update_list (ResRQ *rptr, aCache *cachep) for (s = (char *) &rptr->he.h_addr.s_addr; ((struct in_addr *) s)->s_addr; s += sizeof (struct in_addr)) { for (i = 0; (t = cp->he.h_addr_list[i]); i++) - if (!bcmp (s, t, sizeof (struct in_addr))) + if (!memcmp (s, t, sizeof (struct in_addr))) break; if (i >= MAXADDRS || addrcount >= MAXADDRS) break; @@ -907,7 +903,7 @@ static void update_list (ResRQ *rptr, aCache *cachep) t += sizeof (struct in_addr); } *base = NULL; - bcopy (s, *--base, sizeof (struct in_addr)); + memcpy (*--base, s, sizeof (struct in_addr)); } } return; @@ -973,7 +969,7 @@ static aCache *find_cache_number (ResRQ *rptr, char *numb) for (; cp; cp = cp->hnum_next) for (i = 0; cp->he.h_addr_list[i]; i++) - if (!bcmp (cp->he.h_addr_list[i], numb, sizeof (struct in_addr))) { + if (!memcmp (cp->he.h_addr_list[i], numb, sizeof (struct in_addr))) { cainfo.ca_nu_hits++; update_list (rptr, cp); return cp; @@ -992,7 +988,7 @@ static aCache *find_cache_number (ResRQ *rptr, char *numb) if (hashv == hash_number ((u_char *) cp->he.h_addr_list[0])) continue; for (i = 1; cp->he.h_addr_list[i]; i++) - if (!bcmp (cp->he.h_addr_list[i], numb, sizeof (struct in_addr))) { + if (!memcmp (cp->he.h_addr_list[i], numb, sizeof (struct in_addr))) { cainfo.ca_nu_hits++; update_list (rptr, cp); return cp; @@ -1029,7 +1025,7 @@ static aCache *make_cache (ResRQ *rptr) ** a matching entry wasnt found in the cache so go and make one up. */ cp = (aCache *) MyMalloc (sizeof (aCache)); - bzero ((char *) cp, sizeof (aCache)); + memset ((char *) cp, 0, sizeof (aCache)); hp = &cp->he; for (i = 0; i < MAXADDRS; i++) @@ -1040,15 +1036,14 @@ static aCache *make_cache (ResRQ *rptr) ** build two arrays, one for IP#'s, another of pointers to them. */ t = hp->h_addr_list = (char **) MyMalloc (sizeof (char *) * (i + 1)); - bzero ((char *) t, sizeof (char *) * (i + 1)); + memset ((char *) t, 0, sizeof (char *) * (i + 1)); s = (char *) MyMalloc (sizeof (struct in_addr) * i); - bzero (s, sizeof (struct in_addr) * i); + memset (s, 0, sizeof (struct in_addr) * i); for (n = 0; n < i; n++, s += sizeof (struct in_addr)) { *t++ = s; - bcopy ((char *) &(rptr->he.h_addr_list[n].s_addr), s, - sizeof (struct in_addr)); + memcpy (s, (char *) &(rptr->he.h_addr_list[n].s_addr), sizeof (struct in_addr)); } *t = (char *) NULL; diff --git a/src/s_bsd.c b/src/s_bsd.c index 85ee7f8..e79d9b6 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -85,7 +85,7 @@ void add_local_domain (hname, size) { #ifdef RES_INIT /* try to fix up unqualified names */ - if (!index (hname, '.')) { + if (!strchr (hname, '.')) { if (!(_res.options & RES_INIT)) { Debug ((DEBUG_DNS, "res_init()")); res_init (); @@ -378,7 +378,7 @@ void write_pidfile () int fd; char buff[20]; if ((fd = open (IRCD_PIDFILE, O_CREAT | O_WRONLY, 0600)) >= 0) { - bzero (buff, sizeof (buff)); + memset (buff, 0, sizeof (buff)); (void) sprintf (buff, "%5d\n", (int) getpid ()); if (write (fd, buff, strlen (buff)) == -1) Debug ((DEBUG_NOTICE, "Error writing to pid file %s", @@ -409,7 +409,7 @@ static int check_init (cptr, sockn) /* If descriptor is a tty, special checking... */ if (isatty (cptr->fd)) { strncpyzt (sockn, me.sockhost, HOSTLEN); - bzero ((char *) &sk, sizeof (struct sockaddr_in)); + memset ((char *) &sk, 0, sizeof (struct sockaddr_in)); } else if (getpeername (cptr->fd, (struct sockaddr *) &sk, &len) == -1) { report_error ("connect failure: %s %s", cptr); @@ -420,8 +420,7 @@ static int check_init (cptr, sockn) cptr->hostp = NULL; strncpyzt (sockn, me.sockhost, HOSTLEN); } - bcopy ((char *) &sk.sin_addr, (char *) &cptr->ip, - sizeof (struct in_addr)); + memcpy ((char *) &cptr->ip, (char *) &sk.sin_addr, sizeof (struct in_addr)); cptr->port = (int) ntohs (sk.sin_port); return 0; @@ -456,8 +455,7 @@ int check_client (cptr) */ if (hp) { for (i = 0; hp->h_addr_list[i]; i++) - if (!bcmp (hp->h_addr_list[i], (char *) &cptr->ip, - sizeof (struct in_addr))) + if (!memcmp (hp->h_addr_list[i], (char *) &cptr->ip, sizeof (struct in_addr))) break; if (!hp->h_addr_list[i]) { sendto_ops ("IP# Mismatch: %s != %s[%08x]", @@ -549,7 +547,7 @@ int check_server_init (cptr) lin.value.aconf = aconf; lin.flags = ASYNC_CONF; nextdnscheck = 1; - if ((s = index (aconf->host, '@'))) + if ((s = strchr (aconf->host, '@'))) s++; else s = aconf->host; @@ -579,8 +577,7 @@ int check_server (cptr, hp, c_conf, n_conf, estab) check_serverback: if (hp) { for (i = 0; hp->h_addr_list[i]; i++) - if (!bcmp (hp->h_addr_list[i], (char *) &cptr->ip, - sizeof (struct in_addr))) + if (!memcmp (hp->h_addr_list[i], (char *) &cptr->ip, sizeof (struct in_addr))) break; if (!hp->h_addr_list[i]) { sendto_ops ("IP# Mismatch: %s != %s[%08x]", @@ -672,8 +669,7 @@ int check_server (cptr, hp, c_conf, n_conf, estab) (void) attach_confs (cptr, name, CONF_HUB | CONF_UWORLD); if ((c_conf->ipnum.s_addr == -1) && !IsUnixSocket (cptr)) - bcopy ((char *) &cptr->ip, (char *) &c_conf->ipnum, - sizeof (struct in_addr)); + memcpy ((char *) &c_conf->ipnum, (char *) &cptr->ip, sizeof (struct in_addr)); if (!IsUnixSocket (cptr)) get_sockhost (cptr, c_conf->host); @@ -812,7 +808,7 @@ void close_connection (cptr) cptr->fd = -2; DBufClear (&cptr->sendQ); DBufClear (&cptr->recvQ); - bzero (cptr->passwd, sizeof (cptr->passwd)); + memset (cptr->passwd, 0, sizeof (cptr->passwd)); /* * clean up extra sockets from P-lines which have been * discarded. @@ -993,8 +989,7 @@ aClient *add_connection (cptr, fd) * have something valid to put into error messages... */ get_sockhost (acptr, (char *) inetntoa ((char *) &addr.sin_addr)); - bcopy ((char *) &addr.sin_addr, (char *) &acptr->ip, - sizeof (struct in_addr)); + memcpy ((char *) &acptr->ip, (char *) &addr.sin_addr, sizeof (struct in_addr)); /* Check for zaps -- Barubary */ if (find_zap (acptr, 0)) { set_non_blocking (fd, acptr); @@ -1013,7 +1008,7 @@ aClient *add_connection (cptr, fd) if (aconf2->status == CONF_CONNECT_SERVER && (match (inetntoa ((char *) &addr.sin_addr), aconf2->host) == 0 || match (inetntoa ((char *) &addr.sin_addr), - index (aconf2->host, '@') + 1) == 0)) + strchr (aconf2->host, '@') + 1) == 0)) break; if (!aconf2) { @@ -1022,7 +1017,7 @@ aClient *add_connection (cptr, fd) (match (inetntoa ((char *) &addr.sin_addr), aconf2->host) == 0 || match (inetntoa ((char *) &addr.sin_addr), - index (aconf2->host, '@') + 1) == 0)) + strchr (aconf2->host, '@') + 1) == 0)) break; } @@ -1440,7 +1435,7 @@ int connect_server (aconf, by, hp) lin.flags = ASYNC_CONNECT; lin.value.aconf = aconf; nextdnscheck = 1; - s = (char *) index (aconf->host, '@'); + s = (char *) strchr (aconf->host, '@'); s++; /* should NEVER be NULL */ if ((aconf->ipnum.s_addr = inet_addr (s)) == -1) { aconf->ipnum.s_addr = 0; @@ -1449,8 +1444,7 @@ int connect_server (aconf, by, hp) hp, aconf, aconf->name, s)); if (!hp) return 0; - bcopy (hp->h_addr, (char *) &aconf->ipnum, - sizeof (struct in_addr)); + memcpy ((char *) &aconf->ipnum, hp->h_addr, sizeof (struct in_addr)); } } cptr = make_client (NULL, NULL); @@ -1561,7 +1555,7 @@ static struct sockaddr *connect_inet (aconf, cptr, lenp) return NULL; } mysk.sin_port = 0; - bzero ((char *) &server, sizeof (server)); + memset ((char *) &server, 0, sizeof (server)); server.sin_family = AF_INET; get_sockhost (cptr, aconf->host); @@ -1590,7 +1584,7 @@ static struct sockaddr *connect_inet (aconf, cptr, lenp) report_error ("error binding to local port for %s:%s", cptr); return NULL; } - bzero ((char *) &server, sizeof (server)); + memset ((char *) &server, 0, sizeof (server)); server.sin_family = AF_INET; /* * By this point we should know the IP# of the host listed in the @@ -1605,12 +1599,10 @@ static struct sockaddr *connect_inet (aconf, cptr, lenp) Debug ((DEBUG_FATAL, "%s: unknown host", aconf->host)); return NULL; } - bcopy (hp->h_addr, (char *) &aconf->ipnum, sizeof (struct in_addr)); + memcpy ((char *) &aconf->ipnum, hp->h_addr, sizeof (struct in_addr)); } - bcopy ((char *) &aconf->ipnum, (char *) &server.sin_addr, - sizeof (struct in_addr)); - bcopy ((char *) &aconf->ipnum, (char *) &cptr->ip, - sizeof (struct in_addr)); + memcpy ((char *) &server.sin_addr, (char *) &aconf->ipnum, sizeof (struct in_addr)); + memcpy ((char *) &cptr->ip, (char *) &aconf->ipnum, sizeof (struct in_addr)); server.sin_port = htons (((aconf->port > 0) ? aconf->port : portnum)); *lenp = sizeof (server); return (struct sockaddr *) &server; @@ -1653,7 +1645,7 @@ int setup_ping () struct sockaddr_in from; int on = 1; - bzero ((char *) &from, sizeof (from)); + memset ((char *) &from, 0, sizeof (from)); from.sin_addr = me.ip; from.sin_port = htons (7007); from.sin_family = AF_INET; @@ -1790,8 +1782,7 @@ static void do_dns_async () case ASYNC_CONNECT: aconf = ln.value.aconf; if (hp && aconf) { - bcopy (hp->h_addr, (char *) &aconf->ipnum, - sizeof (struct in_addr)); + memcpy ((char *) &aconf->ipnum, hp->h_addr, sizeof (struct in_addr)); (void) connect_server (aconf, NULL, hp); } else @@ -1801,8 +1792,7 @@ static void do_dns_async () case ASYNC_CONF: aconf = ln.value.aconf; if (hp && aconf) - bcopy (hp->h_addr, (char *) &aconf->ipnum, - sizeof (struct in_addr)); + memcpy ((char *) &aconf->ipnum, hp->h_addr, sizeof (struct in_addr)); break; case ASYNC_SERVER: cptr = ln.value.cptr; diff --git a/src/s_conf.c b/src/s_conf.c index 4992786..3c32007 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -192,7 +192,7 @@ int attach_Iline (cptr, hp, sockhost) (void) strncpy (fullname, hname, sizeof (fullname) - 1); add_local_domain (fullname, HOSTLEN - strlen (fullname)); Debug ((DEBUG_DNS, "a_il: %s->%s", sockhost, fullname)); - if (index (aconf->name, '@')) { + if (strchr (aconf->name, '@')) { (void) strcpy (uhost, cptr->username); (void) strcat (uhost, "@"); } @@ -203,7 +203,7 @@ int attach_Iline (cptr, hp, sockhost) if (!match (aconf->name, uhost)) goto attach_iline; } - if (index (aconf->host, '@')) { + if (strchr (aconf->host, '@')) { strncpyzt (uhost, cptr->username, sizeof (uhost)); (void) strcat (uhost, "@"); } @@ -570,14 +570,14 @@ aConfItem *find_conf_ip (lp, ip, user, statmask) tmp = lp->value.aconf; if (!(tmp->status & statmask)) continue; - s = index (tmp->host, '@'); + s = strchr (tmp->host, '@'); *s = '\0'; if (match (tmp->host, user)) { *s = '@'; continue; } *s = '@'; - if (!bcmp ((char *) &tmp->ipnum, ip, sizeof (struct in_addr))) + if (!memcmp ((char *) &tmp->ipnum, ip, sizeof (struct in_addr))) return tmp; } return NULL; @@ -915,11 +915,11 @@ int initconf (opt) line[i-2] = '\n'; line[i-1] = '\0'; } - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = 0; else while (dgets (fd, c, sizeof (c) - 1) > 0) - if ((tmp = (char *) index (c, '\n'))) { + if ((tmp = (char *) strchr (c, '\n'))) { *tmp = 0; break; } @@ -1166,12 +1166,12 @@ int initconf (opt) } if (aconf->status & CONF_SERVER_MASK) if (ncount > MAXCONFLINKS || ccount > MAXCONFLINKS || - !aconf->host || index (aconf->host, '*') || - index (aconf->host, '?') || !aconf->name) + !aconf->host || strchr (aconf->host, '*') || + strchr (aconf->host, '?') || !aconf->name) continue; if (aconf->status & (CONF_SERVER_MASK | CONF_LOCOP | CONF_OPERATOR)) - if (!index (aconf->host, '@') && *aconf->host != '/') { + if (!strchr (aconf->host, '@') && *aconf->host != '/') { char *newhost; int len = 3; /* *@\0 = 3 */ @@ -1242,7 +1242,7 @@ static int lookup_confhost (aconf) if (BadPtr (aconf->host) || BadPtr (aconf->name)) goto badlookup; - if ((s = index (aconf->host, '@'))) + if ((s = strchr (aconf->host, '@'))) s++; else s = aconf->host; @@ -1263,14 +1263,14 @@ static int lookup_confhost (aconf) if (isdigit (*s)) aconf->ipnum.s_addr = inet_addr (s); else if ((hp = gethost_byname (s, &ln))) - bcopy (hp->h_addr, (char *) &(aconf->ipnum), sizeof (struct in_addr)); + memcpy ((char *) &(aconf->ipnum), hp->h_addr, sizeof (struct in_addr)); if (aconf->ipnum.s_addr == -1) goto badlookup; return 0; badlookup: if (aconf->ipnum.s_addr == -1) - bzero ((char *) &aconf->ipnum, sizeof (struct in_addr)); + memset ((char *) &aconf->ipnum, 0, sizeof (struct in_addr)); Debug ((DEBUG_ERROR, "Host/server name error: (%s) (%s)", aconf->host, aconf->name)); return -1; @@ -1449,9 +1449,9 @@ int m_killcomment (sptr, parv, filename) tm = localtime (&sb.st_mtime); (void) dgets (-1, NULL, 0); /* make sure buffer is at empty pos */ while (dgets (fd, line, sizeof (line) - 1) > 0) { - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = '\0'; - if ((tmp = (char *) index (line, '\r'))) + if ((tmp = (char *) strchr (line, '\r'))) *tmp = '\0'; sendto_one (sptr, rpl_str (RPL_MOTD), me.name, parv, line); } @@ -1970,7 +1970,7 @@ int m_zline (cptr, sptr, parc, parv) } /* z-lines don't support user@host format, they only work with ip addresses and nicks */ - if ((in = index (parv[1], '@')) && (*(in + 1) != '\0')) { + if ((in = strchr (parv[1], '@')) && (*(in + 1) != '\0')) { strcpy (userhost, in + 1); in = &userhost[0]; while (*in) { @@ -2149,7 +2149,7 @@ int m_unzline (cptr, sptr, parc, parv) } /* parse the removal mask the same way so an oper can just use the same thing to remove it if they specified *@ or something... */ - if ((in = index (parv[1], '@'))) { + if ((in = strchr (parv[1], '@'))) { strcpy (userhost, in + 1); in = &userhost[0]; while (*in) { @@ -2239,7 +2239,7 @@ int m_unzline (cptr, sptr, parc, parv) */ int advanced_check (char *userhost, int ipstat) { - register int retval = TRUE; + int retval = TRUE; char *up = NULL, *p, *thisseg; int numdots = 0, segno = 0, numseg, i = 0; char *ipseg[10 + 2]; @@ -2282,7 +2282,7 @@ int advanced_check (char *userhost, int ipstat) if (ipstat == TRUE) for (i = 0; i < numseg; i++) { if (!IP_WILDS_OK (i) - && (index (ipseg[i], '*') || index (ipseg[i], '?'))) + && (strchr (ipseg[i], '*') || strchr (ipseg[i], '?'))) retval = FALSE; MyFree (ipseg[i]); } @@ -2296,7 +2296,7 @@ int advanced_check (char *userhost, int ipstat) if (i == numseg || (i + 1) == numseg) wildsok = 0; if (wildsok == 0 - && (index (ipseg[i], '*') || index (ipseg[i], '?'))) { + && (strchr (ipseg[i], '*') || strchr (ipseg[i], '?'))) { retval = FALSE; } MyFree (ipseg[i]); diff --git a/src/s_misc.c b/src/s_misc.c index 2c2dd70..bd27708 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -72,7 +72,7 @@ char *date (clock) if (!clock) time (&clock); gm = gmtime (&clock); - bcopy ((char *) gm, (char *) &gmbuf, sizeof (gmbuf)); + memcpy ((char *) &gmbuf, (char *) gm, sizeof (gmbuf)); gm = &gmbuf; lt = localtime (&clock); @@ -128,7 +128,7 @@ char *make_nick_user_host (nick, name, host) static char namebuf[NICKLEN + USERLEN + HOSTLEN + 6]; char *s = namebuf; - bzero (namebuf, sizeof (namebuf)); + memset (namebuf, 0, sizeof (namebuf)); nick = check_string (nick); strncpyzt (namebuf, nick, NICKLEN + 1); s += strlen (s); @@ -163,7 +163,7 @@ char *myctime (value) char *p; (void) strcpy (buf, ctime (&value)); - if ((p = (char *) index (buf, '\n')) != NULL) + if ((p = (char *) strchr (buf, '\n')) != NULL) *p = '\0'; return buf; @@ -292,7 +292,7 @@ void get_sockhost (cptr, host) char *host; { char *s; - if ((s = (char *) index (host, '@'))) + if ((s = (char *) strchr (host, '@'))) s++; else s = host; @@ -308,15 +308,15 @@ char *my_name_for_link (name, aconf) aConfItem *aconf; { static char namebuf[HOSTLEN]; - register int count = aconf->port; - register char *start = name; + int count = aconf->port; + char *start = name; if (count <= 0 || count > 5) return start; while (count-- && name) { name++; - name = (char *) index (name, '.'); + name = (char *) strchr (name, '.'); } if (!name) return start; @@ -709,7 +709,7 @@ void checklist () void initstats () { - bzero ((char *) &ircst, sizeof (ircst)); + memset ((char *) &ircst, 0, sizeof (ircst)); } void tstats (cptr, name) @@ -723,7 +723,7 @@ void tstats (cptr, name) time_t now = time (NULL); sp = &tmp; - bcopy ((char *) ircstp, (char *) sp, sizeof (*sp)); + memcpy ((char *) sp, (char *) ircstp, sizeof (*sp)); for (i = 0; i < MAXCONNECTIONS; i++) { if (!(acptr = local[i])) continue; @@ -889,9 +889,9 @@ void get_max_users (void) (void) dgets (-1, NULL, 0); /* make sure buffer is at empty pos */ while ((nr = dgets (fd, line, sizeof (line) - 1)) > 0) { line[nr] = '\0'; - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = '\0'; - if ((tmp = (char *) index (line, '\r'))) + if ((tmp = (char *) strchr (line, '\r'))) *tmp = '\0'; } diff --git a/src/s_ping.c b/src/s_ping.c index 08968c9..8b314db 100644 --- a/src/s_ping.c +++ b/src/s_ping.c @@ -107,8 +107,7 @@ int start_ping (cptr) if (!(cptr->acpt)) return -1; - bcopy ((char *) &cptr->ip, (char *) &remote_addr.sin_addr, - sizeof (struct in_addr)); + memcpy ((char *) &remote_addr.sin_addr, (char *) &cptr->ip, sizeof (struct in_addr)); remote_addr.sin_port = htons (cptr->port); remote_addr.sin_family = AF_INET; @@ -136,8 +135,7 @@ void send_ping (cptr) struct sockaddr_in remote_addr; struct timeval tv; - bcopy ((char *) &cptr->ip, (char *) &remote_addr.sin_addr, - sizeof (struct in_addr)); + memcpy ((char *) &remote_addr.sin_addr, (char *) &cptr->ip, sizeof (struct in_addr)); remote_addr.sin_port = htons (cptr->port); remote_addr.sin_family = AF_INET; @@ -181,8 +179,7 @@ void read_ping (cptr) unsigned long int pingtime; char *s; - bcopy ((char *) &cptr->ip, (char *) &remote_addr.sin_addr, - sizeof (struct in_addr)); + memcpy ((char *) &remote_addr.sin_addr, (char *) &cptr->ip, sizeof (struct in_addr)); remote_addr.sin_port = htons (cptr->port); remote_addr.sin_family = AF_INET; @@ -247,7 +244,7 @@ int ping_server (cptr, hp) lin.flags = ASYNC_PING; lin.value.cptr = cptr; nextdnscheck = 1; - s = (char *) index (cptr->sockhost, '@'); + s = (char *) strchr (cptr->sockhost, '@'); s++; /* should never be NULL; cptr->sockhost is actually a conf->host */ if ((cptr->ip.s_addr = inet_addr (s)) == -1) { cptr->ip.s_addr = 0; @@ -255,7 +252,7 @@ int ping_server (cptr, hp) Debug ((DEBUG_NOTICE, "ping_sv: hp %x ac %x ho %s", hp, cptr, s)); if (!hp) return 0; - bcopy (hp->h_addr, (char *) &cptr->ip, sizeof (struct in_addr)); + memcpy ((char *) &cptr->ip, hp->h_addr, sizeof (struct in_addr)); } } return start_ping (cptr); @@ -338,7 +335,7 @@ int m_uping (cptr, sptr, parc, parv) for (aconf = conf; aconf; aconf = aconf->next) if (aconf->status == CONF_CONNECT_SERVER && (match (parv[1], aconf->host) == 0 || - match (parv[1], index (aconf->host, '@') + 1) == 0)) + match (parv[1], strchr (aconf->host, '@') + 1) == 0)) break; if (!aconf) { sendto_one_notice (sptr, "UPING: Host %s not listed in ircd.conf", @@ -409,8 +406,7 @@ int m_uping (cptr, sptr, parc, parv) strcpy (cptr->sockhost, aconf->host); cptr->acpt = sptr; SetAskedPing (sptr); - bcopy ((void *) &aconf->ipnum, (void *) &cptr->ip, - sizeof (struct in_addr)); + memcpy ((void *) &cptr->ip, (void *) &aconf->ipnum, sizeof (struct in_addr)); strcpy (cptr->name, aconf->name); cptr->firsttime = 0; SetPing (cptr); @@ -427,7 +423,7 @@ int m_uping (cptr, sptr, parc, parv) } void end_ping (cptr) - register aClient *cptr; + aClient *cptr; { Debug ((DEBUG_DEBUG, "end_ping: %x", cptr)); if (cptr->acpt) { diff --git a/src/s_serv.c b/src/s_serv.c index 15cea35..404e368 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -287,7 +287,7 @@ int m_protoctl (cptr, sptr, parc, parv) for (i = 1; i < parc; i++) { strncpy (proto, parv[i], 127); proto[127] = '\0'; /* Just to be safe... */ - equal = (char *) index (proto, '='); + equal = (char *) strchr (proto, '='); if (equal == NULL) options = dummyblank; else { @@ -383,7 +383,7 @@ int m_server (cptr, sptr, parc, parv) for (ch = host; *ch; ch++) if (*ch <= ' ' || *ch > '~') break; - if (*ch || !index (host, '.')) { + if (*ch || !strchr (host, '.')) { sendto_one (sptr, "ERROR :Bogus server name (%s)", sptr->name, host); sendto_ops ("Bogus server name (%s) from %s", host, get_client_name (cptr, TRUE)); @@ -422,7 +422,7 @@ int m_server (cptr, sptr, parc, parv) sendto_locfailops ("Access denied (passwd mismatch) %s", inpath); return exit_client (cptr, cptr, cptr, "Bad Password"); } - /* bzero(cptr->passwd, sizeof(cptr->passwd)); */ + /* memset (cptr->passwd, 0, sizeof(cptr->passwd)); */ } if ((acptr = find_name (host, NULL))) { aClient *ocptr; @@ -619,7 +619,7 @@ int m_server_estab (cptr) sendto_ops ("Access denied (passwd mismatch) %s", inpath); return exit_client (cptr, cptr, cptr, "Bad Password"); } - bzero (cptr->passwd, sizeof (cptr->passwd)); + memset (cptr->passwd, 0, sizeof (cptr->passwd)); #ifndef HUB for (i = 0; i <= highest_fd; i++) @@ -667,7 +667,7 @@ int m_server_estab (cptr) } else { - s = (char *) index (aconf->host, '@'); + s = (char *) strchr (aconf->host, '@'); *s = '\0'; /* should never be NULL */ Debug ((DEBUG_INFO, "Check Usernames [%s]vs[%s]", aconf->host, cptr->username)); @@ -1009,7 +1009,7 @@ int m_watch (cptr, sptr, parc, parv) } for (s = (char *) strtoken (&p, *++pav, " "); s; s = (char *) strtoken (&p, NULL, " ")) { - if ((user = (char *) index (s, '!'))) + if ((user = (char *) strchr (s, '!'))) *user++ = '\0'; /* Not used */ /* @@ -1420,7 +1420,7 @@ int m_stats (cptr, sptr, parc, parv) doall = 2; else if (match (name, me.name) == 0) doall = 1; - if (index (name, '*') || index (name, '?')) + if (strchr (name, '*') || strchr (name, '?')) wilds = 1; } else @@ -1603,7 +1603,7 @@ int m_stats (cptr, sptr, parc, parv) break; case 'u': { - register time_t tmpnow; + time_t tmpnow; tmpnow = time (NULL) - me.since; sendto_one (sptr, rpl_str (RPL_STATSUPTIME), me.name, parv[0], @@ -1924,7 +1924,7 @@ int m_connect (cptr, sptr, parc, parv) for (aconf = conf; aconf; aconf = aconf->next) if (aconf->status == CONF_CONNECT_SERVER && (match (parv[1], aconf->host) == 0 || - match (parv[1], index (aconf->host, '@') + 1) == 0)) + match (parv[1], strchr (aconf->host, '@') + 1) == 0)) break; if (!aconf) { @@ -2357,7 +2357,7 @@ int m_trace (cptr, sptr, parc, parv) } doall = (parv[1] && (parc > 1)) ? !match (tname, me.name) : TRUE; - wilds = !parv[1] || index (tname, '*') || index (tname, '?'); + wilds = !parv[1] || strchr (tname, '*') || strchr (tname, '?'); dow = wilds || doall; for (i = 0; i < MAXCONNECTIONS; i++) @@ -2535,9 +2535,9 @@ int m_motd (cptr, sptr, parc, parv) (void) dgets (-1, NULL, 0); /* make sure buffer is at empty pos */ while ((nr = dgets (fd, line, sizeof (line) - 1)) > 0) { line[nr] = '\0'; - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = '\0'; - if ((tmp = (char *) index (line, '\r'))) + if ((tmp = (char *) strchr (line, '\r'))) *tmp = '\0'; sendto_one (sptr, rpl_str (RPL_MOTD), me.name, parv[0], line); } @@ -2582,9 +2582,9 @@ int m_opermotd (cptr, sptr, parc, parv) (void) dgets (-1, NULL, 0); /* make sure buffer is at empty pos */ while ((nr = dgets (fd, line, sizeof (line) - 1)) > 0) { line[nr] = '\0'; - if ((tmp = (char *) index (line, '\n'))) + if ((tmp = (char *) strchr (line, '\n'))) *tmp = '\0'; - if ((tmp = (char *) index (line, '\r'))) + if ((tmp = (char *) strchr (line, '\r'))) *tmp = '\0'; sendto_one (sptr, rpl_str (RPL_OMOTD), me.name, parv[0], line); } diff --git a/src/s_user.c b/src/s_user.c index 86d638c..28d5bd8 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -283,8 +283,8 @@ static struct aThrottle *throttles[256]; static void remove_clone_check (aClient * cptr) { - register unsigned char *p = (unsigned char *) &cptr->ip.s_addr; - register struct aThrottle *ptr = + unsigned char *p = (unsigned char *) &cptr->ip.s_addr; + struct aThrottle *ptr = throttles[(p[0] + p[1] + p[2] + p[3]) & 0xff]; if (cptr->ip.s_addr == 0) @@ -419,8 +419,8 @@ char *canonize (buffer) char *buffer; { static char cbuf[BUFSIZ]; - register char *s, *t, *cp = cbuf; - register int l = 0; + char *s, *t, *cp = cbuf; + int l = 0; char *p = NULL, *p2; *cp = '\0'; @@ -775,7 +775,7 @@ static int register_user (cptr, sptr, nick, username) sptr->info); #endif if (MyConnect (sptr) && !BadPtr (sptr->passwd)) - bzero (sptr->passwd, sizeof (sptr->passwd)); + memset (sptr->passwd, 0, sizeof (sptr->passwd)); return 0; } @@ -869,7 +869,7 @@ int m_nick (cptr, sptr, parc, parv) sendto_one (sptr, err_str (ERR_NONICKNAMEGIVEN), me.name, parv[0]); return 0; } - if (MyConnect (sptr) && (s = (char *) index (parv[1], '~'))) + if (MyConnect (sptr) && (s = (char *) strchr (parv[1], '~'))) *s = '\0'; if (MyConnect (sptr) && IsJinxed (sptr)) @@ -1476,7 +1476,7 @@ static int m_message (cptr, sptr, parc, parv, notice) ** Armin, 8Jun90 (gruner@informatik.tu-muenchen.de) */ if ((*nick == '$' || *nick == '#') && IsAnOper (sptr)) { - if (!(s = (char *) rindex (nick, '.'))) { + if (!(s = (char *) strrchr (nick, '.'))) { sendto_one (sptr, err_str (ERR_NOTOPLEVEL), me.name, parv[0], nick); continue; @@ -1500,7 +1500,7 @@ static int m_message (cptr, sptr, parc, parv, notice) /* ** user[%host]@server addressed? */ - if ((server = (char *) index (nick, '@')) && + if ((server = (char *) strchr (nick, '@')) && (acptr = find_server (server + 1, NULL))) { /* ** Not destined for a user on me :-( @@ -1824,7 +1824,7 @@ int m_who (cptr, sptr, parc, parv) cptr->flags2 |= FLAGS2_HTC; /* To prevent a dead socket */ if (!BadPtr (mask)) { - if ((s = (char *) index (mask, ','))) { + if ((s = (char *) strchr (mask, ','))) { parv[1] = ++s; (void) m_who (cptr, sptr, parc, parv); } @@ -2015,7 +2015,7 @@ int m_whois (cptr, sptr, parc, parv) found = 0; (void) collapse (nick); - wilds = (index (nick, '?') || index (nick, '*')); + wilds = (strchr (nick, '?') || strchr (nick, '*')); if (wilds && IsServer (cptr)) continue; for (acptr = client; (acptr = next_client (acptr, nick)); @@ -2195,7 +2195,7 @@ int m_user (cptr, sptr, parc, parv) if (IsServer (cptr) && !IsUnknown (sptr)) return 0; - if (parc > 2 && (username = (char *) index (parv[1], '@'))) + if (parc > 2 && (username = (char *) strchr (parv[1], '@'))) *username = '\0'; if (parc < 5 || *parv[1] == '\0' || *parv[2] == '\0' || *parv[3] == '\0' || *parv[4] == '\0') { @@ -2327,7 +2327,7 @@ int m_kill (cptr, sptr, parc, parv) strcpy (inpath, oinpath); - if (IsServer (cptr) && (s = (char *) index (inpath, '.')) != NULL) + if (IsServer (cptr) && (s = (char *) strchr (inpath, '.')) != NULL) *s = '\0'; /* Truncate at first "." */ if (!IsPrivileged (cptr)) { @@ -2423,7 +2423,7 @@ int m_kill (cptr, sptr, parc, parv) auser = acptr->user ? acptr->user : &UnknownUser; - if (index (parv[0], '.')) + if (strchr (parv[0], '.')) sendto_umode (UMODE_KILLS | UMODE_OPER, "*** Notice -- Received KILL message for %s!%s@%s from %s Path: %s!%s", acptr->name, auser->username, auser->host, parv[0], @@ -2483,7 +2483,7 @@ int m_kill (cptr, sptr, parc, parv) (void) sprintf (buf2, "Local kill by %s (%s)", sptr->name, BadPtr (parv[2]) ? sptr->name : parv[2]); else { - if ((killer = index (path, ' '))) { + if ((killer = strchr (path, ' '))) { while (*killer && *killer != '!') killer--; if (!*killer) @@ -2524,7 +2524,7 @@ int m_mkill (cptr, sptr, parc, parv) sendto_one (sptr, err_str (ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } - if (!index (parv[1], '.')) { + if (!strchr (parv[1], '.')) { if ((acptr = find_client (parv[1], NULL))) lookhost = acptr->user->host; else { @@ -2858,7 +2858,7 @@ int m_oper (cptr, sptr, parc, parv) int old = (sptr->umodes & ALL_UMODES); char *s; - s = index (aconf->host, '@'); + s = strchr (aconf->host, '@'); *s++ = '\0'; if (!(aconf->port & OFLAG_ISGLOBAL)) SetLocOp (sptr); @@ -3113,7 +3113,7 @@ int m_ison (cptr, sptr, parc, parv) len = strlen (buf); for (s = strtoken (&p, *++pav, " "); s; s = strtoken (&p, NULL, " ")) { - if ((user = index (s, '!'))) + if ((user = strchr (s, '!'))) *user++ = '\0'; if ((acptr = find_person (s, NULL))) { if (user) { @@ -3631,7 +3631,7 @@ static int add_silence (sptr, mask) } lp = make_link (); - bzero ((char *) lp, sizeof (Link)); + memset ((char *) lp, 0, sizeof (Link)); lp->next = sptr->user->silence; lp->value.cp = (char *) MyMalloc (strlen (mask) + 1); (void) strcpy (lp->value.cp, mask); @@ -3677,8 +3677,8 @@ int m_silence (cptr, sptr, parc, parv) c = *cp; if (c == '-' || c == '+') cp++; - else if (!(index (cp, '@') || index (cp, '.') || - index (cp, '!') || index (cp, '*'))) { + else if (!(strchr (cp, '@') || strchr (cp, '.') || + strchr (cp, '!') || strchr (cp, '*'))) { sendto_one (sptr, err_str (ERR_NOSUCHNICK), me.name, parv[0], parv[1]); return -1; diff --git a/src/s_zip.c b/src/s_zip.c index faa847b..4e781a3 100644 --- a/src/s_zip.c +++ b/src/s_zip.c @@ -132,8 +132,8 @@ char *unzip_packet (aClient * cptr, char *buffer, int *length) /* ERR */ } /* put everything in zipbuf */ - bcopy (cptr->zip->inbuf, zipbuf, cptr->zip->incount); - bcopy (buffer, zipbuf + cptr->zip->incount, *length); + memcpy (zipbuf, cptr->zip->inbuf, cptr->zip->incount); + memcpy (zipbuf + cptr->zip->incount, buffer, *length); zin->next_in = zipbuf; zin->avail_in = cptr->zip->incount + *length; @@ -144,7 +144,7 @@ char *unzip_packet (aClient * cptr, char *buffer, int *length) case Z_OK: if (zin->avail_in) { /* put the leftover in cptr->zip->inbuf */ - bcopy (zin->next_in, cptr->zip->inbuf, zin->avail_in); + memcpy (cptr->zip->inbuf, zin->next_in, zin->avail_in); cptr->zip->incount = zin->avail_in; } *length = UNZIP_BUFFER_SIZE - zin->avail_out; @@ -203,7 +203,7 @@ char *zip_buffer (aClient * cptr, char *buffer, int *length, int flush) if (buffer) { /* concatenate buffer in cptr->zip->outbuf */ - bcopy (buffer, cptr->zip->outbuf + cptr->zip->outcount, *length); + memcpy (cptr->zip->outbuf + cptr->zip->outcount, buffer, *length); cptr->zip->outcount += *length; } *length = 0; diff --git a/src/send.c b/src/send.c index bda1065..e2e33b2 100644 --- a/src/send.c +++ b/src/send.c @@ -300,7 +300,7 @@ void sendto_channel_butone (one, from, chptr, pattern, aClient *acptr; int i; - bzero (sentalong, sizeof (sentalong)); + memset (sentalong, 0, sizeof (sentalong)); for (lp = chptr->members; lp; lp = lp->next) { acptr = lp->value.cptr; if (acptr->from == one || (lp->flags & CHFL_ZOMBIE)) @@ -507,7 +507,7 @@ void sendto_common_channels (user, pattern, p1, p2, p3, p4, p5, p6, p7, p8) aClient *cptr; Link *lp, *lp2; - bzero (sentalong, sizeof (sentalong)); + memset (sentalong, 0, sizeof (sentalong)); sentalong[0] = 1; for (lp = user->user->channel; lp; lp = lp->next) for (lp2 = lp->value.chptr->members; lp2; lp2 = lp2->next) { @@ -592,7 +592,7 @@ sendto_match_servs (chptr, from, format, p1, p2, p3, p4, p5, p6, p7, p8, p9) if (chptr) { if (*chptr->chname == '&') return; - if ((mask = (char *) rindex (chptr->chname, ':'))) + if ((mask = (char *) strrchr (chptr->chname, ':'))) mask++; } else @@ -989,7 +989,7 @@ void sendto_prefix_one (to, from, pattern, p1, p2, p3, p4, p5, p6, p7, p8) } } /* - ** flag is used instead of index(sender, '@') for speed and + ** flag is used instead of strchr (sender, '@') for speed and ** also since username/nick may have had a '@' in them. -avalon */ if (!flag && MyConnect (from) && *user->host) { diff --git a/src/support.c b/src/support.c index 3755850..18c6174 100644 --- a/src/support.c +++ b/src/support.c @@ -23,8 +23,6 @@ #include "sys.h" #include "h.h" -extern int errno; /* ...seems that errno.h doesn't define this everywhere */ - extern void outofmemory (); #ifndef HAVE_STRTOKEN @@ -45,7 +43,7 @@ char *strtoken (save, str, fs) if (str) pos = str; /* new string scan */ - while (pos && *pos && index (fs, *pos) != NULL) + while (pos && *pos && strchr (fs, *pos) != NULL) pos++; /* skip leading separators */ if (!pos || !*pos) @@ -53,7 +51,7 @@ char *strtoken (save, str, fs) tmp = pos; /* now, keep position of the token */ - while (*pos && index (fs, *pos) == NULL) + while (*pos && strchr (fs, *pos) == NULL) pos++; /* skip content of the token */ if (*pos) @@ -138,8 +136,8 @@ static int mindex = 0; char *MyMalloc (x) size_t x; { - register int i; - register char **s; + int i; + char **s; char *ret; ret = (char *) malloc (x + (size_t) SZ_EX); @@ -147,10 +145,10 @@ char *MyMalloc (x) if (!ret) { outofmemory (); } - bzero (ret, (int) x + SZ_EX); - bcopy ((char *) &ret, ret, SZ_CH); - bcopy ((char *) &x, ret + SZ_CH, SZ_ST); - bcopy ("VAVA", ret + SZ_CHST + (int) x, 4); + memset (ret, 0, (int) x + SZ_EX); + memcpy (ret, (char *) &ret, SZ_CH); + memcpy (ret + SZ_CH, (char *) &x, SZ_ST); + memcpy (ret + SZ_CHST + (int) x, "VAVA", 4); Debug ((DEBUG_MALLOC, "MyMalloc(%ld) = %#x", x, ret + 8)); for (i = 0, s = marray; *s && i < mindex; i++, s++); if (i < 20000) { @@ -165,26 +163,26 @@ char *MyRealloc (x, y) char *x; size_t y; { - register int l; - register char **s; + int l; + char **s; char *ret, *cp; size_t i; int k; x -= SZ_CHST; - bcopy (x, (char *) &cp, SZ_CH); - bcopy (x + SZ_CH, (char *) &i, SZ_ST); - bcopy (x + (int) i + SZ_CHST, (char *) &k, 4); - if (bcmp ((char *) &k, "VAVA", 4) || (x != cp)) + memcpy ((char *) &cp, x, SZ_CH); + memcpy ((char *) &i, x + SZ_CH, SZ_ST); + memcpy ((char *) &k, x + (int) i + SZ_CHST, 4); + if (memcmp ((char *) &k, "VAVA", 4) || (x != cp)) dumpcore ("MyRealloc %#x %d %d %#x %#x", x, y, i, cp, k); ret = (char *) realloc (x, y + (size_t) SZ_EX); if (!ret) { outofmemory (); } - bcopy ((char *) &ret, ret, SZ_CH); - bcopy ((char *) &y, ret + SZ_CH, SZ_ST); - bcopy ("VAVA", ret + SZ_CHST + (int) y, 4); + memcpy (ret, (char *) &ret, SZ_CH); + memcpy (ret + SZ_CH, (char *) &y, SZ_ST); + memcpy (ret + SZ_CHST + (int) y, "VAVA", 4); Debug ((DEBUG_NOTICE, "MyRealloc(%#x,%ld) = %#x", x, y, ret + SZ_CHST)); for (l = 0, s = marray; *s != x && l < mindex; l++, s++); if (l < mindex) @@ -206,18 +204,18 @@ void MyFree (x) size_t i; char *j; u_char k[4]; - register int l; - register char **s; + int l; + char **s; if (!x) return; x -= SZ_CHST; - bcopy (x, (char *) &j, SZ_CH); - bcopy (x + SZ_CH, (char *) &i, SZ_ST); - bcopy (x + SZ_CHST + (int) i, (char *) k, 4); + memcpy ((char *) &j, x, SZ_CH); + memcpy ((char *) &i, x + SZ_CH, SZ_ST); + memcpy ((char *) k, x + SZ_CHST + (int) i, 4); - if (bcmp ((char *) k, "VAVA", 4) || (j != x)) + if (memcmp ((char *) k, "VAVA", 4) || (j != x)) dumpcore ("MyFree %#x %ld %#x %#x", x, i, j, (k[3] << 24) | (k[2] << 16) | (k[1] << 8) | k[0]); @@ -277,8 +275,8 @@ int dgets (fd, buf, num) { static char dgbuf[8192]; static char *head = dgbuf, *tail = dgbuf; - register char *s, *t; - register int n, nr; + char *s, *t; + int n, nr; /* ** Sanity checks. @@ -303,10 +301,10 @@ int dgets (fd, buf, num) ** check input buffer for EOL and if present return string. */ if (head < tail && - ((s = index (head, '\n')) || (s = index (head, '\r'))) && s < tail) { + ((s = strchr (head, '\n')) || (s = strchr (head, '\r'))) && s < tail) { n = MIN (s - head + 1, num); /* at least 1 byte */ dgetsreturnbuf: - bcopy (head, buf, n); + memcpy (buf, head, n); head += n; if (head == tail) head = tail = dgbuf; @@ -332,7 +330,7 @@ int dgets (fd, buf, num) } tail += nr; *tail = '\0'; - for (t = head; (s = index (t, '\n'));) { + for (t = head; (s = strchr (t, '\n'));) { if ((s > head) && (s > dgbuf)) { t = s - 1; for (nr = 0; *t == '\\'; nr++) diff --git a/src/userload.c b/src/userload.c index af77cf5..d19c640 100644 --- a/src/userload.c +++ b/src/userload.c @@ -46,7 +46,7 @@ clock_t clock_last = 0; void update_load () { static struct timeval now, last; - register struct load_entry *cur_load_entry; + struct load_entry *cur_load_entry; /* This seems to get polluted on startup by an exit_client() * before any connections have been recorded. @@ -54,7 +54,7 @@ void update_load () if (current_load_data.local_count > MAXCONNECTIONS || current_load_data.client_count > MAXCONNECTIONS || current_load_data.conn_count > MAXCONNECTIONS) - bzero (¤t_load_data, sizeof (struct current_load_struct)); + memset (¤t_load_data, 0, sizeof (struct current_load_struct)); memcpy (&last, &now, sizeof (struct timeval)); @@ -91,7 +91,7 @@ void update_load () } else { load_list_head = cur_load_entry; - bzero (cur_load_entry, sizeof (struct load_entry)); + memset (cur_load_entry, 0, sizeof (struct load_entry)); cur_load_entry->time_incr = 1; } cur_load_entry->prev = load_list_tail; @@ -103,7 +103,7 @@ void calc_load (sptr, parv) aClient *sptr; char *parv; /* we only get passed the original parv[0] */ { - register struct load_entry *cur_load_entry; + struct load_entry *cur_load_entry; struct load_entry *last = NULL; #ifdef DEBUGMODE u_long secs = 0, adj_secs, total[4], adj[4]; /*[local,client,conn,cpu] */ @@ -111,13 +111,13 @@ void calc_load (sptr, parv) u_int times[5][4]; /* [min,hour,day,Yest,YYest][local,client,conn,cpu] */ char what[4][HOSTLEN + 1]; - bzero (total, 4 * sizeof (u_long)); + memset (total, 0, 4 * sizeof (u_long)); #else u_long secs = 0, adj_secs, total[3], adj[3]; /*[local,client,conn] */ int i, times[5][3]; /* [min,hour,day,Yest,YYest][local,client,conn] */ char what[3][HOSTLEN + 1]; - bzero (total, 3 * sizeof (u_long)); + memset (total, 0, 3 * sizeof (u_long)); #endif current_load_data.entries = 0; @@ -241,9 +241,9 @@ void calc_load (sptr, parv) } #ifdef DEBUGMODE - bzero (total, 4 * sizeof (u_long)); + memset (total, 0, 4 * sizeof (u_long)); #else - bzero (total, 3 * sizeof (u_long)); + memset (total, 0, 3 * sizeof (u_long)); #endif for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs += @@ -282,9 +282,9 @@ void calc_load (sptr, parv) } #ifdef DEBUGMODE - bzero (total, 4 * sizeof (u_long)); + memset (total, 0, 4 * sizeof (u_long)); #else - bzero (total, 3 * sizeof (u_long)); + memset (total, 0, 3 * sizeof (u_long)); #endif for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs += @@ -370,6 +370,6 @@ void calc_load (sptr, parv) void initload () { - bzero (¤t_load_data, sizeof (struct current_load_struct)); + memset (¤t_load_data, 0, sizeof (struct current_load_struct)); update_load (); /* Initialize the load list */ } diff --git a/src/whowas.c b/src/whowas.c index 6e2c4c1..b374d82 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -82,7 +82,7 @@ void add_history (cptr) free_link (lp); } } - bcopy ((char *) &ntmp, (char *) np2, sizeof (aName)); + memcpy ((char *) np2, (char *) &ntmp, sizeof (aName)); /* * Add this whowas entry into the clients history list @@ -157,7 +157,7 @@ void initwhowas () int i; for (i = 0; i < NICKNAMEHISTORYLENGTH; i++) - bzero ((char *) &was[i], sizeof (aName)); + memset ((char *) &was[i], 0, sizeof (aName)); return; } -- 2.30.2