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
RevLine 
[0]1//roaraudio.h:
2
[704]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
[0]28#ifndef _ROARAUDIO_H_
29#define _ROARAUDIO_H_
30
[1074]31#include <roaraudio/config.h>
[1073]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
[1251]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
[0]45#include <stdlib.h>
[1426]46
47#ifdef ROAR_HAVE_H_UNISTD
[0]48#include <unistd.h>
[1426]49#endif
50
[0]51#include <stdio.h>
52#include <string.h>
53#include <errno.h>
[1425]54
55#ifdef ROAR_HAVE_H_SYS_TYPES
[0]56#include <sys/types.h>
[1425]57#endif
58
[0]59#include <limits.h>
[1422]60#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
[57]61#include <sys/mman.h>
[1075]62#endif
[0]63
[60]64// TODO: can we move the next block into roard specific includes?
[1422]65#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
[60]66#include <grp.h>
67#include <pwd.h>
68#include <sys/stat.h>
[1074]69#endif
[60]70
[1072]71#ifdef ROAR_TARGET_WIN32
72#include <winsock2.h>
[1375]73#else /* ROAR_TARGET_WIN32 */
74#ifdef ROAR_HAVE_BSDSOCKETS
75
76#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
[0]77#include <arpa/inet.h>
[1375]78#endif
[0]79
80#include <sys/socket.h>
[1375]81
82#ifdef ROAR_HAVE_IPV4
[0]83#include <netinet/in.h>
84#include <netinet/tcp.h>
[1375]85#endif
86#ifdef ROAR_HAVE_UNIX
[0]87#include <sys/un.h>
[1072]88#endif
[0]89
[1375]90#endif /* ROAR_HAVE_BSDSOCKETS */
91#endif /* ROAR_TARGET_WIN32 */
92
[480]93#ifdef __NetBSD__
94#include <netinet/in_systm.h>
95#endif
96
[1424]97#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
[0]98#include <netdb.h>
[1074]99#endif
[0]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
[988]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
[874]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
[0]130#include <roaraudio/proto.h>
[780]131#include <roaraudio/error.h>
[0]132#include <roaraudio/audio.h>
133#include <roaraudio/stream.h>
134#include <roaraudio/client.h>
135#include <roaraudio/sample.h>
[87]136#include <roaraudio/meta.h>
[344]137#include <roaraudio/acl.h>
[0]138
139#include <libroar/libroar.h>
140
[508]141// IP
[0]142#define ROAR_DEFAULT_PORT        16002
143#define ROAR_DEFAULT_HOST        "localhost"
144
[508]145// UNIX Domain Sockets
[0]146#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
147#define ROAR_DEFAULT_SOCK_USER   ".roar"
148
[508]149// DECnet
150#define ROAR_DEFAULT_OBJECT      "roar"
151#define ROAR_DEFAULT_NUM         0
[515]152#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
[508]153
[927]154// now handled by condiguere
155//#define ROAR_DEFAULT_SOCKGRP     "audio"
[450]156
[313]157#define ROAR_LIBS                "-lroar"
158#define ROAR_CFLAGS              ""
[0]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
[472]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
[0]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
[311]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)
[0]188
[472]189#endif
[0]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
[56]197#ifdef ROAR_HAVE_MLOCK
[312]198#ifdef __linux__
[57]199#define ROAR_MLOCK(p,s) mlock((p), (s))
[312]200#else
[701]201int _ROAR_MLOCK(const void *addr, size_t len);
[700]202#define ROAR_MLOCK _ROAR_MLOCK
[56]203#endif
[699]204#endif
[0]205
[1098]206#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
[0]207
[1096]208#ifdef ROAR_TARGET_WIN32
209#error This is nonsens. No win32 runs on a BE machine
210#endif
211
[0]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
[508]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
[0]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
[508]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
[0]245#endif
246
[874]247__END_DECLS
248
[0]249#endif
250
251//ll
Note: See TracBrowser for help on using the repository browser.