From: michael Date: Sun, 18 Jan 2015 14:13:42 +0000 (+0000) Subject: - firedns.c: removed max() macro. Renamed 'fdns_errno', and 'fdns_fdinuse', X-Git-Tag: 1.0.3~9 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=0886f9c2bdc7f07926d165362189854d96119a0f;p=hopm.git - firedns.c: removed max() macro. Renamed 'fdns_errno', and 'fdns_fdinuse', to meet our coding convention. git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@5391 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/dnsbl.c b/src/dnsbl.c index b43181d..261dba2 100644 --- a/src/dnsbl.c +++ b/src/dnsbl.c @@ -87,9 +87,9 @@ dnsbl_add(struct scan_struct *ss) res = firedns_getip(FDNS_QRY_A, lookup, ds); - if (res == -1 && fdns_errno != FDNS_ERR_FDLIMIT) + if (res == -1 && firedns_errno != FDNS_ERR_FDLIMIT) { - log_printf("DNSBL -> Error sending dns lookup for '%s': %s", lookup, firedns_strerror(fdns_errno)); + log_printf("DNSBL -> Error sending dns lookup for '%s': %s", lookup, firedns_strerror(firedns_errno)); MyFree(ds); } else @@ -178,7 +178,7 @@ dnsbl_result(struct firedns_result *res) (unsigned char)res->text[0], (unsigned char)res->text[1], (unsigned char)res->text[2], - (unsigned char)res->text[3], fdns_errno); + (unsigned char)res->text[3], firedns_errno); else log_printf("DNSBL -> Lookup result for %s!%s@%s (%s) %d.%d.%d.%d (error: %d)", ds->ss->irc_nick, @@ -188,11 +188,11 @@ dnsbl_result(struct firedns_result *res) (unsigned char)res->text[0], (unsigned char)res->text[1], (unsigned char)res->text[2], - (unsigned char)res->text[3], fdns_errno); + (unsigned char)res->text[3], firedns_errno); } /* Everything is OK */ - if (res->text[0] == '\0' && fdns_errno == FDNS_ERR_NXDOMAIN) + if (res->text[0] == '\0' && firedns_errno == FDNS_ERR_NXDOMAIN) { if (ds->ss->manual_target) irc_send("PRIVMSG %s :CHECK -> DNSBL -> %s does not appear in BL zone %s", @@ -206,16 +206,16 @@ dnsbl_result(struct firedns_result *res) } /* Either an error, or a positive lookup */ - if (fdns_errno == FDNS_ERR_NONE) + if (firedns_errno == FDNS_ERR_NONE) dnsbl_positive(ds->ss, ds->bl, (unsigned char)res->text[3]); else { log_printf("DNSBL -> Lookup error on %s: %s", res->lookup, - firedns_strerror(fdns_errno)); + firedns_strerror(firedns_errno)); - if (fdns_errno != FDNS_ERR_TIMEOUT) + if (firedns_errno != FDNS_ERR_TIMEOUT) irc_send_channels("DNSBL -> Lookup error on %s: %s", res->lookup, - firedns_strerror(fdns_errno)); + firedns_strerror(firedns_errno)); } /* Check if ss has any remaining scans */ diff --git a/src/firedns.c b/src/firedns.c index cb21638..ded6d70 100644 --- a/src/firedns.c +++ b/src/firedns.c @@ -45,12 +45,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "dnsbl.h" #define FIREDNS_TRIES 3 -#define min(a,b) (a < b ? a : b) -int fdns_errno = FDNS_ERR_NONE; +int firedns_errno = FDNS_ERR_NONE; /* Variables local to this file */ -static unsigned int fdns_fdinuse; +static unsigned int firedns_fdinuse; /* up to FDNS_MAX nameservers; populated by firedns_init() */ static struct in_addr servers4[FDNS_MAX]; @@ -287,18 +286,18 @@ firedns_resolveip(int type, const char *const name) result = firedns_getresult(fd); - if (fdns_errno == FDNS_ERR_NONE) + if (firedns_errno == FDNS_ERR_NONE) /* * Return is from static memory in getresult, so there is no need to * copy it until the next call to firedns. */ return result->text; - else if (fdns_errno == FDNS_ERR_NXDOMAIN) + else if (firedns_errno == FDNS_ERR_NXDOMAIN) return NULL; } - if (fdns_errno == FDNS_ERR_NONE) - fdns_errno = FDNS_ERR_TIMEOUT; + if (firedns_errno == FDNS_ERR_NONE) + firedns_errno = FDNS_ERR_TIMEOUT; return NULL; } @@ -320,9 +319,9 @@ firedns_getip(int type, const char * const name, void *info) s->info = info; strlcpy(s->lookup, name, sizeof(s->lookup)); - if (fdns_fdinuse >= OptionsItem->dns_fdlimit) + if (firedns_fdinuse >= OptionsItem->dns_fdlimit) { - fdns_errno = FDNS_ERR_FDLIMIT; + firedns_errno = FDNS_ERR_FDLIMIT; /* Don't add to queue if there is no info */ if (info == NULL) @@ -377,7 +376,7 @@ firedns_doquery(struct s_connection *s) if (len == -1) { - fdns_errno = FDNS_ERR_FORMAT; + firedns_errno = FDNS_ERR_FORMAT; return -1; } @@ -514,7 +513,7 @@ firedns_send_requests(struct s_header *h, struct s_connection *s, int l) if (s->fd == -1) { - fdns_errno = FDNS_ERR_NETWORK; + firedns_errno = FDNS_ERR_NETWORK; return -1; } } @@ -566,13 +565,13 @@ firedns_send_requests(struct s_header *h, struct s_connection *s, int l) { close(s->fd); s->fd = -1; - fdns_errno = FDNS_ERR_NETWORK; + firedns_errno = FDNS_ERR_NETWORK; return -1; } time(&s->start); - fdns_fdinuse++; - fdns_errno = FDNS_ERR_NONE; + firedns_fdinuse++; + firedns_errno = FDNS_ERR_NONE; return s->fd; } @@ -590,7 +589,7 @@ firedns_getresult(const int fd) char *src, *dst; int bytes; - fdns_errno = FDNS_ERR_OTHER; + firedns_errno = FDNS_ERR_OTHER; result.info = NULL; memset(result.text, 0, sizeof(result.text)); @@ -617,7 +616,7 @@ firedns_getresult(const int fd) if (l == -1) { - fdns_errno = FDNS_ERR_NETWORK; + firedns_errno = FDNS_ERR_NETWORK; goto cleanup; } @@ -639,7 +638,7 @@ firedns_getresult(const int fd) if ((h.flags2 & FLAGS2_MASK_RCODE) != 0) { - fdns_errno = (h.flags2 & FLAGS2_MASK_RCODE); + firedns_errno = (h.flags2 & FLAGS2_MASK_RCODE); goto cleanup; } @@ -647,7 +646,7 @@ firedns_getresult(const int fd) if (h.ancount < 1) { - fdns_errno = FDNS_ERR_NXDOMAIN; + firedns_errno = FDNS_ERR_NXDOMAIN; /* no sense going on if we don't have any answers */ goto cleanup; } @@ -745,7 +744,7 @@ firedns_getresult(const int fd) if (rr->rdlength > 1023) goto cleanup; - fdns_errno = FDNS_ERR_NONE; + firedns_errno = FDNS_ERR_NONE; memcpy(result.text, &h.payload[i], rr->rdlength); result.text[rr->rdlength] = '\0'; @@ -754,7 +753,7 @@ cleanup: list_remove(CONNECTIONS, node); node_free(node); close(c->fd); - fdns_fdinuse--; + firedns_fdinuse--; MyFree(c); return &result; @@ -801,10 +800,10 @@ firedns_cycle(void) strlcpy(new_result.lookup, p->lookup, sizeof(new_result.lookup)); close(p->fd); - fdns_fdinuse--; + firedns_fdinuse--; MyFree(p); - fdns_errno = FDNS_ERR_TIMEOUT; + firedns_errno = FDNS_ERR_TIMEOUT; if (new_result.info) dnsbl_result(&new_result); @@ -847,7 +846,7 @@ firedns_cycle(void) } } } - else if (fdns_fdinuse < OptionsItem->dns_fdlimit) + else if (firedns_fdinuse < OptionsItem->dns_fdlimit) firedns_doquery(p); } } diff --git a/src/firedns.h b/src/firedns.h index 86caf11..bd65d5b 100644 --- a/src/firedns.h +++ b/src/firedns.h @@ -63,7 +63,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define FDNS_ERR_OTHER 9 /* Used with the above error values */ -extern int fdns_errno; +extern int firedns_errno; struct firedns_result { diff --git a/src/irc.c b/src/irc.c index 795fcc7..abeca40 100644 --- a/src/irc.c +++ b/src/irc.c @@ -197,7 +197,7 @@ irc_init(void) else { log_printf("IRC -> firedns_resolveip(\"%s\"): %s", IRCItem->server, - firedns_strerror(fdns_errno)); + firedns_strerror(firedns_errno)); exit(EXIT_FAILURE); } diff --git a/src/scan.c b/src/scan.c index 938edc4..d0719f6 100644 --- a/src/scan.c +++ b/src/scan.c @@ -892,7 +892,7 @@ scan_manual(char *param, const struct ChannelConf *target) if ((addr = firedns_resolveip4(ip)) == NULL) { irc_send("PRIVMSG %s :CHECK -> Error resolving host '%s': %s", - target->name, ip, firedns_strerror(fdns_errno)); + target->name, ip, firedns_strerror(firedns_errno)); return; }