aboutsummaryrefslogtreecommitdiff
path: root/src/osc.h
blob: f8aa6d969318f519c8ebfe734d56a698d73c8abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __OSC_H
#define __OSC_H

#include <unistd.h>
#ifdef __WATCOMC__
#include <types.h>
#endif
#include <sys/socket.h>

#include <SDL.h>
#include <SDL_thread.h>

		/* mainly for Open Watcom C */

#ifndef HAVE_IN_ADDR_T
#define HAVE_IN_ADDR_T
typedef Uint32 in_addr_t;
#endif

#if !(defined(SHUT_RD) || defined(SHUT_WR) || defined(SHUT_RDWR))
enum {
	SHUT_RD = 0,          /* No more receptions.  */
#define SHUT_RD SHUT_RD
	SHUT_WR,              /* No more transmissions.  */
#define SHUT_WR SHUT_WR
	SHUT_RDWR             /* No more receptions or transmissions.  */
#define SHUT_RDWR SHUT_RDWR
};
#endif

int Osc_Connect(const char *hostname, int port);
static inline void Osc_Disconnect(int fd);

SDL_Thread *Osc_InitThread(int *fd);
int Osc_TerminateThread(void);

int Osc_EnqueueFloatMessage(const char *address, float value);

static inline void
Osc_Disconnect(int fd)
{
	shutdown(fd, SHUT_WR);
	close(fd);
}

enum Osc_DataType {
	OSC_INT = 0,
	OSC_FLOAT,
	OSC_DOUBLE,
	OSC_STRING,
	OSC_BOOL
};
#define OSC_DATATYPE	\
	"int\0"		\
	"float\0"	\
	"double\0"	\
	"string\0"	\
	"bool\0"

#endif