Skip to content

Commit

Permalink
Merge pull request #10 from DouglasHeriot/windows
Browse files Browse the repository at this point in the history
Fix compiling with Visual Studio.
  • Loading branch information
nomis52 committed Sep 3, 2015
2 parents c3bcd0e + 4237539 commit 4e63da4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
6 changes: 6 additions & 0 deletions artnet/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ typedef int socklen_t;
#include <iphlpapi.h>
#endif

// Visual Studio specific things, that may not be needed for MinGW/MSYS
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#endif

#include "private.h"

Expand Down
50 changes: 34 additions & 16 deletions artnet/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@

#include <artnet/common.h>




#ifdef _MSC_VER
#define PACKED
#pragma pack(push,1)
#else
#define PACKED __attribute__((packed))
#endif


enum { ARTNET_MAX_RDM_ADCOUNT = 32 };

enum { ARTNET_MAX_UID_COUNT = 200 };
Expand Down Expand Up @@ -63,19 +74,18 @@ enum artnet_packet_type_e {
ARTNET_MEDIA = 0x9000,
ARTNET_MEDIAPATCH = 0x9200,
ARTNET_MEDIACONTROLREPLY = 0x9300
}__attribute__((packed));
} PACKED;

typedef enum artnet_packet_type_e artnet_packet_type_t;


struct artnet_poll_s {
struct artnet_poll_s {
uint8_t id[8];
uint16_t opCode;
uint8_t verH;
uint8_t ver;
uint8_t ttm;
uint8_t pad;
} __attribute__((packed));
} PACKED;

typedef struct artnet_poll_s artnet_poll_t;

Expand Down Expand Up @@ -112,7 +122,7 @@ struct artnet_reply_s {
uint8_t style;
uint8_t mac[ARTNET_MAC_SIZE];
uint8_t filler[32];
} __attribute__((packed));
} PACKED;

typedef struct artnet_reply_s artnet_reply_t;

Expand Down Expand Up @@ -144,7 +154,7 @@ struct artnet_ipprog_s {
uint8_t Spare7;
uint8_t Spare8;

} __attribute__((packed));
} PACKED;

typedef struct artnet_ipprog_s artnet_ipprog_t;

Expand Down Expand Up @@ -175,7 +185,7 @@ struct artnet_ipprog_reply_s {
uint8_t Spare6;
uint8_t Spare7;
uint8_t Spare8;
} __attribute__((packed));
} PACKED;

typedef struct artnet_ipprog_reply_s artnet_ipprog_reply_t;

Expand All @@ -194,7 +204,7 @@ struct artnet_address_s {
uint8_t subnet;
uint8_t swvideo;
uint8_t command;
} __attribute__((packed));
} PACKED;

typedef struct artnet_address_s artnet_address_t;

Expand All @@ -210,7 +220,7 @@ struct artnet_dmx_s {
uint8_t lengthHi;
uint8_t length;
uint8_t data[ARTNET_DMX_LENGTH];
} __attribute__((packed));
} PACKED;

typedef struct artnet_dmx_s artnet_dmx_t;

Expand All @@ -225,7 +235,7 @@ struct artnet_input_s {
uint8_t numbportsH;
uint8_t numbports;
uint8_t input[ARTNET_MAX_PORTS];
} __attribute__((packed));
} PACKED;

typedef struct artnet_input_s artnet_input_t;

Expand All @@ -248,7 +258,7 @@ struct artnet_todrequest_s {
uint8_t command;
uint8_t adCount;
uint8_t address[ARTNET_MAX_RDM_ADCOUNT];
} __attribute__((packed));
} PACKED;

typedef struct artnet_todrequest_s artnet_todrequest_t;

Expand Down Expand Up @@ -276,7 +286,7 @@ struct artnet_toddata_s {
uint8_t blockCount;
uint8_t uidCount;
uint8_t tod[ARTNET_MAX_UID_COUNT][ARTNET_RDM_UID_WIDTH];
} __attribute__((packed));
} PACKED;

typedef struct artnet_toddata_s artnet_toddata_t;

Expand All @@ -292,7 +302,7 @@ struct artnet_firmware_s {
uint8_t length[4];
uint8_t spare[20];
uint16_t data[ARTNET_FIRMWARE_SIZE ];
} __attribute__((packed));
} PACKED;

typedef struct artnet_firmware_s artnet_firmware_t;

Expand All @@ -313,7 +323,7 @@ struct artnet_todcontrol_s {
uint8_t spare8;
uint8_t cmd;
uint8_t address;
} __attribute__((packed));
} PACKED;


typedef struct artnet_todcontrol_s artnet_todcontrol_t;
Expand All @@ -338,7 +348,7 @@ struct artnet_rdm_s {
uint8_t cmd;
uint8_t address;
uint8_t data[ARTNET_MAX_RDM_DATA];
} __attribute__((packed));
} PACKED;


typedef struct artnet_rdm_s artnet_rdm_t;
Expand All @@ -353,7 +363,7 @@ struct artnet_firmware_reply_s {
uint8_t filler2;
uint8_t type;
uint8_t spare[21];
} __attribute__((packed));
} PACKED;

typedef struct artnet_firmware_reply_s artnet_firmware_reply_t;

Expand Down Expand Up @@ -387,4 +397,12 @@ typedef struct {

typedef artnet_packet_t *artnet_packet;


#ifdef _MSC_VER
#pragma pack(pop)
#endif

#undef PACKED


#endif

0 comments on commit 4e63da4

Please sign in to comment.