[0] | 1 | //libroar.h: |
---|
| 2 | |
---|
[690] | 3 | /* |
---|
[5961] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014 |
---|
[690] | 5 | * |
---|
| 6 | * This file is part of libroar a 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 General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroar 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 General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[690] | 23 | * |
---|
| 24 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
[0] | 36 | #ifndef _LIBROAR_H_ |
---|
| 37 | #define _LIBROAR_H_ |
---|
| 38 | |
---|
[4299] | 39 | //#define ROAR_DBG_PREFIX "libroar" |
---|
[0] | 40 | |
---|
[474] | 41 | #include <roaraudio.h> |
---|
| 42 | |
---|
[5951] | 43 | // Parameter passing: |
---|
| 44 | |
---|
[1351] | 45 | #include <stdarg.h> |
---|
| 46 | |
---|
[5951] | 47 | // Process control: |
---|
| 48 | |
---|
[1386] | 49 | #ifdef ROAR_HAVE_WAIT |
---|
[1254] | 50 | #include <sys/wait.h> |
---|
[1386] | 51 | #endif |
---|
[1254] | 52 | |
---|
[5951] | 53 | // File handle control: |
---|
| 54 | |
---|
[1425] | 55 | #ifdef ROAR_HAVE_H_FCNTL |
---|
[0] | 56 | #include <fcntl.h> |
---|
[1425] | 57 | #endif |
---|
[1374] | 58 | |
---|
[5951] | 59 | // Signal handling: |
---|
| 60 | |
---|
[3056] | 61 | #ifdef ROAR_HAVE_H_SIGNAL |
---|
[1418] | 62 | #include <signal.h> |
---|
| 63 | #endif |
---|
| 64 | |
---|
[5951] | 65 | // Logging: |
---|
| 66 | |
---|
[3611] | 67 | #ifdef ROAR_HAVE_SYSLOG |
---|
| 68 | #include <syslog.h> |
---|
| 69 | #endif |
---|
| 70 | |
---|
[5951] | 71 | // Network: |
---|
[1374] | 72 | |
---|
[5951] | 73 | #ifdef ROAR_TARGET_WIN32 |
---|
| 74 | #include <winsock2.h> |
---|
| 75 | #elif defined(ROAR_HAVE_BSDSOCKETS) |
---|
| 76 | |
---|
[4554] | 77 | #ifdef ROAR_HAVE_H_SYS_SOCKET |
---|
[322] | 78 | #include <sys/socket.h> |
---|
[4554] | 79 | #endif |
---|
[5951] | 80 | |
---|
[1374] | 81 | #ifdef ROAR_HAVE_IPV4 |
---|
[726] | 82 | #include <netinet/in_systm.h> |
---|
[322] | 83 | #include <netinet/in.h> |
---|
| 84 | #include <netinet/ip.h> |
---|
[5951] | 85 | #include <netinet/tcp.h> |
---|
[1374] | 86 | #endif |
---|
[5951] | 87 | |
---|
| 88 | #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) |
---|
| 89 | #include <arpa/inet.h> |
---|
| 90 | #endif |
---|
| 91 | |
---|
[902] | 92 | #include <sys/uio.h> |
---|
[3805] | 93 | |
---|
| 94 | #ifdef ROAR_HAVE_UNIX |
---|
| 95 | #include <sys/un.h> |
---|
[1075] | 96 | #endif |
---|
[3805] | 97 | |
---|
[501] | 98 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 99 | #include <netdnet/dn.h> |
---|
| 100 | #include <netdnet/dnetdb.h> |
---|
| 101 | #endif |
---|
[3805] | 102 | |
---|
[529] | 103 | #ifdef ROAR_HAVE_IPX |
---|
[528] | 104 | #include <netipx/ipx.h> |
---|
| 105 | #endif |
---|
[0] | 106 | |
---|
[1374] | 107 | #endif /* ROAR_HAVE_BSDSOCKETS */ |
---|
| 108 | |
---|
[5951] | 109 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
| 110 | #include <netdb.h> |
---|
| 111 | #endif |
---|
| 112 | |
---|
| 113 | // OpenSLP (autoconf): |
---|
| 114 | |
---|
[1996] | 115 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 116 | #include <slp.h> |
---|
[3203] | 117 | #ifdef ROAR_HAVE_H_SYS_TIME |
---|
| 118 | #include <sys/time.h> |
---|
| 119 | #endif |
---|
[4943] | 120 | #endif |
---|
| 121 | |
---|
[5951] | 122 | // Time related: |
---|
| 123 | |
---|
[3203] | 124 | #ifdef ROAR_HAVE_H_TIME |
---|
| 125 | #include <time.h> |
---|
| 126 | #endif |
---|
[1996] | 127 | |
---|
[5951] | 128 | // Dynamic loader: |
---|
| 129 | |
---|
[5517] | 130 | #if defined(ROAR_HAVE_H_DLFCN) |
---|
[3297] | 131 | #include <dlfcn.h> |
---|
| 132 | #endif |
---|
| 133 | |
---|
[5951] | 134 | // X11: |
---|
| 135 | |
---|
[3371] | 136 | #ifdef ROAR_HAVE_LIBX11 |
---|
| 137 | #include <X11/Xlib.h> |
---|
| 138 | #include <X11/Xatom.h> |
---|
| 139 | #endif |
---|
| 140 | |
---|
[4597] | 141 | #include "roarfeatures.h" |
---|
[797] | 142 | #include "error.h" |
---|
[4779] | 143 | #include "trap.h" |
---|
[2477] | 144 | #include "config.h" |
---|
[4524] | 145 | #include "roarfloat.h" |
---|
[4585] | 146 | #include "crc.h" |
---|
[4586] | 147 | #include "base64.h" |
---|
[3376] | 148 | #include "keyval.h" |
---|
[5505] | 149 | #include "uuid.h" |
---|
[3958] | 150 | #include "env.h" |
---|
[3297] | 151 | #include "roardl.h" |
---|
[5317] | 152 | #include "plugincontainer.h" |
---|
[5820] | 153 | #include "services.h" |
---|
[2648] | 154 | #include "debug.h" |
---|
[2976] | 155 | #include "memmgr.h" |
---|
[1280] | 156 | #include "stack.h" |
---|
[1297] | 157 | #include "buffer.h" |
---|
[4454] | 158 | #include "crypto.h" |
---|
[4446] | 159 | #include "random.h" |
---|
| 160 | #include "hash.h" |
---|
[4457] | 161 | #include "hash_tiger.h" |
---|
[2812] | 162 | #include "nnode.h" |
---|
[2058] | 163 | #include "vio_ctl.h" |
---|
[588] | 164 | #include "vio.h" |
---|
[3969] | 165 | #include "vio_buffer.h" |
---|
[3994] | 166 | #include "vio_buffer_store.h" |
---|
[1255] | 167 | #include "vio_cmd.h" |
---|
[4956] | 168 | #include "vio_zlib.h" |
---|
[1274] | 169 | #include "vio_ops.h" |
---|
[2060] | 170 | #include "vio_string.h" |
---|
[1274] | 171 | #include "vio_magic.h" |
---|
[1347] | 172 | #include "vio_bio.h" |
---|
[2059] | 173 | #include "vio_stdio.h" |
---|
[1347] | 174 | #include "vio_stack.h" |
---|
[2981] | 175 | #include "vio_jumbo.h" |
---|
[1300] | 176 | #include "vio_pipe.h" |
---|
[1331] | 177 | #include "vio_socket.h" |
---|
[3315] | 178 | #include "vio_winsock.h" |
---|
[1347] | 179 | #include "vio_proto.h" |
---|
[5367] | 180 | #include "vio_proxy.h" |
---|
[3272] | 181 | #include "vio_rtp.h" |
---|
[1506] | 182 | #include "vio_select.h" |
---|
[1326] | 183 | // dstr needs to have access to all other VIOs, so it must be included last |
---|
[1321] | 184 | #include "vio_dstr.h" |
---|
[3109] | 185 | #include "vio_tantalos.h" |
---|
[4533] | 186 | #include "vio_stdvios.h" |
---|
[4824] | 187 | #include "vio_misc.h" |
---|
[2812] | 188 | #include "client.h" |
---|
[0] | 189 | #include "basic.h" |
---|
[4426] | 190 | #include "serverinfo.h" |
---|
[0] | 191 | #include "stream.h" |
---|
| 192 | #include "simple.h" |
---|
[808] | 193 | #include "cdrom.h" |
---|
[4483] | 194 | #include "authfile.h" |
---|
[0] | 195 | #include "auth.h" |
---|
| 196 | #include "socket.h" |
---|
| 197 | #include "ctl.h" |
---|
[4497] | 198 | #include "caps.h" |
---|
[5031] | 199 | #include "roartime.h" |
---|
[94] | 200 | #include "meta.h" |
---|
[320] | 201 | #include "file.h" |
---|
[347] | 202 | #include "acl.h" |
---|
[1232] | 203 | #include "pinentry.h" |
---|
[1288] | 204 | #include "sshaskpass.h" |
---|
[4462] | 205 | #include "passwordapi.h" |
---|
[2000] | 206 | #include "roarslp.h" |
---|
[3632] | 207 | #include "display.h" |
---|
[3370] | 208 | #include "roarx11.h" |
---|
[3567] | 209 | #include "beep.h" |
---|
[4263] | 210 | #include "ltm.h" |
---|
[4172] | 211 | #include "vs.h" |
---|
[4300] | 212 | #include "enumdev.h" |
---|
[4302] | 213 | #include "notify.h" |
---|
[4314] | 214 | #include "notify_proxy.h" |
---|
[4341] | 215 | #include "asyncctl.h" |
---|
[5443] | 216 | #include "kstore.h" |
---|
[5619] | 217 | #include "watchdog.h" |
---|
[5692] | 218 | #include "scheduler.h" |
---|
[0] | 219 | |
---|
[2067] | 220 | // some basic macros: |
---|
| 221 | #define ROAR_MAX2(a,b) ((a) > (b) ? (a) : (b)) |
---|
| 222 | #define ROAR_MIN2(a,b) ((a) < (b) ? (a) : (b)) |
---|
| 223 | |
---|
| 224 | #define ROAR_MAX3(a,b,c) ROAR_MAX2(ROAR_MAX2(a,b),c) |
---|
| 225 | #define ROAR_MIN3(a,b,c) ROAR_MIN2(ROAR_MIN2(a,b),c) |
---|
| 226 | |
---|
| 227 | #define ROAR_MAX4(a,b,c,d) ROAR_MAX2(ROAR_MAX2(a,b),ROAR_MAX2(c,d)) |
---|
| 228 | #define ROAR_MIN4(a,b,c,d) ROAR_MIN2(ROAR_MIN2(a,b),ROAR_MIN2(c,d)) |
---|
| 229 | |
---|
| 230 | #define ROAR_MAX ROAR_MAX2 |
---|
| 231 | #define ROAR_MIN ROAR_MIN2 |
---|
| 232 | |
---|
[5945] | 233 | #define ROAR_CKHAVEARGS(x) if ( (i + (x)) >= argc ) { \ |
---|
| 234 | ROAR_ERR("Option %s requires more arguments. See --help for more details.", k); \ |
---|
| 235 | return 70; \ |
---|
| 236 | } |
---|
| 237 | |
---|
[4913] | 238 | int roar_usleep(uint_least32_t t); |
---|
| 239 | int roar_sleep(int t); |
---|
[5373] | 240 | pid_t roar_fork(const struct roar_libroar_forkapi * api); |
---|
[4896] | 241 | |
---|
[4965] | 242 | // call this function after we fork/exec()ed or similar. |
---|
[5010] | 243 | enum roar_reset { |
---|
| 244 | ROAR_RESET_UNKNOWN = -1, |
---|
| 245 | #define ROAR_RESET_UNKNOWN ROAR_RESET_UNKNOWN |
---|
| 246 | ROAR_RESET_NONE = 0, |
---|
| 247 | #define ROAR_RESET_NONE ROAR_RESET_NONE |
---|
| 248 | ROAR_RESET_ON_FORK = 1, |
---|
| 249 | #define ROAR_RESET_ON_FORK ROAR_RESET_ON_FORK |
---|
| 250 | ROAR_RESET_ON_EXIT = 2, |
---|
| 251 | #define ROAR_RESET_ON_EXIT ROAR_RESET_ON_EXIT |
---|
| 252 | ROAR_RESET_ON_PRE_EXEC = 3, |
---|
| 253 | #define ROAR_RESET_ON_PRE_EXEC ROAR_RESET_ON_PRE_EXEC |
---|
| 254 | ROAR_RESET_MEMORY = 0x81, |
---|
| 255 | #define ROAR_RESET_MEMORY ROAR_RESET_MEMORY |
---|
| 256 | ROAR_RESET_CONFIG = 0x82, |
---|
| 257 | #define ROAR_RESET_CONFIG ROAR_RESET_CONFIG |
---|
| 258 | ROAR_RESET_RANDOMPOOL = 0x84, |
---|
| 259 | #define ROAR_RESET_RANDOMPOOL ROAR_RESET_RANDOMPOOL |
---|
| 260 | ROAR_RESET_EOL = -2 |
---|
| 261 | #define ROAR_RESET_EOL ROAR_RESET_EOL |
---|
| 262 | }; |
---|
| 263 | int roar_reset(enum roar_reset what); |
---|
[4965] | 264 | |
---|
[4970] | 265 | // fatal probelms: |
---|
| 266 | enum roar_fatal_error { |
---|
| 267 | ROAR_FATAL_ERROR_NONE = 0, // ??? |
---|
| 268 | ROAR_FATAL_ERROR_UNKNOWN, // Unknown error |
---|
[4998] | 269 | #define ROAR_FATAL_ERROR_UNKNOWN ROAR_FATAL_ERROR_UNKNOWN |
---|
[4970] | 270 | ROAR_FATAL_ERROR_MEMORY_CORRUPTION, // some structure has been corrupted |
---|
[4998] | 271 | #define ROAR_FATAL_ERROR_MEMORY_CORRUPTION ROAR_FATAL_ERROR_MEMORY_CORRUPTION |
---|
[4970] | 272 | ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD, // memory was corruppted but no data has been harmed (yet) |
---|
[4998] | 273 | #define ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD |
---|
| 274 | ROAR_FATAL_ERROR_CPU_FAILURE, // CPU general CPU failure |
---|
| 275 | #define ROAR_FATAL_ERROR_CPU_FAILURE ROAR_FATAL_ERROR_CPU_FAILURE |
---|
| 276 | ROAR_FATAL_ERROR_CPU_FAILTURE = ROAR_FATAL_ERROR_CPU_FAILURE, |
---|
| 277 | ROAR_FATAL_ERROR_MEMORY_USED_AFTER_FREE, |
---|
| 278 | #define ROAR_FATAL_ERROR_MEMORY_USED_AFTER_FREE ROAR_FATAL_ERROR_MEMORY_USED_AFTER_FREE |
---|
| 279 | ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE, |
---|
| 280 | #define ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE |
---|
[5619] | 281 | ROAR_FATAL_ERROR_WATCHDOG, |
---|
| 282 | #define ROAR_FATAL_ERROR_WATCHDOG ROAR_FATAL_ERROR_WATCHDOG |
---|
[4970] | 283 | |
---|
| 284 | ROAR_FATAL_ERROR_EOL |
---|
| 285 | }; |
---|
| 286 | |
---|
| 287 | #if __STDC_VERSION__ < 199901L |
---|
| 288 | #if __GNUC__ >= 2 |
---|
| 289 | #define __roar_func__ __FUNCTION__ |
---|
| 290 | #else |
---|
| 291 | #define __roar_func__ NULL |
---|
| 292 | #endif |
---|
| 293 | #else |
---|
| 294 | #define __roar_func__ __func__ |
---|
| 295 | #endif |
---|
| 296 | |
---|
| 297 | #define roar_panic(err,info) roar_panic_real((err), (info), __LINE__, __FILE__, ROAR_DBG_PREFIX, __roar_func__) |
---|
| 298 | void roar_panic_real(enum roar_fatal_error error, const char * info, |
---|
| 299 | unsigned long int line, const char * file, const char * prefix, const char * func); |
---|
| 300 | |
---|
[4976] | 301 | // version stuff: |
---|
| 302 | const char * roar_version_string(void); |
---|
| 303 | uint32_t roar_version_num(void); |
---|
| 304 | |
---|
[0] | 305 | #endif |
---|
| 306 | |
---|
| 307 | //ll |
---|