source: roaraudio/include/roaraudio.h @ 1426:2d690248f454

Last change on this file since 1426:2d690248f454 was 1426:2d690248f454, checked in by phi, 15 years ago

test also for unistd.h

File size: 6.2 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
47#ifdef ROAR_HAVE_H_UNISTD
48#include <unistd.h>
49#endif
50
51#include <stdio.h>
52#include <string.h>
53#include <errno.h>
54
55#ifdef ROAR_HAVE_H_SYS_TYPES
56#include <sys/types.h>
57#endif
58
59#include <limits.h>
60#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
61#include <sys/mman.h>
62#endif
63
64// TODO: can we move the next block into roard specific includes?
65#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
66#include <grp.h>
67#include <pwd.h>
68#include <sys/stat.h>
69#endif
70
71#ifdef ROAR_TARGET_WIN32
72#include <winsock2.h>
73#else /* ROAR_TARGET_WIN32 */
74#ifdef ROAR_HAVE_BSDSOCKETS
75
76#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
77#include <arpa/inet.h>
78#endif
79
80#include <sys/socket.h>
81
82#ifdef ROAR_HAVE_IPV4
83#include <netinet/in.h>
84#include <netinet/tcp.h>
85#endif
86#ifdef ROAR_HAVE_UNIX
87#include <sys/un.h>
88#endif
89
90#endif /* ROAR_HAVE_BSDSOCKETS */
91#endif /* ROAR_TARGET_WIN32 */
92
93#ifdef __NetBSD__
94#include <netinet/in_systm.h>
95#endif
96
97#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
98#include <netdb.h>
99#endif
100
101// NOTE: we need this macro in some of our header files.
102#if INT_MAX >= 32767
103#define roar_intm16  int
104#define roar_uintm16 unsigned int
105#else
106#define roar_intm16  int16_t
107#define roar_uintm16 uint16_t
108#endif
109
110// this is to avoid warning messages on platforms
111// where sizeof(void*) == 8 and szeof(int) == 4
112#ifdef __LP64__
113#define ROAR_INSTINT long int
114#else
115#define ROAR_INSTINT int
116#endif
117
118#ifndef __BEGIN_DECLS
119#ifdef __cplusplus
120# define __BEGIN_DECLS extern "C" {
121# define __END_DECLS }
122#else
123# define __BEGIN_DECLS
124# define __END_DECLS
125#endif
126#endif
127
128__BEGIN_DECLS
129
130#include <roaraudio/proto.h>
131#include <roaraudio/error.h>
132#include <roaraudio/audio.h>
133#include <roaraudio/stream.h>
134#include <roaraudio/client.h>
135#include <roaraudio/sample.h>
136#include <roaraudio/meta.h>
137#include <roaraudio/acl.h>
138
139#include <libroar/libroar.h>
140
141// IP
142#define ROAR_DEFAULT_PORT        16002
143#define ROAR_DEFAULT_HOST        "localhost"
144
145// UNIX Domain Sockets
146#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
147#define ROAR_DEFAULT_SOCK_USER   ".roar"
148
149// DECnet
150#define ROAR_DEFAULT_OBJECT      "roar"
151#define ROAR_DEFAULT_NUM         0
152#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
153
154// now handled by condiguere
155//#define ROAR_DEFAULT_SOCKGRP     "audio"
156
157#define ROAR_LIBS                "-lroar"
158#define ROAR_CFLAGS              ""
159
160//some basic macros:
161#define ROAR_STDIN  0
162#define ROAR_STDOUT 1
163#define ROAR_STDERR 2
164
165#define ROAR_DEBUG_OUTFH stderr
166
167#ifdef ROAR_DBG_PREFIX
168#undef ROAR_DBG_PREFIX
169#endif
170#define ROAR_DBG_PREFIX "roaraudio"
171
172#define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): "
173
174#if __GNUC__ < 3
175 #define ROAR_DBG(format, args...)
176 #define ROAR_ERR(format, args...)
177 #define ROAR_WARN(format, args...)
178#else
179
180#ifdef DEBUG
181 #define ROAR_DBG(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "DEBUG: " format "\n", __LINE__, ## args)
182#else
183 #define ROAR_DBG(format, args...)
184#endif
185
186#define ROAR_ERR(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Error: "   format "\n", __LINE__, ## args)
187#define ROAR_WARN(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Warning: " format "\n", __LINE__, ## args)
188
189#endif
190
191#ifdef ROAR_HAVE_SAFE_OVERFLOW
192#define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b))
193#else
194#define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b))
195#endif
196
197#ifdef ROAR_HAVE_MLOCK
198#ifdef __linux__
199#define ROAR_MLOCK(p,s) mlock((p), (s))
200#else
201int _ROAR_MLOCK(const void *addr, size_t len);
202#define ROAR_MLOCK _ROAR_MLOCK
203#endif
204#endif
205
206#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
207
208#ifdef ROAR_TARGET_WIN32
209#error This is nonsens. No win32 runs on a BE machine
210#endif
211
212#define ROAR_NET2HOST32(x) (x)
213#define ROAR_HOST2NET32(x) (x)
214#define ROAR_NET2HOST16(x) (x)
215#define ROAR_HOST2NET16(x) (x)
216
217#ifdef ROAR_HAVE_LIBDNET
218#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
219#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
220                           ((dn_ntohs(((x)>>16)))) )
221#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
222#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
223#endif
224
225//#elif BYTE_ORDER == LITTLE_ENDIAN
226#else
227
228#define ROAR_NET2HOST32(x) ntohl((x))
229#define ROAR_HOST2NET32(x) htonl((x))
230#define ROAR_NET2HOST16(x) ntohs((x))
231#define ROAR_HOST2NET16(x) htons((x))
232
233#ifdef ROAR_HAVE_LIBDNET
234#if BYTE_ORDER == LITTLE_ENDIAN
235#define ROAR_dn_ntohs(x) (x)
236#define ROAR_dn_htons(x) (x)
237
238#define ROAR_dn_ntohl(x) (x)
239#define ROAR_dn_htonl(x) (x)
240#else
241#error can not build on this architecture with DECnet support enabled
242#endif
243#endif
244
245#endif
246
247__END_DECLS
248
249#endif
250
251//ll
Note: See TracBrowser for help on using the repository browser.