aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-07-20 04:20:36 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-07-20 04:20:36 +0000
commitb75b43db636a92444be6224e56c765edece19fc3 (patch)
tree5c6e39db52fac5cb7c5bbad3c2c7aa7247947212
parent66965e0e36694b9bec880073b3e4e02a70988355 (diff)
downloadfetchmail-b75b43db636a92444be6224e56c765edece19fc3.tar.gz
fetchmail-b75b43db636a92444be6224e56c765edece19fc3.tar.bz2
fetchmail-b75b43db636a92444be6224e56c765edece19fc3.zip
Trivial reformatting.
svn path=/trunk/; revision=1982
-rw-r--r--checkalias.c97
1 files changed, 53 insertions, 44 deletions
diff --git a/checkalias.c b/checkalias.c
index 413b4047..1eca63da 100644
--- a/checkalias.c
+++ b/checkalias.c
@@ -1,3 +1,10 @@
+/*
+ * checkalias.c -- check to see if the IP addresses of two hosts are the same
+ *
+ * Copyright 1997 by Eric S. Raymond
+ * For license terms, see the file COPYING in this directory.
+ */
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -6,7 +13,6 @@
#include <arpa/inet.h>
#include <netdb.h>
#include "fetchmail.h"
-
int is_ip_alias(const char *name1,const char *name2)
/* Given two hostnames as arguments, returns TRUE if they
@@ -15,59 +21,62 @@ int is_ip_alias(const char *name1,const char *name2)
* No check is done on errors returned by gethostbyname,
* the calling function does them.
*/
- {
-
- typedef unsigned char address_t[sizeof (struct in_addr)];
- typedef struct _address_e { struct _address_e *next;
- address_t address;
- } address_e;
+{
+ typedef unsigned char address_t[sizeof (struct in_addr)];
+ typedef struct _address_e
+ {
+ struct _address_e *next;
+ address_t address;
+ }
+ address_e;
+ address_e *host_a_addr, *host_b_addr,*dummy_addr;
- address_e *host_a_addr, *host_b_addr,*dummy_addr;
-
- int i;
-
- struct hostent *hp;
-
- char **p;
+ int i;
+ struct hostent *hp;
+ char **p;
- hp = gethostbyname(name1);
+ hp = gethostbyname(name1);
- dummy_addr = (address_e *)NULL;
-
- for (i=0,p = hp->h_addr_list; *p != 0; i++,p++) {
- struct in_addr in;
- (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
- host_a_addr = (address_e *)xmalloc(sizeof( address_e));
- memset (host_a_addr,0, sizeof (address_e));
- host_a_addr->next = dummy_addr;
- (void) memcpy(&host_a_addr->address, *p, sizeof (in.s_addr));
- dummy_addr = host_a_addr;
- }
+ dummy_addr = (address_e *)NULL;
+ for (i=0,p = hp->h_addr_list; *p != 0; i++,p++)
+ {
+ struct in_addr in;
+ (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
+ host_a_addr = (address_e *)xmalloc(sizeof( address_e));
+ memset (host_a_addr,0, sizeof (address_e));
+ host_a_addr->next = dummy_addr;
+ (void) memcpy(&host_a_addr->address, *p, sizeof (in.s_addr));
+ dummy_addr = host_a_addr;
+ }
- hp = gethostbyname(name2);
- dummy_addr = (address_e *)NULL;
+ hp = gethostbyname(name2);
- for (i=0,p = hp->h_addr_list; *p != 0; i++,p++) {
- struct in_addr in;
- (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
- host_b_addr = (address_e *)xmalloc(sizeof( address_e));
- memset (host_b_addr,0, sizeof (address_e));
- host_b_addr->next = dummy_addr;
- (void) memcpy(&host_b_addr->address, *p, sizeof (in.s_addr));
- dummy_addr = host_b_addr;
- }
+ dummy_addr = (address_e *)NULL;
- while (host_a_addr) {
- while (host_b_addr) {
+ for (i=0,p = hp->h_addr_list; *p != 0; i++,p++)
+ {
+ struct in_addr in;
+ (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
+ host_b_addr = (address_e *)xmalloc(sizeof( address_e));
+ memset (host_b_addr,0, sizeof (address_e));
+ host_b_addr->next = dummy_addr;
+ (void) memcpy(&host_b_addr->address, *p, sizeof (in.s_addr));
+ dummy_addr = host_b_addr;
+ }
- if (!memcmp(host_b_addr->address,host_a_addr->address, sizeof (address_t))) return (TRUE);
+ while (host_a_addr)
+ {
+ while (host_b_addr)
+ {
+ if (!memcmp(host_b_addr->address,host_a_addr->address, sizeof (address_t)))
+ return (TRUE);
- host_b_addr = host_b_addr->next;
- }
- host_a_addr = host_a_addr->next;
+ host_b_addr = host_b_addr->next;
}
-return (FALSE);
+ host_a_addr = host_a_addr->next;
+ }
+ return (FALSE);
}