]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented an lhnetaddresstype_t enum instead of using #define's
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 19 Aug 2008 13:29:33 +0000 (13:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 19 Aug 2008 13:29:33 +0000 (13:29 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8461 d7cf8633-e32d-0410-b094-e92efae38249

lhnet.c
lhnet.h

diff --git a/lhnet.c b/lhnet.c
index 9b190ce5ff89698a513d9cb82679ea0aab0ab3c2..37d9c6202049321e6f7feb3f85f4f7e7ce8efef2 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -68,7 +68,7 @@
 
 typedef struct lhnetaddressnative_s
 {
-       int addresstype;
+       lhnetaddresstype_t addresstype;
        int port;
        union
        {
@@ -91,13 +91,15 @@ static struct namecache_s
 namecache[MAX_NAMECACHE];
 static int namecacheposition = 0;
 
-int LHNETADDRESS_FromPort(lhnetaddress_t *vaddress, int addresstype, int port)
+int LHNETADDRESS_FromPort(lhnetaddress_t *vaddress, lhnetaddresstype_t addresstype, int port)
 {
        lhnetaddressnative_t *address = (lhnetaddressnative_t *)vaddress;
        if (!address)
                return 0;
        switch(addresstype)
        {
+       default:
+               return 0;
        case LHNETADDRESSTYPE_LOOP:
                // local:port  (loopback)
                memset(address, 0, sizeof(*address));
diff --git a/lhnet.h b/lhnet.h
index e4224c76372e272db1c77f7c087374f979bdf61e..08850fb3f52dddc443853721a2ac38a24105b704 100644 (file)
--- a/lhnet.h
+++ b/lhnet.h
@@ -4,20 +4,24 @@
 #ifndef LHNET_H
 #define LHNET_H
 
-#define LHNETADDRESSTYPE_NONE 0
-#define LHNETADDRESSTYPE_LOOP 1
-#define LHNETADDRESSTYPE_INET4 2
-#define LHNETADDRESSTYPE_INET6 3
+typedef enum lhnetaddresstype_e
+{
+       LHNETADDRESSTYPE_NONE,
+       LHNETADDRESSTYPE_LOOP,
+       LHNETADDRESSTYPE_INET4,
+       LHNETADDRESSTYPE_INET6,
+}
+lhnetaddresstype_t;
 
 typedef struct lhnetaddress_s
 {
-       int addresstype;
+       lhnetaddresstype_t addresstype;
        int port; // used by LHNETADDRESSTYPE_LOOP
        unsigned char storage[256]; // sockaddr_in or sockaddr_in6
 }
 lhnetaddress_t;
 
-int LHNETADDRESS_FromPort(lhnetaddress_t *address, int addresstype, int port);
+int LHNETADDRESS_FromPort(lhnetaddress_t *address, lhnetaddresstype_t addresstype, int port);
 int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int defaultport);
 int LHNETADDRESS_ToString(const lhnetaddress_t *address, char *string, int stringbuffersize, int includeport);
 int LHNETADDRESS_GetAddressType(const lhnetaddress_t *address);