#ifndef DEMI_TYPES_H_IS_INCLUDED
#define DEMI_TYPES_H_IS_INCLUDED
#include <stddef.h>
#include <stdint.h>
#include <demi/cc.h>
#ifdef __linux__
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#ifdef _WIN32
#include <WinSock2.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#define DEMI_SGARRAY_MAXSIZE 1
typedef uint64_t demi_qtoken_t;
#ifdef _WIN32
#pragma pack(push, 1)
typedef struct demi_sgaseg
#endif
#ifdef __linux__
typedef struct __attribute__((__packed__)) demi_sgaseg
#endif
{
void *sgaseg_buf;
uint32_t sgaseg_len;
} demi_sgaseg_t;
#ifdef _WIN32
#pragma pack(pop)
#endif
#ifdef _WIN32
#pragma pack(push, 1)
typedef struct demi_sgarray
#endif
#ifdef __linux__
typedef struct __attribute__((__packed__)) demi_sgarray
#endif
{
void *sga_buf;
uint32_t sga_numsegs;
demi_sgaseg_t sga_segs[DEMI_SGARRAY_MAXSIZE];
struct sockaddr_in sga_addr;
} demi_sgarray_t;
#ifdef _WIN32
#pragma pack(pop)
#endif
typedef enum demi_opcode
{
DEMI_OPC_INVALID = 0,
DEMI_OPC_PUSH,
DEMI_OPC_POP,
DEMI_OPC_ACCEPT,
DEMI_OPC_CONNECT,
DEMI_OPC_CLOSE,
DEMI_OPC_FAILED,
} demi_opcode_t;
#ifdef _WIN32
#pragma pack(push, 1)
typedef struct demi_accept_result
#endif
#ifdef __linux__
typedef struct __attribute__((__packed__)) demi_accept_result
#endif
{
int32_t qd;
struct sockaddr_in addr;
} demi_accept_result_t;
#ifdef _WIN32
#pragma pack(pop)
#endif
#ifdef _WIN32
#pragma pack(push, 1)
typedef struct demi_qresult
#endif
#ifdef __linux__
typedef struct __attribute__((__packed__)) demi_qresult
#endif
{
enum demi_opcode qr_opcode;
int32_t qr_qd;
demi_qtoken_t qr_qt;
int64_t qr_ret;
union
{
demi_sgarray_t sga;
demi_accept_result_t ares;
} qr_value;
} demi_qresult_t;
#ifdef _WIN32
#pragma pack(pop)
#endif
typedef void (*demi_callback_t)(const char *, uint32_t, uint64_t);
#ifdef _WIN32
#pragma pack(push, 1)
struct demi_args
#endif
#ifdef __linux__
struct __attribute__((__packed__)) demi_args
#endif
{
int argc;
char *const *argv;
demi_callback_t callback;
};
#ifdef __cplusplus
}
#endif
#endif