diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 22:14:42 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 22:14:42 -0700 |
commit | 3beb4d278caa281ea8ebad55ae2f45ea0d46a6e6 (patch) | |
tree | c8f6bfcc9b11540fd7c102752c343078080513ac /access.c | |
parent | b80b263f964031b1edef0a5e0a77a6615dc4be82 (diff) |
Use imdent to show cpp macro nesting more clearly
Also strip trailing whitespace to make git happier.
While many lines are changes, "git diff -w" shows no changes other
than pure whitespace.
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'access.c')
-rw-r--r-- | access.c | 134 |
1 files changed, 67 insertions, 67 deletions
@@ -32,8 +32,8 @@ in this Software without prior written authorization from the copyright holder. * and (potentially) a list of hosts to send ForwardQuery packets to */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" #ifdef XDMCP @@ -51,20 +51,20 @@ in this Software without prior written authorization from the copyright holder. # include <arpa/inet.h> # endif -#define ALIAS_CHARACTER '%' -#define NEGATE_CHARACTER '!' -#define CHOOSER_STRING "CHOOSER" -#define BROADCAST_STRING "BROADCAST" -#define NOBROADCAST_STRING "NOBROADCAST" -#define LISTEN_STRING "LISTEN" -#define WILDCARD_STRING "*" - -#define HOST_ALIAS 0 -#define HOST_ADDRESS 1 -#define HOST_BROADCAST 2 -#define HOST_CHOOSER 3 -#define HOST_NOBROADCAST 4 -#define HOST_ANYADDR 5 +# define ALIAS_CHARACTER '%' +# define NEGATE_CHARACTER '!' +# define CHOOSER_STRING "CHOOSER" +# define BROADCAST_STRING "BROADCAST" +# define NOBROADCAST_STRING "NOBROADCAST" +# define LISTEN_STRING "LISTEN" +# define WILDCARD_STRING "*" + +# define HOST_ALIAS 0 +# define HOST_ADDRESS 1 +# define HOST_BROADCAST 2 +# define HOST_CHOOSER 3 +# define HOST_NOBROADCAST 4 +# define HOST_ANYADDR 5 typedef struct _hostEntry { struct _hostEntry *next; @@ -76,10 +76,10 @@ typedef struct _hostEntry { int hopCount; } HostEntry; -#define DISPLAY_ALIAS 0 -#define DISPLAY_PATTERN 1 -#define DISPLAY_ADDRESS 2 -#define DISPLAY_LISTEN 3 +# define DISPLAY_ALIAS 0 +# define DISPLAY_PATTERN 1 +# define DISPLAY_ADDRESS 2 +# define DISPLAY_LISTEN 3 typedef struct _displayEntry { struct _displayEntry *next; @@ -106,10 +106,10 @@ ARRAY8Ptr getLocalAddress (void) { static int haveLocalAddress; - + if (!haveLocalAddress) { -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai; if (getaddrinfo(localHostname(), NULL, NULL, &ai) != 0) { @@ -121,18 +121,18 @@ getLocalAddress (void) } else { if (ai->ai_addr->sa_family == AF_INET) { XdmcpAllocARRAY8 (&localAddress, sizeof(struct in_addr)); - memcpy(localAddress.data, + memcpy(localAddress.data, &((struct sockaddr_in *)ai->ai_addr)->sin_addr, sizeof(struct in_addr)); } else if (ai->ai_addr->sa_family == AF_INET6) { XdmcpAllocARRAY8 (&localAddress, sizeof(struct in6_addr)); - memcpy(localAddress.data, + memcpy(localAddress.data, &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr, sizeof(struct in6_addr)); - } + } freeaddrinfo(ai); } -#else +# else struct hostent *hostent; hostent = gethostbyname (localHostname()); @@ -147,7 +147,7 @@ getLocalAddress (void) localAddress.data[2] = 0; localAddress.data[3] = 1; } -#endif +# endif } return &localAddress; @@ -207,7 +207,7 @@ FreeAccessDatabase (void) database = NULL; } -#define WORD_LEN 256 +# define WORD_LEN 256 static char wordBuffer[WORD_LEN]; static int nextIsEOF; @@ -314,11 +314,11 @@ tryagain: { void *addr=NULL; size_t addr_length=0; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai = NULL; -#else +# else struct hostent *hostent = gethostbyname (hostOrAlias); -#endif +# endif char *hops = strrchr(hostOrAlias, '/'); if (hops) { @@ -328,7 +328,7 @@ tryagain: h->hopCount = 1; } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (getaddrinfo(hostOrAlias, NULL, NULL, &ai) == 0) { if (ai->ai_addr->sa_family == AF_INET) { addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr; @@ -336,14 +336,14 @@ tryagain: } else if (ai->ai_addr->sa_family == AF_INET6) { addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; addr_length = sizeof(struct in6_addr); - } + } } -#else +# else if (hostent) { addr = hostent->h_addr; addr_length = hostent->h_length; } -#endif +# endif h->type = HOST_ADDRESS; if (!addr) @@ -351,27 +351,27 @@ tryagain: Debug ("No such host %s\n", hostOrAlias); LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias); free ((char *) h); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif goto tryagain; } if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, addr_length)) { LogOutOfMem ("ReadHostEntry\n"); free ((char *) h); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } memmove( h->entry.hostAddress.data, addr, addr_length); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif } return h; } @@ -396,7 +396,7 @@ ReadDisplayEntry (FILE *file) DisplayEntry *d; struct _display *display; HostEntry *h, **prev; - + displayOrAlias = ReadWord (file, FALSE); if (!displayOrAlias) return NULL; @@ -414,7 +414,7 @@ ReadDisplayEntry (FILE *file) return NULL; } } - else if (!strcmp(displayOrAlias, LISTEN_STRING)) + else if (!strcmp(displayOrAlias, LISTEN_STRING)) { d->type = DISPLAY_LISTEN; } @@ -441,7 +441,7 @@ ReadDisplayEntry (FILE *file) size_t addr_length = 0; int addrtype = 0; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai = NULL; if (getaddrinfo(displayOrAlias, NULL, NULL, &ai) == 0) { @@ -452,9 +452,9 @@ ReadDisplayEntry (FILE *file) } else if (addrtype == AF_INET6) { addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; addr_length = sizeof(struct in6_addr); - } + } } -#else +# else struct hostent *hostent; if ((hostent = gethostbyname (displayOrAlias)) != NULL) @@ -464,15 +464,15 @@ ReadDisplayEntry (FILE *file) addrtype = hostent->h_addrtype; addr_length = hostent->h_length; } -#endif +# endif if (addr == NULL) { LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias); free ((char *) d); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } d->type = DISPLAY_ADDRESS; @@ -480,39 +480,39 @@ ReadDisplayEntry (FILE *file) if (!XdmcpAllocARRAY8 (&display->clientAddress, addr_length)) { free ((char *) d); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } memmove( display->clientAddress.data, addr, addr_length); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif switch (addrtype) { -#ifdef AF_UNIX +# ifdef AF_UNIX case AF_UNIX: display->connectionType = FamilyLocal; break; -#endif -#ifdef AF_INET +# endif +# ifdef AF_INET case AF_INET: display->connectionType = FamilyInternet; break; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: display->connectionType = FamilyInternet6; break; -#endif -#ifdef AF_DECnet +# endif +# ifdef AF_DECnet case AF_DECnet: display->connectionType = FamilyDECnet; break; -#endif +# endif default: display->connectionType = FamilyLocal; break; @@ -585,7 +585,7 @@ ScanAccessDatabase (void) * the local host exists on any of the lists, else FALSE */ -#define MAX_DEPTH 32 +# define MAX_DEPTH 32 static int indirectAlias ( char *alias, @@ -936,21 +936,21 @@ void ForEachListenAddr ( } if (!listenFound) { (*listenfunction) (NULL, closure); -#if defined(IPv6) && defined(AF_INET6) && defined(XDM_DEFAULT_MCAST_ADDR6) +# if defined(IPv6) && defined(AF_INET6) && defined(XDM_DEFAULT_MCAST_ADDR6) { /* Join default IPv6 Multicast Group */ static ARRAY8 defaultMcastAddress; if (defaultMcastAddress.length == 0) { struct in6_addr addr6; - + if (inet_pton(AF_INET6,XDM_DEFAULT_MCAST_ADDR6,&addr6) == 1) { - if (!XdmcpAllocARRAY8 (&defaultMcastAddress, + if (!XdmcpAllocARRAY8 (&defaultMcastAddress, sizeof(struct in6_addr))) { LogOutOfMem ("ReadHostEntry\n"); defaultMcastAddress.length = -1; } else { - memcpy(defaultMcastAddress.data, &addr6, + memcpy(defaultMcastAddress.data, &addr6, sizeof(struct in6_addr)); } } else { @@ -961,7 +961,7 @@ void ForEachListenAddr ( (*mcastfunction) (&defaultMcastAddress, closure); } } -#endif +# endif } } |