source: roaraudio/include/roaraudio.h @ 1375:0d3028defc3c

Last change on this file since 1375:0d3028defc3c was 1375:0d3028defc3c, checked in by phi, 15 years ago

only include IPv4 headers if we have IPv4 networking enabled, only include socket headers if we have BSD Sockets

File size: 6.0 KB
Line 
1//roaraudio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
5 *
6 *  This file is part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 *  NOTE: Even though this file is LGPLed it (may) include GPLed files
24 *  so the license of this file is/may therefore downgraded to GPL.
25 *  See HACKING for details.
26 */
27
28#ifndef _ROARAUDIO_H_
29#define _ROARAUDIO_H_
30
31#include <roaraudio/config.h>
32#include <roaraudio/win32hacks.h> // we include this at the beginning of the file
33                                  // so we can define well known standard types known to everyone
34                                  // and everywhere but win32 here
35
36// consts we need to set depending on the OS and features:
37#if defined(ROAR_NEED_GNU_SOURCE) && !defined(_GNU_SOURCE)
38#define _GNU_SOURCE
39#endif
40
41#if defined(ROAR_NEED_BSD_VISIBLE) && !defined(__BSD_VISIBLE)
42#define __BSD_VISIBLE 1
43#endif
44
45#include <stdlib.h>
46#include <unistd.h>
47#include <stdio.h>
48#include <string.h>
49#include <errno.h>
50#include <sys/types.h>
51#include <limits.h>
52#ifndef ROAR_TARGET_WIN32
53#include <sys/mman.h>
54#endif
55
56// TODO: can we move the next block into roard specific includes?
57#ifndef ROAR_TARGET_WIN32
58#include <grp.h>
59#include <pwd.h>
60#include <sys/stat.h>
61#endif
62
63#ifdef ROAR_TARGET_WIN32
64#include <winsock2.h>
65#else /* ROAR_TARGET_WIN32 */
66#ifdef ROAR_HAVE_BSDSOCKETS
67
68#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
69#include <arpa/inet.h>
70#endif
71
72#include <sys/socket.h>
73
74#ifdef ROAR_HAVE_IPV4
75#include <netinet/in.h>
76#include <netinet/tcp.h>
77#endif
78#ifdef ROAR_HAVE_UNIX
79#include <sys/un.h>
80#endif
81
82#endif /* ROAR_HAVE_BSDSOCKETS */
83#endif /* ROAR_TARGET_WIN32 */
84
85#ifdef __NetBSD__
86#include <netinet/in_systm.h>
87#endif
88
89#ifndef ROAR_TARGET_WIN32
90#include <netdb.h>
91#endif
92
93// NOTE: we need this macro in some of our header files.
94#if INT_MAX >= 32767
95#define roar_intm16  int
96#define roar_uintm16 unsigned int
97#else
98#define roar_intm16  int16_t
99#define roar_uintm16 uint16_t
100#endif
101
102// this is to avoid warning messages on platforms
103// where sizeof(void*) == 8 and szeof(int) == 4
104#ifdef __LP64__
105#define ROAR_INSTINT long int
106#else
107#define ROAR_INSTINT int
108#endif
109
110#ifndef __BEGIN_DECLS
111#ifdef __cplusplus
112# define __BEGIN_DECLS extern "C" {
113# define __END_DECLS }
114#else
115# define __BEGIN_DECLS
116# define __END_DECLS
117#endif
118#endif
119
120__BEGIN_DECLS
121
122#include <roaraudio/proto.h>
123#include <roaraudio/error.h>
124#include <roaraudio/audio.h>
125#include <roaraudio/stream.h>
126#include <roaraudio/client.h>
127#include <roaraudio/sample.h>
128#include <roaraudio/meta.h>
129#include <roaraudio/acl.h>
130
131#include <libroar/libroar.h>
132
133// IP
134#define ROAR_DEFAULT_PORT        16002
135#define ROAR_DEFAULT_HOST        "localhost"
136
137// UNIX Domain Sockets
138#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
139#define ROAR_DEFAULT_SOCK_USER   ".roar"
140
141// DECnet
142#define ROAR_DEFAULT_OBJECT      "roar"
143#define ROAR_DEFAULT_NUM         0
144#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
145
146// now handled by condiguere
147//#define ROAR_DEFAULT_SOCKGRP     "audio"
148
149#define ROAR_LIBS                "-lroar"
150#define ROAR_CFLAGS              ""
151
152//some basic macros:
153#define ROAR_STDIN  0
154#define ROAR_STDOUT 1
155#define ROAR_STDERR 2
156
157#define ROAR_DEBUG_OUTFH stderr
158
159#ifdef ROAR_DBG_PREFIX
160#undef ROAR_DBG_PREFIX
161#endif
162#define ROAR_DBG_PREFIX "roaraudio"
163
164#define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): "
165
166#if __GNUC__ < 3
167 #define ROAR_DBG(format, args...)
168 #define ROAR_ERR(format, args...)
169 #define ROAR_WARN(format, args...)
170#else
171
172#ifdef DEBUG
173 #define ROAR_DBG(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "DEBUG: " format "\n", __LINE__, ## args)
174#else
175 #define ROAR_DBG(format, args...)
176#endif
177
178#define ROAR_ERR(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Error: "   format "\n", __LINE__, ## args)
179#define ROAR_WARN(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Warning: " format "\n", __LINE__, ## args)
180
181#endif
182
183#ifdef ROAR_HAVE_SAFE_OVERFLOW
184#define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b))
185#else
186#define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b))
187#endif
188
189#ifdef ROAR_HAVE_MLOCK
190#ifdef __linux__
191#define ROAR_MLOCK(p,s) mlock((p), (s))
192#else
193int _ROAR_MLOCK(const void *addr, size_t len);
194#define ROAR_MLOCK _ROAR_MLOCK
195#endif
196#endif
197
198#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
199
200#ifdef ROAR_TARGET_WIN32
201#error This is nonsens. No win32 runs on a BE machine
202#endif
203
204#define ROAR_NET2HOST32(x) (x)
205#define ROAR_HOST2NET32(x) (x)
206#define ROAR_NET2HOST16(x) (x)
207#define ROAR_HOST2NET16(x) (x)
208
209#ifdef ROAR_HAVE_LIBDNET
210#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
211#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
212                           ((dn_ntohs(((x)>>16)))) )
213#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
214#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
215#endif
216
217//#elif BYTE_ORDER == LITTLE_ENDIAN
218#else
219
220#define ROAR_NET2HOST32(x) ntohl((x))
221#define ROAR_HOST2NET32(x) htonl((x))
222#define ROAR_NET2HOST16(x) ntohs((x))
223#define ROAR_HOST2NET16(x) htons((x))
224
225#ifdef ROAR_HAVE_LIBDNET
226#if BYTE_ORDER == LITTLE_ENDIAN
227#define ROAR_dn_ntohs(x) (x)
228#define ROAR_dn_htons(x) (x)
229
230#define ROAR_dn_ntohl(x) (x)
231#define ROAR_dn_htonl(x) (x)
232#else
233#error can not build on this architecture with DECnet support enabled
234#endif
235#endif
236
237#endif
238
239__END_DECLS
240
241#endif
242
243//ll
Note: See TracBrowser for help on using the repository browser.