Index: libroar/.cvsignore
===================================================================
--- libroar/.cvsignore	(revision 2861)
+++ 	(revision )
@@ -1,1 +1,0 @@
-*.dll
Index: libroar/Makefile
===================================================================
--- libroar/Makefile	(revision 5849)
+++ libroar/Makefile	(revision 0)
@@ -1,35 +1,16 @@
-include ../Makefile.conf
-include ../Makefile.inc
-
-BASENAME=libroar
-SLIB=$(BASENAME)$(SHARED_SUFFIX)
-ALIB=$(BASENAME).a
-
-TARGETS=$(SLIB) $(ALIB) $(IMPLIB)
-VIO_META=vio.o vio_select.o vio_ops.o vio_string.o
-VIO_BRIDGE=vio_bio.o vio_stdio.o
-VIO=$(VIO_META) $(VIO_BRIDGE) vio_cmd.o vio_magic.o vio_pipe.o vio_socket.o vio_winsock.o vio_stack.o vio_jumbo.o vio_proto.o vio_dstr.o vio_tantalos.o vio_rtp.o vio_buffer.o vio_buffer_store.o vio_stdvios.o vio_misc.o vio_zlib.o vio_stream.o vio_proxy.o
-HASHES=hash.o hash_tiger.o hash_sha1.o
-PASSWORD=passwordapi.o pinentry.o sshaskpass.o
-CRYPTO=crypto.o random.o $(HASHES) crc.o
-OBJS=libroar.o config.o debug.o error.o basic.o stream.o client.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o $(PASSWORD) $(VIO) stack.o slp.o nnode.o roardl.o plugincontainer.o roarx11.o beep.o proto.o env.o keyval.o vs.o ltm.o notify.o notify_proxy.o asyncctl.o enumdev.o serverinfo.o $(CRYPTO) authfile.o caps.o roarfloat.o base64.o trap.o memmgr.o time.o kstore.o uuid.o watchdog.o scheduler.o
+TARGETS=libroar.so
+OBJS=libroar.o basic.o stream.o simple.o auth.o socket.o ctl.o buffer.o convert.o
 
 #DEFINES        = -DDEBUG
-#DEFINES+= -D_LIBROAR_NOATTR_WARNINGS
-INCLUDE = -I../include -I../include/libroar
-CFLAGS += $(DEBUG_g) $(Wall) $(OPTI_O) $(DEFINES) $(INCLUDE) $(INCPATH) $(SHARED_CF) $(fPIC)
-LDFLAGS+= $(DEBUG_g) $(Wall) $(SHARED) $(LDPATH)
-LIBS    = $(LIBROAR_NS)
+INCLUDE = -I../include -I./include
+CFLAGS  = -g -Wall -O2 $(DEFINES) $(INCLUDE)
+LDFLAGS = -g -shared
 
 all: ${TARGETS}
-	rm -f ../lib/${SLIB} 2> /dev/null || true
-	cp $(cp_v) ${TARGETS} ../lib/
+	cp -v ${TARGETS} ../lib/
 clean:
 	rm -f ${TARGETS} *.o
 new: clean all
 
-$(SLIB): ${OBJS}
-	${CC} ${LDFLAGS} -Wl,-soname,$(SLIB).$(LIBROAR_V) -o $(SLIB) ${OBJS} ${LIBS}
-$(ALIB): ${OBJS}
-	${AR} cru $(ALIB) ${OBJS}
-	${RANLIB} $(ALIB)
+libroar.so: ${OBJS}
+	${CC} ${LDFLAGS} -o libroar.so ${OBJS}
Index: libroar/acl.c
===================================================================
--- libroar/acl.c	(revision 6052)
+++ 	(revision )
@@ -1,52 +1,0 @@
-//acl.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_acl_rule_chk_connect (struct roar_acl_rule * rule, struct sockaddr * addr, socklen_t addrlen) {
-
- if ( !rule )
-  return -1;
-
- if ( rule->pid || rule->uid || rule->gid || rule->cookie )
-  return 0;
-
- if ( rule->addr && addr != NULL )
-  return 0;
-
- return -1;
-}
-
-//ll
Index: libroar/asyncctl.c
===================================================================
--- libroar/asyncctl.c	(revision 6052)
+++ 	(revision )
@@ -1,117 +1,0 @@
-//asyncctl.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_wait (struct roar_connection * con, struct roar_event * triggered, struct roar_event * events, size_t num) {
- struct roar_message m;
- uint16_t * u16 = (uint16_t *) m.data;
- void * vp = m.data;
- size_t i, len_left, len_have, tmp;
-
- if ( con == NULL || triggered == NULL )
-  return -1;
-
- if ( num == 0 )
-  return 0;
-
- if ( events == NULL )
-  return -1;
-
- memset(&m, 0, sizeof(m));
-
- m.cmd = ROAR_CMD_WAIT;
- m.stream = -1;
-
- u16[0] = ROAR_HOST2NET16(0); // version
- u16[1] = ROAR_HOST2NET16(0); // flags
-
- vp += 4; // we have 4 byte header (version + flags)
-
- len_left = sizeof(m.data) - 4;
- len_have = 4;
-
- for (i = 0; i < num; i++) {
-  tmp = len_left;
-  if ( roar_event_to_blob(&(events[i]), vp, &tmp) == -1 )
-   return -1;
-
-  len_left -= tmp;
-  len_have += tmp;
-  vp       += tmp;
- }
-
- m.datalen = len_have;
-
- if ( roar_req3(con, &m, NULL) != 0 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- u16[0] = ROAR_NET2HOST16(u16[0]);
- u16[1] = ROAR_NET2HOST16(u16[1]);
-
- // check if we have a complet header:
- if ( m.datalen < 2 )
-  return -1;
-
- // check if we have a unsupported version or flags:
- if ( u16[0] != 0 || u16[1] != 0 )
-  return -1;
-
- vp  = (void*)m.data;
- vp += 4;
- len_have = tmp = m.datalen - 4;
-
- memset(triggered, 0, sizeof(struct roar_event));
-
- if ( roar_event_from_blob(triggered, vp, &tmp) != 0 )
-  return -1;
-
- // test if we have a length match:
- if ( len_have != tmp )
-  return -1;
-
- // we now have an event.
-
- // we maybe have some data, need to reset this as it is of a local buffer:
- triggered->arg2 = NULL;
- triggered->arg2_len = 0;
-
- return 0;
-}
-
-//ll
Index: libroar/auth.c
===================================================================
--- libroar/auth.c	(revision 6052)
+++ libroar/auth.c	(revision 0)
@@ -1,505 +1,13 @@
 //auth.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illegal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroar.h"
 
-/* How auth works:
- * 0) set stage to zero
- * 1) get server address and local node name (from uname())
- * 2) look up authfile/authdb/authservice for the server+local address + stage.
- *    if no data was found send NONE-Auth.
- * 3) send data to server
- * 4) read answer from server
- * 5) if stage of server response is non-zero increment stage to server stage+1
- *    and repeat from step 2)
- * 6) check if we got an OK or an ERROR, return correct value
- */
-
-/* The protocol:
- * Auth request:
- * Byte 0: auth type
- * Byte 1: stage
- * Byte 2: reserved (must be zero)
- * Byte 3: reserved (must be zero)
- * Byte 4-end: auth type depending data.
- *
- * If no data is to be send bytes 2 and 3 can be omitted.
- * If no data is to be send and stage is zero bytes 1, 2 and 3 can be omitted.
- *
- * Auth response:
- * The same as the auth request.
- * if the server sends an zero size message back it means the server accepted our connection
- * and no additional stage is needed.
- * if the message type is OK the server accepted our auth.
- * if the message type is ERROR the server rejected us. we may try other auth methods.
- * if the server accepted our data and the stage is non-zero we need to continue with the next
- * stage of the auth.
- * if the server rejected us the auth type value of the response is a suggested next auth type
- * we should try if possible. This may help the client to find a working auth type.
- */
-
-/* The protocol by auth type:
- *
- * --- NONE:
- * No data is send, the server accepts the connect or rejects it depending on some
- * magic within the server. we do not care about this.
- * The data block is not used.
- *
- * --- COOKIE:
- * We send cookies for all stages the server ask us to provide a cookie.
- * if a cookie is wrong the server rejects us or asks us for another.
- * The cookie is send as binary data in the data block.
- *
- * --- TRUST:
- * We ask the server to auth us based on our UID/GID/PID.
- * The server may reject this because we are not allowed or because it is not
- * supported by the transport.
- * If we get rejected we may try to continue with IDENT then RHOST before we use NONE.
- * The data block is not used.
- *
- * --- PASSWORD:
- * This is technically the same as COOKIE just that the cookie is limited to
- * printable ASCII chars and that the user should be asked to provide the password.
- * This may be done via a GUI popup window.
- *
- * --- SYSUSER:
- * We provide a Username + Password for a system user.
- * The data block contains of two main parts:
- * The first part is a one byte long subtype.
- * The value must be 0x01 for username+password.
- * future versions may define other types.
- * the second part is the actual data block.
- * for username+password it is splited into two fields, both terminated with \0.
- * the first is the username the last one the password as clear text.
- * Example: char data[] = "\001MyUser\0MyPassword\0";
- * 
- * --- OPENPGP_SIGN:
- *
- * --- OPENPGP_ENCRYPT:
- *
- * --- OPENPGP_AUTH:
- *
- * --- KERBEROS:
- * We use Kerberos to auth.
- *
- * --- RHOST:
- * The server is asked to auth us based on our source address.
- * The data block is not used.
- *
- * --- XAUTH:
- * We send an X11 Cookie.
- *
- * --- IDENT:
- * The server is asked to auth us based on our source address using the IDENT protocol.
- * The data block is not used.
- *
- */
-
-static int roar_auth_ask_server (struct roar_connection * con, struct roar_auth_message * authmes) {
- struct roar_error_frame error_frame;
- struct roar_message     mes;
- char                  * header = mes.data;
- int                     ret;
- char                  * data = NULL;
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type);
-
- roar_err_init(&error_frame);
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
+int roar_auth   (struct roar_connection * con) {
+ struct roar_message mes;
 
  mes.cmd     = ROAR_CMD_AUTH;
- mes.stream  = -1;
- mes.datalen =  4 + authmes->len;
+ mes.datalen = 0;
 
- if ( mes.datalen > sizeof(mes.data) ) {
-  data = roar_mm_malloc(mes.datalen);
-  if ( data == NULL )
-   return -1;
-
-  header   = data;
- }
-
- header[0] = authmes->type;
- header[1] = authmes->stage;
- header[2] = authmes->reserved.c[0];
- header[3] = authmes->reserved.c[1];
-
- if ( authmes->len ) {
-  if ( data == NULL ) {
-   memcpy(mes.data + 4, authmes->data, authmes->len);
-  } else {
-   memcpy(data + 4, authmes->data, authmes->len);
-  }
- }
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type);
-
- if ( (ret = roar_req2(con, &mes, &data, &error_frame)) == -1 ) {
-  authmes->type = -1;
-  ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = -1 // next: -1", con, authmes);
-  return -1;
- }
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): mes->cmd=%i", con, authmes, authmes->type, mes.cmd);
-
- if ( data != NULL ) {
-  header = data;
- } else {
-  header = mes.data;
- }
-
- if ( mes.cmd == ROAR_CMD_ERROR )
-  ret = -1;
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): error_frame.data=%p",
-           con, authmes, authmes->type, error_frame.data);
-
- if ( mes.cmd == ROAR_CMD_ERROR && error_frame.data != NULL ) {
-  header = error_frame.data;
-  mes.datalen = error_frame.datalen;
- }
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type);
-
- if ( mes.datalen < 4 ) {
-  memset(header+mes.datalen, 0, 4-mes.datalen);
-  authmes->type          = -1;
- } else {
-  authmes->type          = header[0];
- }
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = ?", con, authmes);
-
- authmes->stage         = header[1];
- authmes->reserved.c[0] = header[2];
- authmes->reserved.c[1] = header[3];
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = %i // next: %i", con, authmes, ret, authmes->type);
- return ret;
-}
-
-static void roar_auth_mes_init(struct roar_auth_message * authmes, int type) {
- memset(authmes, 0, sizeof(struct roar_auth_message));
-
- authmes->type  = type;
- authmes->stage = 0;
- authmes->data  = NULL;
- authmes->len   = 0;
-}
-
-
-static int try_password (struct roar_connection * con, int * next) {
- struct roar_message mes;
- struct roar_auth_message authmes;
- char * pw;
-
- // TODO: add support for *next.
-
- roar_auth_mes_init(&authmes, ROAR_AUTH_T_PASSWORD);
-
- if ( roar_passwd_simple_ask_pw(&pw, "Password for RoarAudio Server?", NULL) == -1 ) {
-  return -1;
- }
-
- authmes.len = strlen(pw);
-
- if ( roar_auth_init_mes(&mes, &authmes) == -1 ) {
-  roar_mm_free(pw);
-  return -1;
- }
-
- // do not use strcpy() because that would copy \0, too.
- memcpy(authmes.data, pw, authmes.len);
-
- roar_mm_free(pw);
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( roar_auth_from_mes(&authmes, &mes, NULL) == -1 )
-  return -1;
-
- if ( authmes.stage == 0 )
-  return 0;
-
- return -1;
-}
-
-static int try_cookie (struct roar_connection * con, int * next) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_auth_message authmes;
- struct roar_authfile * authfile;
- struct roar_authfile_key * key;
- int idx;
- int done = 0;
-
- roar_auth_mes_init(&authmes, ROAR_AUTH_T_COOKIE);
-
- if ( (authfile = roar_authfile_open(ROAR_AUTHFILE_TYPE_AUTO, config->authfile, 0, ROAR_AUTHFILE_VERSION_AUTO)) == NULL )
-  return -1;
-
- for (idx = 0; !done; idx++) {
-  if ( (key = roar_authfile_lookup_key(authfile, ROAR_AUTH_T_COOKIE, idx, NULL)) == NULL )
-   break;
-
-  authmes.data = key->data;
-  authmes.len  = key->len;
-
-  if ( roar_auth_ask_server(con, &authmes) != -1 )
-   done = 1;
-
-  roar_authfile_key_unref(key);
- }
-
- roar_authfile_close(authfile);
-
- return done ? 0 : -1;
-}
-
-#define _EOL ROAR_AUTH_T_AUTO
-int roar_auth   (struct roar_connection * con) {
- struct roar_auth_message authmes;
- int ret;
- int i;
- int cur, next;
- int done;
- int ltt[] = {
-              ROAR_AUTH_T_TRUST,
-              ROAR_AUTH_T_IDENT,
-              ROAR_AUTH_T_RHOST,
-//              ROAR_AUTH_T_PASSWORD,
-              ROAR_AUTH_T_COOKIE,
-              ROAR_AUTH_T_NONE,
-              ROAR_AUTH_T_PASSWORD, // (re-)try password if there is no guest access.
-              _EOL
-             };
-
- for (i = 0; ltt[i] != _EOL; i++) {
-  next = ltt[i];
-  ROAR_DBG("roar_auth(con=%p): next from ltt: %s(%i)", con, roar_autht2str(next), next);
-
-  while (next != -1) {
-   done = 1;
-
-   cur  = next;
-   next = -1;
-
-   ROAR_DBG("roar_auth(con=%p): cur=%s(%i)", con, roar_autht2str(cur), cur);
-
-   switch (cur) {
-    case ROAR_AUTH_T_PASSWORD:
-      if ( (ret = try_password(con, &next)) == -1 )
-       done = 0;
-      break;
-    case ROAR_AUTH_T_TRUST:
-    case ROAR_AUTH_T_IDENT:
-    case ROAR_AUTH_T_RHOST:
-    case ROAR_AUTH_T_NONE:
-      roar_auth_mes_init(&authmes, cur);
-      if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 )
-       done = 0;
-
-      next = authmes.type;
-     break;
-    case ROAR_AUTH_T_COOKIE:
-      if ( (ret = try_cookie(con, &next)) == -1 )
-       done = 0;
-      break;
-     break;
-    default: /* Bad error! */
-      return -1;
-     break;
-   }
-
-   if ( authmes.stage != 0 )
-    done = 0;
-
-   ROAR_DBG("roar_auth(con=%p): done=%i, next=%i", con, done, next);
-
-   if ( done ) {
-    ROAR_DBG("roar_auth(con=%p) = 0", con);
-    return 0;
-   }
-  }
- }
-
- ROAR_DBG("roar_auth(con=%p) = -1", con);
- return -1;
-}
-
-
-int roar_auth_from_mes(struct roar_auth_message * ames, struct roar_message * mes, void * data) {
- void * ibuf;
- char header[4] = {0, 0, 0, 0};
-
- if ( ames == NULL || mes == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( data != NULL ) {
-  ibuf = data;
- } else {
-  ibuf = mes->data;
- }
-
- memset(ames, 0, sizeof(struct roar_auth_message));
-
- memcpy(header, ibuf, mes->datalen < 4 ? mes->datalen : 4);
-
- ames->type          = header[0];
- ames->stage         = header[1];
- ames->reserved.c[0] = header[2];
- ames->reserved.c[1] = header[3];
-
- if ( mes->datalen > 4 ) {
-  ames->data = ibuf + 4;
-  ames->len  = mes->datalen - 4;
- } else {
-  ames->data = NULL;
-  ames->len  = 0;
- }
-
- return 0;
-}
-
-int roar_auth_to_mes(struct roar_message * mes, void ** data, struct roar_auth_message * ames) {
- char * obuf;
-
- if ( mes == NULL || ames == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( data != NULL )
-  *data = NULL;
-
- memset(mes, 0, sizeof(struct roar_message));
-
- mes->cmd = ROAR_CMD_AUTH;
-
- if ( (ames->len + 4) > sizeof(mes->data) ) {
-  *data = roar_mm_malloc(ames->len + 4);
-  if ( *data == NULL )
-   return -1;
-  obuf = *data;
- } else {
-  obuf = mes->data;
- }
-
- obuf[0] = ames->type;
- obuf[1] = ames->stage;
- obuf[2] = ames->reserved.c[0];
- obuf[3] = ames->reserved.c[1];
-
- memcpy(obuf + 8, ames->data, ames->len);
-
- mes->datalen = ames->len + 4;
-
- return 0;
-}
-
-int roar_auth_init_mes(struct roar_message * mes, struct roar_auth_message * ames) {
- if ( mes == NULL || ames == NULL )
-  return -1;
-
- if ( (ames->len + 4) > sizeof(mes->data) )
-  return -1;
-
- memset(mes, 0, sizeof(struct roar_message));
-
- mes->cmd = ROAR_CMD_AUTH;
-
- mes->data[0] = ames->type;
- mes->data[1] = ames->stage;
- mes->data[2] = ames->reserved.c[0];
- mes->data[3] = ames->reserved.c[1];
-
- ames->data = &(mes->data[4]);
-
- mes->datalen = ames->len + 4;
-
- return 0;
-}
-
-
-
-// String functions:
-static struct {
- int    type;
- const char * name;
-} _g_authts[] = {
-// grep ^'#define ROAR_AUTH_T_' auth.h | while read d t d; do n=$(cut -d_ -f4 <<<$t | tr A-Z a-z); printf ' {%-28s %-10s},\n' $t, \"$n\"; done
- {ROAR_AUTH_T_NONE,            "none"    },
- {ROAR_AUTH_T_COOKIE,          "cookie"  },
- {ROAR_AUTH_T_TRUST,           "trust"   },
- {ROAR_AUTH_T_PASSWORD,        "password"},
- {ROAR_AUTH_T_SYSUSER,         "sysuser" },
- {ROAR_AUTH_T_OPENPGP_SIGN,    "openpgp" },
- {ROAR_AUTH_T_OPENPGP_ENCRYPT, "openpgp" },
- {ROAR_AUTH_T_OPENPGP_AUTH,    "openpgp" },
- {ROAR_AUTH_T_KERBEROS,        "kerberos"},
- {ROAR_AUTH_T_RHOST,           "rhost"   },
- {ROAR_AUTH_T_XAUTH,           "xauth"   },
- {ROAR_AUTH_T_IDENT,           "ident"   },
- {-1, NULL}
-};
-
-int    roar_str2autht(const char * str) {
- int i;
-
- for (i = 0; _g_authts[i].name != NULL; i++)
-  if ( !strcasecmp(_g_authts[i].name, str) )
-   return _g_authts[i].type;
-
- return -1;
-}
-
-const char * roar_autht2str(const int auth) {
- int i;
-
- for (i = 0; _g_authts[i].name != NULL; i++)
-  if ( _g_authts[i].type == auth )
-   return _g_authts[i].name;
-
- return "(UNKNOWN)";
+ return roar_req(con, &mes, NULL);
 }
 
Index: libroar/authfile.c
===================================================================
--- libroar/authfile.c	(revision 6052)
+++ 	(revision )
@@ -1,283 +1,0 @@
-//authfile.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-struct roar_authfile {
- size_t refc;
- size_t lockc;
- int type;
- int rw;
- int version;
- size_t magiclen;
- struct roar_vio_calls vio;
-};
-
-struct roar_authfile * roar_authfile_open(int type, const char * filename, int rw, int version) {
- struct roar_vio_defaults def;
- struct roar_authfile * ret;
- size_t magiclen = 0;
-#if defined(ROAR_HAVE_STAT) && defined(ROAR_HAVE_H_SYS_STAT)
- struct stat filestat;
-#endif
-
- if ( type == ROAR_AUTHFILE_TYPE_AUTO ) {
-#if defined(ROAR_HAVE_STAT) && defined(ROAR_HAVE_H_SYS_STAT)
-  if ( stat(filename, &filestat) != 0 )
-   return NULL;
-
-  if ( filestat.st_size == 16 ) {
-   type = ROAR_AUTHFILE_TYPE_ESD;
-  } else if ( filestat.st_size == 256 ) {
-   type = ROAR_AUTHFILE_TYPE_PULSE;
-  } else {
-   return NULL;
-  }
-#else
-  return NULL;
-#endif
- }
-
- switch (type) {
-  case ROAR_AUTHFILE_TYPE_ESD:
-  case ROAR_AUTHFILE_TYPE_PULSE:
-   break;
-  default:
-    return NULL;
-   break;
- }
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, rw ? O_RDWR|O_CREAT : O_RDONLY, 0600) == -1 )
-  return NULL;
-
- if ( (ret = roar_mm_malloc(sizeof(struct roar_authfile))) == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_authfile));
-
- ret->refc     = 1;
- ret->lockc    = 0;
- ret->type     = type;
- ret->rw       = rw;
- ret->version  = version;
- ret->magiclen = magiclen;
-
- filename = roar_mm_strdup(filename);
-
- if ( roar_vio_open_dstr(&(ret->vio), filename, &def, 1) == -1 ) {
-  roar_mm_free((void*)filename);
-  roar_mm_free(ret);
-  return NULL;
- }
-
- roar_mm_free((void*)filename);
-
- return ret;
-}
-
-int roar_authfile_close(struct roar_authfile * authfile) {
- if ( authfile == NULL )
-  return -1;
-
- roar_vio_close(&(authfile->vio));
-
- roar_mm_free(authfile);
-
- return 0;
-}
-
-int roar_authfile_lock(struct roar_authfile * authfile) {
- if ( authfile == NULL )
-  return -1;
-
- // TODO: implement real locking here.
- return 0;
-}
-
-int roar_authfile_unlock(struct roar_authfile * authfile) {
- if ( authfile == NULL )
-  return -1;
-
- // TODO: implement real unlocking here.
- return 0;
-}
-
-int roar_authfile_sync(struct roar_authfile * authfile) {
- if ( authfile == NULL )
-  return -1;
-
- return roar_vio_sync(&(authfile->vio));
-}
-
-
-struct roar_authfile_key * roar_authfile_key_new(int type, size_t len, const char * addr) {
- struct roar_authfile_key * ret;
- size_t addrlen;
- size_t retlen;
-
- if ( addr == NULL ) {
-  addrlen = 0;
- } else {
-  addrlen = strlen(addr) + 1;
- }
-
- retlen = sizeof(struct roar_authfile_key) + len + addrlen;
-
- if ( (ret = roar_mm_malloc(retlen)) == NULL )
-  return NULL;
-
- memset(ret, 0, retlen);
-
- ret->refc  = 1;
- ret->type  = type;
- ret->index = -1;
-
- if ( addrlen == 0 ) {
-  ret->address = NULL;
- } else {
-  ret->address = (const void *)ret+sizeof(struct roar_authfile_key);
-  memcpy((void*)ret->address, addr, addrlen);
- }
-
- ret->data = (void*)ret + sizeof(struct roar_authfile_key) + addrlen;
-
- ret->len  = len;
-
- return ret;
-}
-
-int roar_authfile_key_ref(struct roar_authfile_key * key) {
- if ( key == NULL )
-  return -1;
-
- key->refc++;
-
- return 0;
-}
-
-int roar_authfile_key_unref(struct roar_authfile_key * key) {
- if ( key == NULL )
-  return -1;
-
- if ( key->refc == 0 ) {
-  ROAR_ERR("roar_authfile_key_unref(key=%p): Key has reference count of zero. This is bad. assuming refc=1", key);
-  key->refc = 1;
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
- }
-
- key->refc--;
-
- if ( key->refc > 0 )
-  return 0;
-
- roar_mm_free(key);
-
- return 0;
-}
-
-int roar_authfile_add_key(struct roar_authfile * authfile, struct roar_authfile_key * key) {
- if ( authfile == NULL || key == NULL )
-  return -1;
-
- switch (authfile->type) {
-  case ROAR_AUTHFILE_TYPE_ESD:
-  case ROAR_AUTHFILE_TYPE_PULSE:
-    if ( key->type != ROAR_AUTH_T_COOKIE || (key->index != 0 && key->index != -1) )
-     return -1;
-    if ( roar_authfile_sync(authfile) == -1 )
-     return -1;
-    if ( roar_authfile_lock(authfile) == -1 )
-     return -1;
-    if ( roar_vio_lseek(&(authfile->vio), 0, SEEK_SET) != 0 )
-     return -1;
-    if ( roar_vio_write(&(authfile->vio), key->data, key->len) != (ssize_t)key->len )
-     return -1;
-    if ( roar_authfile_unlock(authfile) == -1 )
-     return -1;
-    return 0;
-   break;
-  default:
-    return -1;
-   break;
- }
-}
-
-struct roar_authfile_key * roar_authfile_lookup_key(struct roar_authfile * authfile,
-                                                    int type, int minindex, const char * address) {
- struct roar_authfile_key * ret = NULL;
- ssize_t len;
-
- if ( authfile == NULL )
-  return NULL;
-
- switch (authfile->type) {
-  case ROAR_AUTHFILE_TYPE_ESD:
-  case ROAR_AUTHFILE_TYPE_PULSE:
-    if ( (type != ROAR_AUTH_T_COOKIE && type != ROAR_AUTH_T_AUTO) || minindex > 0 )
-     return NULL;
-
-    if ( (ret = roar_authfile_key_new(ROAR_AUTH_T_COOKIE, 256, NULL)) == NULL )
-     return NULL;
-
-    len = roar_vio_read(&(authfile->vio), ret->data, ret->len);
-
-    if ( len == -1 ) {
-     roar_authfile_key_unref(ret);
-     return NULL;
-    }
-
-    ret->len   = len;
-    ret->index = 0;
-   break;
-  default:
-    return NULL;
-   break;
- }
-
- return ret;
-}
-
-struct roar_authfile_key * roar_authfile_key_new_random(int type, size_t len, const char * addr) {
- struct roar_authfile_key * ret = roar_authfile_key_new(type, len, addr);
-
- if ( ret == NULL )
-  return NULL;
-
- roar_random_gen_nonce(ret->data, ret->len);
-
- return ret;
-}
-
-//ll
Index: libroar/base64.c
===================================================================
--- libroar/base64.c	(revision 6052)
+++ 	(revision )
@@ -1,316 +1,0 @@
-//base64.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static char _base64_tab_fw[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
-
-static char _base64_tab_bw[] = {
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
-  0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
-  0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
-  0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
-  0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
-  0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-
-int roar_base64_init(struct roar_base64 * state, int flags) {
- if ( flags == -1 )
-  flags = 0;
-
- if ( state == NULL )
-  return -1;
-
- memset(state, 0, sizeof(struct roar_base64));
-
- state->flags = flags;
-
- return 0;
-}
-
-static inline void _libroar_base64_encode_block(unsigned char out[4], const unsigned char in[3]) {
-// printf("in={'%c', '%c', '%c'}\n", in[0], in[1], in[2]);
- out[0] = _base64_tab_fw[(in[0] >> 2) & 0x3F];
- out[1] = _base64_tab_fw[(((in[0] & 0x03) << 4) | (in[1] >> 4)) & 0x3F];
- out[2] = _base64_tab_fw[(((in[1] & 0x0F) << 2) | ((in[2] >> 6) & 0x03)) & 0x3F];
- out[3] = _base64_tab_fw[in[2] & 0x3F];
-}
-
-#define _setoff(x) do { if ( off != NULL ) { *off = (x); } } while (0)
-
-ssize_t roar_base64_encode(struct roar_base64 * state, void * out, size_t outlen, const void * in, size_t inlen, size_t * off, int eof) {
- struct roar_base64 state_store;
- size_t offset = 0;
- size_t tlen;
- ssize_t ret = 0;
- unsigned char * outp;
- const unsigned char * inp;
-
- if ( inlen && in == NULL )
-  return -1;
-
- if ( outlen && out == NULL )
-  return -1;
-
- // this test should be removed as soon as those modes are supported.
- if ( in == NULL || out == NULL )
-  return -1;
-
- // we can not write anything anyway...
- if ( outlen < 4 )
-  return 0;
-
- if ( state == NULL ) {
-  state = &state_store;
-  roar_base64_init_encode(state, ROAR_BASE64_FLAG_NONE);
-  eof = 1;
- }
-
- if ( state->buflen ) {
-  tlen = 3 - state->buflen;
-  ROAR_DBG("roar_base64_encode(state=%p,...): Still %llu bytes in state", state, (long long unsigned int)state->buflen);
-  ROAR_DBG("roar_base64_encode(state=%p,...): Need %llu bytes", state, (long long unsigned int)tlen);
-  if ( inlen >= tlen ) {
-   memcpy(state->iobuf + state->buflen, in, tlen);
-   offset += tlen;
-   in += tlen;
-   inlen -= tlen;
-   _libroar_base64_encode_block(out, state->iobuf);
-   out += 4;
-   outlen -= 4;
-   ret += 4;
-   state->buflen = 0;
-  } else {
-   memcpy(state->iobuf + state->buflen, in, inlen);
-   state->buflen += inlen;
-   _setoff(inlen);
-   return 0;
-  }
- }
-
- for (; inlen >= 3 && outlen >= 4;) {
-  _libroar_base64_encode_block(out, in);
-  ret += 4;
-  out += 4;
-  in  += 3;
-  offset += 3;
-  inlen -= 3;
-  outlen -= 4;
- }
-
- // something left?
- if ( inlen ) {
-  if ( eof ) {
-   if ( outlen >= 4 ) {
-    outp = out;
-    inp  = in;
-    switch (inlen) {
-     case 1:
-       outp[0] = _base64_tab_fw[inp[0] >> 2];
-       outp[1] = _base64_tab_fw[(inp[0] & 0x03) << 4];
-       outp[2] = '=';
-       outp[3] = '=';
-       ret += 4;
-       out += 4;
-       in  += 1;
-       offset += 1;
-       inlen  -= 1;
-       outlen -= 4;
-      break;
-     case 2:
-       outp[0] = _base64_tab_fw[inp[0] >> 2];
-       outp[1] = _base64_tab_fw[(((inp[0] & 0x03) << 4) | (inp[1] >> 4)) & 0x3F];
-       outp[2] = _base64_tab_fw[(((inp[1] & 0x0F) << 2))                 & 0x3F];
-       outp[3] = '=';
-       ret += 4;
-       out += 4;
-       in  += 2;
-       offset += 2;
-       inlen  -= 2;
-       outlen -= 4;
-      break;
-    }
-   }
-  } else {
-   memcpy(state->iobuf, in, inlen);
-   state->buflen = inlen;
-   offset += inlen;
-   in += inlen;
-   inlen -= inlen;
-  }
- }
-
- if ( outlen ) {
-  *(char*)out = 0;
- }
-
- _setoff(offset);
-
- return 0;
-}
-
-ssize_t roar_base64_decode(struct roar_base64 * state, void * out, size_t outlen, const void * in, size_t inlen, size_t * off) {
- struct roar_base64 state_store;
- ssize_t ret = 0;
- unsigned char c;
- int bits;
- const unsigned char * inp = in;
- unsigned char * outp = out;
- size_t offset = 0;
-
- if ( inlen && in == NULL )
-  return -1;
-
- if ( outlen && out == NULL )
-  return -1;
-
- // this test should be removed as soon as those modes are supported.
- if ( in == NULL || out == NULL )
-  return -1;
-
- if ( state == NULL ) {
-  state = &state_store;
-  roar_base64_init_encode(state, ROAR_BASE64_FLAG_NONE);
- }
-
- if ( state->reglen >= 8 ) {
-  *outp  = (state->reg >> (state->reglen - 8)) & 0xFF;
-  state->reglen -= 8;
-  outp++;
-  outlen--;
-  ret++;
- }
-
- if ( state->flags & ROAR_BASE64_FLAG_EOF ) {
-  if ( outlen ) {
-   *outp = 0;
-  }
-  return ret;
- }
-
- //printf("state->reglen=%i\n", (int)state->reglen);
-
- for (; inlen && outlen; ) {
-  c = *inp;
-  inp++;
-  inlen--;
-  offset++;
-
-  if ( c == '=' ) {
-   bits = 0;
-  } else {
-   // hi-bit set chars need to be ignored.
-   if ( (size_t)c > sizeof(_base64_tab_bw) )
-    continue;
-
-   bits = _base64_tab_bw[c];
-
-   // ignore unknown chars.
-   if ( bits == (char)0xFF )
-    continue;
-  }
-
-  state->reg   <<= 6;
-  state->reg    |= bits;
-  state->reglen += 6;
-
-  if ( state->reglen >= 8 ) {
-   *outp  = (state->reg >> (state->reglen - 8)) & 0xFF;
-   state->reglen -= 8;
-   outp++;
-   outlen--;
-   ret++;
-  }
-
-  if ( c == '=' ) {
-   state->flags |= ROAR_BASE64_FLAG_EOF;
-   if ( state->reglen <= 6 ) {
-    state->reglen = 0;
-   }
-   if ( inlen ) {
-    if ( *inp == '=' ) {
-     offset++;
-    }
-   }
-   break;
-  }
- }
-
- if ( off != NULL ) {
-  *off = offset;
- }
-
- if ( outlen ) {
-  *outp = 0;
- }
-
- return ret;
-}
-
-int roar_base64_is_eof(struct roar_base64 * state) {
- if ( state == NULL )
-  return -1;
-
- if ( state->reglen >= 8 )
-  return 0;
-
- return !!(state->flags & ROAR_BASE64_FLAG_EOF);
-}
-
-int roar_base64_uninit(struct roar_base64 * state) {
- if ( state == NULL )
-  return -1;
-
- if ( state->buflen ) {
-  ROAR_WARN("roar_base64_uninit(state=%p): State has %i bytes left in IO buffer. This is a application error.", state, state->buflen);
- }
-
- if ( state->reglen ) {
-  ROAR_WARN("roar_base64_uninit(state=%p): State has %i bits left in decode register. This is a application error.", state, state->reglen);
- }
-
- return 0;
-}
-
-//ll
Index: libroar/basic.c
===================================================================
--- libroar/basic.c	(revision 6052)
+++ libroar/basic.c	(revision 0)
@@ -1,894 +1,90 @@
 //basic.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
 #include "libroar.h"
 
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
-#include <pwd.h>
-#endif
-
-enum mode {
- NORMAL = 0,
- SYSTEM = 1
-};
-
-static int _connect_server(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout);
-
-int __get_daemonimage(char ** daemonimage, enum mode * mode, const char * server) {
- const char * tmp = NULL;
-
- *daemonimage = NULL;
- *mode = NORMAL;
-
- if ( !!strncmp(server, "+fork", 5) ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- server += 5;
-
- if ( server[0] == '=' ) {
-  server++;
-
-  if ( server[0] == 0 ) {
-   // no special case, we just ignore it.
-  } else if ( server[0] == 'd' && server[1] == ':' ) {
-   server += 2;
-   tmp = server;
-   *mode = NORMAL;
-  } else if ( server[0] == '!' ) {
-   server += 1;
-   tmp = server;
-   *mode = SYSTEM;
-  } else {
-   roar_err_set(ROAR_ERROR_ILLSEQ);
-   return -1;
-  }
- }
-
- if ( tmp == NULL || *tmp == 0 )
-  tmp = roar_libroar_get_config()->daemonimage;
-
- // we keep this step to be compatible with older versions.
- if ( tmp == NULL || *tmp == 0 ) {
-  tmp = roar_env_get("ROAR_DAEMONIMAGE");
-  if ( tmp != NULL ) {
-   ROAR_WARN("__get_daemonimage(*): Usage of $ROAR_DAEMONIMAGE is obsolete. Use ROAR_OPTIONS=daemonimage:...");
-  }
- }
-
- if ( tmp != NULL && *tmp != 0 ) {
-  *daemonimage = roar_mm_strdup(tmp);
-  return 0;
- }
-
- *daemonimage = roar_libroar_get_path("bin-default-daemonimage", 0, NULL, NULL);
- if ( *daemonimage == NULL )
-  return -1;
-
- return 0;
-}
-
-#if defined(ROAR_TARGET_WIN32)
-#define NUM_TRIES 16
-static int _start_server_win32(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) {
- enum mode mode = NORMAL;
- char * daemonimage = NULL;
- char buf[64];
- int port;
- size_t i;
- int fh;
- int ret;
- int err;
-
- if ( __get_daemonimage(&daemonimage, &mode, server) == -1 )
-  return -1;
-
- if ( mode != NORMAL ) {
-  roar_mm_free(daemonimage);
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- for (i = 0; i < NUM_TRIES; i++) {
-  port = roar_random_uint16();
-  if ( port < 1025 ) /* it seems on some strange systems the magic border is at 1025 not 1024. */
-   continue;
-
-  fh = roar_socket_connect(ROAR_SOCKET_TYPE_TCP, "localhost", port);
-  if ( fh == -1 )
-   break;
-
-  closesocket(fh);
- }
-
- if ( i == NUM_TRIES ) {
-  roar_mm_free(daemonimage);
-  roar_err_set(ROAR_ERROR_LOOP);
-  return -1;
- }
-
- // port is the port to use. It seems to be 'free'.
-
-#if defined(_P_DETACH)
-#define MODE _P_DETACH
-#elif defined(_P_NOWAIT)
-#define MODE _P_NOWAIT
-#else
-#define MODE _P_NOWAITO
-#endif
-
- snprintf(buf, sizeof(buf), "%i", port);
- roar_err_clear_all();
- if ( _spawnlp(MODE, daemonimage, daemonimage, "--tcp", "--bind", "localhost", "--port", buf, (const char*)NULL) < 0 ) {
-  roar_err_update();
-  ROAR_ERR("_start_server_win32(server='%s', ...): Can not start server: %s: %s", server, daemonimage, roar_errorstring);
-  roar_mm_free_noerror(daemonimage);
-  return -1;
- }
-
- roar_mm_free(daemonimage);
-
- snprintf(buf, sizeof(buf), "localhost:%i", port);
-
- // give the daemon some time to come up:
- roar_usleep(25000);
-
- ret = -1;
- for (i = 0; ret == -1 && i < NUM_TRIES; i++) {
-  ret = _connect_server(con, buf, type, flags, timeout);
-  if ( ret == -1 && i < NUM_TRIES )
-   roar_sleep(1);
- }
-
- if ( ret == -1 )
-  return -1;
-
- con->flags |= ROAR_CON_FLAGS_TERMINATE;
-
- return 0;
-}
-#elif !defined(ROAR_TARGET_MICROCONTROLLER)
-static int _start_server_posix(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) {
- enum mode mode = NORMAL;
- char * daemonimage = NULL;
- int socks[2];
- int r;
- char fhstr[12];
- size_t len;
- char * bin_sh;
- int err;
-
- if ( __get_daemonimage(&daemonimage, &mode, server) == -1 )
-  return -1;
-
- len = roar_mm_strlen(daemonimage) + 9; // 9 = '+fork=' + 'X:' + '\0'
- con->server_name = roar_mm_malloc(len);
- if ( con->server_name != NULL ) {
-  snprintf(con->server_name, len, "+fork=%s%s", mode == NORMAL ? "d:" : "!", daemonimage);
- }
-
- if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) {
-  roar_err_from_errno();
-  roar_mm_free_noerror(daemonimage);
-  return -1;
- }
-
- r = roar_fork(NULL);
-
- if ( r == -1 ) { // error!
-  ROAR_ERR("_start_server(*): Can not fork: %s", roar_error2str(roar_error));
-  err = roar_error;
-  close(socks[0]);
-  close(socks[1]);
-  roar_mm_free(daemonimage);
-  roar_error = err;
-  return -1;
- } else if ( r == 0 ) { // we are the child
-  roar_watchdog_stop();
-
-  close(socks[0]);
-
-  close(ROAR_STDIN ); // we do not want roard to have any standard input
-  close(ROAR_STDOUT); // STDOUT is also not needed, so we close it,
-                      // but STDERR we keep open for error messages.
-
-  snprintf(fhstr, sizeof(fhstr), "%i", socks[1]);
-
-  switch (mode) {
-   case NORMAL:
-     execlp(daemonimage, daemonimage, "--no-listen", "--client-fh", fhstr, (_LIBROAR_GOOD_CAST char*)NULL);
-    break;
-   case SYSTEM:
-     dup2(socks[1], ROAR_STDIN );
-     dup2(socks[1], ROAR_STDOUT);
-     bin_sh = roar_libroar_get_path("bin-sh", 0, NULL, NULL);
-     if ( bin_sh != NULL ) {
-      execl(bin_sh, bin_sh, "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL);
-      roar_mm_free(bin_sh);
-     }
-     execlp("sh", "sh", "-c", daemonimage, (_LIBROAR_GOOD_CAST char*)NULL);
-    break;
-  }
-
-  roar_mm_free(daemonimage);
-
-  // we are still alive?
-  ROAR_ERR("_start_server(*): alive after exec(), that's bad!");
-  ROAR_U_EXIT(1);
- } else { // we are the parent
-  close(socks[1]);
-  roar_mm_free(daemonimage);
-  if ( roar_vio_open_fh_socket(con->viocon, socks[0]) == -1 ) {
-   close(socks[0]);
-   return -1;
-  } else {
-   con->flags |= ROAR_CON_FLAGS_VIO;
-  }
-  return 0;
- }
-
- return -1;
-}
-#endif
-
-static int _start_server(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) {
-#if defined(ROAR_TARGET_WIN32)
- return _start_server_win32(con, server, type, flags, timeout);
-#elif !defined(ROAR_TARGET_MICROCONTROLLER)
- return _start_server_posix(con, server, type, flags, timeout);
-#else
- ROAR_ERR("_start_server(*): There is no UNIX Domain Socket, download a real OS.");
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-static int _connect_internal(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_vio_calls * vio;
-
- if ( config->connect_internal != NULL ) {
-  vio = config->connect_internal(con, server, type, flags, timeout);
-  if ( vio == NULL )
-   return -1;
-
-  con->viocon = vio;
-  con->flags |= ROAR_CON_FLAGS_VIO;
-
-  return 0;
- }
-
- roar_err_set(ROAR_ERROR_BADHOST);
- return -1;
-}
-
-static int _connect_server(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) {
-#if defined(ROAR_HAVE_STAT) && defined(ROAR_HAVE_H_SYS_STAT)
- struct stat sockstat;
-#endif
- const char * obj = NULL;
- char user_sock[128];
- int is_decnet = 0;
+int roar_connect_raw (char * server) {
+ char user_sock[80];
+ char * roar_server;
+ int i;
  int port = 0;
- int i = 0;
  int fh = -1;
- int err;
- int ret;
-
- if ( con == NULL || server == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( !strcmp(server, "+invalid") ) {
-  roar_err_set(ROAR_ERROR_CANCELED);
-  return -1;
- } else if ( !strncmp(server, "+dstr=", 6) ) {
-  if ( roar_vio_open_dstr_simple(con->viocon, server+6, ROAR_VIOF_READWRITE) == -1 )
-   return -1;
-  con->flags |= ROAR_CON_FLAGS_VIO;
-  con->server_name = roar_mm_strdup(server);
-  return 0;
- } else if ( !strcmp(server, "+fork") || !strncmp(server, "+fork=", 6) ) {
-  return _start_server(con, server, type, flags, timeout);
- } else if ( !strcmp(server, "+internal") || !strncmp(server, "+internal=", 10) ) {
-  ret = _connect_internal(con, server, type, flags, timeout);
-  if ( ret == 0 )
-   con->server_name = roar_mm_strdup(server);
-  return ret;
- }
-
- strncpy(user_sock, server, sizeof(user_sock)-1);
- user_sock[sizeof(user_sock)-1] = 0;
-
-
- if ( *user_sock != '/' ) { // don't test AF_UNIX sockets for ports
-  for (i = 0; user_sock[i] != 0; i++) {
-   if ( user_sock[i] == ':' ) {
-    if ( user_sock[i+1] == ':' ) { // DECnet, leave unchanged
-     is_decnet = 1;
-     obj = &user_sock[i+2];
-     break;
-    }
-
-    port = atoi(&(user_sock[i+1]));
-    user_sock[i] = 0;
+
+ if ( (roar_server = getenv("ROAR_SERVER")) != NULL )
+  server = roar_server;
+
+ if ( server == NULL ) {
+  /* connect via defaults */
+
+
+  if ( (fh = roar_socket_connect(ROAR_DEFAULT_SOCK_GLOBAL, 0)) != -1 )
+   return fh;
+
+  snprintf(user_sock, 79, "%s/%s", getenv("HOME"), ROAR_DEFAULT_SOCK_USER);
+
+  if ( (fh = roar_socket_connect(user_sock, 0)) != -1 )
+   return fh;
+
+  if ( (fh = roar_socket_connect(ROAR_DEFAULT_HOST, ROAR_DEFAULT_PORT)) != -1 )
+   return fh;
+
+ } else {
+  /* connect via (char*)server */
+  for (i = 0; server[i] != 0; i++) {
+   if ( server[i] == ':' ) {
+    port = atoi(server+i+1);
+    server[i] = 0;
     break;
    }
   }
+
+  if ( port ) {
+   fh = roar_socket_connect(server, port);
+   // restore the original string
+   server[i] = ':';
+  } else {
+   fh = roar_socket_connect(server, ROAR_DEFAULT_PORT);
+  }
  }
 
- if ( is_decnet ) {
-  if ( *user_sock == ':' ) {
-   if ( roar_socket_get_local_nodename() != NULL ) {
-    strncpy(user_sock, roar_socket_get_local_nodename(), sizeof(user_sock)-1);
-    user_sock[sizeof(user_sock)-1] = 0;
-    roar_mm_strlcat(user_sock, server, sizeof(user_sock)-1);
-    user_sock[sizeof(user_sock)-1] = 0;
-    obj  = strstr(user_sock, "::");
-    obj += 2;
-   }
-  }
-
-  if ( *obj == 0 ) {
-   roar_mm_strlcat(user_sock, ROAR_DEFAULT_OBJECT, sizeof(user_sock)-1);
-   user_sock[sizeof(user_sock)-1] = 0;
-  }
-
-  ROAR_DBG("roar_connect_raw(*): user_sock='%s'", user_sock);
- }
-
- if ( port || is_decnet ) {
-  fh = roar_socket_connect(type, user_sock, port);
-  // restore the original string
-  user_sock[i] = ':';
- } else {
-#if defined(ROAR_HAVE_STAT) && defined(ROAR_HAVE_H_SYS_STAT)
-  if ( user_sock[0] == '/' ) {
-   if ( stat(user_sock, &sockstat) == 0 ) {
-    if ( S_ISCHR(sockstat.st_mode) ) {
-#ifdef O_NOCTTY
-     fh = open(user_sock, O_RDWR|O_NOCTTY, 0666);
-#else
-     fh = open(user_sock, O_RDWR, 0666);
-#endif
-    }
-   }
-  }
-#endif
-  if ( fh == -1 )
-   fh = roar_socket_connect(type, user_sock, ROAR_DEFAULT_PORT);
- }
-
- if ( fh == -1 )
-  return -1;
-
- if ( roar_vio_open_fh_socket(con->viocon, fh) == -1 ) {
-  err = roar_error;
-#ifdef ROAR_TARGET_WIN32
-  closesocket(fh);
-#else
-  close(fh);
-#endif
-  roar_error = err;
-  return -1;
- } else {
-  con->flags |= ROAR_CON_FLAGS_VIO;
- }
-
- con->server_name = roar_mm_strdup(server);
-
- roar_err_set(ROAR_ERROR_NONE);
- return 0;
-}
-
-static int roar_connect_raw (struct roar_connection * con, const char * server, int flags, uint_least32_t timeout) {
-#ifdef ROAR_HAVE_LIBSLP
- struct roar_libroar_config * config = roar_libroar_get_config();
-#endif
-#if defined(ROAR_HAVE_UNIX)
- char user_sock[128];
- const char * roar_server;
-#endif
-#if defined(ROAR_HAVE_LIBSLP) || !defined(ROAR_TARGET_MICROCONTROLLER)
- int i = 0;
-#endif
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
- struct passwd * pwd;
- char * sysconf_roarserver;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
- struct stat decnet_stat;
-#endif
-#ifdef ROAR_HAVE_LIBX11
- struct roar_x11_connection * x11con;
-#endif
-#ifdef ROAR_HAVE_LIBSLP
- struct roar_server * list;
- int workarounds_store;
-#endif
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
-
- if ( timeout != 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( flags & ROAR_ENUM_FLAG_HARDNONBLOCK )
-  flags |= ROAR_ENUM_FLAG_NONBLOCK;
-
-
- if ( server == NULL || *server == 0 )
-  server = roar_libroar_get_server();
-
- if ( server == NULL || *server == 0 )
-  server = roar_env_get("ROAR_SERVER");
-
-#ifdef ROAR_HAVE_LIBX11
- if ( server == NULL || *server == 0 ) {
-  if ( (x11con = roar_x11_connect(NULL)) != NULL ) {
-   server = roar_x11_get_prop(x11con, "ROAR_SERVER");
-   roar_x11_disconnect(x11con);
-  }
- }
-#endif
-
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
- sysconf_roarserver = roar_libroar_get_path("sysconf-roarserver", 0, NULL, NULL);
- if ( sysconf_roarserver != NULL ) {
-  if ( (server == NULL || *server == 0) && (i = readlink(sysconf_roarserver, user_sock, sizeof(user_sock)-1)) != -1 ) {
-    user_sock[i] = 0;
-    server = user_sock;
-  }
-  roar_mm_free(sysconf_roarserver);
- }
-#endif
-
- if ( server != NULL && !strcasecmp(server, "+slp") ) {
-  server = roar_slp_find_roard(0);
-  if ( server == NULL ) {
-   return -1;
-  }
- }
-
- // "+default" is an alias for NULL.
- if ( server != NULL && !strcasecmp(server, "+default") ) {
-  server = NULL;
- }
-
- if ( server == NULL || *server == 0 ) {
-  /* connect via defaults */
-
-#ifdef ROAR_HAVE_UNIX
-#ifndef ROAR_TARGET_MICROCONTROLLER
-  roar_server = roar_env_get("HOME");
-#else
-  roar_server = NULL;
-#endif
-
-  if ( roar_server == NULL ) {
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
-   if ( (pwd = getpwuid(getuid())) != NULL ) {
-    roar_server = pwd->pw_dir;
-   }
-#endif
-  }
-
-  if ( roar_server != NULL ) {
-   snprintf(user_sock, sizeof(user_sock)-1, "%s/%s", roar_server, ROAR_DEFAULT_SOCK_USER);
-   user_sock[sizeof(user_sock)-1] = 0;
-
-   if ( _connect_server(con, user_sock, ROAR_SOCKET_TYPE_UNIX, flags, timeout) == 0 )
-    return 0;
-  }
-
-  if ( _connect_server(con, ROAR_DEFAULT_SOCK_GLOBAL, ROAR_SOCKET_TYPE_UNIX, flags, timeout) == 0 )
-   return 0;
-#endif
-
-  if ( _connect_server(con, ROAR_DEFAULT_HOSTPORT, ROAR_SOCKET_TYPE_TCP, flags, timeout) == 0 )
-   return 0;
-
-#ifdef ROAR_HAVE_LIBDNET
-  if ( stat(ROAR_PROC_NET_DECNET, &decnet_stat) == 0 ) {
-   if ( roar_socket_get_local_nodename() ) {
-    snprintf(user_sock, sizeof(user_sock)-1, "%s::%s", roar_socket_get_local_nodename(), ROAR_DEFAULT_OBJECT);
-    if ( _connect_server(con, user_sock, ROAR_SOCKET_TYPE_DECNET, flags, timeout) == 0 )
-     return 0;
-   }
-  }
-#endif
-
-  if ( _connect_server(con, "+abstract", ROAR_SOCKET_TYPE_UNKNOWN, flags, timeout) == 0 )
-   return 0;
-
-#ifdef ROAR_HAVE_LIBSLP
- if ( !(config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_NO_SLP) &&
-      !(flags & ROAR_ENUM_FLAG_NONBLOCK) &&
-      !(flags & ROAR_ENUM_FLAG_LOCALONLY)
-    ) {
-  if ( (server = roar_slp_find_roard(0)) != NULL ) {
-   if ( _connect_server(con, server, ROAR_SOCKET_TYPE_UNKNOWN, 0, 0) == 0 )
-    return 0;
-
-   /* in case we can not connect to the server given this may be a cache problem,
-      we do a new lookup with the cache disabled in this case                     */
-   ROAR_WARN("roar_connect_raw(*): Can not connect to SLP located server, disabling cache");
-   if ( (server = roar_slp_find_roard(1)) != NULL )
-    if ( _connect_server(con, server, ROAR_SOCKET_TYPE_UNKNOWN, 0, 0) == 0 )
-     return 0;
-  }
- }
-
- workarounds_store = config->workaround.workarounds;
- config->workaround.workarounds |= ROAR_LIBROAR_CONFIG_WAS_NO_SLP;
- list = roar_enum_servers(flags, -1, -1);
- config->workaround.workarounds = workarounds_store;
- if ( list != NULL ) {
-  for (i = 0; list[i].server != NULL; i++) {
-   if ( _connect_server(con, list[i].server, ROAR_SOCKET_TYPE_UNKNOWN, 0, 0) == 0 ) {
-    roar_enum_servers_free(list);
-    return 0;
-   }
-  }
-  roar_enum_servers_free(list);
- }
-#endif
-
- return -1;
-
- } else {
-  /* connect via (char*)server */
-  if ( _connect_server(con, server, ROAR_SOCKET_TYPE_UNKNOWN, flags, timeout) != 0 )
-   return -1;
-  return 0;
- }
-
- roar_err_set(ROAR_ERROR_NODEV);
- ROAR_DBG("roar_connect_raw(*) = -1 // error=NODEV");
- return -1;
-}
-
-int roar_connect     (struct roar_connection * con, const char * server, int flags, uint_least32_t timeout) {
- struct roar_libroar_config * config = roar_libroar_get_config();
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( roar_connect_none(con) == -1 )
-  return -1;
-
- if ( roar_connect_raw(con, server, flags | config->serverflags, timeout) == -1 )
-  return -1;
-
- return 0;
-}
-
-int roar_connect_none (struct roar_connection * con) {
- struct roar_libroar_config * config = roar_libroar_get_config();
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- memset(con, 0, sizeof(struct roar_connection));
- con->refc        = 1;
- con->flags       = ROAR_CON_FLAGS_ISCLIENT;
- con->version     = _ROAR_MESSAGE_VERSION;
- con->cb_userdata = NULL;
- con->cb          = NULL;
- con->server_stds = NULL;
- con->server_name = NULL;
-
- roar_err_init(&(con->errorframe));
-
- con->viocon = &(con->viocon_store);
-
-// con->flags |= ROAR_CON_FLAGS_VIO;
-
- if ( config->protocolversion != -1 )
-  roar_set_connection_version(con, config->protocolversion);
-
- roar_err_set(ROAR_ERROR_NONE);
- return 0;
-}
-
-int roar_connect_vio (struct roar_connection * con, struct roar_vio_calls * vio) {
- if ( con == NULL || vio == NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( roar_connect_none(con) == -1 )
-  return -1;
-
- con->viocon = vio;
- con->flags |= ROAR_CON_FLAGS_VIO;
-
- return -1;
-}
-
-int roar_connect_fh (struct roar_connection * con, int fh) {
-
- if ( con == NULL || fh == -1 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( roar_connect_none(con) == -1 )
-  return -1;
-
- // special hack to set an illegal value used internally in libroar:
- if ( fh == -2 )
-  fh = -1;
-
- if ( roar_vio_open_fh_socket(con->viocon, fh) != -1 ) {
-  con->flags |= ROAR_CON_FLAGS_VIO;
- } else {
-  return -1;
- }
-
- roar_err_set(ROAR_ERROR_NONE);
- return 0;
-}
-
-int roar_get_connection_fh (struct roar_connection * con) {
- int fh;
-
- ROAR_DBG("roar_get_connection_fh(con=%p) = ?", con);
-
- roar_debug_warn_sysio("roar_get_connection_fh", "roar_get_connection_vio2", NULL);
-
- if ( con == NULL )
-  return -1;
-
- ROAR_DBG("roar_get_connection_fh(con=%p) = ?", con);
-
- if ( roar_vio_ctl(con->viocon, ROAR_VIO_CTL_GET_FH, &fh) == -1 ) {
-#ifdef ROAR_TARGET_WIN32
-  if ( roar_vio_ctl(con->viocon, ROAR_VIO_CTL_GET_SELECT_FH, &fh) == -1 )
-   return -1;
-#else
-  return -1;
-#endif
- }
-
- ROAR_DBG("roar_get_connection_fh(con=%p) = %i", con, fh);
+ ROAR_DBG("roar_connect_raw(*) = %i", fh);
 
  return fh;
 }
 
-struct roar_vio_calls * roar_get_connection_vio2 (struct roar_connection * con) {
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( con->flags & ROAR_CON_FLAGS_VIO )
-  return con->viocon;
-
-// TODO: try to open the VIO.
-
- roar_err_set(ROAR_ERROR_BADFH);
- return NULL;
-}
-
-const char * roar_get_connection_server(struct roar_connection * con) {
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- return con->server_name;
-}
-
-int roar_connectionref(struct roar_connection * con) {
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- con->refc++;
-
- return 0;
-}
-
-int roar_connectionunref(struct roar_connection * con) {
- struct roar_vio_calls * vio;
+int roar_connect    (struct roar_connection * con, char * server) {
+ con->fh = roar_connect_raw(server);
+
+ if ( con->fh == -1 )
+  return -1;
+
+ return 0;
+}
+
+int roar_disconnect (struct roar_connection * con) {
  struct roar_message m;
 
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- con->refc--;
-
- if ( con->refc )
-  return 0;
-
- if ( con->flags & ROAR_CON_FLAGS_TERMINATE ) {
-  if ( roar_terminate(con, 1) == -1 ) {
-   ROAR_WARN("roar_connectionunref(con=%p{.server_name='%s'}): Can not terminate server as requested.", con, con->server_name);
-   if ( roar_terminate(con, 0) == -1 ) {
-    ROAR_ERR("roar_connectionunref(con=%p{.server_name='%s'}): Can not exit server. BAD.", con, con->server_name);
-   }
-  }
- }
-
- memset(&m, 0, sizeof(m));
-
- m.datalen =  0;
- m.stream  = -1;
- m.pos     =  0;
+ m.datalen = 0;
+ m.stream  = 0;
  m.cmd     = ROAR_CMD_QUIT;
 
  roar_req(con, &m, NULL);
 
- if ( (vio = roar_get_connection_vio2(con)) != NULL ) {
-  roar_vio_close(vio);
- }
-
- if ( con->server_stds != NULL ) {
-  roar_stds_free(con->server_stds);
-  con->server_stds = NULL;
- }
-
- if ( con->server_name != NULL ) {
-  roar_mm_free(con->server_name);
-  con->server_name = NULL;
- }
-
- if ( con->flags & ROAR_CON_FLAGS_FREESELF ) {
-  roar_mm_free(con);
- } else {
-  roar_connect_fh(con, -2);
- }
-
- return 0;
-}
-
-int roar_set_connection_callback(struct roar_connection * con,
-                                 void (*cb)(struct roar_connection * con,
-                                            struct roar_message    * mes,
-                                            void                   * data,
-                                            void                   * userdata),
-                                 void * userdata) {
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- con->cb       = cb;
- con->cb_userdata = userdata;
-
- return 0;
-}
-
-int roar_set_connection_version(struct roar_connection * con, int version) {
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( version == -1 )
-  version = _ROAR_MESSAGE_VERSION;
-
- if ( version < 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- con->version = version;
-
- if ( version == 2 ) {
-  con->flags |= ROAR_CON_FLAGS_SUPPORT_V2;
- }
-
- return 0;
-}
-
-int16_t roar_message_genseq(struct roar_connection * con, int is_client) {
- static int16_t store = 0;
- int16_t ret = 0;
-
- ret = store++;
-
- if ( ret == 0 )
-  ret = store++;
-
- if ( is_client == -1 ) {
-  if ( con != NULL ) {
-   is_client = con->flags & ROAR_CON_FLAGS_ISCLIENT ? 1 : 0;
-  }
- }
-
- if ( is_client == -1 )
-  is_client = 1;
-
- ret |= 0x8000U;
- if ( !is_client )
-  ret -= 0x8000U;
-
- return ret;
-}
-
-int roar_sync         (struct roar_connection * con) {
- // wait for any non-client reqs
- return roar_wait_msg(con, 0x0000, 0x8000);
-}
-
-int roar_wait_msg     (struct roar_connection * con, int16_t seq, int16_t seqmask) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-int roar_noop         (struct roar_connection * con) {
+ close(con->fh);
+
+ con->fh = -1;
+
+ return 0;
+}
+
+int roar_identify   (struct roar_connection * con, char * name) {
  struct roar_message mes;
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&mes, 0, sizeof(mes));
-
- mes.cmd = ROAR_CMD_NOOP;
- mes.stream = -1;
-
- return roar_req3(con, &mes, NULL);
-}
-
-int roar_identify   (struct roar_connection * con, const char * name) {
- struct roar_message mes;
- uint32_t pid;
+ pid_t pid;
  int max_len;
 
- roar_err_set(ROAR_ERROR_UNKNOWN);
-
  ROAR_DBG("roar_identify(*): try to identify myself...");
 
- memset(&mes, 0, sizeof(mes));
-
  mes.cmd    = ROAR_CMD_IDENTIFY;
- mes.stream = -1;
- mes.pos    =  0;
+ mes.stream = 0;
+ mes.pos    = 0;
 
  ROAR_DBG("roar_identify(*): name=%p", name);
@@ -899,5 +95,5 @@
  ROAR_DBG("roar_identify(*): name=%p", name);
 
- max_len = roar_mm_strlen(name);
+ max_len = strlen(name);
  ROAR_DBG("roar_identify(*): strlen(name) = %i", max_len);
 
@@ -909,13 +105,123 @@
 
  pid = getpid();
- mes.data[1] = (pid & 0xFF000000UL) >> 24;
- mes.data[2] = (pid & 0x00FF0000UL) >> 16;
- mes.data[3] = (pid & 0x0000FF00UL) >>  8;
- mes.data[4] = (pid & 0x000000FFUL) >>  0;
- ROAR_DBG("roar_identify(*): pid = %i", (int)pid);
+ *(uint32_t*)(mes.data+1) = ROAR_HOST2NET32(pid);
+ ROAR_DBG("roar_identify(*): pid = %i", pid);
 
  strncpy(mes.data+5, name, max_len);
 
- return roar_req3(con, &mes, NULL);
+ return roar_req(con, &mes, NULL);
+}
+
+#define _ROAR_MESS_BUF_LEN (1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */)
+int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) {
+ char buf[_ROAR_MESS_BUF_LEN];
+
+ ROAR_DBG("roar_send_message(*): try to send an request...");
+
+ buf[0] = (unsigned char) mes->cmd;
+ *(uint16_t*)(buf+1) = ROAR_HOST2NET16(mes->stream);
+ *(uint32_t*)(buf+3) = ROAR_HOST2NET32(mes->pos);
+ *(uint16_t*)(buf+7) = ROAR_HOST2NET16(mes->datalen);
+
+ if ( write(con->fh, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN )
+  return -1;
+
+ if ( mes->datalen != 0 )
+  if ( write(con->fh, data == NULL ? mes->data : data, mes->datalen) != mes->datalen )
+   return -1;
+
+ ROAR_DBG("roar_send_message(*) = 0");
+ return 0;
+}
+
+int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) {
+ char buf[_ROAR_MESS_BUF_LEN];
+
+ ROAR_DBG("roar_recv_message(*): try to get a response form the server...");
+
+ if ( data )
+  *data = NULL;
+
+ if ( read(con->fh, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN )
+  return -1;
+
+ ROAR_DBG("roar_recv_message(*): Got a header");
+
+ mes->cmd     = (unsigned char)buf[0];
+ mes->stream  = ROAR_NET2HOST16(*(uint16_t*)(buf+1));
+ mes->pos     = ROAR_NET2HOST32(*(uint32_t*)(buf+3));
+ mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(buf+7));
+
+ ROAR_DBG("roar_recv_message(*): command=%i(%s)", mes->cmd,
+           mes->cmd == ROAR_CMD_OK ? "OK" : (mes->cmd == ROAR_CMD_ERROR ? "ERROR" : "UNKNOWN"));
+
+ if ( mes->datalen <= LIBROAR_BUFFER_MSGDATA ) {
+  if ( read(con->fh, mes->data, mes->datalen) == mes->datalen ) {
+   ROAR_DBG("roar_recv_message(*): Got data!");
+   ROAR_DBG("roar_recv_message(*) = 0");
+   return 0;
+  }
+  return -1;
+ } else {
+  if ( data == NULL )
+   return -1;
+
+  if ( (*data = malloc(mes->datalen)) == NULL )
+   return -1;
+
+  if ( mes->datalen == 0 ) {
+   ROAR_DBG("roar_recv_message(*): no data in this pkg");
+   ROAR_DBG("roar_recv_message(*) = 0");
+   return 0;
+  }
+
+  if ( mes->datalen == 0 )
+   return 0;
+
+  if ( read(con->fh, *data, mes->datalen) == mes->datalen ) {
+   ROAR_DBG("roar_recv_message(*): Got data!");
+   ROAR_DBG("roar_recv_message(*) = 0");
+   return 0;
+  }
+  return -1;
+ }
+
+ return -1;
+}
+
+int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) {
+ if ( roar_send_message(con, mes, data ? *data : NULL) != 0 )
+  return -1;
+
+ if ( data )
+  free(*data);
+
+ return roar_recv_message(con, mes, data);
+}
+
+int roar_debug_message_print (struct roar_message * mes) {
+ if ( mes == NULL )
+  return -1;
+
+ ROAR_DBG("roar_debug_message_print(*): Command: %i", mes->cmd);
+ ROAR_DBG("roar_debug_message_print(*): Stream : %u", mes->stream);
+ ROAR_DBG("roar_debug_message_print(*): Pos    : %u", mes->pos);
+ ROAR_DBG("roar_debug_message_print(*): Datalen: %i", mes->datalen);
+
+ ROAR_DBG("roar_debug_message_print(*) = 0");
+ return 0;
+}
+
+int roar_debug_audio_info_print (struct roar_audio_info * info) {
+ if ( info == NULL )
+  return -1;
+
+ ROAR_DBG("roar_debug_audio_info_print(*): Rate    : %i", info->rate);
+ ROAR_DBG("roar_debug_audio_info_print(*): Channels: %i", info->channels);
+ ROAR_DBG("roar_debug_audio_info_print(*): Bits    : %i", info->bits);
+ ROAR_DBG("roar_debug_audio_info_print(*): Codec   : %i", info->codec);
+
+ ROAR_DBG("roar_debug_audio_info_print(*) = 0");
+ return 0;
 }
 
Index: libroar/beep.c
===================================================================
--- libroar/beep.c	(revision 6052)
+++ 	(revision )
@@ -1,74 +1,0 @@
-//beep.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_beep(struct roar_connection * con, const struct roar_beep * beep) {
- struct roar_message m;
- int16_t * data = (int16_t*)m.data;
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m, 0, sizeof(m));
-
- m.cmd = ROAR_CMD_BEEP;
-
- if ( beep == NULL ) {
-  m.datalen = 0;
- } else {
-  m.datalen = 8*2;
-  data[0]   = ROAR_HOST2NET16(0); // version
-  data[1]   = ROAR_HOST2NET16(beep->vol);
-  data[2]   = ROAR_HOST2NET16(beep->time);
-  data[3]   = ROAR_HOST2NET16(beep->freq);
-  data[4]   = ROAR_HOST2NET16(beep->type);
-  data[5]   = ROAR_HOST2NET16(beep->x);
-  data[6]   = ROAR_HOST2NET16(beep->y);
-  data[7]   = ROAR_HOST2NET16(beep->z);
- }
-
- if ( roar_req3(con, &m, NULL) != 0 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return m.stream;
-}
-
-//ll
Index: libroar/buffer.c
===================================================================
--- libroar/buffer.c	(revision 6052)
+++ libroar/buffer.c	(revision 0)
@@ -1,150 +1,21 @@
 //buffer.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroar.h"
 
-struct roar_buffer_ring {
- size_t read_pos;
- size_t write_pos;
-};
-
-struct roar_buffer {
- size_t               refc;
- size_t               len;
- size_t               user_len;
- int                  flags;
- void               * data;
- void               * user_data;
- union {
-  void                    * vp;
-  int32_t                   i32;
-  struct roar_buffer_ring   ring;
- }                    meta;
- int                  type;
- struct roar_buffer * next;
-};
-
-#define _ckbuf_free(m)  if ( buf == NULL || (m) ) { roar_err_set(ROAR_ERROR_FAULT); return -1; }
-#define _ckbuf(m)       if ( _ckmem_corruption(buf, (m)) == -1 ) return -1;
-
-// if we use the 'inline' keyword here the program segfaults. why?
-static int _ckmem_corruption(volatile struct roar_buffer * buf, int m) {
- int flags;
-
- ROAR_DBG("_ckmem_corruption(buf=%p) = ?", buf);
-
- // we need to recheck here, why?
- // gcc changes the order of the above macros. why?
- // this is a strange world.
- if ( buf == NULL || m ) {
-  ROAR_DBG("_ckmem_corruption(buf=%p) = -1 // FAULT", buf);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- ROAR_DBG("_ckmem_corruption(buf=%p) = ?", buf);
-
- flags = buf->flags & (ROAR_BUFFER_FLAG_USEABLE|ROAR_BUFFER_FLAG_FREED);
-
- ROAR_DBG("_ckmem_corruption(buf=%p{.flags=0x%.4x, ...}) = ?", buf, buf->flags);
-
- if ( flags == ROAR_BUFFER_FLAG_USEABLE ) {
-  // seems ok, continue with next check.
- } else if ( flags == ROAR_BUFFER_FLAG_FREED ) {
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_USED_AFTER_FREE, NULL);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- } else {
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
-  roar_err_set(ROAR_ERROR_BADCKSUM);
-  return -1;
- }
-
- if ( buf->refc == 0 ) {
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return 0;
-}
-
-int roar_buffer_new_data (struct roar_buffer ** buf, size_t len, void ** data) {
- void * bufdata;
- int err;
-
- if ((bufdata = roar_mm_malloc(len)) == NULL) {
-  return -1;
- }
-
- if ( roar_buffer_new_no_ma(buf, len, bufdata) == -1 ) {
-  roar_mm_free_noerror(bufdata);
-  return -1;
- }
-
- if ( roar_buffer_set_flag(*buf, ROAR_BUFFER_FLAG_NOFREE, ROAR_BUFFER_RESET) == -1 ) {
-  err = roar_error;
-  roar_buffer_free(*buf);
-  roar_mm_free(bufdata);
-  roar_err_set(err);
-  return -1;
- }
-
- if ( data != NULL )
-  *data = bufdata;
-
- return 0;
-}
-
-int roar_buffer_new_no_ma(struct roar_buffer ** buf, size_t len, void * data) { // no internal malloc
+int roar_buffer_new      (struct roar_buffer ** buf, size_t len) {
  struct roar_buffer * new;
 
  ROAR_DBG("buffer_new(buf=%p, len=%i) = ?", buf, len);
 
- _ckbuf_free(data == NULL)
-
- if ((new = roar_mm_malloc(sizeof(struct roar_buffer))) == NULL) {
+ if ((new = malloc(sizeof(struct roar_buffer))) == NULL) {
   *buf = NULL;
   return -1;
  }
 
- new->refc      =  1;
-
- new->data      = data;
-
- new->flags     = ROAR_BUFFER_FLAG_NONE|ROAR_BUFFER_FLAG_NOFREE|ROAR_BUFFER_FLAG_USEABLE;
- new->type      = -1;
+ if ((new->data = malloc(len)) == NULL) {
+  free(new);
+  *buf = NULL;
+  return -1;
+ }
 
  new->user_data = new->data;
@@ -161,73 +32,19 @@
 }
 
-int roar_buffer_new_str  (struct roar_buffer ** buf, const char * str, int terminate) {
- size_t len;
- void * data;
+int roar_buffer_free     (struct roar_buffer * buf) {
+ struct roar_buffer * next;
 
- if ( buf == NULL || str == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
+ if ( buf == NULL )
   return -1;
+
+ while ((next = buf->next)) {
+  free(buf->data);
+  free(buf);
+  buf = next;
  }
 
- len = roar_mm_strlen(str);
- if ( terminate )
-  len++;
+ free(buf->data);
+ free(buf);
 
- if ( roar_buffer_new_data(buf, len, &data) == -1 )
-  return -1;
-
- if ( len )
-  memcpy(data, str, len);
- return 0;
-}
-
-int roar_buffer_ref      (struct roar_buffer *  buf) {
- _ckbuf(0)
-
- buf->refc++;
-
- return 0;
-}
-
-int roar_buffer_unref     (struct roar_buffer * buf) {
- struct roar_buffer * next, * cur;
- int flags;
-
- ROAR_DBG("roar_buffer_unref(buf=%p) = ?", buf);
-
- _ckbuf_free(0)
-
- ROAR_DBG("roar_buffer_unref(buf=%p) = ?", buf);
-
- cur = buf;
- while (cur != NULL) {
-  flags = cur->flags & (ROAR_BUFFER_FLAG_USEABLE|ROAR_BUFFER_FLAG_FREED);
-  if ( flags == ROAR_BUFFER_FLAG_FREED ) {
-   roar_panic(ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE, NULL);
-  }
-
-  _ckmem_corruption(cur, 0);
-
-  if ( cur->refc == 0 ) {
-   ROAR_WARN("roar_buffer_unref(buf=%p): Ref counter for buffer at %p is wrong. assuming one.", cur, cur);
-   cur->refc = 1;
-   roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
-  } else if ( cur->refc > 1 ) {
-   cur->refc--;
-   return 0;
-  }
-
-  ROAR_DBG("roar_buffer_unref(buf=%p) = ?", buf);
-
-  if ( roar_buffer_get_flag(cur, ROAR_BUFFER_FLAG_NOFREE) != 1 )
-   roar_mm_free(cur->data);
-
-  cur->flags = ROAR_BUFFER_FLAG_FREED;
-  next = cur->next;
-  roar_mm_free(cur);
-  cur = next;
- }
-
- ROAR_DBG("roar_buffer_unref(buf=%p) = 0", buf);
  return 0;
 }
@@ -237,133 +54,40 @@
   if ( next != NULL )
    *next = NULL;
-  roar_err_set(ROAR_ERROR_FAULT);
   return -1;
  }
 
- ROAR_DBG("roar_buffer_delete(buf=%p, next=%p) = ?", buf, next);
+ ROAR_DBG("buffer_delete(buf=%p, next=%p) = ?", buf, next);
 
- if ( next != NULL ) {
-  *next = buf;
-  return roar_buffer_next(next);
- } else {
-  return roar_buffer_unref(buf);
- }
+ if ( next != NULL )
+  *next = buf->next;
+
+ free(buf->data);
+ free(buf);
+
+ ROAR_DBG("buffer_delete(buf=%p, next=%p) = 0", buf, next);
+ return 0;
 }
 
-int roar_buffer_next     (struct roar_buffer ** buf) {
- struct roar_buffer * ret;
+int roar_buffer_add      (struct roar_buffer * buf, struct roar_buffer *  next) {
+ if ( buf == NULL )
+  return -1;
 
- if ( buf == NULL || *buf == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
+ ROAR_DBG("buffer_add(buf=%p, next=%p) = ?", buf, next);
+
+ while ( buf->next != NULL ) {
+//  ROAR_DBG("buffer_add(): buf=%p, buf->next=%p", buf, buf->next);
+  buf = buf->next;
  }
 
- ret = (*buf)->next;
-
- if ( ret != NULL )
-  roar_buffer_ref(ret);
-
- roar_buffer_unref(*buf);
-
- *buf = ret;
+ buf->next = next;
 
  return 0;
 }
 
-int roar_buffer_add      (struct roar_buffer * buf, struct roar_buffer *  next) {
- if ( roar_buffer_ref(next) == -1 )
+int roar_buffer_get_next (struct roar_buffer *  buf, struct roar_buffer ** next) {
+ if ( buf == NULL )
   return -1;
- return roar_buffer_moveinto(buf, &next);
-}
-
-int roar_buffer_moveinto (struct roar_buffer * buf, struct roar_buffer ** next) {
- unsigned int deep = 0;
-
- _ckbuf(next == NULL || _ckmem_corruption(*next, 0))
-
- ROAR_DBG("buffer_add(buf=%p, next=%p) = ?", buf, next);
- ROAR_DBG("buffer_add(buf=%p, next=%p): *next=%p", buf, next, *next);
-
- if ( buf->flags & ROAR_BUFFER_FLAG_RING ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( buf == *next ) {
-  ROAR_ERR("buffer_add(*): both pointer are of the same destination, This is a error in the application");
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- while ( buf->next != NULL ) {
-  ROAR_DBG("buffer_add(*): buf=%p, next=%p (len=%i)", buf, buf->next, buf->user_len);
-//  ROAR_DBG("buffer_add(): buf=%p, buf->next=%p", buf, buf->next);
-  buf = buf->next;
-  deep++;
-
-  if ( buf == *next ) {
-   ROAR_ERR("buffer_add(*): Can not add buffer: loop detected at deep %u. This is a error in the application", deep);
-   // why don't we return here?
-  }
- }
-
- buf->next = *next;
-
- ROAR_DBG("buffer_add(*): adding buffer at deep %u", deep);
-
- *next = NULL;
-
- return 0;
-}
-
-int roar_buffer_moveintoqueue(struct roar_buffer ** buf, struct roar_buffer ** next) {
- if ( buf == NULL || next == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( *buf == NULL ) {
-  *buf = *next;
-  *next = NULL;
-  return 0;
- } else {
-  return roar_buffer_moveinto(*buf, next);
- }
-}
-
-int roar_buffer_get_next (struct roar_buffer *  buf, struct roar_buffer ** next) {
- _ckbuf(0)
 
  *next = buf->next;
-
- return roar_buffer_ref(*next);
-}
-
-int roar_buffer_ring_new (struct roar_buffer ** buf, size_t len, int free_running) {
- struct roar_buffer * n;
-
- _ckbuf_free(0)
-
- if ( len == 0 ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- // just to be sure:
- *buf = NULL;
-
- if ( roar_buffer_new(&n, len) == -1 )
-  return -1;
-
- n->flags |= ROAR_BUFFER_FLAG_RING;
-
- if ( free_running )
-  n->flags |= ROAR_BUFFER_FLAG_FREE_RUNNING;
-
- n->meta.ring.read_pos  = 0;
- n->meta.ring.write_pos = 0;
-
- memset(n->data, 0, n->len);
-
- *buf = n;
 
  return 0;
@@ -371,5 +95,6 @@
 
 int roar_buffer_get_data (struct roar_buffer *  buf, void   ** data) {
- _ckbuf(data == NULL)
+ if ( buf == NULL )
+  return -1;
 
  *data = buf->user_data;
@@ -378,22 +103,7 @@
 }
 
-int roar_buffer_get_datalen(struct roar_buffer * buf, void   ** data, size_t * len) {
- _ckbuf(0)
-
- if ( data != NULL )
-  *data = buf->user_data;
- if ( len != NULL )
- *len = buf->user_len;
-
- return 0;
-}
-
 int roar_buffer_set_offset (struct roar_buffer *  buf, size_t off) {
- _ckbuf(0)
-
- if ( off > buf->user_len ) {
-  roar_err_set(ROAR_ERROR_RANGE);
+ if ( buf == NULL )
   return -1;
- }
 
  buf->user_len  -= off;
@@ -403,71 +113,9 @@
 }
 
-int roar_buffer_shift_out (struct roar_buffer ** buf, void * data, size_t * len) {
- size_t todo, cl;
- struct roar_buffer * cur;
- void * cd;
+int roar_buffer_set_meta (struct roar_buffer * buf, void *  meta) {
+ if ( buf == NULL )
+  return -1;
 
- _ckbuf_free(len == NULL || data == NULL);
-
- if ( *buf == NULL ) {
-  ROAR_DBG("roar_buffer_shift_out(buf=%p, data=%p, len={%lu}) = -1 // Invalid pointer to buffer ring", buf, data, (unsigned long)len);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- todo = *len;
- cur  = *buf;
-
- *len = 0;
-
- while (todo && cur != NULL) {
-  ROAR_DBG("roar_buffer_shift_out(*): todo=%u, cur=%p", (unsigned int) todo, cur);
-
-  _ckmem_corruption(cur, 0);
-
-  if ( roar_buffer_get_len(cur, &cl) == -1 )
-   return -1;
-
-  if ( cl > todo ) {
-   if ( roar_buffer_get_data(cur, &cd) == -1 )
-    return -1;
-
-   cl = todo;
-
-   memcpy(data, cd, cl);
-   todo -= cl;
-   data += cl;
-   *len += cl;
-
-   if ( roar_buffer_set_offset(cur, cl) == -1 )
-    return -1;
-  } else {
-   if ( roar_buffer_get_data(cur, &cd) == -1 )
-    return -1;
-
-   memcpy(data, cd, cl);
-   todo -= cl;
-   data += cl;
-   *len += cl;
-
-   if ( roar_buffer_next(&cur) == -1 )
-    return -1;
-  }
-
-/*
-  if ( cur == NULL )
-   break;
-*/
- }
-
- *buf = cur;
-
- return 0;
-}
-
-int roar_buffer_set_meta (struct roar_buffer * buf, void *  meta) {
- _ckbuf(0)
-
- buf->meta.vp = meta;
+ buf->meta = meta;
 
  return 0;
@@ -475,51 +123,8 @@
 
 int roar_buffer_get_meta (struct roar_buffer * buf, void ** meta) {
- _ckbuf(meta == NULL)
+ if ( buf == NULL )
+  return -1;
 
- *meta = buf->meta.vp;
-
- return 0;
-}
-
-int roar_buffer_set_meta_i32(struct roar_buffer *  buf, int32_t    meta) {
- _ckbuf(0)
-
- buf->meta.i32 = meta;
-
- return 0;
-}
-
-int roar_buffer_get_meta_i32(struct roar_buffer *  buf, int32_t *  meta) {
- _ckbuf(meta == NULL)
-
- *meta = buf->meta.i32;
-
- return 0;
-}
-
-int roar_buffer_set_type    (struct roar_buffer *  buf, int        type) {
- _ckbuf(0)
-
- switch (type) {
-  case ROAR_VIO_DFT_RAW:
-  case ROAR_VIO_DFT_PACKET:
-  case ROAR_VIO_DFT_UNFRAMED:
-  case ROAR_VIO_DFT_OGG_PACKET:
-  case ROAR_VIO_DFT_OGG_PAGE:
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
- }
-
- buf->type = type;
-
- return 0;
-}
-
-int roar_buffer_get_type    (struct roar_buffer *  buf, int     *  type) {
- _ckbuf(type == NULL)
-
- *type = buf->type;
+ *meta = buf->meta;
 
  return 0;
@@ -527,55 +132,15 @@
 
 int roar_buffer_set_len  (struct roar_buffer *  buf, size_t    len) {
- size_t   totlen;
- void   * newbuf;
- size_t true_len;
+ if ( buf == NULL )
+  return -1;
 
- ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu) = ?", buf, (long unsigned int)len);
+ buf->user_len = len;
 
- _ckbuf(0)
-
- ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu) = ?", buf, (long unsigned int)len);
-
- // handle special case where user length is zero:
- if ( len && !buf->user_len ) {
-  buf->user_data = buf->data;
-  buf->user_len  = buf->len;
- }
-
- ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu) = ?", buf, (long unsigned int)len);
-
- // calculate the true length of our buffer starting at buf->user_data.
- true_len = buf->len - (buf->user_data - buf->data);
-
- if ( len > true_len ) {
-  ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu): We need to enlarge the buffer.", buf, (long unsigned int)len);
-
-  // we can only enlage a buffer if it's one of our own memory segments
-  if ( buf->flags & ROAR_BUFFER_FLAG_NOFREE )  {
-   ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu) = -1 //error=NOTSUP", buf, (long unsigned int)len);
-   roar_err_set(ROAR_ERROR_NOTSUP);
-   return -1;
-  }
-
-  totlen = (buf->len - buf->user_len) + len;
-  newbuf = roar_mm_realloc(buf->data, totlen);
-  if ( newbuf == NULL )
-   return -1;
-
-  buf->user_data = newbuf + (buf->user_data - buf->data);
-  buf->user_len = len;
-  buf->data = newbuf;
-  buf->len  = totlen;
- } else {
-  ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu): No need to enlarge the buffer.", buf, (long unsigned int)len);
-  buf->user_len = len;
- }
-
- ROAR_DBG("roar_buffer_set_len(buf=%p, len=%lu) = 0", buf, (long unsigned int)len);
  return 0;
 }
 
 int roar_buffer_get_len  (struct roar_buffer *  buf, size_t *  len) {
- _ckbuf(0)
+ if ( buf == NULL )
+  return -1;
 
  *len = buf->user_len;
@@ -584,358 +149,3 @@
 }
 
-int roar_buffer_set_flag (struct roar_buffer *  buf, int flag, int reset) {
- _ckbuf(0)
-
- buf->flags |= flag;
-
- if ( reset )
-  buf->flags -= flag;
-
- return 0;
-}
-
-int roar_buffer_get_flag (struct roar_buffer *  buf, int flag) {
- _ckbuf(0)
-
- return buf->flags & flag;
-}
-
-int roar_buffer_duplicate (struct roar_buffer *  buf, struct roar_buffer ** copy) {
- struct roar_buffer *  cur = buf;
- struct roar_buffer *  new;
- void * od, * nd;
- int err;
-
- _ckbuf(copy == NULL)
-
- *copy = NULL;
-
- // TODO:  This function does not handle ring buffers.
- // FIXME: This function does not error out in case of wrong buffer type in buf.
- // TODO:  This function does not handle buffer meta data.
-
- while (cur != NULL) {
-  if ( roar_buffer_new(&new, cur->user_len) == -1 ) {
-   err = roar_error;
-   roar_buffer_free(*copy);
-   roar_err_set(err);
-   return -1;
-  }
-
-  if ( *copy == NULL )
-   *copy = new;
-
-  _LIBROAR_IGNORE_RET(roar_buffer_get_data(cur, &od));
-  _LIBROAR_IGNORE_RET(roar_buffer_get_data(new, &nd));
-  memcpy(nd, od, cur->user_len);
-
-  if ( *copy != new ) {
-   _LIBROAR_IGNORE_RET(roar_buffer_moveinto(*copy, &new));
-  }
-
-  cur = cur->next;
- }
-
- return 0;
-}
-
-int roar_buffer_ring_stats (struct roar_buffer *  buf, struct roar_buffer_stats * stats) {
- ROAR_DBG("roar_buffer_ring_stats(buf=%p, stats=%p) = ?", buf, stats);
-
- _ckbuf(0)
-
- ROAR_DBG("roar_buffer_ring_stats(buf=%p, stats=%p) = ?", buf, stats);
-
- stats->parts        = 0;
- stats->bytes        = 0;
- stats->memory_usage = 0;
-
- while (buf != NULL ) {
-  stats->parts++;
-  stats->bytes        += buf->user_len;
-  stats->memory_usage += buf->len + sizeof(struct roar_buffer);
-  buf = buf->next;
- }
-
- return 0;
-}
-
-int roar_buffer_ring_read  (struct roar_buffer *  buf, void * data, size_t * len) {
- struct roar_buffer_ring * ring;
- size_t havelen;
- size_t done;
- size_t tmp;
-
- _ckbuf(len == NULL)
-
- if ( buf == NULL || len == NULL )
-  return -1;
-
- if ( data == NULL && *len != 0 ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( !(buf->flags & ROAR_BUFFER_FLAG_RING) ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- if ( *len == 0 )
-  return 0;
-
- // we may handle this later:
- if ( *len > buf->user_len ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- if ( (buf->flags & ROAR_BUFFER_FLAG_FREE_RUNNING) ) {
-  if ( buf->meta.ring.read_pos >= buf->user_len )
-   buf->meta.ring.read_pos -= buf->user_len;
-
-  if ( (*len + buf->meta.ring.read_pos) > buf->user_len ) {
-   // wraped mode:
-   memcpy(data, buf->user_data+buf->meta.ring.read_pos, buf->user_len - buf->meta.ring.read_pos);
-   memcpy(data, buf->user_data, *len + buf->meta.ring.read_pos - buf->user_len);
- 
-   buf->meta.ring.read_pos += *len;
-   buf->meta.ring.read_pos -= buf->user_len;
-   return 0;
-  } else {
-   // unwarped mode:
-   memcpy(data, buf->user_data+buf->meta.ring.read_pos, *len);
-   buf->meta.ring.read_pos += *len;
-   return 0;
-  }
- } else {
-  ring = &(buf->meta.ring);
-
-  if ( ring->read_pos == ring->write_pos ) {
-   *len = 0;
-   return 0;
-  } else if ( ring->read_pos < ring->write_pos ) {
-   havelen = ring->write_pos - ring->read_pos;
-
-   if ( havelen > *len )
-    havelen = *len;
-
-   memcpy(data, buf->user_data+ring->read_pos, havelen);
-   ring->read_pos += havelen;
-
-   *len = havelen;
-   return 0;
-  } else { // write_pos < read_pos
-   done = 0;
-
-   // first pass: use data up to end of buffer
-
-   havelen = buf->user_len - ring->read_pos;
-
-   if ( havelen > *len )
-    havelen = *len;
-
-   memcpy(data, buf->user_data+ring->read_pos, havelen);
-   ring->read_pos += havelen;
-
-   done += havelen;
-
-   if ( ring->read_pos == buf->user_len ) {
-    ring->read_pos = 0;
-   }
-
-   // second pass: use data from strat of buffer to write pointer
-
-   if ( *len > done ) {
-    tmp = *len - done;
-    if ( roar_buffer_ring_read(buf, data+done, &tmp) == 0 ) {
-     done += tmp;
-    }
-   }
-
-   *len = done;
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
- return -1;
-}
-
-int roar_buffer_ring_write (struct roar_buffer *  buf, void * data, size_t * len) {
- struct roar_buffer_ring * ring;
- size_t havelen;
- size_t done;
- size_t tmp;
-
- ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = ?", buf, data, len);
-
- _ckbuf(len == NULL)
-
- if ( data == NULL && *len != 0 ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( !(buf->flags & ROAR_BUFFER_FLAG_RING) ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- if ( *len == 0 )
-  return 0;
-
- // we may handle this later:
- if ( *len > buf->user_len ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- if ( (buf->flags & ROAR_BUFFER_FLAG_FREE_RUNNING) ) {
-  if ( buf->meta.ring.write_pos >= buf->user_len )
-   buf->meta.ring.write_pos -= buf->user_len;
-
-  if ( (*len + buf->meta.ring.write_pos) > buf->user_len ) {
-   // wraped mode:
-   memcpy(buf->user_data+buf->meta.ring.write_pos, data, buf->user_len - buf->meta.ring.write_pos);
-   memcpy(buf->user_data, data, *len + buf->meta.ring.write_pos - buf->user_len);
-
-   buf->meta.ring.write_pos += *len;
-   buf->meta.ring.write_pos -= buf->user_len;
-   return 0;
-  } else {
-   // unwarped mode:
-   memcpy(buf->user_data+buf->meta.ring.write_pos, data, *len);
-   buf->meta.ring.write_pos += *len;
-   return 0;
-  }
- } else {
-  ring = &(buf->meta.ring);
-  done = 0;
-
-  ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p): write_pos=%u, read_pos=%u, user_len=%u", buf, data, len, (unsigned int)ring->write_pos, (unsigned int)ring->read_pos, (unsigned int)buf->user_len);
-
-  if ( ring->write_pos >= ring->read_pos ) {
-   ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = ?", buf, data, len);
-
-   havelen = buf->user_len - ring->write_pos;
-
-   if ( ring->read_pos == 0 )
-    havelen--;
-
-   if ( havelen > *len )
-    havelen = *len;
-
-   memcpy(buf->user_data+ring->write_pos, data, havelen);
-
-   done += havelen;
-   ring->write_pos += havelen;
-
-   if ( ring->write_pos == buf->user_len )
-    ring->write_pos = 0;
-
-   if ( *len > done && ring->read_pos != 0 ) {
-    tmp = *len - done;
-    if ( roar_buffer_ring_write(buf, data+done, &tmp) == 0 ) {
-     done += tmp;
-    }
-   }
-
-   *len = done;
-   ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = 0", buf, data, len);
-   return 0;
-  } else {
-   ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = ?", buf, data, len);
-
-   // test for buffer-is-full:
-   if ( (ring->write_pos + 1) == ring->read_pos ) {
-    *len = 0;
-    ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = 0", buf, data, len);
-    return 0;
-   }
-
-   ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = ?", buf, data, len);
-
-   havelen = ring->read_pos - ring->write_pos - 1;
-
-   if ( havelen > *len )
-    havelen = *len;
-
-   memcpy(buf->user_data+ring->write_pos, data, havelen);
-
-   ring->write_pos += havelen;
-   *len = havelen;
-
-   ROAR_DBG("roar_buffer_ring_write(buf=%p, data=%p, len=%p) = 0", buf, data, len);
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
- return -1;
-}
-
-int roar_buffer_ring_avail(struct roar_buffer *  buf, size_t * readlen, size_t * writelen) {
- struct roar_buffer_ring * ring;
- size_t have;
-
- _ckbuf(0)
-
- if ( !(buf->flags & ROAR_BUFFER_FLAG_RING) ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- ring = &(buf->meta.ring);
-
- ROAR_DBG("roar_buffer_ring_avail(buf=%p, readlen=%p, writelen=%p) = ?", buf, readlen, writelen);
-
- if ( readlen != NULL ) {
-  have = 0;
-
-  if ( ring->write_pos >= ring->read_pos ) {
-   have  = ring->write_pos - ring->read_pos;
-  } else {
-   have  = buf->user_len - ring->read_pos;
-   have += ring->write_pos;
-   have -= 1;
-  }
-
-  *readlen = have;
-  ROAR_DBG("roar_buffer_ring_avail(buf=%p, readlen=%p, writelen=%p): readlen=%llu", buf, readlen, writelen, (unsigned long long int)have);
- }
-
- if ( writelen != NULL ) {
-  have = 0;
-
-  if ( ring->read_pos > ring->write_pos ) {
-   have  = ring->read_pos - ring->write_pos - 1;
-  } else {
-   have  = buf->user_len - ring->write_pos;
-   have += ring->read_pos;
-   have -= 1;
-  }
-
-  *writelen = have;
-  ROAR_DBG("roar_buffer_ring_avail(buf=%p, readlen=%p, writelen=%p): readlen=%llu", buf, readlen, writelen, (unsigned long long int)have);
- }
-
- ROAR_DBG("roar_buffer_ring_avail(buf=%p, readlen=%p, writelen=%p) = 0", buf, readlen, writelen);
-
- return 0;
-}
-
-int roar_buffer_ring_reset(struct roar_buffer *  buf) {
- _ckbuf(0)
-
- if ( !(buf->flags & ROAR_BUFFER_FLAG_RING) ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- buf->meta.ring.read_pos = buf->meta.ring.write_pos = 0;
-
- return 0;
-}
-
 //ll
Index: libroar/caps.c
===================================================================
--- libroar/caps.c	(revision 6052)
+++ 	(revision )
@@ -1,317 +1,0 @@
-//caps.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-const struct roar_stds * libroar_libstds(void) {
- static const uint32_t std[] = {
-  ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO, 0, 0)  // ra-msg-v0
- };
- static const struct roar_stds stds = {.stds_len = sizeof(std)/sizeof(*std), .stds = (uint32_t*)std};
- return &stds;
-}
-
-int roar_caps_to_msg(struct roar_message * mes,  struct roar_caps    * caps, void ** data) {
- char * datap;
- size_t needlen = 4;
-
- if ( mes == NULL || caps == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- needlen += caps->len;
-
- if ( needlen > sizeof(mes->data) ) {
-  if ( data == NULL ) {
-   roar_err_set(ROAR_ERROR_FAULT);
-   return -1;
-  }
-
-  if ( (*data = roar_mm_malloc(needlen)) == NULL )
-   return -1;
-
-  datap = *data;
- } else {
-  datap = mes->data;
- }
-
- datap[0] = caps->version;
- datap[1] = caps->type;
- datap[2] = (caps->flags & 0xFF00) >> 8;
- datap[3] = caps->flags & 0xFF;
-
- if ( caps->len != 0 ) {
-  memcpy(&(datap[4]), caps->data, caps->len);
- }
-
- mes->datalen = needlen;
-
- return 0;
-}
-
-int roar_caps_from_msg(struct roar_caps  * caps, struct roar_message * mes,  void  * data) {
- char * datap;
-
- if ( mes == NULL || caps == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( data != NULL ) {
-  datap = data;
- } else {
-  datap = mes->data;
- }
-
- // versin check.
- if ( datap[0] != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- if ( mes->datalen < 4 ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return -1;
- }
-
- memset(caps, 0, sizeof(struct roar_caps));
-
- caps->version = datap[0];
- caps->type    = datap[1];
- caps->flags   = (datap[2] << 8) | datap[3];
-
- if ( mes->datalen == 4 ) {
-  caps->data    = NULL;
-  caps->len     = 0;
- } else {
-  caps->data    = &(datap[4]);
-  caps->len     = mes->datalen - 4;
- }
-
- return 0;
-}
-
-int roar_caps_stds(struct roar_connection * con, struct roar_stds ** out, struct roar_stds * in, int flags) {
- struct roar_message mes;
- struct roar_caps caps;
- void * data = NULL;
- char * data_char;
- size_t i;
-
- ROAR_DBG("roar_caps_stds(con=%p, out=%p, in=%p, flags=0x%.4x) = ?", con, out, in, flags);
-
- if ( flags == -1 )
-  flags = 0;
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( out != NULL )
-  flags |= ROAR_CF_REQUEST;
-
- if ( (flags & ROAR_CF_REQUEST) && out == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( in != NULL )
-  if ( in->stds_len == 0 )
-   in = NULL;
-
- memset(&caps, 0, sizeof(caps));
-
- caps.version = 0;
- caps.type    = ROAR_CT_STANDARDS;
- caps.flags   = flags;
-
- memset(&mes, 0, sizeof(mes));
-
- if ( in != NULL ) {
-  // we use a hack here to avoid double alloc:
-  // first pass the data in native byte order.
-  // after we got a buffer swap in-buffer.
-  caps.data = in->stds;
-  caps.len  = in->stds_len * 4;
- }
-
- if ( roar_caps_to_msg(&mes, &caps, &data) == -1 )
-  return -1;
-
- if ( in != NULL ) {
-  if ( data == NULL ) {
-   for (i = 0; i < in->stds_len; i++) {
-    ((uint32_t*)mes.data)[i] = ROAR_HOST2NET32(((uint32_t*)mes.data)[i]);
-   }
-  } else {
-   for (i = 0; i < in->stds_len; i++) {
-    ((uint32_t*)data)[i] = ROAR_HOST2NET32(((uint32_t*)data)[i]);
-   }
-  }
- }
-
- mes.cmd = ROAR_CMD_CAPS;
-
- data_char = data;
- if ( roar_req(con, &mes, &data_char) == -1 )
-  return -1;
- data = data_char;
-
- if ( mes.cmd != ROAR_CMD_OK ) {
-  if ( data != NULL )
-   roar_mm_free_noerror(data);
-  return -1;
- }
-
- if ( roar_caps_from_msg(&caps, &mes, data) == -1 ) {
-  if ( data != NULL )
-   roar_mm_free_noerror(data);
-  return -1;
- }
-
- // check if response matches the request:
- if ( caps.version != 0 || caps.type != ROAR_CT_STANDARDS || (caps.len & 0x3) != 0 ) {
-  if ( data != NULL )
-   roar_mm_free(data);
-  roar_err_set(ROAR_ERROR_PROTO);
-  return -1;
- }
-
- if ( out != NULL ) {
-  *out = roar_stds_new(caps.len/4);
-  if ( *out == NULL ) {
-   if ( data != NULL )
-    roar_mm_free_noerror(data);
-   return -1;
-  }
-
-  ROAR_DBG("roar_caps_stds(con=%p, out=%p, in=%p, flags=0x%.4x): (*out)->stds_len=%llu", con, out, in, flags, (long long unsigned int)(*out)->stds_len);
-
-  for (i = 0; i < (*out)->stds_len; i++) {
-   (*out)->stds[i] = ROAR_NET2HOST32(((uint32_t*)caps.data)[i]);
-   ROAR_DBG("roar_caps_stds(con=%p, out=%p, in=%p, flags=0x%.4x): (*out)->stds[%llu] = 0x%.8x", con, out, in, flags, (long long unsigned int)i, (*out)->stds[i]);
-  }
- }
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- return 0;
-}
-
-struct roar_stds * roar_stds_new(size_t len) {
- struct roar_stds * ret;
-
- if ( len == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return NULL;
- }
-
- ret = roar_mm_malloc(sizeof(struct roar_stds));
-
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_stds));
-
- ret->stds_len = len;
- ret->stds     = roar_mm_malloc(len*sizeof(uint32_t));
-
- if ( ret->stds == NULL ) {
-  roar_mm_free_noerror(ret);
-  return NULL;
- }
-
- memset(ret->stds, 0, len*sizeof(uint32_t));
-
- return ret;
-}
-
-int roar_stds_free(struct roar_stds * stds) {
- if ( stds == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( stds->stds != NULL )
-  roar_mm_free(stds->stds);
-
- roar_mm_free(stds);
-
- return 0;
-}
-
-
-static struct {
- const int    vendor;
- const char * name;
-} _libroar_std_vendors[] = {
- {ROAR_STDV_ROARAUDIO, "RoarAudio"},
- {ROAR_STDV_PROTO,     "Protocols"},
- {ROAR_STDV_RFC,       "RFC"},
- {-1, NULL}
-};
-
-int roar_stds_str2vendor(const char * vendor) {
- int i;
-
- if ( vendor == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; _libroar_std_vendors[i].name != NULL; i++)
-  if ( !strcasecmp(_libroar_std_vendors[i].name, vendor) )
-   return _libroar_std_vendors[i].vendor;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char * roar_stds_vendor2str(const int vendor) {
- int i;
-
- for (i = 0; _libroar_std_vendors[i].name != NULL; i++)
-  if ( _libroar_std_vendors[i].vendor == vendor )
-   return _libroar_std_vendors[i].name;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-
-//ll
Index: libroar/cdrom.c
===================================================================
--- libroar/cdrom.c	(revision 6052)
+++ 	(revision )
@@ -1,270 +1,0 @@
-//cdrom.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define ROAR_CDROM_ERROR_NORETURN(format, args...) ROAR_ERR(format, ## args); ROAR_U_EXIT(3)
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT "--output-raw-big-endian"
-#elif BYTE_ORDER == LITTLE_ENDIAN
-#define ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT "--output-raw-little-endian"
-#endif
-
-#ifdef ROAR_TARGET_WIN32
-#undef ROAR_HAVE_BIN_CDPARANOIA
-#endif
-
-pid_t roar_cdrom_run_cdparanoia (int cdrom, int data, int track, char * pos) {
-#if defined(ROAR_HAVE_BIN_CDPARANOIA) && defined(ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT) && defined(ROAR_HAVE_CDROM)
- char my_pos[32] = {0};
- pid_t pid;
- int fh[2];
- char * bin_cdparanoia = NULL, * dev_stdin = NULL;
-
- ROAR_DBG("roar_cdrom_run_cdparanoia(cdrom=%i, data=%i, track=%i, pos='%s') = ?", cdrom, data, track, pos);
-
- if ( cdrom == -1 || data == -1 || (track == -1 && pos == NULL) || (track != -1 && pos != NULL) )
-  return -1;
-
- if ( track != -1 ) {
-  pos = my_pos;
-  snprintf(pos, sizeof(my_pos), "%i", track);
- }
-
- if ( (pid = roar_fork(NULL)) == (pid_t)-1 ) {
-  return -1;
- }
-
- if ( pid )
-  return pid;
-
- fh[0] = dup(cdrom);
- fh[1] = dup(data);
-
- if ( fh[0] == -1 || fh[1] == -1 ) {
-  ROAR_CDROM_ERROR_NORETURN("Can not dup(): %s", strerror(errno));
- }
-
- close(ROAR_STDIN);
- close(ROAR_STDOUT);
-
- // TODO: should I close some other handles?
-
- if ( dup2(fh[0], ROAR_STDIN) == -1 || dup2(fh[1], ROAR_STDOUT) == -1 ) {
-  ROAR_CDROM_ERROR_NORETURN("Can not dup2(): %s", strerror(errno));
- }
-
- // now close our backups:
- close(fh[0]);
- close(fh[1]);
-
- bin_cdparanoia = roar_libroar_get_path("bin-cdparanoia", 0, NULL, NULL);
- if ( bin_cdparanoia == NULL )
-  return -1;
- dev_stdin = roar_libroar_get_path("dev-stdin", 0, NULL, NULL);
- if ( dev_stdin == NULL ) {
-  roar_mm_free_noerror(bin_cdparanoia);
-  return -1;
- }
- execl(bin_cdparanoia, bin_cdparanoia, "--force-cdrom-device", dev_stdin, "-q",
-                ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT, pos, "-", NULL);
-
- roar_mm_free(bin_cdparanoia);
- roar_mm_free(dev_stdin);
-
- ROAR_CDROM_ERROR_NORETURN("We are still alive after exec()!, very bad!, error was: %s", strerror(errno));
- return -1;
-#else
-#ifndef ROAR_HAVE_BIN_CDPARANOIA
- ROAR_ERR("roar_cdrom_run_cdparanoia(*): ROAR_HAVE_BIN_CDPARANOIA not defined!");
-#endif
-#ifndef ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT
- ROAR_ERR("roar_cdrom_run_cdparanoia(*): ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT not defined!");
-#endif
- ROAR_ERR("roar_cdrom_run_cdparanoia(cdrom=%i, data=%i, track=%i, pos='%s') = -1 // no cdparanoia support compiled in",
-             cdrom, data, track, pos);
- return -1;
-#endif
-}
-
-int roar_cdrom_open (struct roar_connection * con, struct roar_cdrom * cdrom, const char * device, int mixer) {
-#ifdef ROAR_HAVE_CDROM
- int flags;
-
- if ( cdrom == NULL )
-  return -1;
-
- memset((void*)cdrom, 0, sizeof(struct roar_cdrom));
-
- if ( device == NULL )
-  device = roar_cdromdevice();
-
- if ( device == NULL )
-  return -1;
-
- strncpy(cdrom->device, device, ROAR_CDROM_MAX_DEVLEN);
-
- cdrom->con        = con; // we do not care here if it is set or not as we can operate in local only mode
- cdrom->mixer      = mixer;
-
- cdrom->stream     = -1;
- cdrom->play_local =  1;
- cdrom->player     = -1;
-
- if ( (cdrom->fh = open(cdrom->device, O_RDONLY, 0644)) == -1 )
-  return -1;
-
-#ifndef ROAR_TARGET_WIN32
- if ( (flags = fcntl(cdrom->fh, F_GETFL, 0)) == -1 ) {
-  close(cdrom->fh);
-  cdrom->fh  = -1;
-  return -1;
- }
-
- flags |= FD_CLOEXEC;
-
- if ( fcntl(cdrom->fh, F_SETFL, flags) == -1 ) {
-  close(cdrom->fh);
-  cdrom->fh = -1;
-  return -1;
- }
-#endif
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_cdrom_close(struct roar_cdrom * cdrom) {
-#ifdef ROAR_HAVE_CDROM
- if ( cdrom == NULL )
-  return -1;
-
- roar_cdrom_stop(cdrom); // stop on close
-
- if ( cdrom->fh != -1 )
-  close(cdrom->fh);
-
- memset((void*)cdrom, 0, sizeof(struct roar_cdrom));
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_cdrom_stop (struct roar_cdrom * cdrom) {
-#ifdef ROAR_HAVE_CDROM
- int ret;
-
- if ( cdrom == NULL )
-  return -1;
-
- if ( cdrom->con == NULL )
-  return -1;
-
- if ( cdrom->stream == -1 )
-  return -1;
-
- if ( (ret = roar_kick(cdrom->con, ROAR_OT_STREAM, cdrom->stream)) == -1 ) {
-  return -1;
- }
-
-#ifndef ROAR_TARGET_WIN32
- if ( cdrom->player != -1 )
-  kill(cdrom->player, SIGINT);
-#else
- if ( cdrom->player != -1 ) {
-  ROAR_ERR("roar_cdrom_stop(*): Can not kill player with pid %i, not supported on win32", cdrom->player);
- }
-#endif
-
- cdrom->player = -1;
- cdrom->stream = -1;
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-int roar_cdrom_play (struct roar_cdrom * cdrom, int track) {
-#ifdef ROAR_HAVE_CDROM
- struct roar_vio_calls vio;
- struct roar_stream stream[1];
- int stream_fh;
-
- if ( cdrom == NULL )
-  return -1;
-
- if ( cdrom->con == NULL )
-  return -1;
-
- if ( cdrom->stream != -1 ) {
-  if ( roar_cdrom_stop(cdrom) == -1 )
-   return -1;
- }
-
- if ( cdrom->play_local ) {
-
-  if ( roar_vio_simple_new_stream_obj(&vio, cdrom->con, stream, ROAR_CDROM_STREAMINFO, ROAR_DIR_PLAY, cdrom->mixer) == -1 ) {
-   return -1;
-  }
-
-  if ( roar_vio_ctl(&vio, ROAR_VIO_CTL_GET_WRITE_FH, &stream_fh) == -1 ) {
-   roar_vio_close(&vio);
-   return -1;
-  }
-
-  if ( (cdrom->player = roar_cdrom_run_cdparanoia(cdrom->fh, stream_fh, track, NULL)) != -1 ) {
-   cdrom->stream = stream->id;
-   return 0;
-  }
-
-  roar_vio_close(&vio);
-
-  return -1;
- } else {
-  // no support for remote playback yet
-  return -1;
- }
-#else
- return -1;
-#endif
-}
-
-//ll
Index: libroar/client.c
===================================================================
--- libroar/client.c	(revision 6052)
+++ 	(revision )
@@ -1,178 +1,0 @@
-//client.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_client_new      (struct roar_client * client) {
- int i;
-
- if ( client == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(client, 0, sizeof(struct roar_client));
-
- client->fh          = -1;
- client->pid         = -1;
- client->uid         = -1;
- client->gid         = -1;
- client->proto       = ROAR_PROTO_ROARAUDIO;
- client->byteorder   = ROAR_BYTEORDER_NETWORK;
-
- for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++)
-  client->streams[i] = -1;
-
- return 0;
-}
-
-int roar_client_set_fh   (struct roar_client * client, int fh) {
- if ( client == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- client->fh = fh;
-
- return 0;
-}
-
-int roar_client_set_proto(struct roar_client * client, int proto, int byteorder) {
- if ( client == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- client->proto = proto;
-
- if ( byteorder != -1 ) {
-  client->byteorder = byteorder;
- } else {
-  switch (proto) {
-   case ROAR_PROTO_ROARAUDIO:
-     client->byteorder = ROAR_BYTEORDER_NETWORK;
-    break;
-   default:
-     roar_err_set(ROAR_ERROR_INVAL);
-     return -1;
-    break;
-  }
- }
-
- return 0;
-}
-
-int roar_client_pass     (struct roar_connection * con, struct roar_client * client, uint16_t flags) {
- struct roar_message m;
- int16_t * d = (int16_t *)m.data;
- int confh;
- int i;
-
- if ( con == NULL || client == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_PASSFH;
- m.stream  =  -1; // client (non-stream) passs
- m.pos     =   0;
- m.datalen = 4*2;
-
- d[0] = 0; // version
- d[1] = flags;
- d[2] = client->proto;
- d[3] = client->byteorder;
-
- for (i = 0; i < 4; i++)
-  d[i] = ROAR_HOST2NET16(d[i]);
-
- if ( (confh = roar_get_connection_fh(con)) == -1 )
-  return -1;
-
- if ( roar_send_message(con, &m, NULL) == -1 ) {
-  return -1;
- }
-
- if ( roar_socket_send_fh(confh, client->fh, NULL, 0) == -1 )
-  return -1;
-
- if ( roar_recv_message(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd == ROAR_CMD_OK )
-  return 0;
-
- return -1;
-}
-
-int roar_client_exec     (struct roar_connection * con, struct roar_client * client, uint16_t flags) {
- struct roar_message m;
- int16_t * d = (int16_t *)m.data;
- int i;
-
- if ( con == NULL || client == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_EXEC_STREAM;
- m.stream  =  -1; // client (non-stream) passs
- m.pos     =   0;
- m.datalen = 4*2;
-
- d[0] = 0; // version
- d[1] = flags;
- d[2] = client->proto;
- d[3] = client->byteorder;
-
- for (i = 0; i < 4; i++)
-  d[i] = ROAR_HOST2NET16(d[i]);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- client->fh = roar_get_connection_fh(con);
-
- return 0;
-}
-
-//ll
Index: libroar/config.c
===================================================================
--- libroar/config.c	(revision 6052)
+++ 	(revision )
@@ -1,778 +1,0 @@
-//config.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define LEN_AUTHFILE 1024
-
-static struct roar_libroar_config_codec *
-           roar_libroar_config_codec_get_conf(int32_t codec, int create, struct roar_libroar_config * config);
-
-
-struct roar_libroar_config * roar_libroar_get_config_ptr(void) {
- static struct roar_libroar_config config;
- static int    inited = 0;
- static char   authfile[LEN_AUTHFILE];
- const  char * home;
-
- if ( !inited ) {
-  memset(&config, 0, sizeof(config));
-
-#ifdef ROAR_SUPPORT_TRAP
-  config.trap_policy      = ROAR_TRAP_IGNORE;
-#endif
-  config.opmode           = ROAR_LIBROAR_CONFIG_OPMODE_NORMAL;
-  config.server           = NULL;
-  config.authfile         = NULL;
-  config.forkapi          = NULL;
-  config.connect_internal = NULL;
-  config.daemonimage      = NULL;
-  config.protocolversion  = -1; // use default.
-
-  home = roar_env_get_home(0);
-  if ( home != NULL ) {
-   snprintf(authfile, sizeof(authfile)-1, "%s/.roarauth", home);
-   authfile[sizeof(authfile)-1] = 0;
-   config.authfile    = authfile;
-   config.serversfile = NULL;
-  }
-
-  roar_random_salt_nonce(&config, sizeof(config));
-
-  inited++;
- }
-
- return &config;
-}
-
-struct roar_libroar_config * roar_libroar_get_config(void) {
- struct roar_libroar_config * config = roar_libroar_get_config_ptr();
- static int inited = 0;
- const char * next;
- char * buf;
-
- if ( !inited ) {
-  inited++; // we do this early so we can use ROAR_{DBG,INFO,WARN,ERR}() in roar_libroar_config_parse().
-
-  next = roar_env_get("ROAR_OPTIONS");
-
-  if ( next != NULL ) {
-   if ( (buf = roar_mm_strdup(next)) != NULL ) {
-    roar_libroar_config_parse(buf, " ");
-    roar_mm_free(buf);
-   }
-  }
- }
-
- return config;
-}
-
-int    roar_libroar_reset_config(void) {
- struct roar_libroar_config * config = roar_libroar_get_config_ptr();
-
- if ( config->codecs.codec != NULL ) {
-  roar_mm_free(config->codecs.codec);
-  config->codecs.num = 0;
- }
-
- if ( config->x11.display != NULL )
-  roar_mm_free(config->x11.display);
- config->x11.display = NULL;
-
- if ( config->daemonimage != NULL )
-  roar_mm_free(config->daemonimage);
- config->daemonimage = NULL;
-
- return 0;
-}
-
-#define _P_FP(v)   ((int)(atof((v))*256.0))
-#define _P_INT(v)  (atoi((v)))
-#define _P_BOOL(v) (*(v) == 'y' || *(v) == 'j' || *(v) == 't' || *(v) == '1' ? 1 : 0)
-
-static int roar_libroar_config_parse_codec(struct roar_libroar_config * config, char * txt) {
- struct roar_libroar_config_codec * codec_cfg;
- int32_t codec;
- char * codec_str, * option_str, * value_str;
- char * toksave = NULL;
-
- ROAR_DBG("roar_libroar_config_parse_codec(config=%p, txt='%s') = ?", config, txt);
-
- if ( config == NULL || txt == NULL )
-  return -1;
-
- ROAR_DBG("roar_libroar_config_parse_codec(config=%p, txt='%s') = ?", config, txt);
-
- codec_str = roar_mm_strtok_r(txt, ":", &toksave);
-
- if ( codec_str == NULL )
-  return -1;
-
- option_str = roar_mm_strtok_r(NULL, ":", &toksave);
-
- if ( option_str == NULL )
-  return -1;
-
- value_str = roar_mm_strtok_r(NULL, ":", &toksave);
-
- if ( value_str == NULL )
-  return -1;
-
- ROAR_DBG("roar_libroar_config_parse_codec(config=%p, txt='%s') = ?", config, txt);
-
- if ( (codec = roar_str2codec(codec_str)) == -1 ) {
-  ROAR_WARN("roar_libroar_config_parse_codec(*): Unknown codec: %s", codec_str);
-  return -1;
- }
-
- ROAR_DBG("roar_libroar_config_parse_codec(config=%p, txt='%s'): codec=%i", config, txt, codec);
-
- if ( (codec_cfg = roar_libroar_config_codec_get_conf(codec, 1, config)) == NULL )
-  return -1;
-
- ROAR_DBG("roar_libroar_config_parse_codec(config=%p, txt='%s'): codec=%i, codec_cfg=%p", config, txt, codec, codec_cfg);
-
- if ( !strcmp(option_str, "q") || !strcmp(option_str, "quality") ) {
-  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_Q;
-  codec_cfg->q = _P_FP(value_str);
- } else if ( !strcmp(option_str, "complexity") ) {
-  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_COMPLEXITY;
-  codec_cfg->complexity = _P_FP(value_str);
- } else if ( !strcmp(option_str, "dtx") ) {
-  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_DTX;
-  codec_cfg->dtx = _P_BOOL(value_str);
- } else if ( !strcmp(option_str, "cc-max") ) {
-  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_MAX_CC;
-  codec_cfg->max_cc = _P_INT(value_str);
- } else if ( !strcmp(option_str, "vbr") ) {
-  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_VBR;
-  codec_cfg->vbr = _P_BOOL(value_str);
- } else if ( !strcmp(option_str, "mode") ) {
-  if ( !strcmp(value_str, "nb") ) {
-   codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_MODE;
-   codec_cfg->mode      = ROAR_LIBROAR_CONFIG_MODE_NB;
-  } else if ( !strcmp(value_str, "wb") ) {
-   codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_MODE;
-   codec_cfg->mode      = ROAR_LIBROAR_CONFIG_MODE_WB;
-  } else if ( !strcmp(value_str, "uwb") ) {
-   codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_MODE;
-   codec_cfg->mode      = ROAR_LIBROAR_CONFIG_MODE_UWB;
-  } else {
-   ROAR_WARN("roar_libroar_config_parse_codec(*): Unknown codec mode: %s", value_str);
-   return -1;
-  }
- } else {
-  ROAR_WARN("roar_libroar_config_parse_codec(*): Unknown codec option: %s", option_str);
-  return -1;
- }
-
- return 0;
-}
-
-int    roar_libroar_config_parse(char * txt, char * delm) {
- struct roar_libroar_config * config = roar_libroar_get_config_ptr();
- ssize_t len;
- char * k, * v, * next = txt;
-
- while (next != NULL) {
-  k = next;
-
-  if ( delm == NULL ) {
-   // no delm -> we have only one option
-   next = NULL;
-  } else {
-   next = strstr(next, delm);
-  }
-
-  if ( next != NULL ) {
-   *next = 0;
-    next++;
-  }
-
-  ROAR_DBG("roar_libroar_config_parse(*): k='%s'", k);
-
-  // strip leading spaces:
-  while ( *k == ' ' ) k++;
-
-  ROAR_DBG("roar_libroar_config_parse(*): k='%s'", k);
-
-  // strip tailing new lions:
-  len = roar_mm_strlen(k);
-  if ( len != -1 )
-   for (len--; len && (k[len] == '\r' || k[len] == '\n'); len--)
-    k[len] = 0;
-
-  ROAR_DBG("roar_libroar_config_parse(*): k='%s'", k);
-
-  // comments
-  if ( *k == '#' )
-   continue;
-
-  ROAR_DBG("roar_libroar_config_parse(*): k='%s'", k);
-
-  // empty options:
-  if ( *k == 0 )
-   continue;
-
-  if ( (v = strstr(k, ":")) != NULL ) {
-   *v = 0;
-    v++;
-  }
-
-  ROAR_DBG("roar_libroar_config_parse(*): k='%s', v='%s'", k, v);
-
-  if ( !strcmp(k, "workaround") ) {
-   if ( !strcmp(v, "use-execed") ) {
-    config->workaround.workarounds |= ROAR_LIBROAR_CONFIG_WAS_USE_EXECED;
-   } else if ( !strcmp(v, "no-slp") ) {
-    config->workaround.workarounds |= ROAR_LIBROAR_CONFIG_WAS_NO_SLP;
-   } else {
-    ROAR_WARN("roar_libroar_config_parse(*): Unknown workaround option: %s", v);
-   }
-  } else if ( !strcmp(k, "warning") || !strcmp(k, "warn") ) {
-   if ( !strcmp(v, "sysio") ) {
-    config->warnings.sysio = ROAR_WARNING_ALWAYS;
-   } else if ( !strcmp(v, "obsolete") ) {
-    config->warnings.obsolete = ROAR_WARNING_ALWAYS;
-   } else if ( !strcmp(v, "all") ) {
-    config->warnings.sysio    = ROAR_WARNING_ALWAYS;
-    config->warnings.obsolete = ROAR_WARNING_ALWAYS;
-   } else {
-    ROAR_WARN("roar_libroar_config_parse(*): Unknown warning option: %s", v);
-   }
-  } else if ( !strcmp(k, "opmode") ) {
-   if ( !strcmp(v, "normal") ) {
-    config->opmode = ROAR_LIBROAR_CONFIG_OPMODE_NORMAL;
-   } else if ( !strcmp(v, "funny") ) {
-    config->opmode = ROAR_LIBROAR_CONFIG_OPMODE_FUNNY;
-   } else if ( !strcmp(v, "ms") ) {
-    config->opmode = ROAR_LIBROAR_CONFIG_OPMODE_MS;
-   } else {
-    ROAR_WARN("roar_libroar_config_parse(*): Unknown opmode: %s", v);
-   }
-#ifdef ROAR_SUPPORT_TRAP
-  } else if ( !strcmp(k, "trap-policy") ) {
-   if ( !strcmp(v, "ignore") ) {
-    config->trap_policy = ROAR_TRAP_IGNORE;
-   } else if ( !strcmp(v, "warn") ) {
-    config->trap_policy = ROAR_TRAP_WARN;
-   } else if ( !strcmp(v, "abort") ) {
-    config->trap_policy = ROAR_TRAP_ABORT;
-#ifdef SIGKILL
-   } else if ( !strcmp(v, "kill") ) {
-    config->trap_policy = ROAR_TRAP_KILL;
-#endif
-#ifdef SIGSTOP
-   } else if ( !strcmp(v, "stop") ) {
-    config->trap_policy = ROAR_TRAP_STOP;
-#endif
-   } else if ( !strcmp(v, "die") ) {
-    config->trap_policy = ROAR_TRAP_DIE;
-   } else {
-    ROAR_WARN("roar_libroar_config_parse(*): Unknown trap policy: %s", v);
-   }
-#endif
-  } else if ( !strcmp(k, "force-rate") ) {
-   config->info.rate = roar_str2rate(v);
-  } else if ( !strcmp(k, "force-bits") ) {
-   config->info.bits = roar_str2bits(v);
-  } else if ( !strcmp(k, "force-channels") ) {
-   config->info.channels = roar_str2channels(v);
-  } else if ( !strcmp(k, "force-codec") ) {
-   config->info.codec = roar_str2codec(v);
-  } else if ( !strcmp(k, "codec") ) {
-   if ( roar_libroar_config_parse_codec(config, v) == -1 ) {
-    ROAR_WARN("roar_libroar_config_parse(*): Error parsing codec config option");
-   }
-  } else if ( !strcmp(k, "set-server") ) {
-   if ( roar_libroar_get_server() == NULL )
-    roar_libroar_set_server(v);
-  } else if ( !strcmp(k, "set-authfile") ) {
-   strncpy(config->authfile, v, LEN_AUTHFILE-1);
-   config->authfile[LEN_AUTHFILE-1] = 0;
-  } else if ( !strcmp(k, "x11-display") ) {
-   if ( config->x11.display != NULL )
-    roar_mm_free(config->x11.display);
-   config->x11.display = roar_mm_strdup(v);
-  } else if ( !strcmp(k, "daemonimage") ) {
-   if ( config->daemonimage != NULL )
-    roar_mm_free(config->daemonimage);
-   config->daemonimage = roar_mm_strdup(v);
-  } else if ( !strcmp(k, "serverflags") ) {
-   if ( !strcmp(v, "nonblock") ) {
-    config->serverflags |= ROAR_ENUM_FLAG_NONBLOCK;
-   } else if ( !strcmp(v, "hardnonblock") ) {
-    config->serverflags |= ROAR_ENUM_FLAG_HARDNONBLOCK;
-   } else if ( !strcmp(v, "localonly") ) {
-    config->serverflags |= ROAR_ENUM_FLAG_LOCALONLY;
-   } else {
-    ROAR_WARN("roar_libroar_config_parse(*): Unknown serverflag: %s", v);
-   }
-  } else if ( !strcmp(k, "protocolversion") ) {
-   config->protocolversion = atoi(v);
-  } else {
-   ROAR_WARN("roar_libroar_config_parse(*): Unknown option: %s", k);
-  }
- }
-
- roar_random_salt_nonce(&config, sizeof(config));
-
- return 0;
-}
-
-struct roar_libroar_config_codec * roar_libroar_config_codec_get(int32_t codec, int create) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- return roar_libroar_config_codec_get_conf(codec, create, config);
-}
-
-static struct roar_libroar_config_codec *
-           roar_libroar_config_codec_get_conf(int32_t codec, int create, struct roar_libroar_config * config) {
- size_t i;
- int need_new = 1;
-
- ROAR_DBG("roar_libroar_config_codec_get_conf(codec=%i, create=%i, config=%p) = ?", codec, create, config);
-
- if ( codec < 0 || create < 0 )
-  return NULL;
-
- ROAR_DBG("roar_libroar_config_codec_get_conf(codec=%i, create=%i, config=%p) = ?", codec, create, config);
-
- if ( config->codecs.num == 0 ) {
-  // no match case:
-  if ( !create )
-   return NULL;
- } else {
-  for (i = 0; i < config->codecs.num; i++) {
-   if ( config->codecs.codec[i].codec == (uint32_t)codec )
-    return &(config->codecs.codec[i]);
-   if ( config->codecs.codec[i].codec == (uint32_t)-1 )
-    need_new = 0;
-  }
- }
-
- ROAR_DBG("roar_libroar_config_codec_get_conf(codec=%i, create=%i, config=%p) = ?", codec, create, config);
-
- if ( !create )
-  return NULL;
-
- if ( !need_new ) {
-  for (i = 0; i < config->codecs.num; i++) {
-   if ( config->codecs.codec[i].codec == (uint32_t)-1 ) {
-    memset(&(config->codecs.codec[i]), 0, sizeof(struct roar_libroar_config_codec));
-    config->codecs.codec[i].codec = codec;
-    return &(config->codecs.codec[i]);
-   }
-  }
- }
-
- if ( config->codecs.num == 0 ) {
-  config->codecs.codec = roar_mm_malloc(16*sizeof(struct roar_libroar_config_codec));
- } else {
-  config->codecs.codec = roar_mm_realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec));
- }
-
- if ( config->codecs.codec == NULL )
-  return NULL;
-
- memset(&(config->codecs.codec[config->codecs.num]), 0, 16);
- for (i = config->codecs.num; i < (config->codecs.num+16); i++) {
-  config->codecs.codec[i].codec = (uint32_t)-1;
- }
-
- i = config->codecs.num;
- config->codecs.num += 16;
-
- memset(&(config->codecs.codec[i]), 0, sizeof(struct roar_libroar_config_codec));
- config->codecs.codec[i].codec = codec;
-
- return &(config->codecs.codec[i]);
-}
-
-int    roar_libroar_set_server(const char * server) {
- roar_libroar_get_config_ptr()->server = server;
- return 0;
-}
-
-const char * roar_libroar_get_server(void) {
- return roar_libroar_get_config_ptr()->server;
-}
-
-int    roar_libroar_set_forkapi(const struct roar_libroar_forkapi * api) {
- roar_libroar_get_config_ptr()->forkapi = api;
- return 0;
-}
-
-int    roar_libroar_set_connect_internal(struct roar_vio_calls * (*func)(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout)) {
- roar_libroar_get_config_ptr()->connect_internal = func;
- return 0;
-}
-
-void   roar_libroar_nowarn(void) {
- roar_libroar_get_config_ptr()->nowarncounter++;
-}
-
-void   roar_libroar_warn(void) {
- struct roar_libroar_config * cfg = roar_libroar_get_config_ptr();
-
- if ( cfg->nowarncounter == 0 ) {
-  ROAR_WARN("roar_libroar_warn(): Re-Enabling already enabled warnings! (Application error?)");
-  return;
- }
-
- cfg->nowarncounter--;
-}
-
-static const struct pathinfo {
- const char * name;
- const char * path;
- const int    with_product; // 0 = no, 1 = yes, 2 = just product.
- const int    with_provider;
-} __paths[] = {
- // prefixes:
- {"prefix",             ROAR_PREFIX, 0, 0},
- {"prefix-bin",         ROAR_PREFIX_BIN, 0, 0},
- {"prefix-sbin",        ROAR_PREFIX_SBIN, 0, 0},
- {"prefix-lib",         ROAR_PREFIX_LIB, 0, 0},
- {"prefix-inc",         ROAR_PREFIX_INC, 0, 0},
- {"prefix-man",         ROAR_PREFIX_MAN, 0, 0},
- {"prefix-man1",        ROAR_PREFIX_MAN "/man1", 0, 0},
- {"prefix-man2",        ROAR_PREFIX_MAN "/man2", 0, 0},
- {"prefix-man3",        ROAR_PREFIX_MAN "/man3", 0, 0},
- {"prefix-man4",        ROAR_PREFIX_MAN "/man4", 0, 0},
- {"prefix-man5",        ROAR_PREFIX_MAN "/man5", 0, 0},
- {"prefix-man6",        ROAR_PREFIX_MAN "/man6", 0, 0},
- {"prefix-man7",        ROAR_PREFIX_MAN "/man7", 0, 0},
- {"prefix-man8",        ROAR_PREFIX_MAN "/man8", 0, 0},
- {"prefix-man9",        ROAR_PREFIX_MAN "/man9", 0, 0},
- {"prefix-pc",          ROAR_PREFIX_PC, 0, 0},
- {"prefix-ckport",      ROAR_PREFIX_CKPORT, 0, 0},
- {"prefix-sysconf",     ROAR_PREFIX_SYSCONF, 2, 0},
- {"prefix-dev",         ROAR_PREFIX_DEV, 0, 0},
- {"prefix-doc",         ROAR_PREFIX_DOC, 2, 0},
- {"prefix-tmp",         ROAR_PREFIX_TMP, 0, 0},
- {"prefix-var",         ROAR_PREFIX_VAR, 0, 0},
- {"prefix-cache",       ROAR_PREFIX_CACHE, 2, 0},
- {"prefix-data",        ROAR_PREFIX_DATA, 2, 0},
- {"prefix-lock",        ROAR_PREFIX_LOCK, 0, 0},
- {"prefix-log",         ROAR_PREFIX_LOG, 0, 0},
- {"prefix-mail",        ROAR_PREFIX_MAIL, 0, 0},
- {"prefix-run",         ROAR_PREFIX_RUN, 0, 0},
- {"prefix-spool",       ROAR_PREFIX_SPOOL, 2, 0},
- {"prefix-comp-libs",   ROAR_PREFIX_COMP_LIBS, 0, 0},
- {"prefix-comp-bins",   ROAR_PREFIX_COMP_BINS, 0, 0},
- {"prefix-plugins",     ROAR_PREFIX_PLUGINS, 1, 1},
- {"prefix-buildsystem", ROAR_PREFIX_BUILDSYSTEM, 0, 0},
-
- // bins:
- {"bin-default-daemonimage", "roard", 0, 0},
-
-#ifdef ROAR_HAVE_BIN_SH
- {"bin-sh",             ROAR_HAVE_BIN_SH, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_OGG123
- {"bin-ogg123",         ROAR_HAVE_BIN_OGG123, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_FLAC
- {"bin-flac",           ROAR_HAVE_BIN_FLAC, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_TIMIDITY
- {"bin-timidity",       ROAR_HAVE_BIN_TIMIDITY, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_CDPARANOIA
- {"bin-cdparanoia",     ROAR_HAVE_BIN_CDPARANOIA, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_GNUPLOT
- {"bin-gnuplot",        ROAR_HAVE_BIN_GNUPLOT, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_SSH
- {"bin-ssh",            ROAR_HAVE_BIN_SSH, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_PINENTRY
- {"bin-pinentry",       ROAR_HAVE_BIN_PINENTRY, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_SSH_ASKPASS
- {"bin-ssh-askpass",    ROAR_HAVE_BIN_SSH_ASKPASS, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_GTK_LED_ASKPASS
- {"bin-gtk-led-askpass", ROAR_HAVE_BIN_GTK_LED_ASKPASS, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_X11_SSH_ASKPASS
- {"bin-x11-ssh-askpass", ROAR_HAVE_BIN_X11_SSH_ASKPASS, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_GNOME_SSH_ASKPASS
- {"bin-gnome-ssh-askpass", ROAR_HAVE_BIN_GNOME_SSH_ASKPASS, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_GPG
- {"bin-gpg",            ROAR_HAVE_BIN_GPG, 0, 0},
-#endif
-#ifdef ROAR_HAVE_BIN_EJECT
- {"bin-eject",          ROAR_HAVE_BIN_EJECT, 0, 0},
-#endif
-
- // devices:
- {"dev-stdin",                  ROAR_PREFIX_DEV "/stdin", 0, 0},
- {"dev-default-pwmled",         ROAR_PREFIX_DEV "/ttyS0", 0, 0},
- {"dev-default-dmx4linux",      ROAR_PREFIX_DEV "/dmx", 0, 0},
-
-#ifdef ROAR_DEFAULT_CDROM
- {"dev-default-cdrom",          ROAR_DEFAULT_CDROM, 0, 0},
-#endif
-#ifdef ROAR_DEFAULT_TTY
- {"dev-default-tty",            ROAR_DEFAULT_TTY, 0, 0},
-#endif
-#ifdef ROAR_DEFAULT_OSS_DEV
- {"dev-default-oss-dev",        ROAR_DEFAULT_OSS_DEV, 0, 0},
-#endif
-#ifdef ROAR_DEFAULT_OSS_MIX_DEV
- {"dev-default-oss-mix-dev",    ROAR_DEFAULT_OSS_MIX_DEV, 0, 0},
-#endif
-
- // proc:
-#ifdef ROAR_PROC_NET_DECNET
- {"proc-net-decnet",            ROAR_PROC_NET_DECNET, 0, 0},
-#endif
-#ifdef ROAR_PROC_NET_DECNET_NEIGH
- {"proc-net-decnet-neigh",      ROAR_PROC_NET_DECNET_NEIGH, 0, 0},
-#endif
-#ifdef ROAR_PROC_NET_ARP
- {"proc-net-arp",               ROAR_PROC_NET_ARP, 0, 0},
-#endif
-
- // sysconf:
- {"sysconf-hosts",              ROAR_PREFIX_SYSCONF "/hosts", 0, 0},
- {"sysconf-roarserver",         ROAR_PREFIX_SYSCONF "/roarserver", 0, 0},
-
- // special dirs:
- {"dir-nx-home",                "/NX-HOME-DIR", 0, 0},
-#ifdef ROAR_TARGET_WIN32
- {"dir-win32-sucks",            "/WIN32-SUCKS", 0, 0}
-#endif
-};
-
-static int __product2path(char * path, size_t pathlen, int null_as_universal, const char * product, int type) {
- const char * c;
- const char * e;
- const char * s;
- const char * b;
-
- if ( product != NULL && !strcmp(product, "universal") ) {
-  null_as_universal = 1;
-  product = NULL;
- }
-
- if ( product == NULL ) {
-  if ( null_as_universal ) {
-   if ( type == 2 ) {
-    snprintf(path, pathlen, "/universal");
-   } else {
-    snprintf(path, pathlen, "/universal/universal");
-   }
-  } else {
-   path[0] = 0;
-  }
-  return 0;
- }
-
- b = strstr(product, " ");
- c = strstr(product, "<");
- e = strstr(product, ">");
-
- if ( b == NULL || c == NULL || e == NULL || c < b || e < c ) {
-  roar_err_set(ROAR_ERROR_ILLSEQ);
-  return -1;
- }
-
- c++;
-
- s = strstr(c, "/");
-
- if ( type == 2 ) {
-  snprintf(path, pathlen, "/%.*s", (int)(size_t)(b-product), product);
- } else if ( s == NULL ) {
-  snprintf(path, pathlen, "/unreg-%.*s/%.*s", (int)(size_t)(e-c), c, (int)(size_t)(b-product), product);
- } else {
-  snprintf(path, pathlen, "/%.*s-%.*s/%.*s", (int)(size_t)(s-c), c, (int)(size_t)(e-s-1), s+1, (int)(size_t)(b-product), product);
- }
-
- return 0;
-}
-
-static int __provider2path(char * path, size_t pathlen, const char * provider) {
- const char * c;
- const char * e;
- const char * s;
-
- if ( provider == NULL ) {
-  path[0] = 0;
-  return 0;
- }
-
- c = strstr(provider, "<");
- e = strstr(provider, ">");
-
- if ( c == NULL || e == NULL || e < c ) {
-  roar_err_set(ROAR_ERROR_ILLSEQ);
-  return -1;
- }
-
- c++;
-
- s = strstr(c, "/");
-
- if ( s == NULL ) {
-  snprintf(path, pathlen, "/unreg-%.*s", (int)(size_t)(e-c), c);
- } else {
-  snprintf(path, pathlen, "/%.*s-%.*s", (int)(size_t)(s-c), c, (int)(size_t)(e-s-1), s+1);
- }
-
- return 0;
-
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-}
-
-static const struct pathinfo * __lookup_path(const char * name) {
- size_t i;
-
- if ( name == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- for (i = 0; i < (sizeof(__paths)/sizeof(*__paths)); i++)
-  if ( !strcmp(__paths[i].name, name) )
-   return &(__paths[i]);
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-void __strip_double_slashes(char * p) {
- const char * in = p;
-
- for (; *in; in++, p++) {
-  *p = *in;
-  if ( *in == '/' )
-   for (; in[1] == '/'; in++);
- }
-
- *p = 0;
-}
-
-char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) {
- const struct pathinfo * path;
- char buf_product[384];
- char buf_provider[384];
- ssize_t len_prefix, len_product, len_provider;
- char * ret, * p;
-
- ROAR_DBG("roar_libroar_get_path(name='%s', null_as_universal=%i, product='%s', provider='%s') = ?", name, null_as_universal, product, provider);
-
- path = __lookup_path(name);
- if ( path == NULL )
-  return NULL;
-
- if ( ((null_as_universal || product != NULL) && !path->with_product) ||
-      (provider != NULL && !path->with_provider) ||
-      (!null_as_universal && product == NULL && provider != NULL) ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return NULL;
- }
-
- if ( __product2path(buf_product, sizeof(buf_product), null_as_universal, product, path->with_product) == -1 )
-  return NULL;
-
- if ( __provider2path(buf_provider, sizeof(buf_provider), provider) == -1 )
-  return NULL;
-
- len_prefix = roar_mm_strlen(path->path);
- len_product = roar_mm_strlen(buf_product);
- len_provider = roar_mm_strlen(buf_provider);
-
- p = ret = roar_mm_malloc(len_prefix+len_product+len_provider+1);
- if ( ret == NULL )
-  return NULL;
-
- memcpy(p, path->path, len_prefix);
- p += len_prefix;
- if ( p[-1] == '/' )
-  p--;
- memcpy(p, buf_product, len_product);
- p += len_product;
- memcpy(p, buf_provider, len_provider);
- p += len_provider;
-
- *p = 0;
-
- __strip_double_slashes(ret);
-
- return ret;
-}
-
-const char * roar_libroar_get_path_static(const char * name) {
- const struct pathinfo * path;
-
- path = __lookup_path(name);
- if ( path == NULL )
-  return NULL;
-
- return path->path;
-}
-
-ssize_t roar_libroar_list_path(const char ** list, size_t len, size_t offset) {
- size_t i;
- ssize_t idx = 0;
-
- ROAR_DBG("roar_libroar_list_path(list=%p, len=%lu, offset=%lu) = ?", list, (long unsigned int)len, (long unsigned int)offset);
-
- if ( list == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( len == 0 )
-  return 0;
-
- if ( offset >= (sizeof(__paths)/sizeof(*__paths)) )
-  return 0;
-
- for (i = offset; idx < len && i < (sizeof(__paths)/sizeof(*__paths)); i++) {
-  list[idx++] = __paths[i].name;
- }
-
- return idx;
-}
-
-//ll
Index: libroar/crc.c
===================================================================
--- libroar/crc.c	(revision 6052)
+++ 	(revision )
@@ -1,153 +1,0 @@
-//crc.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define CRC24_POLY 0x01864CFBL
-#define CRC24_INIT 0x00B704CEL
-
-#define ADLER32_BASE 65521L
-#define ADLER32_INIT 1L
-
-uint32_t roar_crc24_add(uint32_t state, const void * data, size_t len) {
- const unsigned char * p = data;
- int i;
-
- if ( data == NULL )
-  return CRC24_INIT;
-
- for (; len; len--) {
-  state ^= ((uint32_t)(*p++)) << 16;
-  for (i = 0; i < 8; i++) {
-   state <<= 1;
-   if ( state & 0x01000000 )
-    state ^= CRC24_POLY;
-  }
- }
-
- return state & 0x00FFFFFFL;
-}
-
-uint32_t roar_adler32_add(uint32_t state, const void * data, size_t len) {
- const unsigned char * p = data;
- uint32_t s1 =  state        & 0xFFFFL;
- uint32_t s2 = (state >> 16) & 0xFFFFL;
- size_t n;
-
- if ( data == NULL )
-  return ADLER32_INIT;
-
- for (n = 0; n < len; n++) {
-  s1 = (s1 + p[n]) % ADLER32_BASE;
-  s2 = (s2 + s1  ) % ADLER32_BASE;
- }
-
- return (s2 << 16) + s1;
-}
-
-
-int roar_hash_crc24_init(void * state) {
- uint32_t * self = state;
-
- *self = roar_crc24_init();
-
- return 0;
-}
-
-int roar_hash_crc24_digest(void * state, void * digest, size_t * len) {
- uint32_t * self = state;
- unsigned char * out  = digest;
- register uint32_t crc;
-
- if ( *len < 3 )
-  return -1;
-
- *len = 3;
-
- crc = *self;
-
- out[0] = ((crc & 0x00FF0000) >> 16) & 0xFF;
- out[1] = ((crc & 0x0000FF00) >>  8) & 0xFF;
- out[2] = ((crc & 0x000000FF) >>  0) & 0xFF;
-
- return 0;
-}
-
-int roar_hash_crc24_proc(void * state, const void * data, size_t len) {
- uint32_t * self = state;
-
- *self = roar_crc24_add(*self, data, len);
-
- return 0;
-}
-
-
-int roar_hash_adler32_init(void * state) {
- uint32_t * self = state;
-
- *self = roar_adler32_init();
-
- return 0;
-}
-
-int roar_hash_adler32_digest(void * state, void * digest, size_t * len) {
- uint32_t * self = state;
- unsigned char * out  = digest;
- register uint32_t crc;
-
- if ( *len < 4 )
-  return -1;
-
- *len = 4;
-
- crc = *self;
-
- out[0] = ((crc & 0xFF000000) >> 24) & 0xFF;
- out[1] = ((crc & 0x00FF0000) >> 16) & 0xFF;
- out[2] = ((crc & 0x0000FF00) >>  8) & 0xFF;
- out[3] = ((crc & 0x000000FF) >>  0) & 0xFF;
-
- return 0;
-}
-
-int roar_hash_adler32_proc(void * state, const void * data, size_t len) {
- uint32_t * self = state;
-
- *self = roar_adler32_add(*self, data, len);
-
- return 0;
-}
-
-//ll
Index: libroar/crypto.c
===================================================================
--- libroar/crypto.c	(revision 6052)
+++ 	(revision )
@@ -1,66 +1,0 @@
-//crypto.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_LIBGCRYPT
-#include <gcrypt.h>
-#endif
-
-int roar_crypto_init (void) {
- static int inited = 0;
-
- if ( inited )
-  return 0;
-
-#ifdef ROAR_HAVE_LIBGCRYPT
- if ( !gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P) ) {
-  ROAR_INFO("roar_crypto_init(void): libgcrypt not yet inited, initing it now.", ROAR_DBG_INFO_INFO);
-  if ( !gcry_check_version(GCRYPT_VERSION) ) {
-   ROAR_ERR("roar_crypto_init(void): libgcrypt version missmatch");
-   return -1;
-  }
-
-  // what about SECMEM?
-
-  gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
- }
-#endif
-
- inited = 1;
- return 0;
-}
-
-//ll
Index: libroar/ctl.c
===================================================================
--- libroar/ctl.c	(revision 6072)
+++ libroar/ctl.c	(revision 0)
@@ -1,82 +1,19 @@
 //ctl.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
 #include "libroar.h"
 
-int roar_get_clientid  (struct roar_connection * con) {
- struct roar_message mes;
-
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- mes.cmd     = ROAR_CMD_WHOAMI;
- mes.stream  = -1;
- mes.datalen =  0;
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( mes.datalen != 1 )
-  return -1;
-
- return mes.data[0];
-}
-
-int roar_server_oinfo  (struct roar_connection * con, struct roar_stream * s, int dir) {
- struct roar_message mes;
-
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
+int roar_server_oinfo   (struct roar_connection * con, struct roar_stream * sa) {
+ struct roar_message mes;
 
  mes.cmd     = ROAR_CMD_SERVER_OINFO;
-
- if ( dir == -1 ) {
-  mes.datalen = 0;
- } else {
-  mes.datalen = 2;
-  mes.data[0] = 0;
-  mes.data[1] = dir;
- }
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( roar_stream_m2s(s, &mes) == -1 )
+ mes.datalen = 0;
+
+ if ( roar_req(con, &mes, NULL) == -1 )
+  return -1;
+
+ if ( mes.cmd != ROAR_CMD_OK )
+  return -1;
+
+ if ( roar_stream_m2s(sa, &mes) == -1 )
   return -1;
 
@@ -86,67 +23,52 @@
 int roar_get_standby   (struct roar_connection * con) {
  struct roar_message mes;
- uint16_t * d16 = (uint16_t *)mes.data;
-
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
 
  mes.cmd = ROAR_CMD_GET_STANDBY;
- mes.stream  = -1;
- mes.datalen =  0;
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- return ROAR_NET2HOST16(*d16);
+ mes.datalen = 0;
+
+ if ( roar_req(con, &mes, NULL) == -1 )
+  return -1;
+
+ if ( mes.cmd != ROAR_CMD_OK )
+  return -1;
+
+ return ROAR_NET2HOST16(*((uint16_t*)mes.data));
 }
 
 int roar_set_standby   (struct roar_connection * con, int state) {
  struct roar_message mes;
- uint16_t * d16 = (uint16_t *)mes.data;
-
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
 
  mes.cmd = ROAR_CMD_SET_STANDBY;
- mes.stream  = -1;
- mes.datalen =  2;
-
- *d16 = ROAR_HOST2NET16((unsigned) state);
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_terminate (struct roar_connection * con, int terminate) {
- struct roar_message mes;
-
- memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- mes.cmd     = ROAR_CMD_EXIT;
- mes.stream  = -1;
- mes.datalen =  1;
- mes.data[0] = terminate;
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_list_filtered(struct roar_connection * con, int * items,   int max, int cmd, unsigned char filter, unsigned char cmp, uint32_t id) {
- struct roar_message m;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- roar_ctl_f2m(&m, filter, cmp, id);
+ mes.datalen = 2;
+
+ *((uint16_t*)mes.data) = ROAR_HOST2NET16((unsigned) state);
+
+ if ( roar_req(con, &mes, NULL) == -1 )
+  return -1;
+
+ if ( mes.cmd != ROAR_CMD_OK )
+  return -1;
+
+ return 0;
+}
+
+int roar_exit   (struct roar_connection * con) {
+ struct roar_message mes;
+
+ mes.cmd = ROAR_CMD_EXIT;
+ mes.datalen = 0;
+ if ( roar_req(con, &mes, NULL) == -1 )
+  return -1;
+
+ if ( mes.cmd != ROAR_CMD_OK )
+  return -1;
+
+ return 0;
+}
+
+int roar_list         (struct roar_connection * con, int * items,   int max, int cmd) {
+ struct roar_message m;
+
+ roar_ctl_f2m_any(&m);
  m.cmd = cmd;
 
@@ -157,23 +79,14 @@
 }
 
-int roar_list         (struct roar_connection * con, int * items,   int max, int cmd) {
- return roar_list_filtered(con, items, max, cmd, ROAR_CTL_FILTER_ANY, ROAR_CTL_CMP_ANY, ROAR_CTL_FILTER_ANY);
-}
-
 int roar_get_client   (struct roar_connection * con, struct roar_client * client, int id) {
  struct roar_message m;
- char * data = NULL;
- int ret;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
 
  m.cmd     = ROAR_CMD_GET_CLIENT;
- m.stream  = -1;
- m.datalen =  1;
+ m.datalen = 1;
  m.data[0] = id;
 
  ROAR_DBG("roar_get_client(*): id = %i", id);
 
- if ( roar_req(con, &m, &data) == -1 )
+ if ( roar_req(con, &m, NULL) == -1 )
   return -1;
 
@@ -183,16 +96,9 @@
  ROAR_DBG("roar_get_client(*): got ok");
 
- ret = roar_ctl_m2c2(&m, client, data);
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- return ret;
+ return roar_ctl_m2c(&m, client);
 }
 
 int roar_get_stream   (struct roar_connection * con, struct roar_stream * stream, int id) {
  struct roar_message m;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
 
  m.cmd     = ROAR_CMD_GET_STREAM;
@@ -200,10 +106,6 @@
  m.data[0] = id;
 
- roar_err_set(ROAR_ERROR_UNKNOWN);
-
- if ( roar_req(con, &m, NULL) == -1 ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return -1;
- }
+ if ( roar_req(con, &m, NULL) == -1 )
+  return -1;
 
  if ( m.cmd != ROAR_CMD_OK )
@@ -215,12 +117,10 @@
 int roar_kick         (struct roar_connection * con, int type, int id) {
  struct roar_message m;
- uint16_t * info = (uint16_t *) m.data;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
+ uint16_t * info = m.data;
 
  m.cmd     = ROAR_CMD_KICK;
  m.datalen = 4;
- info[0] = ROAR_HOST2NET16(type);
- info[1] = ROAR_HOST2NET16(id);
+ info[0] = type;
+ info[1] = id;
 
  if ( roar_req(con, &m, NULL) == -1 )
@@ -233,69 +133,4 @@
 }
 
-int roar_set_vol     (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int   channels, int mode) {
- struct roar_message m;
- uint16_t * info = (uint16_t *) m.data;
- int i;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- m.cmd     = ROAR_CMD_SET_VOL;
- m.datalen = (3 + channels) * 2;
- m.stream  = id;
- info[0] = ROAR_HOST2NET16(1);
- info[1] = ROAR_HOST2NET16(mixer->scale);
- info[2] = ROAR_HOST2NET16(mode);
-
- for (i = 0; i < channels; i++)
-  info[i+3] = ROAR_HOST2NET16(mixer->mixer[i]);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_get_vol      (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int * channels) {
- struct roar_message m;
- uint16_t * info = (uint16_t *) m.data;
- int i;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- m.cmd     = ROAR_CMD_GET_VOL;
- m.datalen = 2*2;
- m.stream  = id;
-
- info[0]   = ROAR_HOST2NET16(1);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( ROAR_NET2HOST16(info[0]) != 1 )
-  return -1;
-
- info[1] = ROAR_NET2HOST16(info[1]);
-
- if ( channels != NULL )
-  *channels = info[1];
-
- if ( info[1] > ROAR_MAX_CHANNELS )
-  return -1;
-
- mixer->scale   = ROAR_NET2HOST16(info[2]);
- mixer->rpg_mul = ROAR_NET2HOST16(info[3]);
- mixer->rpg_div = ROAR_NET2HOST16(info[4]);
-
- for (i = 0; i < info[1]; i++)
-  mixer->mixer[i] = ROAR_NET2HOST16(info[i+5]);
-
- return 0;
-}
 
 // converts: *_m2*, *_*2m
@@ -308,13 +143,9 @@
  m->data[1] = filter;
  m->data[2] = cmp;
- m->data[3] = (id & 0xFF000000LU) >> 24;
- m->data[4] = (id & 0x00FF0000LU) >> 16;
- m->data[5] = (id & 0x0000FF00LU) >>  8;
- m->data[6] = (id & 0x000000FFLU) >>  0;
+ *((uint32_t*)&(m->data[3])) = ROAR_HOST2NET32(id);
 
  return 0;
 }
 int roar_ctl_m2f      (struct roar_message * m, unsigned char * filter, unsigned char * cmp, uint32_t * id) {
- register uint32_t idreg;
 
  if ( m->datalen != 7 )
@@ -322,6 +153,5 @@
 
  if ( m->data[0] != 0 ) {
-  ROAR_DBG("roar_ctl_m2f(*): version %i not supported!", (int)m->data[0]);
-  roar_err_set(ROAR_ERROR_NSVERSION);
+  ROAR_ERR("roar_ctl_m2f(*): version %i not supported!", m->data[0]);
   return -1;
  }
@@ -330,37 +160,14 @@
  *cmp    = m->data[2];
 
- idreg   = ((uint32_t)(unsigned char)m->data[3]) << 24;
- idreg  |= ((uint32_t)(unsigned char)m->data[4]) << 16;
- idreg  |= ((uint32_t)(unsigned char)m->data[5]) <<  8;
- idreg  |= ((uint32_t)(unsigned char)m->data[6]) <<  0;
- *id     = idreg;
-
- return 0;
-}
-
-int roar_filter_match (const unsigned cmp, const uint32_t a, const uint32_t b) {
- switch (cmp) {
-  case ROAR_CTL_CMP_ANY:
-    return 1;
-   break;
-  case ROAR_CTL_CMP_EQ:
-    return a == b;
-   break;
-  case ROAR_CTL_CMP_NE:
-    return a != b;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
- }
-}
-
-int roar_ctl_ia2m     (struct roar_message * m, int * data, size_t len) {
- size_t i;
-
- if ( len > LIBROAR_BUFFER_MSGDATA ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
+ *id = ROAR_NET2HOST32(*((uint32_t*)&(m->data[3])));
+
+ return 0;
+}
+
+int roar_ctl_ia2m     (struct roar_message * m, int * data, int len) {
+ int i;
+
+ if ( len > LIBROAR_BUFFER_MSGDATA )
+  return -1;
 
  m->datalen = len;
@@ -371,11 +178,9 @@
  return 0;
 }
-int roar_ctl_m2ia     (struct roar_message * m, int * data, size_t len) {
- size_t i;
-
- if ( m->datalen > len ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
+int roar_ctl_m2ia     (struct roar_message * m, int * data, int len) {
+ int i;
+
+ if ( m->datalen > len )
+  return -1;
 
  for (i = 0; i < m->datalen; i++)
@@ -385,58 +190,26 @@
 }
 
-int roar_ctl_c2m2     (struct roar_message * m, struct roar_client * c, void ** data) {
- char * d;
- size_t cur = 0;
+int roar_ctl_c2m      (struct roar_message * m, struct roar_client * c) {
+ int cur = 0;
  int h;
  int i;
  int max_len;
- uint32_t pid;
- size_t nnode_len;
- size_t needed_len = 3 + 5*4 + 18 /* 18 = current max size for blob */;
 
  if ( c == NULL )
   return -1;
 
- if ( data != NULL )
-  *data = NULL;
+ m->data[cur++] = 0;                       // 0: Version
+ m->data[cur++] = c->execed;               // 1: execed
+
+ h = 0;
+ for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
+  if ( c->streams[i] != -1 )
+   m->data[cur+1+h++] = c->streams[i];
+ }
+
+ m->data[cur++] = h;                       // 2: num of streams
+ cur += h;
 
  max_len = strlen(c->name);
- needed_len += max_len;
-
- for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++)
-  if ( c->streams[i] != -1 )
-   needed_len++;
-
- if ( needed_len > sizeof(m->data) ) {
-  if ( data == NULL ) {
-   needed_len -= max_len;
-   if ( needed_len > sizeof(m->data) ) {
-    roar_panic(ROAR_FATAL_ERROR_CPU_FAILURE, "needed_len > sizeof(m->data) happend.");
-    roar_err_set(ROAR_ERROR_BADCKSUM);
-    return -1;
-   }
-   max_len = sizeof(m->data) - needed_len;
-   needed_len = sizeof(m->data);
-   d = m->data;
-  } else {
-   d = roar_mm_malloc(needed_len);
-   if ( d == NULL )
-    return -1;
-   *data = d;
-  }
- } else {
-  d = m->data;
- }
-
- d[cur++] = 0;                       // 0: Version
- d[cur++] = c->execed;               // 1: execed
-
- h = 0;
- for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++)
-  if ( c->streams[i] != -1 )
-   d[cur+1+h++] = c->streams[i];
-
- d[cur++] = h;                       // 2: num of streams
- cur += h;
 
  // TODO: add some code to check if this fits in the pkg
@@ -444,537 +217,49 @@
  //       and fully decieded about this function.
 
- d[cur++] = max_len;
-
- strncpy(d+cur, c->name, max_len);
+ m->data[cur++] = max_len;
+
+ strncpy((m->data)+cur, c->name, max_len);
 
  cur += max_len;
 
- pid = ROAR_HOST2NET32(c->pid);
- memcpy(&(d[cur]), &pid, 4);
- cur += 4;
-
- pid = ROAR_HOST2NET32(c->uid);
- memcpy(&(d[cur]), &pid, 4);
- cur += 4;
-
- pid = ROAR_HOST2NET32(c->gid);
- memcpy(&(d[cur]), &pid, 4);
- cur += 4;
-
- pid = ROAR_HOST2NET32(c->proto);
- memcpy(&(d[cur]), &pid, 4);
- cur += 4;
-
- pid = ROAR_HOST2NET32(c->byteorder);
- memcpy(&(d[cur]), &pid, 4);
- cur += 4;
-
- if ( cur > needed_len ) {
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
+ m->datalen = cur;
+
+ return 0;
+}
+
+int roar_ctl_m2c      (struct roar_message * m, struct roar_client * c) {
+ int i;
+ int cur;
+
+ if ( m == NULL || c == NULL )
+  return -1;
+
+ if ( m->datalen == 0 )
+  return -1;
+
+ ROAR_DBG("roar_ctl_m2c(*): got data!, len = %i", m->datalen);
+
+ if ( m->data[0] != 0 ) {
+  ROAR_DBG("roar_ctl_m2c(*): wrong version!");
+  return -1;
  }
 
- nnode_len = needed_len - cur;
- if ( roar_nnode_to_blob(&(c->nnode), &(d[cur]), &nnode_len) == 0 ) {
-  cur += nnode_len;
- }
-
- if ( cur > needed_len ) {
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
- }
-
- m->datalen = cur;
-
- return 0;
-}
-
-int roar_ctl_m2c2      (struct roar_message * m, struct roar_client * c, void * data) {
- char * d = data;
- uint32_t pid;
- size_t len;
- size_t cur;
- int i;
-
- if ( m == NULL || c == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( m->datalen == 0 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- if ( d == NULL ) {
-  if ( m->datalen > sizeof(m->data) ) {
-   roar_err_set(ROAR_ERROR_FAULT);
-   return -1;
-  }
-  d = m->data;
- }
-
- ROAR_DBG("roar_ctl_m2c(*): got data!, len = %i", m->datalen);
-
- if ( d[0] != 0 ) {
-  ROAR_DBG("roar_ctl_m2c(*): wrong version!");
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- if ( m->datalen < 3 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
+ if ( m->datalen < 3 )
+  return -1;
 
  ROAR_DBG("roar_ctl_m2c(*): have usable data!");
 
- c->execed = d[1];
+ c->execed = m->data[1];
 
  for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++)
   c->streams[i] = -1;
 
- if ( d[2] < 0 || d[2] > ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT ) {
-  roar_err_set(ROAR_ERROR_TOOMANYARGS);
-  return -1;
- }
-
- for (i = 0; i < d[2]; i++)
-  c->streams[i] = d[3+i];
-
- cur = 3 + d[2];
-
- // check length here!
- strncpy(c->name, d+cur+1, d[cur] > (sizeof(c->name)-1) ? sizeof(c->name)-1 : d[cur]);
- c->name[(size_t)d[cur] > (sizeof(c->name)-1) ? sizeof(c->name)-1 : (size_t)d[cur]] = 0;
-
- cur += d[cur] + 1;
-
- memcpy(&pid, &(d[cur]), 4);
- c->pid = ROAR_NET2HOST32(pid);
- cur += 4;
-
- memcpy(&pid, &(d[cur]), 4);
- c->uid = ROAR_NET2HOST32(pid);
- cur += 4;
-
- memcpy(&pid, &(d[cur]), 4);
- c->gid = ROAR_NET2HOST32(pid);
- cur += 4;
-
- if ( m->datalen >= cur+4 ) {
-  memcpy(&pid, &(d[cur]), 4);
-  c->proto = ROAR_NET2HOST32(pid);
-  cur += 4;
- } else {
-  c->proto = ROAR_PROTO_NONE;
- }
-
- if ( m->datalen >= cur+4 ) {
-  memcpy(&pid, &(d[cur]), 4);
-  c->byteorder = ROAR_NET2HOST32(pid);
-  cur += 4;
- } else {
-  c->byteorder = ROAR_BYTEORDER_UNKNOWN;
- }
-
- if ( m->datalen > cur ) {
-  len = m->datalen - cur;
-  if ( roar_nnode_from_blob(&(c->nnode), &(d[cur]), &len) == 0 ) {
-   cur += len;
-  } else {
-   if ( roar_nnode_new(&(c->nnode), ROAR_SOCKET_TYPE_UNKNOWN) == -1 )
-    return -1;
-  }
- } else {
-  if ( roar_nnode_new(&(c->nnode), ROAR_SOCKET_TYPE_UNKNOWN) == -1 )
-   return -1;
- }
-
- return 0;
-}
-
-int roar_ctl_c2m      (struct roar_message * m, struct roar_client * c) {
- return roar_ctl_c2m2(m, c, NULL);
-}
-int roar_ctl_m2c      (struct roar_message * m, struct roar_client * c) {
- return roar_ctl_m2c2(m, c, NULL);
-}
-
-static struct {
- int id;
- const char * name;
-} _proto[] = {
- {ROAR_PROTO_NONE,        "none"},
- {ROAR_PROTO_ROARAUDIO,   "RoarAudio"},
- {ROAR_PROTO_ESOUND,      "EsounD"},
- {ROAR_PROTO_ESOUND,      "ESD"}, // alias
- {ROAR_PROTO_AUTO,        "(auto)"},
- {ROAR_PROTO_HTTP,        "http"},
- {ROAR_PROTO_GOPHER,      "gopher"},
- {ROAR_PROTO_ICY,         "ICY"},
- {ROAR_PROTO_SIMPLE,      "Simple"},
- {ROAR_PROTO_RSOUND,      "RSound"},
- {ROAR_PROTO_RPLAY,       "RPlay"},
- {ROAR_PROTO_IRC,         "IRC"},
- {ROAR_PROTO_DCC,         "DCC"},
- {ROAR_PROTO_ECHO,        "Echo"},
- {ROAR_PROTO_DISCARD,     "Discard"},
- {ROAR_PROTO_WHOIS,       "Whois"},
- {ROAR_PROTO_FINGER,      "Finger"},
- {ROAR_PROTO_QUOTE,       "quote"},
- {ROAR_PROTO_DAYTIME,     "daytime"},
- {ROAR_PROTO_GAME,        "game"},
- {ROAR_PROTO_TELNET,      "telnet"},
- {ROAR_PROTO_DHCP,        "dhcp"},
- {ROAR_PROTO_SSH,         "ssh"},
- {ROAR_PROTO_TIME,        "time"},
- {ROAR_PROTO_RLOGIN,      "rlogin"},
- {ROAR_PROTO_RPLD,        "rpld"},
- {ROAR_PROTO_MPD,         "mpd"},
- {ROAR_PROTO_RTP,         "rtp"},
- {ROAR_PROTO_RTCP,        "rtcp"},
- {ROAR_PROTO_RTSP,        "rtsp"},
- {ROAR_PROTO_SIP,         "sip"},
- {ROAR_PROTO_DYNAMIC0,    "dynamic0"},
- {ROAR_PROTO_DYNAMIC1,    "dynamic1"},
- {ROAR_PROTO_DYNAMIC2,    "dynamic2"},
- {ROAR_PROTO_DYNAMIC3,    "dynamic3"},
- {ROAR_PROTO_DYNAMIC4,    "dynamic4"},
- {ROAR_PROTO_DYNAMIC5,    "dynamic5"},
- {ROAR_PROTO_DYNAMIC6,    "dynamic6"},
- {ROAR_PROTO_DYNAMIC7,    "dynamic7"},
- {ROAR_PROTO_DYNAMIC8,    "dynamic8"},
- {ROAR_PROTO_DYNAMIC9,    "dynamic9"},
- {ROAR_PROTO_DYNAMIC10,   "dynamic10"},
- {ROAR_PROTO_DYNAMIC11,   "dynamic11"},
- {ROAR_PROTO_DYNAMIC12,   "dynamic12"},
- {ROAR_PROTO_DYNAMIC13,   "dynamic13"},
- {ROAR_PROTO_DYNAMIC14,   "dynamic14"},
- {ROAR_PROTO_DYNAMIC15,   "dynamic15"},
- {ROAR_PROTO_USER0,       "user0"},
- {ROAR_PROTO_USER1,       "user1"},
- {ROAR_PROTO_USER2,       "user2"},
- {ROAR_PROTO_USER3,       "user3"},
- {ROAR_PROTO_USER4,       "user4"},
- {ROAR_PROTO_USER5,       "user5"},
- {ROAR_PROTO_USER6,       "user6"},
- {ROAR_PROTO_USER7,       "user7"},
- {ROAR_PROTO_USER8,       "user8"},
- {ROAR_PROTO_USER9,       "user9"},
- {ROAR_PROTO_USER10,      "user10"},
- {ROAR_PROTO_USER11,      "user11"},
- {ROAR_PROTO_USER12,      "user12"},
- {ROAR_PROTO_USER13,      "user13"},
- {ROAR_PROTO_USER14,      "user14"},
- {ROAR_PROTO_USER15,      "user15"},
- {-1, NULL}
-};
-
-int    roar_str2proto (const char * proto) {
- size_t i;
-
- for (i = 0; _proto[i].id != -1; i++)
-  if ( !strcasecmp(proto, _proto[i].name) )
-   return _proto[i].id;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char * roar_proto2str (const int    proto) {
- size_t i;
-
- roar_err_set(ROAR_ERROR_NONE);
-
- for (i = 0; _proto[i].id != -1; i++)
-  if ( proto == _proto[i].id )
-   return _proto[i].name;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return "(unknown)";
-}
-
-int    roar_str2byteorder (const char * byteorder) {
- if (        !strcasecmp(byteorder, "le")            || !strcasecmp(byteorder, "little") ||
-             !strcasecmp(byteorder, "little endian") || !strcasecmp(byteorder, "1234")   ) {
-  return ROAR_BYTEORDER_LE;
- } else if ( !strcasecmp(byteorder, "be")            || !strcasecmp(byteorder, "big")    ||
-             !strcasecmp(byteorder, "big endian")    || !strcasecmp(byteorder, "4321")   ) {
-  return ROAR_BYTEORDER_BE;
- } else if ( !strcasecmp(byteorder, "pdp")           ||
-             !strcasecmp(byteorder, "pdp endian") ) {
-  return ROAR_BYTEORDER_PDP;
- } else if ( !strcasecmp(byteorder, "network")       ||
-             !strcasecmp(byteorder, "network byteorder") ) {
-  return ROAR_BYTEORDER_NETWORK;
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char * roar_byteorder2str (const int    byteorder) {
- switch (byteorder) {
-  case ROAR_BYTEORDER_LE:      return "little endian"; break;
-  case ROAR_BYTEORDER_BE:      return "big endian";    break;
-  case ROAR_BYTEORDER_PDP:     return "pdp endian";    break;
-//  case ROAR_BYTEORDER_NETWORK: return "network";       break;
-  default:
-    return "(unknown)";
- }
-}
-
-// grep '^#define ROAR_OT_' roaraudio/proto.h | cut -d' ' -f2 | sed 's/^\(ROAR_OT_\)\(.*\)$/ {\1\2, "\2"},/'
-static struct {
- const int ot;
- const char * name;
-} _libroar_ot[] = {
- {ROAR_OT_CLIENT,   "client"},
- {ROAR_OT_STREAM,   "stream"},
- {ROAR_OT_SOURCE,   "source"},
- {ROAR_OT_SAMPLE,   "sample"},
- {ROAR_OT_OUTPUT,   "output"},
- {ROAR_OT_MIXER,    "mixer"},
- {ROAR_OT_BRIDGE,   "bridge"},
- {ROAR_OT_LISTEN,   "listen"},
- {ROAR_OT_ACTION,   "action"},
- {ROAR_OT_MSGQUEUE, "msgqueue"},
- {ROAR_OT_MSGBUS,   "msgbus"},
- {-1, NULL}
-};
-
-int    roar_str2ot        (const char * ot) {
- int i;
-
- for (i = 0; _libroar_ot[i].ot != -1; i++)
-  if ( !strcasecmp(ot, _libroar_ot[i].name) )
-   return _libroar_ot[i].ot;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char * roar_ot2str  (const int    ot) {
- int i;
-
- for (i = 0; _libroar_ot[i].ot != -1; i++)
-  if ( _libroar_ot[i].ot == ot )
-   return _libroar_ot[i].name;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int roar_conv_volume (struct roar_mixer_settings * dst, struct roar_mixer_settings * src, int dstchans, int srcchans) {
- struct roar_mixer_settings lsrc;
- int i;
- uint_least32_t s;
-
- if ( dst == NULL || src == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( dstchans < 0 || srcchans < 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( dstchans == srcchans ) {
-  if ( dst == src )
-   return 0;
-
-  memcpy(dst, src, sizeof(struct roar_mixer_settings));
-  return 0;
- }
-
- if ( dst == src ) {
-  memcpy(&lsrc, src, sizeof(lsrc));
-  src = &lsrc;
- }
-
- // sepcal handling for N->1:
- if ( dstchans == 1 ) {
-  s = 0;
-
-  for (i = 0; i < srcchans; i++)
-   s += src->mixer[i];
-
-  dst->mixer[0] = s / srcchans;
- } else {
-  switch (srcchans) {
-   case  1:
-     for (i = 0; i < dstchans; i++)
-      dst->mixer[i] = src->mixer[0];
-    break;
-   case 2:
-     switch (dstchans) {
-      case 3:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = (src->mixer[0] + src->mixer[1]) / 2;
-       break;
-      case 4:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[0];
-        dst->mixer[3] = src->mixer[1];
-       break;
-      case 5:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = (src->mixer[0] + src->mixer[1]) / 2;
-        dst->mixer[3] = src->mixer[0];
-        dst->mixer[4] = src->mixer[1];
-       break;
-      case 6:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = (src->mixer[0] + src->mixer[1]) / 2;
-        dst->mixer[3] = dst->mixer[2];
-        dst->mixer[4] = src->mixer[0];
-        dst->mixer[5] = src->mixer[1];
-       break;
-      default:
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       break;
-     }
-    break;
-   case 3:
-     switch (dstchans) {
-      case 2:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-       break;
-      case 4:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[0];
-        dst->mixer[3] = src->mixer[1];
-       break;
-      case 5:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[2];
-        dst->mixer[3] = src->mixer[0];
-        dst->mixer[4] = src->mixer[1];
-       break;
-      case 6:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[2];
-        dst->mixer[3] = src->mixer[2];
-        dst->mixer[4] = src->mixer[0];
-        dst->mixer[5] = src->mixer[1];
-       break;
-      default:
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       break;
-     }
-    break;
-   case 4:
-     switch (dstchans) {
-      case 2:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[2]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[3]) / 2;
-       break;
-      case 3:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[2]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[3]) / 2;
-        dst->mixer[2] = (dst->mixer[0] + dst->mixer[1]) / 2;
-       break;
-      case 5:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = (src->mixer[0] + src->mixer[2] + src->mixer[1] + src->mixer[3]) / 4;
-        dst->mixer[3] = src->mixer[2];
-        dst->mixer[4] = src->mixer[3];
-       break;
-      case 6:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = (src->mixer[0] + src->mixer[2] + src->mixer[1] + src->mixer[3]) / 4;
-        dst->mixer[3] = dst->mixer[2];
-        dst->mixer[4] = src->mixer[2];
-        dst->mixer[5] = src->mixer[3];
-       break;
-      default:
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       break;
-     }
-    break;
-   case 5:
-     switch (dstchans) {
-      case 2:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[3]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[4]) / 2;
-       break;
-      case 3:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[3]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[4]) / 2;
-        dst->mixer[2] = src->mixer[2];
-       break;
-      case 4:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[3];
-        dst->mixer[3] = src->mixer[4];
-       break;
-      case 6:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[2];
-        dst->mixer[3] = src->mixer[2];
-        dst->mixer[4] = src->mixer[3];
-        dst->mixer[5] = src->mixer[4];
-       break;
-      default:
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       break;
-     }
-    break;
-   case 6:
-     switch (dstchans) {
-      case 2:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[4]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[5]) / 2;
-       break;
-      case 3:
-        dst->mixer[0] = (src->mixer[0] + src->mixer[4]) / 2;
-        dst->mixer[1] = (src->mixer[1] + src->mixer[5]) / 2;
-        dst->mixer[2] = src->mixer[2];
-       break;
-      case 4:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[4];
-        dst->mixer[3] = src->mixer[5];
-       break;
-      case 5:
-        dst->mixer[0] = src->mixer[0];
-        dst->mixer[1] = src->mixer[1];
-        dst->mixer[2] = src->mixer[2];
-        dst->mixer[3] = src->mixer[4];
-        dst->mixer[4] = src->mixer[5];
-       break;
-      default:
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       break;
-     }
-    break;
-   default:
-     roar_err_set(ROAR_ERROR_NOTSUP);
-     return -1;
-    break;
-  }
- }
-
- dst->scale   = src->scale;
- dst->rpg_mul = src->rpg_mul;
- dst->rpg_div = src->rpg_div;
+ for (i = 0; i < m->data[2]; i++)
+  c->streams[i] = m->data[3+i];
+
+ cur = 3 + m->data[2];
+
+ strncpy(c->name, (m->data)+cur+1, m->data[cur]);
+ c->name[m->data[cur]] = 0;
 
  return 0;
Index: libroar/debug.c
===================================================================
--- libroar/debug.c	(revision 6052)
+++ 	(revision )
@@ -1,239 +1,0 @@
-//debug.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static int                     roar_debug_stderr_mode = ROAR_DEBUG_MODE_SYSIO;
-static int                     roar_debug_stderr_fh   = ROAR_STDERR;
-static struct roar_vio_calls * roar_debug_stderr_vio  = NULL;
-
-void roar_debug_warn_sysio_real(char * func, char * newfunc, char * info) {
- struct roar_libroar_config * config = roar_libroar_get_config();
-
- if ( !roar_libroar_iswarn(config) )
-  return;
-
- if ( config->warnings.sysio == ROAR_WARNING_ALWAYS ) {
-  if ( newfunc == NULL ) {
-   ROAR_WARN("%s(*): This function is obsolete. %s", func, info == NULL ? "" : info);
-  } else {
-   ROAR_WARN("%s(*): This function is obsolete. Please use %s(...). %s", func, newfunc, info == NULL ? "" : info);
-  }
- }
-}
-
-void roar_debug_warn_obsolete_real(char * func, char * newfunc, char * info) {
- struct roar_libroar_config * config = roar_libroar_get_config();
-
- if ( !roar_libroar_iswarn(config) )
-  return;
-
- if ( config->warnings.obsolete == ROAR_WARNING_ALWAYS ) {
-  if ( newfunc == NULL ) {
-   ROAR_WARN("%s(*): This function is obsolete. %s", func, info == NULL ? "" : info);
-  } else {
-   ROAR_WARN("%s(*): This function is obsolete. Please use %s(...). %s", func, newfunc, info == NULL ? "" : info);
-  }
- }
-}
-
-void roar_debug_bin_obsolete(const char * progname, const char * newprog, const char * info) {
- if ( info == NULL )
-  info = "";
-
- if ( newprog == NULL ) {
-  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, 0, progname, ROAR_DBG_PREFIX, "This program is obsolete and will be removed soon. %s", info);
- } else {
-  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, 0, progname, ROAR_DBG_PREFIX, "This program is obsolete and will be removed soon. Please use %s. %s", newprog, info);
- }
-}
-
-void roar_debug_option_obsolete(const char * progname, const char * option, const char * newopt, const char * info) {
- if ( info == NULL )
-  info = "";
-
- if ( newopt == NULL ) {
-  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, 0, progname, ROAR_DBG_PREFIX, "The option \"%s\" is obsolete and will be removed soon. %s", option, info);
- } else {
-  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, 0, progname, ROAR_DBG_PREFIX, "The option \"%s\" is obsolete and will be removed soon. Please use \"%s\". %s", option, newopt, info);
- }
-}
-
-void   roar_debug_set_stderr_fh(int fh) {
- roar_debug_stderr_fh = fh;
-}
-
-void   roar_debug_set_stderr_vio(struct roar_vio_calls * vio) {
- roar_debug_stderr_vio = vio;
-}
-
-void   roar_debug_set_stderr_mode(int mode) {
- roar_debug_stderr_mode = mode;
-}
-
-struct roar_vio_calls * roar_debug_get_stderr(void) {
- static struct roar_vio_calls STDERR;
-
- switch (roar_debug_stderr_mode) {
-  case ROAR_DEBUG_MODE_SYSIO:
-    if ( roar_debug_stderr_fh == -1 )
-     return NULL;
-
-    roar_vio_open_fh(&STDERR, roar_debug_stderr_fh);
-
-    return &STDERR;
-   break;
-  case ROAR_DEBUG_MODE_VIO:
-    return roar_debug_stderr_vio;
-   break;
-  default:
-    return NULL;
-   break;
- }
-}
-
-// NOTE: This function MUST NOT alter RA's error values nor errno!
-void roar_debug_msg_simple(const char *format, ...) {
- struct roar_vio_calls * vio;
- va_list ap;
- int ret;
- char buf[8192];
-#ifdef ROAR_HAVE_SYSLOG
- size_t len;
-#endif
- int _ra_error  = roar_error;
- int _sys_error = errno;
-
- vio = roar_debug_get_stderr();
-
- va_start(ap, format);
- ret = vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
-
- buf[sizeof(buf)-1] = 0;
-
- if ( vio != NULL ) {
-  _LIBROAR_IGNORE_RET(roar_vio_write(vio, buf, ret));
-  roar_vio_sync(vio);
- } else {
-  switch (roar_debug_stderr_mode) {
-#ifdef ROAR_HAVE_SYSLOG
-   case ROAR_DEBUG_MODE_SYSLOG:
-     // strip \n if needed for syslog:
-     len = strlen(buf);
-     if ( buf[len-1] == '\n' )
-      buf[len-1] = 0;
-
-     syslog(LOG_ERR, "%s", buf); // bad to use some defaults
-    break;
-#endif
-   default:
-     // do nothing.
-    break;
-  }
- }
-
- roar_error = _ra_error;
- errno      = _sys_error;
-}
-
-void roar_debug_msg(int type, unsigned long int line, const char * file, const char * prefix, const char * format, ...) {
- struct roar_vio_calls * vio;
- va_list ap;
- char    buf[8192];
- char  * bufp = buf;
- char  * typename;
- int     ret;
-#ifdef ROAR_HAVE_SYSLOG
- int     priority;
-#endif
- size_t  len;
- struct roar_error_state error_state;
-
- roar_err_store(&error_state);
-
- switch (type) {
-  case ROAR_DEBUG_TYPE_ERROR:   typename = "Error";   break;
-  case ROAR_DEBUG_TYPE_WARNING: typename = "Warning"; break;
-  case ROAR_DEBUG_TYPE_INFO:    typename = "Info";    break;
-  case ROAR_DEBUG_TYPE_DEBUG:   typename = "Debug";   break;
-  default: typename = "Unknown Type"; break;
- }
-
- ret = snprintf(buf, sizeof(buf), "(%s: %s:%lu): %s: ", prefix, file, line, typename);
-
- if ( ret > 0 && ret < (int)sizeof(buf) ) {
-  bufp += ret;
- } else {
-  ret = 0;
- }
-
- len = ret;
-
- va_start(ap, format);
- ret = vsnprintf(bufp, sizeof(buf)-ret, format, ap);
- va_end(ap);
-
- buf[sizeof(buf)-1] = 0;
-
- len += ret;
-
- switch (roar_debug_stderr_mode) {
-  case ROAR_DEBUG_MODE_SYSIO:
-  case ROAR_DEBUG_MODE_VIO:
-    if ( (vio = roar_debug_get_stderr()) == NULL ) {
-      roar_err_restore(&error_state);
-     return;
-    }
-    _LIBROAR_IGNORE_RET(roar_vio_write(vio, buf, len));
-    _LIBROAR_IGNORE_RET(roar_vio_write(vio, "\n", 1));
-    roar_vio_sync(vio);
-   break;
-#ifdef ROAR_HAVE_SYSLOG
-  case ROAR_DEBUG_MODE_SYSLOG:
-    switch (type) {
-     case ROAR_DEBUG_TYPE_ERROR:   priority = LOG_ERR;     break;
-     case ROAR_DEBUG_TYPE_WARNING: priority = LOG_WARNING; break;
-     case ROAR_DEBUG_TYPE_INFO:    priority = LOG_INFO;    break;
-     case ROAR_DEBUG_TYPE_DEBUG:   priority = LOG_DEBUG;   break;
-     default: priority = LOG_ERR; break;
-    }
-    syslog(priority, "%s", buf);
-   break;
-#endif
- }
- roar_err_restore(&error_state);
-}
-//ll
Index: libroar/empty.c
===================================================================
--- libroar/empty.c	(revision 6052)
+++ libroar/empty.c	(revision 0)
@@ -1,36 +1,3 @@
 //*.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2013-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroar.h"
Index: libroar/enumdev.c
===================================================================
--- libroar/enumdev.c	(revision 6052)
+++ 	(revision )
@@ -1,412 +1,0 @@
-//enumdev.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-// TODO: we should put all the data in one big alloced block.
-
-static int _test_server(struct roar_server * c, int flags) {
- struct roar_connection con;
- struct roar_server_info * info;
- int checked = 0;
-
- if ( c->server == NULL )
-  return -1;
-
- if ( flags & ROAR_ENUM_FLAG_NONBLOCK )
-  return 0;
-
- ROAR_DBG("_test_server(c=%p{.server='%s', ...}, flags=0x%.4X) = ?", c, c->server, flags);
-
- roar_libroar_nowarn();
- if ( roar_connect(&con, c->server, 0, 0) == -1 ) {
-  roar_libroar_warn();
-  return -1;
- }
- roar_libroar_warn();
-
- ROAR_DBG("_test_server(c=%p{.server='%s', ...}, flags=0x%.4X) = ?", c, c->server, flags);
-
- if ( (flags & ROAR_ENUM_FLAG_DESC) || (flags & ROAR_ENUM_FLAG_LOCATION) ) {
-  info = roar_server_info(&con);
-  if ( info != NULL ) {
-   checked = 1;
-   if ( info->location != NULL )
-    c->location = roar_mm_strdup(info->location);
-
-   if ( info->description != NULL )
-    c->description = roar_mm_strdup(info->description);
-
-   roar_server_info_free(info);
-  }
- }
-
- ROAR_DBG("_test_server(c=%p{.server='%s', ...}, flags=0x%.4X) = ?", c, c->server, flags);
-
- // make sure we get at least a NOOP from the server to detect protocol mismatch.
- if ( !checked ) {
-  if ( roar_noop(&con) != 0 ) {
-   roar_disconnect(&con);
-   return -1;
-  }
- }
-
- roar_disconnect(&con);
-
- ROAR_DBG("_test_server(c=%p{.server='%s', ...}, flags=0x%.4X) = 0", c, c->server, flags);
- return 0;
-}
-
-#define _add(x) if ( (x) != NULL ) servers[ret++] = roar_mm_strdup((x))
-static ssize_t _esl_defaults(int flags, int dir, int socktype, char ** servers, size_t maxlen) {
-#ifdef ROAR_HAVE_LIBX11
- struct roar_x11_connection * x11con;
-#endif
- ssize_t ret = 0;
- const char * new;
- char buf[1024];
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
- int i;
-#endif
- char * ssh_buf, * tmp;
-
- (void)flags, (void)dir, (void)socktype;
-
- if ( maxlen < 12 )
-  return -1;
-
- // We can not yet test if those servers are local or reachable via network so
- // we skip them for now.
- // TODO: test those servers.
- if ( !(flags & ROAR_ENUM_FLAG_LOCALONLY) ) {
-  new = roar_libroar_get_server();
-  _add(new);
-
-  new = roar_env_get("ROAR_SERVER");
-  _add(new);
-
-#ifdef ROAR_HAVE_LIBX11
-  if ( (x11con = roar_x11_connect(NULL)) != NULL ) {
-   new = roar_x11_get_prop(x11con, "ROAR_SERVER");
-   _add(new);
-   roar_x11_disconnect(x11con);
-  }
-#endif
-
-  new = roar_env_get("SSH_CLIENT");
-  if ( new == NULL )
-   new = roar_env_get("SSH_CONNECTION");
-
-  if ( new != NULL ) {
-   ssh_buf = roar_mm_strdup(new);
-   if ( ssh_buf != NULL ) {
-    tmp = strstr(ssh_buf, " ");
-    if ( tmp == NULL ) {
-     // invalid format.
-     roar_mm_free(ssh_buf);
-    } else {
-     *tmp = 0;
-     servers[ret++] = ssh_buf;
-    }
-   }
-  }
-
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
-  tmp = roar_libroar_get_path("sysconf-roarserver", 0, NULL, NULL);
-  if ( tmp != NULL ) {
-   if ( (i = readlink(tmp, buf, sizeof(buf)-1)) != -1 ) {
-     buf[i] = 0;
-     _add(buf);
-   }
-   roar_mm_free(tmp);
-  }
-#endif
- }
-
- if ( (new = roar_env_get_home(0)) != NULL ) {
-  snprintf(buf, sizeof(buf)-1, "%s/%s", new, ROAR_DEFAULT_SOCK_USER);
-  buf[sizeof(buf)-1] = 0;
-  _add(buf);
- }
-
- servers[ret++] = roar_mm_strdup(ROAR_DEFAULT_SOCK_GLOBAL);
- servers[ret++] = roar_mm_strdup(ROAR_DEFAULT_HOST);
- servers[ret++] = roar_mm_strdup("::" ROAR_DEFAULT_OBJECT);
- servers[ret++] = roar_mm_strdup("+abstract");
- servers[ret++] = roar_mm_strdup("/tmp/muroard");
- servers[ret++] = roar_mm_strdup("/dev/roar");
-
- return ret;
-}
-
-static ssize_t _esl_slp(int flags, int dir, int socktype, char ** servers, size_t maxlen) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_slp_cookie cookie;
- int offset;
- char * url;
- size_t i;
- ssize_t ret = 0;
-
- if ( config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_NO_SLP )
-  return 0;
-
- if ( roar_slp_cookie_init(&cookie, NULL) == -1 )
-  return -1;
-
- if ( roar_slp_search(&cookie, ROAR_SLP_URL_TYPE) == -1 )
-  return -1;
-
- if ( cookie.matchcount == 0 )
-  return -1;
-
- ROAR_DBG("_esl_slp(*): cookie.matchcount=%i", (int)cookie.matchcount);
-
- for (i = 0; i < (size_t)cookie.matchcount && (ssize_t)maxlen > ret; i++) {
-  url = cookie.match[i].url;
-  ROAR_DBG("_esl_slp(*): cookie.match[%i].url='%s'", (int)i, url);
-
-  offset = 0;
-
-  if ( !strncmp(url, ROAR_SLP_URL_TYPE "://", ROAR_SLP_URL_TYPE_LEN + 3) )
-   offset = ROAR_SLP_URL_TYPE_LEN + 3;
-
-  ROAR_DBG("_esl_slp(*): url=%p, offset=%i", url, offset);
-  url = &(url[offset]);
-  ROAR_DBG("_esl_slp(*): url='%s'", url);
-
-  if ( *url == 0 )
-   continue;
-
-  _add(url);
- }
-
- return ret;
-}
-
-#ifdef ROAR_HAVE_FOPEN
-static ssize_t _esl_neighbours(int flags, int dir, int socktype, char ** servers, size_t maxlen) {
- ssize_t ret = 0;
- char buf[1024];
- FILE * inp;
- size_t i;
- char * delm;
- const struct {
-  const char * file;
-  const char * suffix;
-  const size_t skip;
- } *f, files[] = {
-#ifdef ROAR_PROC_NET_DECNET_NEIGH
-  {ROAR_PROC_NET_DECNET_NEIGH, "::", 1},
-#endif
-#ifdef ROAR_PROC_NET_ARP
-  {ROAR_PROC_NET_ARP, NULL, 1},
-#endif
-//  {roar_libroar_get_path_static("sysconf-hosts"), NULL, 0},
-  {NULL, NULL, 0}
- };
-
- (void)flags, (void)dir, (void)socktype;
-
- for (f = &(files[0]); f->file != NULL; f++) {
-  if ( (inp = fopen(f->file, "r")) == NULL )
-   continue;
-
-  for (i = 0; i < f->skip; i++) {
-   if ( fgets(buf, sizeof(buf), inp) == NULL ) {
-    // bad error...
-    fclose(inp);
-    return ret;
-   }
-  }
-
-  while (ret < (ssize_t)maxlen && fgets(buf, sizeof(buf), inp) != NULL) {
-   // skip comments and empty lions
-   if ( buf[0] == '#' || buf[0] == '\0' )
-    continue;
-
-   // ensure we have a tailing \0.
-   buf[sizeof(buf)-1] = 0;
-
-   delm = strstr(buf, " ");
-   if ( delm == NULL )
-    delm = strstr(buf, "\t");
-
-   // does it look like a correctly formated lion?
-   // we may remove this check or relax it later.
-   if ( delm == NULL )
-    continue;
-
-   *delm = 0;
-
-   if ( f->suffix != NULL ) {
-    if ( (roar_mm_strlen(buf) + roar_mm_strlen(f->suffix) + 1) > sizeof(buf) )
-     continue;
-
-    roar_mm_strscat(buf, f->suffix);
-   }
-
-   // work around a bug in Linux kernel which always reports node 0.2 to be up.
-   if ( !strcmp(buf, "0.2::") )
-    continue;
-
-   _add(buf);
-  }
-
-  fclose(inp);
-  if ( ret == (ssize_t)maxlen )
-   break;
- }
-
- return ret;
-}
-#endif
-
-struct locmed {
- int supflags;
- ssize_t (*func)(int flags, int dir, int socktype, char ** servers, size_t maxlen);
-};
-
-static struct locmed _libroar_locmod[] = {
- {ROAR_ENUM_FLAG_NONBLOCK|ROAR_ENUM_FLAG_HARDNONBLOCK|ROAR_ENUM_FLAG_LOCALONLY, _esl_defaults},
- {ROAR_ENUM_FLAG_NONE,                                                          _esl_slp},
-#ifdef ROAR_HAVE_FOPEN
- {ROAR_ENUM_FLAG_NONBLOCK,                                                      _esl_neighbours}
-#endif
-};
-
-struct roar_server * roar_enum_servers(int flags, int dir, int socktype) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_server * ret = NULL;
- struct roar_server * c;
- char * servers[64];
- size_t have = 1;
- size_t i, cp, unic;
- ssize_t r;
- int testflags;
- int is_uniq;
-
- flags     |= config->serverflags;
- testflags  = flags;
-
- if ( flags & ROAR_ENUM_FLAG_HARDNONBLOCK )
-  flags |= ROAR_ENUM_FLAG_NONBLOCK;
-
- if ( testflags & ROAR_ENUM_FLAG_DESC )
-  testflags -= ROAR_ENUM_FLAG_DESC;
- if ( testflags & ROAR_ENUM_FLAG_LOCATION )
-  testflags -= ROAR_ENUM_FLAG_LOCATION;
-
- for (i = 0; i < sizeof(_libroar_locmod)/sizeof(*_libroar_locmod); i++) {
-  if ( (_libroar_locmod[i].supflags & testflags) == testflags ) {
-   r = _libroar_locmod[i].func(flags, dir, socktype, &(servers[have-1]), (sizeof(servers)/sizeof(*servers)) - have);
-   if ( r > 0 )
-    have += r;
-  }
- }
-
- ret = roar_mm_malloc(have*sizeof(struct roar_server));
-
- if (ret == NULL)
-  return NULL;
-
- have--;
-
- for (i = cp = 0; i < have; i++) {
-  c = &(ret[cp]);
-  c->server = servers[i];
-  c->description = NULL;
-  c->location = NULL;
-
-  // uniq test:
-  is_uniq = 1;
-  for (unic = 0; unic < cp; unic++)
-   if ( !strcmp(ret[unic].server, servers[i]) )
-    is_uniq = 0;
-
-  if ( is_uniq && _test_server(c, flags) == 0 ) {
-   cp++;
-  } else {
-   roar_mm_free(servers[i]);
-  }
- }
-
- ret[cp].server = NULL;
- ret[cp].description = roar_mm_strdup("Default server");
- ret[cp].location = NULL;
-
- return ret;
-}
-
-int roar_enum_servers_free(struct roar_server * servs) {
- struct roar_server * c;
- int i;
-
- if ( servs == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; (c = &(servs[i]))->server != NULL; i++) {
-  roar_mm_free((void*)c->server);
-  if ( c->description != NULL )
-   roar_mm_free((void*)c->description);
-  if ( c->location != NULL )
-   roar_mm_free((void*)c->location);
- }
-
- if ( c->description != NULL )
-  roar_mm_free((void*)c->description);
- if ( c->location != NULL )
-  roar_mm_free((void*)c->location);
-
- roar_mm_free(servs);
-
- return 0;
-}
-
-ssize_t roar_enum_servers_num(struct roar_server * servs) {
- size_t ret;
-
- if ( servs == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (ret = 0; servs[ret].server != NULL; ret++);
-
- return ret;
-}
-
-//ll
Index: libroar/env.c
===================================================================
--- libroar/env.c	(revision 6052)
+++ 	(revision )
@@ -1,230 +1,0 @@
-//env.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_env_set(struct roar_keyval * keyval) {
-#if defined(ROAR_HAVE_PUTENV) && !defined(ROAR_HAVE_SETENV)
- size_t len;
- char * str;
-#endif
-
- if ( keyval == NULL || keyval->key == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
-#ifdef ROAR_HAVE_SETENV
- return setenv(keyval->key, keyval->value, 1);
-#elif defined(ROAR_HAVE_PUTENV)
- len = strlen(keyval->key) + strlen(keyval->value) + 2;
-
- // TODO: does this leak memory?
- if ( (str = malloc(len)) == NULL ) {
-  return -1;
- }
-
- snprintf(str, len, "%s=%s", keyval->key, keyval->value);
-
- return putenv(str) == 0 ? 0 : -1;
-#else
- roar_strap(ROAR_TRAP_GROUP_LIBROAR, "env_set.not-implemented");
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-const char * roar_env_get(const char * key) {
- const char * ret;
-
- if ( key == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- roar_err_clear_all();
- ret = getenv(key);
- roar_err_update();
-
- if ( ret == NULL && roar_error == ROAR_ERROR_NONE )
-  roar_err_set(ROAR_ERROR_NOENT);
-
- return ret;
-}
-
-const char * roar_env_get_home(int level) {
- const char * home = roar_env_get("HOME");
-
- (void)level;
-
- return home;
-}
-
-int roar_env_get_home_r(int level, char * str, size_t len) {
- size_t homelen;
- const char * home;
-
- if ( len == 0 )
-  return 0;
-
- if ( str == NULL )
-  return -1;
-
- *str = 0; // write a single termination byte to be safe...
-
- home = roar_env_get_home(level);
-
- if ( home == NULL )
-  return -1;
-
- homelen = strlen(home);
-
- if ( (len - 1) < homelen )
-  return -1;
-
- strncpy(str, home, len);
- str[homelen] = 0;
-
- return 0;
-}
-
-static char * __get_path(const char ** inpath) {
- char buf_path[64];
- size_t i;
-
- (*inpath)++;
-
- for (i = 0; i < sizeof(buf_path); i++) {
-  if ( (*inpath)[i] == '/' || (*inpath)[i] == 0 ) {
-   break;
-  } else {
-   buf_path[i] = (*inpath)[i];
-  }
- }
-
- if ( i == sizeof(buf_path) ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return NULL;
- }
-
- buf_path[i] = 0;
-
- (*inpath) += i;
-
- return roar_libroar_get_path(buf_path, 0, NULL, NULL);
-}
-
-int roar_env_render_path_r(char * out, size_t len, const char * inpath) {
- size_t inlen;
- size_t needlen = 0;
- size_t homelen = 0;
- const char * home;
- const char * prefix = NULL;
- char * prefix_path = NULL;
- enum { UNKNOWN, COPY, HOME, PREFIX } mode = UNKNOWN;
-
- if ( len == 0 && inpath == NULL )
-  return 0;
-
- if ( inpath == NULL )
-  return -1;
-
- inlen = strlen(inpath);
-
- if ( len == 0 && inlen == 0 )
-  return 0;
-
- if ( len == 0 )
-  return -1;
-
- if ( out == NULL )
-  return -1;
-
- home = roar_env_get_home(0);
-
- if ( home != NULL )
-  homelen = strlen(home);
-
- if ( inpath[0] == '/' ) {
-  needlen = inlen;
-  mode    = COPY;
- } else if ( inpath[0] == '~' && inpath[1] == '/' ) {
-  if ( homelen == 0 ) /* we don't know our $HOME */
-   return -1;
-
-  needlen = inlen + homelen - 1;
-  mode    = HOME;
-  prefix  = home;
-  inpath++;
- } else if ( inpath[0] == '$' ) {
-  prefix_path = __get_path(&inpath);
-  if ( prefix_path == NULL )
-   return -1;
-  needlen = roar_mm_strlen(inpath) + roar_mm_strlen(prefix_path) + 1;
-  mode    = PREFIX;
-  prefix  = prefix_path;
- }
-
- if ( len < (needlen + 1) ) {
-  if ( prefix_path != NULL )
-   roar_mm_free(prefix_path);
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- switch (mode) {
-  case COPY:
-    strncpy(out, inpath, len);
-    out[len-1] = 0;
-   break;
-  case HOME:
-  case PREFIX:
-    roar_mm_strlcpy(out, prefix, len);
-    roar_mm_strlcat(out, inpath, len); // strip only ~, so we have the / if home is not /-terminated.
-   break;
-  default:
-    if ( prefix_path != NULL )
-     roar_mm_free(prefix_path);
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- if ( prefix_path != NULL )
-  roar_mm_free(prefix_path);
- return 0;
-}
-
-//ll
Index: libroar/error.c
===================================================================
--- libroar/error.c	(revision 6052)
+++ 	(revision )
@@ -1,1509 +1,0 @@
-//error.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-// 'no error' value for errno.
-// zero is true for GNU/Linux.
-// don't know about other systems.
-// IEEE Std 1003.1-2008 (POSIX 7) requires:
-// 'distinct positive values'.
-#define CLEAN_ERRNO 0
-
-static int roar_errno = ROAR_ERROR_NONE;
-
-struct roar_error_frame * roar_err_errorframe(void) {
- static struct roar_error_frame frame = {
-  .version     =  0,
-  .cmd         = -1,
-  .ra_errno    = ROAR_ERROR_UNKNOWN,
-  .ra_suberrno = -1,
-  .p_errno     = -1,
-  .flags       =  0,
-  .datalen     =  0,
-  .data        = NULL
- };
-
- return &frame;
-}
-
-int    roar_err_init(struct roar_error_frame * frame) {
- if ( frame == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(frame, 0, sizeof(struct roar_error_frame));
-
- frame->cmd         = -1;
- frame->ra_errno    = ROAR_ERROR_UNKNOWN;
- frame->ra_suberrno = -1;
- frame->p_errno     = -1;
- frame->datalen     =  0;
- frame->data        = NULL;
-
- return 0;
-}
-
-
-void * roar_err_buildmsg(struct roar_message * mes, void ** data, struct roar_error_frame * frame) {
- char * databuf = NULL;
- int16_t * d;
- size_t datalen;
-
- if ( mes == NULL || frame == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( data != NULL )
-  *data = NULL;
-
- datalen = 8 + frame->datalen;
- if ( datalen > LIBROAR_BUFFER_MSGDATA ) {
-  if ( data == NULL ) {
-   roar_err_set(ROAR_ERROR_FAULT);
-   return NULL;
-  }
-
-  roar_err_clear_errno();
-  *data = roar_mm_malloc(datalen);
-  roar_err_from_errno();
-  if ( *data == NULL )
-   return NULL;
-
-  databuf = *data;
- } else {
-  databuf = mes->data;
- }
-
- memset(mes,  0, sizeof(struct roar_message));
- memset(databuf, 0, mes->datalen);
-
- mes->datalen = datalen;
-
- d = (int16_t*)databuf;
-
- frame->data  = &(databuf[8]);
-
- databuf[0]    = 0; // version.
- databuf[1]    = frame->cmd;
- databuf[2]    = frame->ra_errno;
- databuf[3]    = frame->ra_suberrno;
- d[2]            = ROAR_HOST2NET16(frame->p_errno);
- d[3]            = ROAR_HOST2NET16(frame->flags);
-
- return frame->data;
-}
-
-int    roar_err_parsemsg(struct roar_message * mes, void *  data, struct roar_error_frame * frame) {
- char * databuf = (char *)data;
- int16_t * d;
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?",
-          mes, (int)mes->datalen, mes->data, data, frame);
-
- if ( mes == NULL || frame == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=FAULT",
-           mes, (int)mes->datalen, mes->data, data, frame);
-  return -1;
- }
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?",
-          mes, (int)mes->datalen, mes->data, data, frame);
-
- if ( databuf == NULL )
-  databuf = mes->data;
-
- d = (int16_t*)databuf;
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?",
-          mes, (int)mes->datalen, mes->data, data, frame);
-
- if ( mes->datalen < 8 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=MSGSIZE",
-           mes, (int)mes->datalen, mes->data, data, frame);
-  return -1;
- }
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?",
-          mes, (int)mes->datalen, mes->data, data, frame);
-
- if ( databuf[0] != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=NSVERSION",
-           mes, (int)mes->datalen, mes->data, data, frame);
-  return -1;
- }
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?",
-          mes, (int)mes->datalen, mes->data, data, frame);
-
- frame->cmd         = databuf[1];
- frame->ra_errno    = databuf[2];
- frame->ra_suberrno = databuf[3];
- frame->p_errno     = ROAR_NET2HOST16(d[2]);
- frame->flags       = ROAR_NET2HOST16(d[3]);
-
- frame->datalen     = mes->datalen - 8;
- frame->data        = &(databuf[8]);
-
- ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = 0",
-          mes, (int)mes->datalen, mes->data, data, frame);
- return 0;
-}
-
-#define roar_errno2_impl (&roar_errno)
-int *  roar_errno2(void) {
- return roar_errno2_impl;
-}
-
-void   roar_err_clear(void) {
- *roar_errno2_impl = ROAR_ERROR_NONE;
-}
-
-void   roar_err_clear_errno(void) {
- errno = CLEAN_ERRNO;
-}
-
-void   roar_err_clear_all(void) {
- roar_err_clear();
- roar_err_clear_errno();
-}
-
-void   roar_err_update(void) {
- int * err = roar_errno2_impl;
-
- // NOTE: _NEVER_ call ROAR_{DBG,INFO,WARN,ERR}() in here! (will result in endless loop)
- //printf("*err=%i, errno=%i\n", *err, (int)errno);
-
- if ( *err != ROAR_ERROR_NONE ) {
-  roar_err_to_errno();
- } else if ( !roar_err_is_errno_clear() ) {
-  roar_err_from_errno();
-#ifdef ROAR_TARGET_WIN32
- } else {
-  roar_err_convert(err, ROAR_ERROR_TYPE_ROARAUDIO, WSAGetLastError(), ROAR_ERROR_TYPE_WINSOCK);
-  roar_err_to_errno();
-#endif
- }
-}
-
-int    roar_err_is_errno_clear(void) {
- return errno == CLEAN_ERRNO ? 1 : 0;
-}
-
-void   roar_err_set(const int error) {
- *roar_errno2_impl = error;
-}
-
-static int   __errno_to_roar(int error) {
- int _roar_errno = ROAR_ERROR_NONE;
-
- switch (error) {
-#ifdef EACCES
-  case EACCES:       _roar_errno = ROAR_ERROR_PERM; break;
-#endif
-#ifdef EPERM
-  case EPERM:        _roar_errno = ROAR_ERROR_PERM; break;
-#endif
-#ifdef ENOENT
-  case ENOENT:       _roar_errno = ROAR_ERROR_NOENT; break;
-#endif
-#ifdef EBADMSG
-  case EBADMSG:      _roar_errno = ROAR_ERROR_BADMSG; break;
-#endif
-#ifdef EBUSY
-  case EBUSY:        _roar_errno = ROAR_ERROR_BUSY; break;
-#endif
-#ifdef ECONNREFUSED
-  case ECONNREFUSED: _roar_errno = ROAR_ERROR_CONNREFUSED; break;
-#endif
-#ifdef ENOSYS
-  case ENOSYS:       _roar_errno = ROAR_ERROR_NOSYS; break;
-#endif
-#ifdef ENOTSUP
-  case ENOTSUP:      _roar_errno = ROAR_ERROR_NOTSUP; break;
-#endif
-#ifdef EPIPE
-  case EPIPE:        _roar_errno = ROAR_ERROR_PIPE; break;
-#endif
-#ifdef EPROTO
-  case EPROTO:       _roar_errno = ROAR_ERROR_PROTO; break;
-#endif
-#ifdef ERANGE
-  case ERANGE:       _roar_errno = ROAR_ERROR_RANGE; break;
-#endif
-#ifdef EMSGSIZE
-  case EMSGSIZE:     _roar_errno = ROAR_ERROR_MSGSIZE; break;
-#endif
-#ifdef ENOMEM
-  case ENOMEM:       _roar_errno = ROAR_ERROR_NOMEM; break;
-#endif
-#ifdef EINVAL
-  case EINVAL:       _roar_errno = ROAR_ERROR_INVAL; break;
-#endif
-#ifdef EALREADY
-  case EALREADY:     _roar_errno = ROAR_ERROR_ALREADY; break;
-#endif
-#ifdef EBADRQC
-  case EBADRQC:      _roar_errno = ROAR_ERROR_BADRQC; break;
-#endif
-#ifdef EDOM
-  case EDOM:         _roar_errno = ROAR_ERROR_DOM; break;
-#endif
-#ifdef EEXIST
-  case EEXIST:       _roar_errno = ROAR_ERROR_EXIST; break;
-#endif
-#ifdef EFAULT
-  case EFAULT:       _roar_errno = ROAR_ERROR_FAULT; break;
-#endif
-#ifdef EIO
-  case EIO:          _roar_errno = ROAR_ERROR_IO; break;
-#endif
-#ifdef EREMOTEIO
-  case EREMOTEIO:    _roar_errno = ROAR_ERROR_RIO; break;
-#endif
-#ifdef EKEYEXPIRED
-  case EKEYEXPIRED:  _roar_errno = ROAR_ERROR_KEYEXPIRED; break;
-#endif
-#ifdef EKEYREJECTED
-  case EKEYREJECTED: _roar_errno = ROAR_ERROR_KEYREJECTED; break;
-#endif
-#ifdef ELOOP
-  case ELOOP:        _roar_errno = ROAR_ERROR_LOOP; break;
-#endif
-#ifdef EMFILE
-  case EMFILE:       _roar_errno = ROAR_ERROR_MFILE; break;
-#endif
-#ifdef ENAMETOOLONG
-  case ENAMETOOLONG: _roar_errno = ROAR_ERROR_NAMETOOLONG; break;
-#endif
-#ifdef ENODATA
-  case ENODATA:      _roar_errno = ROAR_ERROR_NODATA; break;
-#endif
-#ifdef ENODEV
-  case ENODEV:       _roar_errno = ROAR_ERROR_NODEV; break;
-#endif
-#ifdef ENOSPC
-  case ENOSPC:       _roar_errno = ROAR_ERROR_NOSPC; break;
-#endif
-#ifdef ENOTCONN
-  case ENOTCONN:     _roar_errno = ROAR_ERROR_NOTCONN; break;
-#endif
-#ifdef EPROTONOSUPPORT
-  case EPROTONOSUPPORT: _roar_errno = ROAR_ERROR_PROTONOSUP; break;
-#endif
-#ifdef EROFS
-  case EROFS:        _roar_errno = ROAR_ERROR_RO; break;
-#endif
-#ifdef ETIMEDOUT
-  case ETIMEDOUT:    _roar_errno = ROAR_ERROR_TIMEDOUT; break;
-#endif
-#ifdef EAGAIN
-  case EAGAIN:       _roar_errno = ROAR_ERROR_AGAIN; break;
-#endif
-#ifdef ENETDOWN
-  case ENETDOWN:     _roar_errno = ROAR_ERROR_LINKDOWN; break;
-#endif
-#ifdef EINTR
-  case EINTR:        _roar_errno = ROAR_ERROR_INTERRUPTED; break;
-#endif
-#ifdef EDQUOT
-  case EDQUOT:       _roar_errno = ROAR_ERROR_QUOTA; break;
-#endif
-#ifdef ELIBBAD
-  case ELIBBAD:      _roar_errno = ROAR_ERROR_BADLIB; break;
-#endif
-#ifdef ENOMEDIUM
-  case ENOMEDIUM:    _roar_errno = ROAR_ERROR_NOMEDIUM; break;
-#endif
-#ifdef ENOTUNIQ
-  case ENOTUNIQ:     _roar_errno = ROAR_ERROR_NOTUNIQ; break;
-#endif
-#ifdef EILSEQ
-  case EILSEQ:       _roar_errno = ROAR_ERROR_ILLSEQ; break;
-#endif
-#ifdef EADDRINUSE
-  case EADDRINUSE:   _roar_errno = ROAR_ERROR_ADDRINUSE; break;
-#endif
-#ifdef ESPIPE
-  case ESPIPE:       _roar_errno = ROAR_ERROR_BADSEEK; break;
-#endif
-#ifdef ECHERNOBYL
-  case ECHERNOBYL:   _roar_errno = ROAR_ERROR_CHERNOBYL; break;
-#endif
-#ifdef ECRAY
-  case ECRAY:        _roar_errno = ROAR_ERROR_CAUSALITY; break;
-#endif
-#ifdef ENOHORSE
-  case ENOHORSE:     _roar_errno = ROAR_ERROR_NOHORSE; break;
-#endif
-#ifdef ETXTBSY
-  case ETXTBSY:      _roar_errno = ROAR_ERROR_TEXTBUSY; break;
-#endif
-#ifdef ENOTEMPTY
-  case ENOTEMPTY:    _roar_errno = ROAR_ERROR_NOTEMPTY; break;
-#endif
-#ifdef EHOSTUNREACH
-  case EHOSTUNREACH: _roar_errno = ROAR_ERROR_NODEUNREACH; break;
-#endif
-#ifdef EIDRM
-  case EIDRM:        _roar_errno = ROAR_ERROR_IDREMOVED; break;
-#endif
-#ifdef EINPROGRESS
-  case EINPROGRESS:  _roar_errno = ROAR_ERROR_INPROGRESS; break;
-#endif
-#ifdef ECHILD
-  case ECHILD:       _roar_errno = ROAR_ERROR_NOCHILD; break;
-#endif
-#ifdef ENETUNREACH
-  case ENETUNREACH:  _roar_errno = ROAR_ERROR_NETUNREACH; break;
-#endif
-#ifdef ECANCELED
-  case ECANCELED:    _roar_errno = ROAR_ERROR_CANCELED; break;
-#endif
-#ifdef EISDIR
-  case EISDIR:       _roar_errno = ROAR_ERROR_ISDIR; break;
-#endif
-#ifdef ENOTDIR
-  case ENOTDIR:      _roar_errno = ROAR_ERROR_NOTDIR; break;
-#endif
-#ifdef ENOEXEC
-  case ENOEXEC:      _roar_errno = ROAR_ERROR_BADEXEC; break;
-#endif
-#ifdef EISCONN
-  case EISCONN:      _roar_errno = ROAR_ERROR_ISCONN; break;
-#endif
-#ifdef EDEADLK
-  case EDEADLK:      _roar_errno = ROAR_ERROR_DEADLOCK; break;
-#endif
-#ifdef ECONNRESET
-  case ECONNRESET:   _roar_errno = ROAR_ERROR_CONNRST; break;
-#endif
-#ifdef EBADF
-  case EBADF:        _roar_errno = ROAR_ERROR_BADFH; break;
-#endif
-#ifdef ENOTSOCK
-  case ENOTSOCK:     _roar_errno = ROAR_ERROR_NOTSOCK; break;
-#endif
-#ifdef E2BIG
-  case E2BIG:        _roar_errno = ROAR_ERROR_TOOMANYARGS; break;
-#endif
-#ifdef EFBIG
-  case EFBIG:        _roar_errno = ROAR_ERROR_TOOLARGE; break;
-#endif
-#ifdef EDESTADDRREQ
-  case EDESTADDRREQ: _roar_errno = ROAR_ERROR_DESTADDRREQ; break;
-#endif
-#ifdef EAFNOSUPPORT
-  case EAFNOSUPPORT: _roar_errno = ROAR_ERROR_AFNOTSUP; break;
-#endif
-#ifdef ENFILE
-  case ENFILE:       _roar_errno = ROAR_ERROR_NFILE; break;
-#endif
-#ifdef ESTALE
-  case ESTALE:       _roar_errno = ROAR_ERROR_STALE; break;
-#endif
-#ifdef EXDEV
-  case EXDEV:        _roar_errno = ROAR_ERROR_XDEVLINK; break;
-#endif
-#ifdef EMLINK
-  case EMLINK:       _roar_errno = ROAR_ERROR_MLINK; break;
-#endif
-#ifdef ENONET
-  case ENONET:       _roar_errno = ROAR_ERROR_NONET; break;
-#endif
-#ifdef ENETRESET
-  case ENETRESET:    _roar_errno = ROAR_ERROR_CONNRSTNET; break;
-#endif
-#ifdef ECONNABORTED
-  case ECONNABORTED: _roar_errno = ROAR_ERROR_CONNABORTED; break;
-#endif
-#ifdef EBADFD
-  case EBADFD: _roar_errno = ROAR_ERROR_BADSTATE; break;
-#endif
-  default:
-    _roar_errno = ROAR_ERROR_UNKNOWN;
-   break;
- }
-
- return _roar_errno;
-}
-
-void   roar_err_from_errno(void) {
- roar_err_set(__errno_to_roar(errno));
-}
-
-static int   __roar_to_errno(int error) {
- switch (error) {
-  case ROAR_ERROR_NONE:
-    return CLEAN_ERRNO;
-   break;
-#ifdef EPERM
-  case ROAR_ERROR_PERM:
-    return EPERM;
-   break;
-#endif
-#ifdef ENOENT
-  case ROAR_ERROR_NOENT:
-    return ENOENT;
-   break;
-#endif
-#ifdef EBADMSG
-  case ROAR_ERROR_BADMSG:
-    return EBADMSG;
-   break;
-#endif
-#ifdef EBUSY
-  case ROAR_ERROR_BUSY:
-    return EBUSY;
-   break;
-#endif
-#ifdef ECONNREFUSED
-  case ROAR_ERROR_CONNREFUSED:
-    return ECONNREFUSED;
-   break;
-#endif
-#ifdef ENOSYS
-  case ROAR_ERROR_NOSYS:
-    return ENOSYS;
-   break;
-#endif
-#ifdef ENOTSUP
-  case ROAR_ERROR_NOTSUP:
-    return ENOTSUP;
-   break;
-#endif
-#ifdef EPIPE
-  case ROAR_ERROR_PIPE:
-    return EPIPE;
-   break;
-#endif
-#ifdef EPROTO
-  case ROAR_ERROR_PROTO:
-    return EPROTO;
-   break;
-#endif
-#ifdef ERANGE
-  case ROAR_ERROR_RANGE:
-    return ERANGE;
-   break;
-#endif
-#ifdef EMSGSIZE
-  case ROAR_ERROR_MSGSIZE:
-    return EMSGSIZE;
-   break;
-#endif
-#ifdef ENOMEM
-  case ROAR_ERROR_NOMEM:
-    return ENOMEM;
-   break;
-#endif
-#ifdef EINVAL
-  case ROAR_ERROR_INVAL:
-    return EINVAL;
-   break;
-#endif
-#ifdef EALREADY
-  case ROAR_ERROR_ALREADY:
-    return EALREADY;
-   break;
-#endif
-#ifdef EBADRQC
-  case ROAR_ERROR_BADRQC:
-    return EBADRQC;
-   break;
-#endif
-#ifdef EDOM
-  case ROAR_ERROR_DOM:
-    return EDOM;
-   break;
-#endif
-#ifdef EEXIST
-  case ROAR_ERROR_EXIST:
-    return EEXIST;
-   break;
-#endif
-#ifdef EFAULT
-  case ROAR_ERROR_FAULT:
-    return EFAULT;
-   break;
-#endif
-#if defined(EREMOTEIO) || defined(EIO)
-  case ROAR_ERROR_RIO:
-#ifdef EREMOTEIO
-    return EREMOTEIO;
-#else
-    return EIO;
-#endif
-   break;
-#endif
-#ifdef EIO
-  case ROAR_ERROR_IO:
-  case ROAR_ERROR_HOLE:
-  case ROAR_ERROR_BADCKSUM:
-  case ROAR_ERROR_LOSTSYNC:
-  case ROAR_ERROR_NOHORSE:
-    return EIO;
-   break;
-#endif
-#ifdef EKEYEXPIRED
-  case ROAR_ERROR_KEYEXPIRED:
-    return EKEYEXPIRED;
-   break;
-#endif
-#ifdef EKEYREJECTED
-  case ROAR_ERROR_KEYREJECTED:
-    return EKEYREJECTED;
-   break;
-#endif
-#ifdef ELOOP
-  case ROAR_ERROR_LOOP:
-    return ELOOP;
-   break;
-#endif
-#ifdef EMFILE
-  case ROAR_ERROR_MFILE:
-    return EMFILE;
-   break;
-#endif
-#ifdef ENAMETOOLONG
-  case ROAR_ERROR_NAMETOOLONG:
-    return ENAMETOOLONG;
-   break;
-#endif
-#ifdef ENODATA
-  case ROAR_ERROR_NODATA:
-    return ENODATA;
-   break;
-#endif
-#ifdef ENODEV
-  case ROAR_ERROR_NODEV:
-  case ROAR_ERROR_NODRV:
-    return ENODEV;
-   break;
-#endif
-#ifdef ENOSPC
-  case ROAR_ERROR_NOSPC:
-    return ENOSPC;
-   break;
-#endif
-#ifdef EINVAL
-  case ROAR_ERROR_TYPEMM:
-    return EINVAL;
-   break;
-#endif
-#ifdef ENOSYS
-  case ROAR_ERROR_NORSYS:
-    return ENOSYS;
-   break;
-#endif
-#ifdef ENOTCONN
-  case ROAR_ERROR_NOTCONN:
-    return ENOTCONN;
-   break;
-#endif
-#ifdef EPROTONOSUPPORT
-  case ROAR_ERROR_PROTONOSUP:
-    return EPROTONOSUPPORT;
-   break;
-#endif
-#ifdef EROFS
-  case ROAR_ERROR_RO:
-    return EROFS;
-   break;
-#endif
-#ifdef ETIMEDOUT
-  case ROAR_ERROR_TIMEDOUT:
-    return ETIMEDOUT;
-   break;
-#endif
-#ifdef EAGAIN
-  case ROAR_ERROR_AGAIN:
-    return EAGAIN;
-   break;
-#endif
-#ifdef ENETDOWN
-  case ROAR_ERROR_LINKDOWN:
-    return ENETDOWN;
-   break;
-#endif
-#ifdef EINTR
-  case ROAR_ERROR_INTERRUPTED:
-    return EINTR;
-   break;
-#endif
-#ifdef EDQUOT
-  case ROAR_ERROR_QUOTA:
-    return EDQUOT;
-   break;
-#endif
-#ifdef ELIBBAD
-  case ROAR_ERROR_BADLIB:
-    return ELIBBAD;
-   break;
-#endif
-#ifdef ENOMEDIUM
-  case ROAR_ERROR_NOMEDIUM:
-    return ENOMEDIUM;
-   break;
-#endif
-#ifdef ENOTUNIQ
-  case ROAR_ERROR_NOTUNIQ:
-    return ENOTUNIQ;
-   break;
-#endif
-#ifdef EILSEQ
-  case ROAR_ERROR_ILLSEQ:
-    return EILSEQ;
-   break;
-#endif
-#ifdef EADDRINUSE
-  case ROAR_ERROR_ADDRINUSE:
-    return EADDRINUSE;
-   break;
-#endif
-#ifdef ESPIPE
-  case ROAR_ERROR_BADSEEK:
-  case ROAR_ERROR_NOSEEK:
-    return ESPIPE;
-   break;
-#endif
-#ifdef ECHERNOBYL
-  case ROAR_ERROR_CHERNOBYL:
-    return ECHERNOBYL;
-   break;
-#endif
-#ifdef ECRAY
-  case ROAR_ERROR_CAUSALITY:
-    return ECRAY;
-   break;
-#endif
-#ifdef ENOHORSE
-  case ROAR_ERROR_NOHORSE:
-    return ENOHORSE;
-   break;
-#endif
-#ifdef ETXTBSY
-  case ROAR_ERROR_TEXTBUSY:
-    return ETXTBSY;
-   break;
-#endif
-#ifdef ENOTEMPTY
-  case ROAR_ERROR_NOTEMPTY:
-    return ENOTEMPTY;
-   break;
-#endif
-#ifdef EHOSTUNREACH
-  case ROAR_ERROR_NODEUNREACH:
-    return EHOSTUNREACH;
-   break;
-#endif
-#ifdef EIDRM
-  case ROAR_ERROR_IDREMOVED:
-    return EIDRM;
-   break;
-#endif
-#ifdef EINPROGRESS
-  case ROAR_ERROR_INPROGRESS:
-    return EINPROGRESS;
-   break;
-#endif
-#ifdef ECHILD
-  case ROAR_ERROR_NOCHILD:
-    return ECHILD;
-   break;
-#endif
-#ifdef ENETUNREACH
-  case ROAR_ERROR_NETUNREACH:
-    return ENETUNREACH;
-   break;
-#endif
-#ifdef ECANCELED
-  case ROAR_ERROR_CANCELED:
-    return ECANCELED;
-   break;
-#endif
-#ifdef EISDIR
-  case ROAR_ERROR_ISDIR:
-    return EISDIR;
-   break;
-#endif
-#ifdef ENOTDOR
-  case ROAR_ERROR_NOTDIR:
-    return ENOTDIR;
-   break;
-#endif
-#ifdef ENOEXEC
-  case ROAR_ERROR_BADEXEC:
-    return ENOEXEC;
-   break;
-#endif
-#ifdef EISCONN
-  case ROAR_ERROR_ISCONN:
-    return EISCONN;
-   break;
-#endif
-#ifdef EDEADLK
-  case ROAR_ERROR_DEADLOCK:
-    return EDEADLK;
-   break;
-#endif
-#ifdef ECONNRESET
-  case ROAR_ERROR_CONNRST:
-    return ECONNRESET;
-   break;
-#endif
-#ifdef EBADF
-  case ROAR_ERROR_BADFH:
-    return EBADF;
-   break;
-#endif
-#ifdef ENOTSOCK
-  case ROAR_ERROR_NOTSOCK:
-    return ENOTSOCK;
-   break;
-#endif
-#ifdef E2BIG
-  case ROAR_ERROR_TOOMANYARGS:
-    return E2BIG;
-   break;
-#endif
-#ifdef EFBIG
-  case ROAR_ERROR_TOOLARGE:
-    return EFBIG;
-   break;
-#endif
-#ifdef EDESTADDRREQ
-  case ROAR_ERROR_DESTADDRREQ:
-    return EDESTADDRREQ;
-   break;
-#endif
-#ifdef EAFNOSUPPORT
-  case ROAR_ERROR_AFNOTSUP:
-    return EAFNOSUPPORT;
-   break;
-#endif
-// FIXME....
-#ifdef ENOPOWER
-  case ROAR_ERROR_NOPOWER:
-    return ENOPOWER;
-   break;
-#endif
-#ifdef EUSER
-  case ROAR_ERROR_USER:
-    return EUSER;
-   break;
-#endif
-
-#ifdef ENFILE
-  case ROAR_ERROR_NFILE:
-    return ENFILE;
-   break;
-#endif
-#ifdef ESTALE
-  case ROAR_ERROR_STALE:
-    return ESTALE;
-   break;
-#endif
-#ifdef EXDEV
-  case ROAR_ERROR_XDEVLINK:
-    return EXDEV;
-   break;
-#endif
-#ifdef EMLINK
-  case ROAR_ERROR_MLINK:
-    return EMLINK;
-   break;
-#endif
-#ifdef ENONET
-  case ROAR_ERROR_NONET:
-    return ENONET;
-   break;
-#endif
-#ifdef ENETRESET
-  case ROAR_ERROR_CONNRSTNET:
-    return ENETRESET;
-   break;
-#endif
-#ifdef ECONNABORTED
-  case ROAR_ERROR_CONNABORTED:
-    return ECONNABORTED;
-   break;
-#endif
-#ifdef EBADFD
-  case ROAR_ERROR_BADSTATE:
-    return EBADFD;
-   break;
-#endif
-
-  default:
-#ifdef EINVAL
-    return EINVAL;
-#else
-    return -1; // just guess
-#endif
-   break;
- }
-}
-
-void   roar_err_to_errno(void) {
- errno = __roar_to_errno(roar_error);
-}
-
-static const struct error_table_entry {
- const enum roar_error_type type;
- const int error;
- const int roarerror;
-} __libroar_error_table[] = {
- {ROAR_ERROR_TYPE_HTTP, 200, ROAR_ERROR_NONE},
- {ROAR_ERROR_TYPE_HTTP, 301, ROAR_ERROR_MOVEDPERM},
- {ROAR_ERROR_TYPE_HTTP, 303, ROAR_ERROR_SEEOTHER},
- {ROAR_ERROR_TYPE_HTTP, 305, ROAR_ERROR_USEPROXY},
- {ROAR_ERROR_TYPE_HTTP, 307, ROAR_ERROR_MOVEDTEMP},
- {ROAR_ERROR_TYPE_HTTP, 400, ROAR_ERROR_INVAL},
- {ROAR_ERROR_TYPE_HTTP, 402, ROAR_ERROR_NEEDPAYMENT},
- {ROAR_ERROR_TYPE_HTTP, 403, ROAR_ERROR_PERM},
- {ROAR_ERROR_TYPE_HTTP, 404, ROAR_ERROR_NOENT},
- {ROAR_ERROR_TYPE_HTTP, 408, ROAR_ERROR_TIMEDOUT},
- {ROAR_ERROR_TYPE_HTTP, 410, ROAR_ERROR_GONE},
- {ROAR_ERROR_TYPE_HTTP, 415, ROAR_ERROR_NSTYPE},
- {ROAR_ERROR_TYPE_HTTP, 423, ROAR_ERROR_BUSY},
- {ROAR_ERROR_TYPE_HTTP, 426, ROAR_ERROR_SWITCHPROTO},
- {ROAR_ERROR_TYPE_HTTP, 451, ROAR_ERROR_CENSORED},
- {ROAR_ERROR_TYPE_HTTP, 450, ROAR_ERROR_CENSORED},
- {ROAR_ERROR_TYPE_HTTP, 501, ROAR_ERROR_NOSYS},
- {ROAR_ERROR_TYPE_HTTP, 504, ROAR_ERROR_TIMEDOUT},
- {ROAR_ERROR_TYPE_HTTP, 505, ROAR_ERROR_NSVERSION},
- {ROAR_ERROR_TYPE_HTTP, 507, ROAR_ERROR_NOSPC},
-#ifdef NETDB_SUCCESS
- {ROAR_ERROR_TYPE_HERROR, NETDB_SUCCESS, ROAR_ERROR_NONE},
-#endif
-#ifdef HOST_NOT_FOUND
- {ROAR_ERROR_TYPE_HERROR, HOST_NOT_FOUND, ROAR_ERROR_NOENT},
-#endif
-#ifdef TRY_AGAIN
- {ROAR_ERROR_TYPE_HERROR, TRY_AGAIN, ROAR_ERROR_AGAIN},
-#endif
-#ifdef NO_RECOVERY
-// {ROAR_ERROR_TYPE_HERROR, NO_RECOVERY, ROAR_ERROR_???},
-#endif
-#ifdef NO_DATA
- {ROAR_ERROR_TYPE_HERROR, NO_DATA, ROAR_ERROR_NODATA},
-#endif
-#ifdef NO_ADDRESS
- {ROAR_ERROR_TYPE_HERROR, NO_ADDRESS, ROAR_ERROR_NOENT},
-#endif
-#ifdef ROAR_TARGET_WIN32
- {ROAR_ERROR_TYPE_WINSOCK, WSA_INVALID_HANDLE, ROAR_ERROR_BADFH},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_NOT_ENOUGH_MEMORY, ROAR_ERROR_NOMEM},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_INVALID_PARAMETER, ROAR_ERROR_INVAL},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_OPERATION_ABORTED, ROAR_ERROR_INTERRUPTED},
-// {ROAR_ERROR_TYPE_WINSOCK, WSA_IO_INCOMPLETE, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSA_IO_PENDING, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEINTR, ROAR_ERROR_INTERRUPTED},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEBADF, ROAR_ERROR_BADFH},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEACCES, ROAR_ERROR_PERM},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEFAULT, ROAR_ERROR_FAULT},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEINVAL, ROAR_ERROR_INVAL},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEMFILE, ROAR_ERROR_MFILE},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEWOULDBLOCK, ROAR_ERROR_AGAIN},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEINPROGRESS, ROAR_ERROR_INPROGRESS},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEALREADY, ROAR_ERROR_ALREADY},
- {ROAR_ERROR_TYPE_WINSOCK, WSAENOTSOCK, ROAR_ERROR_NOTSOCK},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEDESTADDRREQ, ROAR_ERROR_DESTADDRREQ},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEMSGSIZE, ROAR_ERROR_MSGSIZE},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEPROTOTYPE, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAENOPROTOOPT, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEPROTONOSUPPORT, ROAR_ERROR_PROTONOSUP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAESOCKTNOSUPPORT, ROAR_ERROR_PROTONOSUP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEOPNOTSUPP, ROAR_ERROR_NOTSUP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEPFNOSUPPORT, ROAR_ERROR_AFNOTSUP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEAFNOSUPPORT, ROAR_ERROR_AFNOTSUP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEADDRINUSE, ROAR_ERROR_ADDRINUSE},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEADDRNOTAVAIL, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAENETDOWN, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAENETUNREACH, ROAR_ERROR_NETUNREACH},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAENETRESET, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAECONNABORTED, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAECONNRESET, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAENOBUFS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEISCONN, ROAR_ERROR_ISCONN},
- {ROAR_ERROR_TYPE_WINSOCK, WSAENOTCONN, ROAR_ERROR_NOTCONN},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAESHUTDOWN, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAETOOMANYREFS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAETIMEDOUT, ROAR_ERROR_TIMEDOUT},
- {ROAR_ERROR_TYPE_WINSOCK, WSAECONNREFUSED, ROAR_ERROR_CONNREFUSED},
- {ROAR_ERROR_TYPE_WINSOCK, WSAELOOP, ROAR_ERROR_LOOP},
- {ROAR_ERROR_TYPE_WINSOCK, WSAENAMETOOLONG, ROAR_ERROR_NAMETOOLONG},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEHOSTDOWN, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAEHOSTUNREACH, ROAR_ERROR_NODEUNREACH},
- {ROAR_ERROR_TYPE_WINSOCK, WSAENOTEMPTY, ROAR_ERROR_NOTEMPTY},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEPROCLIM, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEUSERS, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEDQUOT, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAESTALE, ROAR_ERROR_STALE},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEREMOTE, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSASYSNOTREADY, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAVERNOTSUPPORTED, ROAR_ERROR_NSVERSION},
-// {ROAR_ERROR_TYPE_WINSOCK, WSANOTINITIALISED, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEDISCON, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAENOMORE, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAECANCELLED, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEINVALIDPROCTABLE, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEINVALIDPROVIDER, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEPROVIDERFAILEDINIT, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSASYSCALLFAILURE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSASERVICE_NOT_FOUND, ROAR_ERROR_NOENT},
- {ROAR_ERROR_TYPE_WINSOCK, WSATYPE_NOT_FOUND, ROAR_ERROR_NOENT},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_E_NO_MORE, ROAR_ERROR_NOENT},
-// {ROAR_ERROR_TYPE_WINSOCK, WSA_E_CANCELLED, ROAR_ERROR_???},
-// {ROAR_ERROR_TYPE_WINSOCK, WSAEREFUSED, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSAHOST_NOT_FOUND, ROAR_ERROR_NOENT},
- {ROAR_ERROR_TYPE_WINSOCK, WSATRY_AGAIN, ROAR_ERROR_AGAIN},
-// {ROAR_ERROR_TYPE_WINSOCK, WSANO_RECOVERY, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSANO_DATA, ROAR_ERROR_NODATA},
-#if 0
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_RECEIVERS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_SENDERS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_NO_SENDERS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_NO_RECEIVERS, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_REQUEST_CONFIRMED, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_ADMISSION_FAILURE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_POLICY_FAILURE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_BAD_STYLE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_BAD_OBJECT, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_TRAFFIC_CTRL_ERROR, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_GENERIC_ERROR, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_ESERVICETYPE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFLOWSPEC, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EPROVSPECBUF, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFILTERSTYLE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFILTERTYPE, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFILTERCOUNT, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EOBJLENGTH, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFLOWCOUNT, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EUNKOWNPSOBJ, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EPOLICYOBJ, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EFLOWDESC, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EPSFLOWSPEC, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_EPSFILTERSPEC, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_ESDMODEOBJ, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_ESHAPERATEOBJ, ROAR_ERROR_???},
- {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_RESERVED_PETYPE, ROAR_ERROR_???},
-#endif
-#endif
- {ROAR_ERROR_TYPE_EAI, 0 /* defined value, see manpage */, ROAR_ERROR_NONE},
-#ifdef EAI_ADDRFAMILY
- {ROAR_ERROR_TYPE_EAI, EAI_ADDRFAMILY, ROAR_ERROR_NOENT},
-#endif
-#ifdef EAI_AGAIN
- {ROAR_ERROR_TYPE_EAI, EAI_AGAIN, ROAR_ERROR_AGAIN},
-#endif
-#ifdef EAI_BADFLAGS
- {ROAR_ERROR_TYPE_EAI, EAI_BADFLAGS, ROAR_ERROR_INVAL},
-#endif
-#ifdef EAI_FAIL
- {ROAR_ERROR_TYPE_EAI, EAI_FAIL, ROAR_ERROR_RIO},
-#endif
-#ifdef EAI_FAMILY
- {ROAR_ERROR_TYPE_EAI, EAI_FAMILY, ROAR_ERROR_AFNOTSUP},
-#endif
-#ifdef EAI_MEMORY
- {ROAR_ERROR_TYPE_EAI, EAI_MEMORY, ROAR_ERROR_NOMEM},
-#endif
-#ifdef EAI_NODATA
- {ROAR_ERROR_TYPE_EAI, EAI_NODATA, ROAR_ERROR_NODATA},
-#endif
-#ifdef EAI_NONAME
- {ROAR_ERROR_TYPE_EAI, EAI_NONAME, ROAR_ERROR_NOENT},
-#endif
-#ifdef EAI_SERVICE
- {ROAR_ERROR_TYPE_EAI, EAI_SERVICE, ROAR_ERROR_PROTONOSUP},
-#endif
-#ifdef EAI_SOCKTYPE
- {ROAR_ERROR_TYPE_EAI, EAI_SOCKTYPE, ROAR_ERROR_INVAL},
-#endif
-#ifdef EAI_SYSTEM
-// {ROAR_ERROR_TYPE_EAI, EAI_SYSTEM, ROAR_ERROR_???},
-#endif
-};
-
-static int roar_err_convert_table_lookup(const struct error_table_entry ** match,
-                                         const int error,
-                                         const enum roar_error_type type,
-                                         const int to_roar) {
- size_t i;
-
- // we have the following loop to times as an inner if() would cost more cycles
- // than the outer if we currently have.
-
- if ( to_roar ) {
-  for (i = 0; i < (sizeof(__libroar_error_table)/sizeof(*__libroar_error_table)); i++) {
-   if ( __libroar_error_table[i].type == type && __libroar_error_table[i].error == error) {
-    *match = &(__libroar_error_table[i]);
-    return ROAR_ERROR_NONE;
-   }
-  }
- } else {
-  for (i = 0; i < (sizeof(__libroar_error_table)/sizeof(*__libroar_error_table)); i++) {
-   if ( __libroar_error_table[i].type == type && __libroar_error_table[i].roarerror == error) {
-    *match = &(__libroar_error_table[i]);
-    return ROAR_ERROR_NONE;
-   }
-  }
- }
-
- return ROAR_ERROR_NOENT;
-}
-
-// Convert error codes between diffrent representations.
-// returnes the error or ROAR_ERROR_NONE on success so it does not alter global error state.
-int    roar_err_convert(int * out, const enum roar_error_type outtype, const int in, const enum roar_error_type intype) {
- const struct error_table_entry * tablematch;
- int tmp;
- int ret;
-
- if ( out == NULL )
-  return ROAR_ERROR_FAULT;
-
- if ( outtype == intype ) {
-  *out = in;
-  return ROAR_ERROR_NONE;
- }
-
- // if not to/from roar, use roar as temp type so we do only need to code two kinds of translators (not any->any).
- if ( intype != ROAR_ERROR_TYPE_ROARAUDIO && outtype != ROAR_ERROR_TYPE_ROARAUDIO ) {
-  ret = roar_err_convert(&tmp, ROAR_ERROR_TYPE_ROARAUDIO, in, intype);
-  if ( ret != ROAR_ERROR_NONE )
-   return ret;
-
-  return roar_err_convert(out, outtype, tmp, ROAR_ERROR_TYPE_ROARAUDIO);
- }
-
- // from here we can asume that if intype != ROAR_ERROR_TYPE_ROARAUDIO outtype is ROAR_ERROR_TYPE_ROARAUDIO
- // and the other way around.
-
- if ( intype == ROAR_ERROR_TYPE_ROARAUDIO ) {
-  ret = roar_err_convert_table_lookup(&tablematch, in, outtype, 0);
- } else {
-  ret = roar_err_convert_table_lookup(&tablematch, in, intype, 1);
- }
-
- if ( ret == ROAR_ERROR_NONE ) {
-  *out = intype == ROAR_ERROR_TYPE_ROARAUDIO ? tablematch->error : tablematch->roarerror;
-  return ROAR_ERROR_NONE;
- }
-
- if ( intype == ROAR_ERROR_TYPE_ROARAUDIO && outtype == ROAR_ERROR_TYPE_ERRNO ) {
-  // the __roar_to_errno() function always succeeds.
-  *out = __roar_to_errno(in);
-  return ROAR_ERROR_NONE;
- }
-
- if ( outtype == ROAR_ERROR_TYPE_ROARAUDIO && intype == ROAR_ERROR_TYPE_ERRNO ) {
-  // the __errno_to_roar() function always succeeds.
-  *out = __errno_to_roar(in);
-  return ROAR_ERROR_NONE;
- }
-
- roar_err_get_default_error(out, outtype);
- return ROAR_ERROR_NOENT;
-}
-
-// Outputs a default error for the given type.
-// returnes the error or ROAR_ERROR_NONE on success so it does not alter global error state.
-int    roar_err_get_default_error(int * out, const enum roar_error_type type) {
- int is_set = 0;
-
- if ( out == NULL )
-  return ROAR_ERROR_FAULT;
-
- switch (type) {
-  case ROAR_ERROR_TYPE_ROARAUDIO: is_set = 1; *out = ROAR_ERROR_UNKNOWN; break;
-#ifdef EINVAL
-  case ROAR_ERROR_TYPE_ERRNO: is_set = 1; *out = EINVAL; break;
-#endif
-#ifdef NO_RECOVERY
-  case ROAR_ERROR_TYPE_HERROR: is_set = 1; *out = NO_RECOVERY; break;
-#endif
-#ifdef __YIFF__
-  case ROAR_ERROR_TYPE_YIFF: is_set = 1; *out = YIFF_ERRNO_UNKNOWN; break;
-#endif
-  case ROAR_ERROR_TYPE_HTTP: is_set = 1; *out = 500; break;
-#ifndef DEBUG
-  // enable compiler warnings in DEBUG mode.
-  default:
-   break;
-#endif
- }
-
- if ( is_set ) {
-  return ROAR_ERROR_NONE;
- }
-
- *out = -1; // some default so we do not leave it uninited.
- return ROAR_ERROR_NOENT;
-}
-
-// Resets the stored state to 'no error' state. This can be used
-// to init the state.
-int    roar_err_initstore(struct roar_error_state * state) {
- struct roar_error_state curstate;
-
- if ( state == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_err_store(&curstate);
- roar_err_clear_all();
- roar_err_store(state);
- roar_err_restore(&curstate);
-
- return -1;
-}
-
-// store a error state (both libroar and system)
-int    roar_err_store(struct roar_error_state * state) {
- if ( state == NULL )
-  return ROAR_ERROR_FAULT;
-
- memset(state, 0, sizeof(struct roar_error_state));
-
- state->refc          = 0;
- state->libroar_error = roar_error;
- state->system_error  = errno;
-
-#ifdef ROAR_TARGET_WIN32
- state->winsock_error = WSAGetLastError();
-#endif
-#ifdef ROAR_HAVE_VAR_H_ERRNO
- state->syssock_herror = h_errno;
-#endif
-
-#ifdef __YIFF__
- state->yiffc_error = yiffc_error;
-#endif
-
- return ROAR_ERROR_NONE;
-}
-
-// restore error state to values at time of call to roar_err_store()
-int    roar_err_restore(struct roar_error_state * state) {
- if ( state == NULL )
-  return ROAR_ERROR_FAULT;
-
- roar_err_set(state->libroar_error);
- errno = state->system_error;
-
-#ifdef ROAR_TARGET_WIN32
- WSASetLastError(state->winsock_error);
-#endif
-#ifdef ROAR_HAVE_VAR_H_ERRNO
- h_errno = state->syssock_herror;
-#endif
-
-#ifdef __YIFF__
- yiffc_error = state->yiffc_error;
-#endif
-
- return ROAR_ERROR_NONE;
-}
-
-
-// phi@ph7:roaraudio $ grep '^#define ROAR_ERROR_' error.h  | tr -d /\* | while read d c d t; do printf "  {%-23s \"%s\"},\n" $c, "$t"; done
-
-static const char * roar_error2str_ms(const int error, const char * msg) {
- static char buf[1024] = "";
- int num[8];
- size_t i;
- int _ra_err = roar_error;
- int _sys_err = errno;
-
- for (i = 0; i < (sizeof(num)/sizeof(*num)); i++)
-  num[i] = roar_random_uint32();
-
- snprintf(buf, sizeof(buf), "\e[44;39;1m\e[2J\e[H"
-                            "                                   RoarAudio\n"
-                            "\n\n"
-                            "Fatal error %.4x: %s\n"
-                            "RA Error: %.4i, Sys Error: %.4i (%s)\n"
-                            "Random numbers:\n"
-                            " A: 0x%.8X B: 0x%.8X\n"
-                            " C: 0x%.8X D: 0x%.8X\n"
-                            " E: 0x%.8X F: 0x%.8X\n"
-                            " G: 0x%.8X H: 0x%.8X\n"
-                            "\n\n"
-                            "\e[0m",
-                            error, msg,
-                            _ra_err, _sys_err, strerror(_sys_err),
-                            num[0], num[1], num[2], num[3], num[4], num[5], num[6], num[7]);
-
- return buf;
-}
-
-const char * roar_error2str(const int error) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- const struct {
-  const int    err;
-  const char * msg;
- } msgs[] = {
-  {ROAR_ERROR_NONE,        "No error"},
-  {ROAR_ERROR_PERM,        "Operation not permitted"},
-  {ROAR_ERROR_NOENT,       "No such object, file, directory or node"},
-  {ROAR_ERROR_BADMSG,      "Bad message"},
-  {ROAR_ERROR_BUSY,        "Device or resource busy"},
-  {ROAR_ERROR_CONNREFUSED, "Connection refused"},
-  {ROAR_ERROR_NOSYS,       "Function not implemented"},
-  {ROAR_ERROR_NOTSUP,      "Operation not supported"},
-  {ROAR_ERROR_PIPE,        "Broken pipe"},
-  {ROAR_ERROR_PROTO,       "Protocol error"},
-  {ROAR_ERROR_RANGE,       "Result too large or parameter out of range"},
-  {ROAR_ERROR_MSGSIZE,     "Message too long"},
-  {ROAR_ERROR_NOMEM,       "Not enough space"},
-  {ROAR_ERROR_INVAL,       "Invalid argument"},
-  {ROAR_ERROR_ALREADY,     "Connection already in progress"},
-  {ROAR_ERROR_BADRQC,      "Invalid request code"},
-  {ROAR_ERROR_DOM,         "Mathematics argument out of domain of function"},
-  {ROAR_ERROR_EXIST,       "File or object exists"},
-  {ROAR_ERROR_FAULT,       "Bad address"},
-  {ROAR_ERROR_IO,          "I/O-Error"},
-  {ROAR_ERROR_KEYEXPIRED,  "Key has expired"},
-  {ROAR_ERROR_KEYREJECTED, "Key was rejected by service"},
-  {ROAR_ERROR_LOOP,        "Too many recursions"},
-  {ROAR_ERROR_MFILE,       "Too many open files or objects"},
-  {ROAR_ERROR_NAMETOOLONG, "File or object name too long"},
-  {ROAR_ERROR_NODATA,      "No message is available on the read queue"},
-  {ROAR_ERROR_NODEV,       "No such device"},
-  {ROAR_ERROR_NODRV,       "No such driver"},
-  {ROAR_ERROR_NOSPC,       "No space left on device"},
-  {ROAR_ERROR_TYPEMM,      "Type missmatch. Object of diffrent type required"},
-  {ROAR_ERROR_NORSYS,      "Feature not implemented by remote end"},
-  {ROAR_ERROR_NOTCONN,     "Socket or object not connected"},
-  {ROAR_ERROR_PROTONOSUP,  "Protocol not supported"},
-  {ROAR_ERROR_RIO,         "Remote I/O Error"},
-  {ROAR_ERROR_RO,          "File or object is read only"},
-  {ROAR_ERROR_TIMEDOUT,    "Connection timed out"},
-  {ROAR_ERROR_AGAIN,       "Resource temporarily unavailable"},
-  {ROAR_ERROR_NOISE,       "Line too noisy"},
-  {ROAR_ERROR_LINKDOWN,    "Physical or logical link down"},
-  {ROAR_ERROR_INTERRUPTED, "Operation was interruped"},
-  {ROAR_ERROR_CAUSALITY,   "Causality error"},
-  {ROAR_ERROR_QUOTA,       "Quota exceeded"},
-  {ROAR_ERROR_BADLIB,      "Accessing a corrupted shared library"},
-  {ROAR_ERROR_NOMEDIUM,    "No medium found"},
-  {ROAR_ERROR_NOTUNIQ,     "Name not unique"},
-  {ROAR_ERROR_ILLSEQ,      "Illegal byte sequence"},
-  {ROAR_ERROR_ADDRINUSE,   "Address in use"},
-  {ROAR_ERROR_HOLE,        "Hole in data"},
-  {ROAR_ERROR_BADVERSION,  "Bad version"},
-  {ROAR_ERROR_NSVERSION,   "Not supported version"},
-  {ROAR_ERROR_BADMAGIC,    "Bad magic number"},
-  {ROAR_ERROR_LOSTSYNC,    "Lost synchronization"},
-  {ROAR_ERROR_BADSEEK,     "Can not seek to destination position"},
-  {ROAR_ERROR_NOSEEK,      "Seeking not supported on resource"},
-  {ROAR_ERROR_BADCKSUM,    "Data integrity error"},
-  {ROAR_ERROR_NOHORSE,     "Mount failed"},
-  {ROAR_ERROR_CHERNOBYL,   "Fatal device error"},
-  {ROAR_ERROR_NOHUG,       "Device needs love"},
-  {ROAR_ERROR_TEXTBUSY,    "Text file busy"},
-  {ROAR_ERROR_NOTEMPTY,    "Directory not empty"},
-  {ROAR_ERROR_NODEUNREACH, "Node is unreachable"},
-  {ROAR_ERROR_IDREMOVED,   "Identifier removed"},
-  {ROAR_ERROR_INPROGRESS,  "Operation in progress"},
-  {ROAR_ERROR_NOCHILD,     "No child processes or object"},
-  {ROAR_ERROR_NETUNREACH,  "Network unreachable"},
-  {ROAR_ERROR_CANCELED,    "Operation canceled"},
-  {ROAR_ERROR_ISDIR,       "Is a directory"},
-  {ROAR_ERROR_NOTDIR,      "Not a directory"},
-  {ROAR_ERROR_BADEXEC,     "Executable file format error"},
-  {ROAR_ERROR_ISCONN,      "Socket or Object is connected"},
-  {ROAR_ERROR_DEADLOCK,    "Resource deadlock would occur"},
-  {ROAR_ERROR_CONNRST,     "Connection reset"},
-  {ROAR_ERROR_BADFH,       "Bad file handle"},
-  {ROAR_ERROR_NOTSOCK,     "Not a socket"},
-  {ROAR_ERROR_TOOMANYARGS, "Argument list too long"},
-  {ROAR_ERROR_TOOLARGE,    "File or Object too large"},
-  {ROAR_ERROR_DESTADDRREQ, "Destination address required"},
-  {ROAR_ERROR_AFNOTSUP,    "Address family not supported"},
-  {ROAR_ERROR_NOPOWER,     "Operation can not be completed because we are low on power"},
-  {ROAR_ERROR_USER,        "Error in front of screen"},
-  {ROAR_ERROR_NFILE,       "Too many filesobjects open in system"},
-  {ROAR_ERROR_STALE,       "Stale file handle or object"},
-  {ROAR_ERROR_XDEVLINK,    "Cross-device link"},
-  {ROAR_ERROR_MLINK,       "Too many links to file or object"},
-  {ROAR_ERROR_NONET,       "Not connected to any network"},
-  {ROAR_ERROR_CONNRSTNET,  "Connection reset by network"},
-  {ROAR_ERROR_CONNABORTED, "Connection aborted"},
-  {ROAR_ERROR_BADHOST,     "Bad host software or hardware"},
-  {ROAR_ERROR_SWITCHPROTO, "Switch protocol"},
-  {ROAR_ERROR_MOVEDPERM,   "Moved Permanently"},
-  {ROAR_ERROR_MOVEDTEMP,   "Moved Temporary"},
-  {ROAR_ERROR_USEPROXY,    "Use Proxy server"},
-  {ROAR_ERROR_SEEOTHER,    "See other resource"},
-  {ROAR_ERROR_GONE,        "Resource gone"},
-  {ROAR_ERROR_BADLICENSE,  "Bad License"},
-  {ROAR_ERROR_NEEDPAYMENT, "Payment Required"},
-  {ROAR_ERROR_NSTYPE,      "Type or Format not supported"},
-  {ROAR_ERROR_CENSORED,    "Access denied because of censorship"},
-  {ROAR_ERROR_BADSTATE,    "Object is in bad/wrong state"},
-  {ROAR_ERROR_DISABLED,    "This has been disabled by the administrator"},
-  {-1, NULL}
- }, msgs_funny[] = {
-//  {ROAR_ERROR_UNKNOWN,     "Unknown (maybe no) error"},
-  {ROAR_ERROR_NONE,        "No error, huh?"},
-  {ROAR_ERROR_PERM,        "Little kitty is not allowed to do this"},
-  {ROAR_ERROR_NOENT,       "Mouse not found"},
-//  {ROAR_ERROR_BADMSG,      "Bad message"},
-  {ROAR_ERROR_BUSY,        "Another kitty is playing with this mouse"},
-//  {ROAR_ERROR_CONNREFUSED, "Connection refused"},
-//  {ROAR_ERROR_NOSYS,       "Function not implemented"},
-//  {ROAR_ERROR_NOTSUP,      "Operation not supported"},
-  {ROAR_ERROR_PIPE,        "Flood"},
-//  {ROAR_ERROR_PROTO,       "Protocol error"},
-//  {ROAR_ERROR_RANGE,       "Result too largegeneral out of range"},
-//  {ROAR_ERROR_MSGSIZE,     "Message too long"},
-//  {ROAR_ERROR_NOMEM,       "Not enough space"},
-//  {ROAR_ERROR_INVAL,       "Invalid argument"},
-//  {ROAR_ERROR_ALREADY,     "Connection already in progress"},
-  {ROAR_ERROR_BADRQC,      "Stupid staff"},
-//  {ROAR_ERROR_DOM,         "Mathematics argument out of domain of function"},
-//  {ROAR_ERROR_EXIST,       "File or object exists"},
-//  {ROAR_ERROR_FAULT,       "Bad address"},
-//  {ROAR_ERROR_IO,          "IO-Error"},
-//  {ROAR_ERROR_KEYEXPIRED,  "Key has expired"},
-//  {ROAR_ERROR_KEYREJECTED, "Key was rejected by service"},
-//  {ROAR_ERROR_LOOP,        "Too many recursions"},
-//  {ROAR_ERROR_MFILE,       "Too many open files or objects"},
-  {ROAR_ERROR_NAMETOOLONG, "Staff can not remember long names"},
-//  {ROAR_ERROR_NODATA,      "No message is available on the read queue"},
-  {ROAR_ERROR_NODEV,       "No such mouse"},
-//  {ROAR_ERROR_NODRV,       "No such driver"},
-  {ROAR_ERROR_NOSPC,       "Too many fish on desk"},
-//  {ROAR_ERROR_TYPEMM,      "Type missmatch. Object of diffrent type required"},
-//  {ROAR_ERROR_NORSYS,      "Feature not implemented by remote end"},
-//  {ROAR_ERROR_NOTCONN,     "Socket or object not connected"},
-//  {ROAR_ERROR_PROTONOSUP,  "Protocol not supported"},
-//  {ROAR_ERROR_RIO,         "Remote IO Error"},
-  {ROAR_ERROR_RO,          "Touching disallowed"},
-//  {ROAR_ERROR_TIMEDOUT,    "Connection timed out"},
-//  {ROAR_ERROR_AGAIN,       "Resource temporarily unavailable"},
-//  {ROAR_ERROR_NOISE,       "Line too noisy"},
-//  {ROAR_ERROR_LINKDOWN,    "Physical or logical link down"},
-//  {ROAR_ERROR_INTERRUPTED, "Operation was interruped"},
-//  {ROAR_ERROR_CAUSALITY,   "Causality error"},
-//  {ROAR_ERROR_QUOTA,       "Quota exceeded"},
-//  {ROAR_ERROR_BADLIB,      "Accessing a corrupted shared library"},
-//  {ROAR_ERROR_NOMEDIUM,    "No medium found"},
-//  {ROAR_ERROR_NOTUNIQ,     "Name not unique"},
-//  {ROAR_ERROR_ILLSEQ,      "Illegal byte sequence"},
-//  {ROAR_ERROR_ADDRINUSE,   "Address in use"},
-  {ROAR_ERROR_HOLE,        "Hole in wall"},
-//  {ROAR_ERROR_BADVERSION,  "Bad version"},
-//  {ROAR_ERROR_NSVERSION,   "Not supported version"},
-  {ROAR_ERROR_BADMAGIC,    "Magician's fault"},
-//  {ROAR_ERROR_LOSTSYNC,    "Lost synchronization"},
-//  {ROAR_ERROR_BADSEEK,     "Can not seek to destination position"},
-//  {ROAR_ERROR_NOSEEK,      "Seeking not supported on resource"},
-//  {ROAR_ERROR_BADCKSUM,    "Data integrity error"},
-  {ROAR_ERROR_NOHORSE,     "No horse"},
-//  {ROAR_ERROR_CHERNOBYL,   "Fatal device error"},
-  {ROAR_ERROR_NOHUG,       "No hug"},
-//  {ROAR_ERROR_TEXTBUSY,    "Text file busy"},
-//  {ROAR_ERROR_NOTEMPTY,    "Directory not empty"},
-//  {ROAR_ERROR_NODEUNREACH, "Node is unreachable"},
-//  {ROAR_ERROR_IDREMOVED,   "Identifier removed"},
-//  {ROAR_ERROR_INPROGRESS,  "Operation in progress"},
-//  {ROAR_ERROR_NOCHILD,     "No child processesobject"},
-//  {ROAR_ERROR_NETUNREACH,  "Network unreachable"},
-//  {ROAR_ERROR_CANCELED,    "Operation canceled"},
-//  {ROAR_ERROR_ISDIR,       "Is a directory"},
-//  {ROAR_ERROR_NOTDIR,      "Not a directory"},
-//  {ROAR_ERROR_BADEXEC,     "Executable file format error"},
-//  {ROAR_ERROR_ISCONN,      "Socket/Object is connected"},
-  {ROAR_ERROR_DEADLOCK,    "Mouse would die"},
-//  {ROAR_ERROR_CONNRST,     "Connection reset"},
-//  {ROAR_ERROR_BADFH,       "Bad file handle"},
-//  {ROAR_ERROR_NOTSOCK,     "Not a socket"},
-//  {ROAR_ERROR_TOOMANYARGS, "Argument list too long"},
-//  {ROAR_ERROR_TOOLARGE,    "File/Object too large"},
-//  {ROAR_ERROR_DESTADDRREQ, "Destination address required"},
-//  {ROAR_ERROR_AFNOTSUP,    "Address family not supported"},
-//  {ROAR_ERROR_NOPOWER,     "Operation can not be completed because we are low on power"},
-//  {ROAR_ERROR_USER,        "Error in front of screen"},
-//  {ROAR_ERROR_NFILE,       "Too many filesobjects open in system"},
-//  {ROAR_ERROR_STALE,       "Stale file handle or object"},
-  {ROAR_ERROR_XDEVLINK,    "Mice tails too short for kinking"},
-//  {ROAR_ERROR_MLINK,       "Too many links to file or object"},
-//  {ROAR_ERROR_NONET,       "Not connected to any network"},
-//  {ROAR_ERROR_CONNRSTNET,  "Connection reset by network"},
-//  {ROAR_ERROR_CONNABORTED, "Connection aborted"},
-//  {ROAR_ERROR_BADHOST,     "Bad host software or hardware"},
-//  {ROAR_ERROR_SWITCHPROTO, "Switch protocol"},
-//  {ROAR_ERROR_MOVEDPERM,   "Moved Permanently"},
-//  {ROAR_ERROR_MOVEDTEMP,   "Moved Temporary"},
-//  {ROAR_ERROR_USEPROXY,    "Use Proxy server"},
-//  {ROAR_ERROR_SEEOTHER,    "See other resource"},
-//  {ROAR_ERROR_GONE,        "Resource gone"},
-  {-1, NULL}
- };
- int i;
-
- if ( config->opmode == ROAR_LIBROAR_CONFIG_OPMODE_MS ) {
-  for (i = 0; msgs[i].msg != NULL; i++) {
-   if ( msgs[i].err == error ) {
-    return roar_error2str_ms(error, msgs[i].msg);
-   }
-  }
-  return roar_error2str_ms(error, "<<<unknown error>>>");
- }
-
- if ( config->opmode == ROAR_LIBROAR_CONFIG_OPMODE_FUNNY )
-  for (i = 0; msgs_funny[i].msg != NULL; i++)
-   if ( msgs_funny[i].err == error )
-    return msgs_funny[i].msg;
-
- for (i = 0; msgs[i].msg != NULL; i++)
-  if ( msgs[i].err == error )
-   return msgs[i].msg;
-
- return NULL;
-}
-
-//ll
Index: libroar/file.c
===================================================================
--- libroar/file.c	(revision 6052)
+++ 	(revision )
@@ -1,99 +1,0 @@
-//file.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_file_codecdetect(const char * buf, const int len) {
- int codec = -1;
-
- if ( len > 3 ) {
-  if ( strncmp(buf, "OggS", 4) == 0 ) {
-   codec = ROAR_CODEC_OGG_GENERAL;
-   if ( len > 32 ) { // this is 5 bytes after the end of the header
-    if ( strncmp(buf+28, "\177FLAC", 5) == 0 ) {
-     codec = ROAR_CODEC_OGG_FLAC;
-    } else if ( strncmp(buf+28, "Speex", 5) == 0 ) {
-     codec = ROAR_CODEC_OGG_SPEEX;
-    } else if ( len > 34 ) { // this is 7 bytes after the end of the header
-     if ( strncmp(buf+28, "\001vorbis", 7) == 0 )
-      codec = ROAR_CODEC_OGG_VORBIS;
-    }
-   }
-  } else if ( strncmp(buf, "MThd", 4) == 0 ) {
-   codec = ROAR_CODEC_MIDI_FILE;
-  } else if ( strncmp(buf, "RIFF", 4) == 0 ) {
-   if ( len > 15 ) {
-    if ( strncmp(buf+8, "WAVEfmt ", 8) == 0 )
-     codec = ROAR_CODEC_RIFF_WAVE;
-   }
-  } else if ( strncmp(buf, "Roar", 4) == 0 ) {
-   if ( len > ROAR_SPEEX_MAGIC_LEN ) {
-    if ( strncmp(buf, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN) == 0 )
-     codec = ROAR_CODEC_ROAR_SPEEX;
-#if ROAR_SPEEX_MAGIC_LEN < ROAR_CELT_MAGIC_LEN
-   }
-   if ( len > ROAR_CELT_MAGIC_LEN ) {
-#endif
-    if ( strncmp(buf, ROAR_CELT_MAGIC_0, ROAR_CELT_MAGIC_LEN) == 0 ||
-         strncmp(buf, ROAR_CELT_MAGIC_1, ROAR_CELT_MAGIC_LEN) == 0  )
-     codec = ROAR_CODEC_ROAR_CELT;
-   }
-  } else if ( strncmp(buf, "fLaC", 4) == 0 ) {
-   codec = ROAR_CODEC_FLAC;
-  } else if ( strncmp(buf, ".snd", 4) == 0 ) {
-   codec = ROAR_CODEC_AU;
-  } else if ( len > 7 && strncmp(buf, "RAUM-CF0", 8) == 0 ) {
-   codec = ROAR_CODEC_RAUM;
-  }
- }
-
- return codec;
-}
-
-const char  * roar_cdromdevice     (void) {
- const char * k;
-
- if ( (k = roar_env_get("CDDA_DEVICE")) != NULL )
-  return k;
-
-#ifdef ROAR_DEFAULT_CDROM
- return ROAR_DEFAULT_CDROM;
-#endif
-
- roar_err_set(ROAR_ERROR_NODEV);
- return NULL;
-}
-
-//ll
Index: libroar/hash.c
===================================================================
--- libroar/hash.c	(revision 6052)
+++ 	(revision )
@@ -1,502 +1,0 @@
-//hash.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_LIBGCRYPT
-#include <gcrypt.h>
-#endif
-
-struct roar_hash_state {
- struct roar_hash_cmds * cmds;
- void * state;
-};
-
-static const struct hashes {
- const roar_hash_t    id;
- const char         * name;
- const ssize_t        dlen;
-} _libroar_hashes[] = {
-/*
-grep '^  +HT_' doc/new-cmds | sed 's/ *#(.*)$//; s/^  +HT_//; s/ *=.*$//' | while read n; do printf " {ROAR_HT_%-12s \"%-12s -1   },\n" $n, $n\",; done
-*/
- {ROAR_HT_NONE,        "NONE",       -1   },
- {ROAR_HT_MD5,         "MD5",         16  },
- {ROAR_HT_SHA1,        "SHA1",        20  },
- {ROAR_HT_RIPEMD160,   "RIPEMD160",   20  },
- {ROAR_HT_MD2,         "MD2",        -1   },
- {ROAR_HT_TIGER,       "TIGER",       24  },
- {ROAR_HT_HAVAL,       "HAVAL",      -1   },
- {ROAR_HT_SHA256,      "SHA256",      32  },
- {ROAR_HT_SHA384,      "SHA384",      48  },
- {ROAR_HT_SHA512,      "SHA512",      64  },
- {ROAR_HT_SHA224,      "SHA224",      28  },
- {ROAR_HT_MD4,         "MD4",         16  },
- {ROAR_HT_CRC32,       "CRC32",       4   },
- {ROAR_HT_RFC1510,     "RFC1510",     4   },
- {ROAR_HT_RFC2440,     "RFC2440",     3   },
- {ROAR_HT_WHIRLPOOL,   "WHIRLPOOL",   64  },
- {ROAR_HT_UUID,        "UUID",        16  },
- {ROAR_HT_GTN8,        "GTN8",        1   },
- {ROAR_HT_GTN16,       "GTN16",       2   },
- {ROAR_HT_GTN32,       "GTN32",       4   },
- {ROAR_HT_GTN64,       "GTN64",       8   },
- {ROAR_HT_CLIENTID,    "CLIENTID",   -1   },
- {ROAR_HT_STREAMID,    "STREAMID",   -1   },
- {ROAR_HT_SOURCEID,    "SOURCEID",   -1   },
- {ROAR_HT_SAMPLEID,    "SAMPLEID",   -1   },
- {ROAR_HT_MIXERID,     "MIXERID",    -1   },
- {ROAR_HT_BRIDGEID,    "BRIDGEID",   -1   },
- {ROAR_HT_LISTENID,    "LISTENID",   -1   },
- {ROAR_HT_ACTIONID,    "ACTIONID",   -1   },
- {ROAR_HT_MSGQUEUEID,  "MSGQUEUEID", -1   },
- {ROAR_HT_MSGBUSID,    "MSGBUSID",   -1   },
- {ROAR_HT_GTIN8,       "GTIN8",       4   },
- {ROAR_HT_GTIN13,      "GTIN13",      8   },
- {ROAR_HT_ISBN10,      "ISBN10",      8   },
- {ROAR_HT_ISBN13,      "ISBN13",      8   },
- {ROAR_HT_ADLER32,     "ADLER32",     4   },
- {-1, NULL, -1}
-};
-
-int roar_hash_sha1_init(void * state);
-int roar_hash_sha1_uninit(void * state);
-int roar_hash_sha1_digest(void * state, void * digest, size_t * len);
-int roar_hash_sha1_proc_block(void * state, const void * block);
-int roar_hash_sha1_proc(void * state, const void * data, size_t len);
-
-static struct roar_hash_cmds _libroar_hash_cmds[] = {
- {ROAR_HT_TIGER, sizeof(struct roar_hash_tiger), 512,
-  (int (*)(void *))roar_hash_tiger_init, (int (*)(void *))roar_hash_tiger_uninit,
-  (int (*)(void *, void *, size_t *))roar_hash_tiger_get_digest,
-  (int (*)(void *, const void *))roar_hash_tiger_proc_block,
-  (int (*)(void *, const void *, size_t))roar_hash_tiger_proc
- },
- {ROAR_HT_RFC2440, sizeof(uint32_t), -1,
-  roar_hash_crc24_init, NULL,
-  roar_hash_crc24_digest, NULL, roar_hash_crc24_proc
- },
- {ROAR_HT_ADLER32, sizeof(uint32_t), -1,
-  roar_hash_adler32_init, NULL,
-  roar_hash_adler32_digest, NULL, roar_hash_adler32_proc
- },
- {ROAR_HT_SHA1, sizeof(struct roar_hash_sha1), 64,
-  roar_hash_sha1_init, roar_hash_sha1_uninit,
-  roar_hash_sha1_digest, roar_hash_sha1_proc_block, roar_hash_sha1_proc},
- {-1, -1, -1, NULL, NULL, NULL, NULL, NULL}
-};
-
-static struct roar_hash_cmds * roar_ht2cmds(const roar_hash_t ht) {
- size_t i;
-
- for(i = 0; _libroar_hash_cmds[i].algo != (roar_hash_t)-1; i++)
-  if ( _libroar_hash_cmds[i].algo == ht )
-   return &(_libroar_hash_cmds[i]);
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-static inline int roar_ht2gcrypt_tested (const roar_hash_t ht) {
-#ifdef ROAR_HAVE_LIBGCRYPT
- const char * name;
-
- if ( ht > 512 )
-  return -1;
-
- // test the algo:
- name = gcry_md_algo_name(ht);
-
- if ( name == NULL )
-  return -1;
-
- if ( *name == 0 )
-  return -1;
-
- return ht;
-#else
- return -1;
-#endif
-}
-
-const char * roar_ht2str (const roar_hash_t  ht) {
- int i;
-
- for (i = 0; _libroar_hashes[i].id != (roar_hash_t)-1; i++)
-  if ( _libroar_hashes[i].id == ht )
-   return _libroar_hashes[i].name;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-roar_hash_t      roar_str2ht (const char * ht) {
- int i;
-
- for (i = 0; _libroar_hashes[i].id != (roar_hash_t)-1; i++)
-  if ( !strcasecmp(_libroar_hashes[i].name, ht) )
-   return _libroar_hashes[i].id;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-ssize_t      roar_ht_digestlen (const roar_hash_t   ht) {
- int i;
-
- for (i = 0; _libroar_hashes[i].id != (uint_least32_t)-1; i++)
-  if ( _libroar_hashes[i].id == ht )
-   return _libroar_hashes[i].dlen;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-static void _bin2hex(char * out, char * in, size_t inlen, int uppercase) {
- const char * tab = uppercase ? "0123456789ABCDEF" : "0123456789abcdef";
- unsigned char c;
- int nib0, nib1;
-
- for (; inlen; inlen--) {
-  c = *(in++);
-  nib0 = (c & 0x0F) >> 0;
-  nib1 = (c & 0xF0) >> 4;
-//  printf("inlen=%zu, c=%u, nibs={%i, %i}\n", inlen, (unsigned)c, nib1, nib0);
-  *(out++) = tab[nib1];
-  *(out++) = tab[nib0];
- }
- *out = 0;
-}
-
-ssize_t      roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, roar_hash_t ht) {
- ssize_t slen = roar_ht_digestlen(ht);
- union {
-  long long int llsi;
- } tmp;
- enum {
-  HEX,
-  TIGER,
-//  BASE64,
-  UUID,
-  INT,
-  GTIN
- } type = HEX;
-
- if ( out == NULL || digest == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( !(slen == -1 || (ssize_t)digestlen == slen) ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- switch (ht) {
-  case ROAR_HT_TIGER: type = TIGER; break;
-  case ROAR_HT_UUID:  type = UUID;  break;
-  case ROAR_HT_CLIENTID:
-  case ROAR_HT_STREAMID:
-  case ROAR_HT_SOURCEID:
-  case ROAR_HT_SAMPLEID:
-  case ROAR_HT_MIXERID:
-  case ROAR_HT_BRIDGEID:
-  case ROAR_HT_LISTENID:
-  case ROAR_HT_ACTIONID:
-  case ROAR_HT_MSGQUEUEID:
-  case ROAR_HT_MSGBUSID:
-    type = INT;
-   break;
-  case ROAR_HT_GTIN8:
-  case ROAR_HT_GTIN13:
-  case ROAR_HT_ISBN10:
-    type = GTIN;
-   break;
- }
-
- switch (type) {
-  case HEX:
-    if ( outlen < (digestlen*2 + 1) ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-    _bin2hex(out, digest, digestlen, 0);
-   break;
-  case UUID:
-    if ( outlen < 37 || digestlen != 16 ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-    _bin2hex(out+ 0, digest+ 0, 4, 0);
-    out[ 8] = '-';
-    _bin2hex(out+ 9, digest+ 4, 2, 0);
-    out[13] = '-';
-    _bin2hex(out+14, digest+ 6, 2, 0);
-    out[18] = '-';
-    _bin2hex(out+19, digest+ 8, 2, 0);
-    out[23] = '-';
-    _bin2hex(out+24, digest+10, 6, 0);
-//    printf("%s\n", out+24);
-   break;
-  case TIGER:
-    if ( outlen < 51 || digestlen != 24 ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-    _bin2hex(out+ 0, digest+ 0, 8, 1);
-    out[16] = ' ';
-    _bin2hex(out+17, digest+ 8, 8, 1);
-    out[33] = ' ';
-    _bin2hex(out+34, digest+16, 8, 1);
-   break;
-  case INT:
-    switch (digestlen) {
-     case 1:
-       tmp.llsi = *(_LIBROAR_GOOD_CAST char*)digest;
-      break;
-     case 2:
-       tmp.llsi = ROAR_NET2HOST16(*(int16_t*)digest);
-      break;
-     case 4:
-       tmp.llsi = ROAR_NET2HOST32(*(int32_t*)digest);
-      break;
-     default:
-       roar_err_set(ROAR_ERROR_NOSYS);
-       return -1;
-      break;
-    }
-    snprintf(out, outlen-1, "%" LIBROAR__ll "i", (LIBROAR__longlong int)tmp.llsi);
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOSYS);
-    return -1;
- }
-
- out[outlen-1] = 0;
- return roar_mm_strlen(out);
-}
-
-int          roar_ht_is_supported(const roar_hash_t ht) {
- roar_crypto_init();
-
- if ( roar_ht2cmds(ht) != NULL )
-  return 1;
-
-#ifdef ROAR_HAVE_LIBGCRYPT
- if ( roar_ht2gcrypt_tested(ht) == -1 )
-  return 0;
-
- return 1;
-#else
- return 0;
-#endif
-}
-
-struct roar_hash_state * roar_hash_new(roar_hash_t algo) {
- struct roar_hash_cmds  * cmds = roar_ht2cmds(algo);
- struct roar_hash_state * self;
-
- if ( cmds == NULL )
-  return NULL;
-
- self = roar_mm_malloc(sizeof(struct roar_hash_state));
-
- if ( self == NULL )
-  return NULL;
-
- memset(self, 0, sizeof(struct roar_hash_state));
-
- self->cmds = cmds;
-
- self->state = roar_mm_malloc(cmds->statelen);
-
- if ( self->state == NULL ) {
-  roar_mm_free(self);
-  return NULL;
- }
-
- memset(self->state, 0, cmds->statelen);
-
- if ( cmds->init != NULL ) {
-  if ( cmds->init(self->state) == -1 ) {
-   roar_mm_free(self->state);
-   roar_mm_free(self);
-   return NULL;
-  }
- }
-
- return self;
-}
-
-int roar_hash_free(struct roar_hash_state * state) {
- int ret = 0;
-
- if ( state == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( state->cmds->uninit != NULL )
-  ret = state->cmds->uninit(state->state);
-
- // clear crypto data.
- memset(state->state, 0, state->cmds->statelen);
- roar_mm_free(state->state);
-
- memset(state, 0, sizeof(struct roar_hash_state));
- roar_mm_free(state);
-
- return ret;
-}
-
-int roar_hash_digest(struct roar_hash_state * state, void * digest, size_t * len) {
- if ( state == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( state->cmds->digest == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- return state->cmds->digest(state->state, digest, len);
-}
-
-int roar_hash_proc(struct roar_hash_state * state, const void * data, size_t len) {
- if ( state == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( state->cmds->proc == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- return state->cmds->proc(state->state, data, len);
-}
-
-int roar_hash_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo) {
- roar_crypto_init();
-
- return roar_hash_salted_buffer(digest, data, datalen, algo, NULL, 0);
-}
-
-#ifdef ROAR_HAVE_LIBGCRYPT
-static inline int roar_hash_salted_buffer_gcrypt(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen) {
- gcry_md_hd_t hdl;
-
- roar_crypto_init();
-
- algo = roar_ht2gcrypt_tested(algo);
- if ( algo == (roar_hash_t)-1 )
-  return -1;
-
-
- if ( salt == NULL ) {
-  // optimized for unsalted:
-  gcry_md_hash_buffer(algo, digest, data, datalen);
-  return 0;
- } else {
-  if ( gcry_md_open(&hdl, algo, 0) != 0 )
-   return -1;
-
-  gcry_md_write(hdl, data, datalen);
-  gcry_md_write(hdl, salt, saltlen);
-
-  memcpy(digest, gcry_md_read(hdl, algo), gcry_md_get_algo_dlen(algo));
-
-  gcry_md_close(hdl);
- }
-
- return 0;
-}
-#endif
-
-int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen) {
- struct roar_hash_state * state;
- size_t len;
- int ret = 0;
-
- ROAR_DBG("roar_hash_salted_buffer(digest=%p, data=%p, datalen=%llu, algo=%i, salt=%p, saltlen=%llu) = ?", digest, data, (unsigned long long int)datalen, algo, salt, (unsigned long long int)saltlen);
-
- if ( digest == NULL || data == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- len = roar_ht_digestlen(algo);
- if ( len == (size_t)-1 ) /* this is a hack to avoid len to be of type ssize_t which breaks following code */
-  return -1;
-
- if ( (state = roar_hash_new(algo)) != NULL ) {
-  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret);
-
-  if ( roar_hash_proc(state, data, datalen) == -1 )
-   ret = -1;
-
-  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret);
-
-  if ( saltlen != 0 )
-   if ( roar_hash_proc(state, salt, saltlen) == -1 )
-    ret = -1;
-
-  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret);
-
-  if ( roar_hash_digest(state, digest, &len) == -1 )
-   ret = -1;
-
-  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret);
-
-  if ( roar_hash_free(state) == -1 )
-   ret = -1;
-
-  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret);
-
-  return ret;
- }
-
- ROAR_DBG("roar_hash_salted_buffer(*): state=%p", state);
-
-#ifdef ROAR_HAVE_LIBGCRYPT
- return roar_hash_salted_buffer_gcrypt(digest, data, datalen, algo, salt, saltlen);
-#else
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-#endif
-}
-
-//ll
Index: libroar/hash_sha1.c
===================================================================
--- libroar/hash_sha1.c	(revision 6052)
+++ 	(revision )
@@ -1,268 +1,0 @@
-//hashh_sha1.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2015
- *      Copyright (C) Steve Reid <steve@edmweb.com>
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define SHA1_BLOCK_LENGTH               64
-#define SHA1_DIGEST_LENGTH              20
-#define SHA1_DIGEST_STRING_LENGTH       (SHA1_DIGEST_LENGTH * 2 + 1)
-
-union uint864uint3216 {
- uint8_t c[64];
- uint32_t l[16];
-};
-
-int roar_hash_sha1_proc(void * state, const void * data, size_t len);
-
-
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-/*
- * blk0() and blk() perform the initial expand.
- * I got the idea of expanding during the round function from SSLeay
- */
-#if BYTE_ORDER == LITTLE_ENDIAN
-# define blk0(i) (compblock->l[i] = (rol(compblock->l[i],24)&0xFF00FF00) \
-    |(rol(compblock->l[i],8)&0x00FF00FF))
-#else
-# define blk0(i) compblock->l[i]
-#endif
-#define blk(i) (compblock->l[i&15] = rol(compblock->l[(i+13)&15]^compblock->l[(i+8)&15] \
-    ^compblock->l[(i+2)&15]^compblock->l[i&15],1))
-
-/*
- * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
- */
-#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
-
-int roar_hash_sha1_init(void * state) {
- struct roar_hash_sha1 * context = state;
-
- if ( state == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(context, 0, sizeof(struct roar_hash_sha1));
-
- context->state[0] = 0x67452301;
- context->state[1] = 0xEFCDAB89;
- context->state[2] = 0x98BADCFE;
- context->state[3] = 0x10325476;
- context->state[4] = 0xC3D2E1F0;
-
- return 0;
-}
-
-int roar_hash_sha1_uninit(void * state) {
- (void)state;
- return 0;
-}
-
-int roar_hash_sha1_digest(void * state, void * digest, size_t * len) {
- struct roar_hash_sha1 * context = state;
- uint64_t count;
- int i;
-
- if ( state == NULL || digest == NULL || len == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( context->is_final ) {
-  roar_err_set(ROAR_ERROR_BUSY);
-  return -1;
- }
-
- if ( *len < SHA1_DIGEST_LENGTH ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- *len = SHA1_DIGEST_LENGTH;
-
- context->count *= 8;
- count = ROAR_HOST2NET64(context->count);
-
- roar_hash_sha1_proc(state, "\200", 1);
-
- // TODO: make this calc the correct length directly.
- // this is inefficent.
- while (context->in_buffer != (SHA1_BLOCK_LENGTH - 8)) {
-  ROAR_DBG("roar_hash_sha1_digest(state=%p, digest=%p, len=%p): context->in_buffer = %i", state, digest, len, (int)context->in_buffer);
-  roar_hash_sha1_proc(state, "\0", 1);
- }
-
- roar_hash_sha1_proc(state, &count, 8);
-
-
- for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
-  ((uint8_t *)digest)[i] = (uint8_t)((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
- }
-
- memset(context, 0, sizeof(struct roar_hash_sha1));
- context->is_final = 1;
-
- return 0;
-}
-
-int roar_hash_sha1_proc_block(void * state, const void * block) {
- struct roar_hash_sha1 * context = state;
- uint32_t a, b, c, d, e;
- uint8_t workspace[SHA1_BLOCK_LENGTH];
- union uint864uint3216 * compblock = (union uint864uint3216 *)(void*)workspace;
-
- if ( state == NULL || block == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( context->is_final ) {
-  roar_err_set(ROAR_ERROR_BUSY);
-  return -1;
- }
-
- if ( context->in_buffer ) {
-  return roar_hash_sha1_proc(state, block, SHA1_BLOCK_LENGTH);
- }
-
- memcpy(compblock, block, SHA1_BLOCK_LENGTH);
-
- /* Copy context->state[] to working vars */
- a = context->state[0];
- b = context->state[1];
- c = context->state[2];
- d = context->state[3];
- e = context->state[4];
-
- /* 4 rounds of 20 operations each. Loop unrolled. */
- R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
- R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
- R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
- R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
- R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
- R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
- R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
- R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
- R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
- R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
- R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
- R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
- R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
- R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
- R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
- R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
- R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
- R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
- R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
- R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
-
- /* Add the working vars back into context.state[] */
- context->state[0] += a;
- context->state[1] += b;
- context->state[2] += c;
- context->state[3] += d;
- context->state[4] += e;
-
- /* Wipe variables */
- a = b = c = d = e = 0;
-
- return 0;
-}
-
-int roar_hash_sha1_proc(void * state, const void * data, size_t len) {
- struct roar_hash_sha1 * context = state;
- size_t buflen;
-
- ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-
- if ( state == NULL || data == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( context->is_final ) {
-  roar_err_set(ROAR_ERROR_BUSY);
-  return -1;
- }
-
- ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-
- context->count += len;
-
- if ( context->in_buffer ) {
-  ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-  buflen = len > (SHA1_BLOCK_LENGTH - context->in_buffer) ? SHA1_BLOCK_LENGTH - context->in_buffer : len;
-  memcpy(context->buffer + context->in_buffer, data, buflen);
-  context->in_buffer += buflen;
-  if ( context->in_buffer == SHA1_BLOCK_LENGTH ) {
-   ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-   context->in_buffer = 0;
-   roar_hash_sha1_proc_block(state, context->buffer);
-  } else {
-   ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = 0", state, data, (long long unsigned int)len);
-   return 0;
-  }
-
-  len  -= buflen;
-  data += buflen;
- }
-
- ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-
- while (len >= SHA1_BLOCK_LENGTH) {
-  ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-  roar_hash_sha1_proc_block(state, data);
-  len  -= SHA1_BLOCK_LENGTH;
-  data += SHA1_BLOCK_LENGTH;
- }
-
- ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-
- if ( len ) {
-  memcpy(context->buffer, data, len);
-  context->in_buffer = len;
- }
-
- ROAR_DBG("roar_hash_sha1_proc(state=%p, data=%p, len=%llu) = 0", state, data, (long long unsigned int)len);
- return 0;
-}
-
-//ll
Index: libroar/hash_tiger.c
===================================================================
--- libroar/hash_tiger.c	(revision 6052)
+++ 	(revision )
@@ -1,895 +1,0 @@
-//hash_tiger.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define STATE_LEN (3*8)
-#define PSTATE_LEN (4*8)
-#define DIGEST_LEN STATE_LEN
-#define BLOCK_LEN (64)
-
-static uint64_t table[4*256] = {
- 0x02AAB17CF7E90C5ELLU   /*    0 */,    0xAC424B03E243A8ECLLU   /*    1 */,
- 0x72CD5BE30DD5FCD3LLU   /*    2 */,    0x6D019B93F6F97F3ALLU   /*    3 */,
- 0xCD9978FFD21F9193LLU   /*    4 */,    0x7573A1C9708029E2LLU   /*    5 */,
- 0xB164326B922A83C3LLU   /*    6 */,    0x46883EEE04915870LLU   /*    7 */,
- 0xEAACE3057103ECE6LLU   /*    8 */,    0xC54169B808A3535CLLU   /*    9 */,
- 0x4CE754918DDEC47CLLU   /*   10 */,    0x0AA2F4DFDC0DF40CLLU   /*   11 */,
- 0x10B76F18A74DBEFALLU   /*   12 */,    0xC6CCB6235AD1AB6ALLU   /*   13 */,
- 0x13726121572FE2FFLLU   /*   14 */,    0x1A488C6F199D921ELLU   /*   15 */,
- 0x4BC9F9F4DA0007CALLU   /*   16 */,    0x26F5E6F6E85241C7LLU   /*   17 */,
- 0x859079DBEA5947B6LLU   /*   18 */,    0x4F1885C5C99E8C92LLU   /*   19 */,
- 0xD78E761EA96F864BLLU   /*   20 */,    0x8E36428C52B5C17DLLU   /*   21 */,
- 0x69CF6827373063C1LLU   /*   22 */,    0xB607C93D9BB4C56ELLU   /*   23 */,
- 0x7D820E760E76B5EALLU   /*   24 */,    0x645C9CC6F07FDC42LLU   /*   25 */,
- 0xBF38A078243342E0LLU   /*   26 */,    0x5F6B343C9D2E7D04LLU   /*   27 */,
- 0xF2C28AEB600B0EC6LLU   /*   28 */,    0x6C0ED85F7254BCACLLU   /*   29 */,
- 0x71592281A4DB4FE5LLU   /*   30 */,    0x1967FA69CE0FED9FLLU   /*   31 */,
- 0xFD5293F8B96545DBLLU   /*   32 */,    0xC879E9D7F2A7600BLLU   /*   33 */,
- 0x860248920193194ELLU   /*   34 */,    0xA4F9533B2D9CC0B3LLU   /*   35 */,
- 0x9053836C15957613LLU   /*   36 */,    0xDB6DCF8AFC357BF1LLU   /*   37 */,
- 0x18BEEA7A7A370F57LLU   /*   38 */,    0x037117CA50B99066LLU   /*   39 */,
- 0x6AB30A9774424A35LLU   /*   40 */,    0xF4E92F02E325249BLLU   /*   41 */,
- 0x7739DB07061CCAE1LLU   /*   42 */,    0xD8F3B49CECA42A05LLU   /*   43 */,
- 0xBD56BE3F51382F73LLU   /*   44 */,    0x45FAED5843B0BB28LLU   /*   45 */,
- 0x1C813D5C11BF1F83LLU   /*   46 */,    0x8AF0E4B6D75FA169LLU   /*   47 */,
- 0x33EE18A487AD9999LLU   /*   48 */,    0x3C26E8EAB1C94410LLU   /*   49 */,
- 0xB510102BC0A822F9LLU   /*   50 */,    0x141EEF310CE6123BLLU   /*   51 */,
- 0xFC65B90059DDB154LLU   /*   52 */,    0xE0158640C5E0E607LLU   /*   53 */,
- 0x884E079826C3A3CFLLU   /*   54 */,    0x930D0D9523C535FDLLU   /*   55 */,
- 0x35638D754E9A2B00LLU   /*   56 */,    0x4085FCCF40469DD5LLU   /*   57 */,
- 0xC4B17AD28BE23A4CLLU   /*   58 */,    0xCAB2F0FC6A3E6A2ELLU   /*   59 */,
- 0x2860971A6B943FCDLLU   /*   60 */,    0x3DDE6EE212E30446LLU   /*   61 */,
- 0x6222F32AE01765AELLU   /*   62 */,    0x5D550BB5478308FELLU   /*   63 */,
- 0xA9EFA98DA0EDA22ALLU   /*   64 */,    0xC351A71686C40DA7LLU   /*   65 */,
- 0x1105586D9C867C84LLU   /*   66 */,    0xDCFFEE85FDA22853LLU   /*   67 */,
- 0xCCFBD0262C5EEF76LLU   /*   68 */,    0xBAF294CB8990D201LLU   /*   69 */,
- 0xE69464F52AFAD975LLU   /*   70 */,    0x94B013AFDF133E14LLU   /*   71 */,
- 0x06A7D1A32823C958LLU   /*   72 */,    0x6F95FE5130F61119LLU   /*   73 */,
- 0xD92AB34E462C06C0LLU   /*   74 */,    0xED7BDE33887C71D2LLU   /*   75 */,
- 0x79746D6E6518393ELLU   /*   76 */,    0x5BA419385D713329LLU   /*   77 */,
- 0x7C1BA6B948A97564LLU   /*   78 */,    0x31987C197BFDAC67LLU   /*   79 */,
- 0xDE6C23C44B053D02LLU   /*   80 */,    0x581C49FED002D64DLLU   /*   81 */,
- 0xDD474D6338261571LLU   /*   82 */,    0xAA4546C3E473D062LLU   /*   83 */,
- 0x928FCE349455F860LLU   /*   84 */,    0x48161BBACAAB94D9LLU   /*   85 */,
- 0x63912430770E6F68LLU   /*   86 */,    0x6EC8A5E602C6641CLLU   /*   87 */,
- 0x87282515337DDD2BLLU   /*   88 */,    0x2CDA6B42034B701BLLU   /*   89 */,
- 0xB03D37C181CB096DLLU   /*   90 */,    0xE108438266C71C6FLLU   /*   91 */,
- 0x2B3180C7EB51B255LLU   /*   92 */,    0xDF92B82F96C08BBCLLU   /*   93 */,
- 0x5C68C8C0A632F3BALLU   /*   94 */,    0x5504CC861C3D0556LLU   /*   95 */,
- 0xABBFA4E55FB26B8FLLU   /*   96 */,    0x41848B0AB3BACEB4LLU   /*   97 */,
- 0xB334A273AA445D32LLU   /*   98 */,    0xBCA696F0A85AD881LLU   /*   99 */,
- 0x24F6EC65B528D56CLLU   /*  100 */,    0x0CE1512E90F4524ALLU   /*  101 */,
- 0x4E9DD79D5506D35ALLU   /*  102 */,    0x258905FAC6CE9779LLU   /*  103 */,
- 0x2019295B3E109B33LLU   /*  104 */,    0xF8A9478B73A054CCLLU   /*  105 */,
- 0x2924F2F934417EB0LLU   /*  106 */,    0x3993357D536D1BC4LLU   /*  107 */,
- 0x38A81AC21DB6FF8BLLU   /*  108 */,    0x47C4FBF17D6016BFLLU   /*  109 */,
- 0x1E0FAADD7667E3F5LLU   /*  110 */,    0x7ABCFF62938BEB96LLU   /*  111 */,
- 0xA78DAD948FC179C9LLU   /*  112 */,    0x8F1F98B72911E50DLLU   /*  113 */,
- 0x61E48EAE27121A91LLU   /*  114 */,    0x4D62F7AD31859808LLU   /*  115 */,
- 0xECEBA345EF5CEAEBLLU   /*  116 */,    0xF5CEB25EBC9684CELLU   /*  117 */,
- 0xF633E20CB7F76221LLU   /*  118 */,    0xA32CDF06AB8293E4LLU   /*  119 */,
- 0x985A202CA5EE2CA4LLU   /*  120 */,    0xCF0B8447CC8A8FB1LLU   /*  121 */,
- 0x9F765244979859A3LLU   /*  122 */,    0xA8D516B1A1240017LLU   /*  123 */,
- 0x0BD7BA3EBB5DC726LLU   /*  124 */,    0xE54BCA55B86ADB39LLU   /*  125 */,
- 0x1D7A3AFD6C478063LLU   /*  126 */,    0x519EC608E7669EDDLLU   /*  127 */,
- 0x0E5715A2D149AA23LLU   /*  128 */,    0x177D4571848FF194LLU   /*  129 */,
- 0xEEB55F3241014C22LLU   /*  130 */,    0x0F5E5CA13A6E2EC2LLU   /*  131 */,
- 0x8029927B75F5C361LLU   /*  132 */,    0xAD139FABC3D6E436LLU   /*  133 */,
- 0x0D5DF1A94CCF402FLLU   /*  134 */,    0x3E8BD948BEA5DFC8LLU   /*  135 */,
- 0xA5A0D357BD3FF77ELLU   /*  136 */,    0xA2D12E251F74F645LLU   /*  137 */,
- 0x66FD9E525E81A082LLU   /*  138 */,    0x2E0C90CE7F687A49LLU   /*  139 */,
- 0xC2E8BCBEBA973BC5LLU   /*  140 */,    0x000001BCE509745FLLU   /*  141 */,
- 0x423777BBE6DAB3D6LLU   /*  142 */,    0xD1661C7EAEF06EB5LLU   /*  143 */,
- 0xA1781F354DAACFD8LLU   /*  144 */,    0x2D11284A2B16AFFCLLU   /*  145 */,
- 0xF1FC4F67FA891D1FLLU   /*  146 */,    0x73ECC25DCB920ADALLU   /*  147 */,
- 0xAE610C22C2A12651LLU   /*  148 */,    0x96E0A810D356B78ALLU   /*  149 */,
- 0x5A9A381F2FE7870FLLU   /*  150 */,    0xD5AD62EDE94E5530LLU   /*  151 */,
- 0xD225E5E8368D1427LLU   /*  152 */,    0x65977B70C7AF4631LLU   /*  153 */,
- 0x99F889B2DE39D74FLLU   /*  154 */,    0x233F30BF54E1D143LLU   /*  155 */,
- 0x9A9675D3D9A63C97LLU   /*  156 */,    0x5470554FF334F9A8LLU   /*  157 */,
- 0x166ACB744A4F5688LLU   /*  158 */,    0x70C74CAAB2E4AEADLLU   /*  159 */,
- 0xF0D091646F294D12LLU   /*  160 */,    0x57B82A89684031D1LLU   /*  161 */,
- 0xEFD95A5A61BE0B6BLLU   /*  162 */,    0x2FBD12E969F2F29ALLU   /*  163 */,
- 0x9BD37013FEFF9FE8LLU   /*  164 */,    0x3F9B0404D6085A06LLU   /*  165 */,
- 0x4940C1F3166CFE15LLU   /*  166 */,    0x09542C4DCDF3DEFBLLU   /*  167 */,
- 0xB4C5218385CD5CE3LLU   /*  168 */,    0xC935B7DC4462A641LLU   /*  169 */,
- 0x3417F8A68ED3B63FLLU   /*  170 */,    0xB80959295B215B40LLU   /*  171 */,
- 0xF99CDAEF3B8C8572LLU   /*  172 */,    0x018C0614F8FCB95DLLU   /*  173 */,
- 0x1B14ACCD1A3ACDF3LLU   /*  174 */,    0x84D471F200BB732DLLU   /*  175 */,
- 0xC1A3110E95E8DA16LLU   /*  176 */,    0x430A7220BF1A82B8LLU   /*  177 */,
- 0xB77E090D39DF210ELLU   /*  178 */,    0x5EF4BD9F3CD05E9DLLU   /*  179 */,
- 0x9D4FF6DA7E57A444LLU   /*  180 */,    0xDA1D60E183D4A5F8LLU   /*  181 */,
- 0xB287C38417998E47LLU   /*  182 */,    0xFE3EDC121BB31886LLU   /*  183 */,
- 0xC7FE3CCC980CCBEFLLU   /*  184 */,    0xE46FB590189BFD03LLU   /*  185 */,
- 0x3732FD469A4C57DCLLU   /*  186 */,    0x7EF700A07CF1AD65LLU   /*  187 */,
- 0x59C64468A31D8859LLU   /*  188 */,    0x762FB0B4D45B61F6LLU   /*  189 */,
- 0x155BAED099047718LLU   /*  190 */,    0x68755E4C3D50BAA6LLU   /*  191 */,
- 0xE9214E7F22D8B4DFLLU   /*  192 */,    0x2ADDBF532EAC95F4LLU   /*  193 */,
- 0x32AE3909B4BD0109LLU   /*  194 */,    0x834DF537B08E3450LLU   /*  195 */,
- 0xFA209DA84220728DLLU   /*  196 */,    0x9E691D9B9EFE23F7LLU   /*  197 */,
- 0x0446D288C4AE8D7FLLU   /*  198 */,    0x7B4CC524E169785BLLU   /*  199 */,
- 0x21D87F0135CA1385LLU   /*  200 */,    0xCEBB400F137B8AA5LLU   /*  201 */,
- 0x272E2B66580796BELLU   /*  202 */,    0x3612264125C2B0DELLU   /*  203 */,
- 0x057702BDAD1EFBB2LLU   /*  204 */,    0xD4BABB8EACF84BE9LLU   /*  205 */,
- 0x91583139641BC67BLLU   /*  206 */,    0x8BDC2DE08036E024LLU   /*  207 */,
- 0x603C8156F49F68EDLLU   /*  208 */,    0xF7D236F7DBEF5111LLU   /*  209 */,
- 0x9727C4598AD21E80LLU   /*  210 */,    0xA08A0896670A5FD7LLU   /*  211 */,
- 0xCB4A8F4309EBA9CBLLU   /*  212 */,    0x81AF564B0F7036A1LLU   /*  213 */,
- 0xC0B99AA778199ABDLLU   /*  214 */,    0x959F1EC83FC8E952LLU   /*  215 */,
- 0x8C505077794A81B9LLU   /*  216 */,    0x3ACAAF8F056338F0LLU   /*  217 */,
- 0x07B43F50627A6778LLU   /*  218 */,    0x4A44AB49F5ECCC77LLU   /*  219 */,
- 0x3BC3D6E4B679EE98LLU   /*  220 */,    0x9CC0D4D1CF14108CLLU   /*  221 */,
- 0x4406C00B206BC8A0LLU   /*  222 */,    0x82A18854C8D72D89LLU   /*  223 */,
- 0x67E366B35C3C432CLLU   /*  224 */,    0xB923DD61102B37F2LLU   /*  225 */,
- 0x56AB2779D884271DLLU   /*  226 */,    0xBE83E1B0FF1525AFLLU   /*  227 */,
- 0xFB7C65D4217E49A9LLU   /*  228 */,    0x6BDBE0E76D48E7D4LLU   /*  229 */,
- 0x08DF828745D9179ELLU   /*  230 */,    0x22EA6A9ADD53BD34LLU   /*  231 */,
- 0xE36E141C5622200ALLU   /*  232 */,    0x7F805D1B8CB750EELLU   /*  233 */,
- 0xAFE5C7A59F58E837LLU   /*  234 */,    0xE27F996A4FB1C23CLLU   /*  235 */,
- 0xD3867DFB0775F0D0LLU   /*  236 */,    0xD0E673DE6E88891ALLU   /*  237 */,
- 0x123AEB9EAFB86C25LLU   /*  238 */,    0x30F1D5D5C145B895LLU   /*  239 */,
- 0xBB434A2DEE7269E7LLU   /*  240 */,    0x78CB67ECF931FA38LLU   /*  241 */,
- 0xF33B0372323BBF9CLLU   /*  242 */,    0x52D66336FB279C74LLU   /*  243 */,
- 0x505F33AC0AFB4EAALLU   /*  244 */,    0xE8A5CD99A2CCE187LLU   /*  245 */,
- 0x534974801E2D30BBLLU   /*  246 */,    0x8D2D5711D5876D90LLU   /*  247 */,
- 0x1F1A412891BC038ELLU   /*  248 */,    0xD6E2E71D82E56648LLU   /*  249 */,
- 0x74036C3A497732B7LLU   /*  250 */,    0x89B67ED96361F5ABLLU   /*  251 */,
- 0xFFED95D8F1EA02A2LLU   /*  252 */,    0xE72B3BD61464D43DLLU   /*  253 */,
- 0xA6300F170BDC4820LLU   /*  254 */,    0xEBC18760ED78A77ALLU   /*  255 */,
- 0xE6A6BE5A05A12138LLU   /*  256 */,    0xB5A122A5B4F87C98LLU   /*  257 */,
- 0x563C6089140B6990LLU   /*  258 */,    0x4C46CB2E391F5DD5LLU   /*  259 */,
- 0xD932ADDBC9B79434LLU   /*  260 */,    0x08EA70E42015AFF5LLU   /*  261 */,
- 0xD765A6673E478CF1LLU   /*  262 */,    0xC4FB757EAB278D99LLU   /*  263 */,
- 0xDF11C6862D6E0692LLU   /*  264 */,    0xDDEB84F10D7F3B16LLU   /*  265 */,
- 0x6F2EF604A665EA04LLU   /*  266 */,    0x4A8E0F0FF0E0DFB3LLU   /*  267 */,
- 0xA5EDEEF83DBCBA51LLU   /*  268 */,    0xFC4F0A2A0EA4371ELLU   /*  269 */,
- 0xE83E1DA85CB38429LLU   /*  270 */,    0xDC8FF882BA1B1CE2LLU   /*  271 */,
- 0xCD45505E8353E80DLLU   /*  272 */,    0x18D19A00D4DB0717LLU   /*  273 */,
- 0x34A0CFEDA5F38101LLU   /*  274 */,    0x0BE77E518887CAF2LLU   /*  275 */,
- 0x1E341438B3C45136LLU   /*  276 */,    0xE05797F49089CCF9LLU   /*  277 */,
- 0xFFD23F9DF2591D14LLU   /*  278 */,    0x543DDA228595C5CDLLU   /*  279 */,
- 0x661F81FD99052A33LLU   /*  280 */,    0x8736E641DB0F7B76LLU   /*  281 */,
- 0x15227725418E5307LLU   /*  282 */,    0xE25F7F46162EB2FALLU   /*  283 */,
- 0x48A8B2126C13D9FELLU   /*  284 */,    0xAFDC541792E76EEALLU   /*  285 */,
- 0x03D912BFC6D1898FLLU   /*  286 */,    0x31B1AAFA1B83F51BLLU   /*  287 */,
- 0xF1AC2796E42AB7D9LLU   /*  288 */,    0x40A3A7D7FCD2EBACLLU   /*  289 */,
- 0x1056136D0AFBBCC5LLU   /*  290 */,    0x7889E1DD9A6D0C85LLU   /*  291 */,
- 0xD33525782A7974AALLU   /*  292 */,    0xA7E25D09078AC09BLLU   /*  293 */,
- 0xBD4138B3EAC6EDD0LLU   /*  294 */,    0x920ABFBE71EB9E70LLU   /*  295 */,
- 0xA2A5D0F54FC2625CLLU   /*  296 */,    0xC054E36B0B1290A3LLU   /*  297 */,
- 0xF6DD59FF62FE932BLLU   /*  298 */,    0x3537354511A8AC7DLLU   /*  299 */,
- 0xCA845E9172FADCD4LLU   /*  300 */,    0x84F82B60329D20DCLLU   /*  301 */,
- 0x79C62CE1CD672F18LLU   /*  302 */,    0x8B09A2ADD124642CLLU   /*  303 */,
- 0xD0C1E96A19D9E726LLU   /*  304 */,    0x5A786A9B4BA9500CLLU   /*  305 */,
- 0x0E020336634C43F3LLU   /*  306 */,    0xC17B474AEB66D822LLU   /*  307 */,
- 0x6A731AE3EC9BAAC2LLU   /*  308 */,    0x8226667AE0840258LLU   /*  309 */,
- 0x67D4567691CAECA5LLU   /*  310 */,    0x1D94155C4875ADB5LLU   /*  311 */,
- 0x6D00FD985B813FDFLLU   /*  312 */,    0x51286EFCB774CD06LLU   /*  313 */,
- 0x5E8834471FA744AFLLU   /*  314 */,    0xF72CA0AEE761AE2ELLU   /*  315 */,
- 0xBE40E4CDAEE8E09ALLU   /*  316 */,    0xE9970BBB5118F665LLU   /*  317 */,
- 0x726E4BEB33DF1964LLU   /*  318 */,    0x703B000729199762LLU   /*  319 */,
- 0x4631D816F5EF30A7LLU   /*  320 */,    0xB880B5B51504A6BELLU   /*  321 */,
- 0x641793C37ED84B6CLLU   /*  322 */,    0x7B21ED77F6E97D96LLU   /*  323 */,
- 0x776306312EF96B73LLU   /*  324 */,    0xAE528948E86FF3F4LLU   /*  325 */,
- 0x53DBD7F286A3F8F8LLU   /*  326 */,    0x16CADCE74CFC1063LLU   /*  327 */,
- 0x005C19BDFA52C6DDLLU   /*  328 */,    0x68868F5D64D46AD3LLU   /*  329 */,
- 0x3A9D512CCF1E186ALLU   /*  330 */,    0x367E62C2385660AELLU   /*  331 */,
- 0xE359E7EA77DCB1D7LLU   /*  332 */,    0x526C0773749ABE6ELLU   /*  333 */,
- 0x735AE5F9D09F734BLLU   /*  334 */,    0x493FC7CC8A558BA8LLU   /*  335 */,
- 0xB0B9C1533041AB45LLU   /*  336 */,    0x321958BA470A59BDLLU   /*  337 */,
- 0x852DB00B5F46C393LLU   /*  338 */,    0x91209B2BD336B0E5LLU   /*  339 */,
- 0x6E604F7D659EF19FLLU   /*  340 */,    0xB99A8AE2782CCB24LLU   /*  341 */,
- 0xCCF52AB6C814C4C7LLU   /*  342 */,    0x4727D9AFBE11727BLLU   /*  343 */,
- 0x7E950D0C0121B34DLLU   /*  344 */,    0x756F435670AD471FLLU   /*  345 */,
- 0xF5ADD442615A6849LLU   /*  346 */,    0x4E87E09980B9957ALLU   /*  347 */,
- 0x2ACFA1DF50AEE355LLU   /*  348 */,    0xD898263AFD2FD556LLU   /*  349 */,
- 0xC8F4924DD80C8FD6LLU   /*  350 */,    0xCF99CA3D754A173ALLU   /*  351 */,
- 0xFE477BACAF91BF3CLLU   /*  352 */,    0xED5371F6D690C12DLLU   /*  353 */,
- 0x831A5C285E687094LLU   /*  354 */,    0xC5D3C90A3708A0A4LLU   /*  355 */,
- 0x0F7F903717D06580LLU   /*  356 */,    0x19F9BB13B8FDF27FLLU   /*  357 */,
- 0xB1BD6F1B4D502843LLU   /*  358 */,    0x1C761BA38FFF4012LLU   /*  359 */,
- 0x0D1530C4E2E21F3BLLU   /*  360 */,    0x8943CE69A7372C8ALLU   /*  361 */,
- 0xE5184E11FEB5CE66LLU   /*  362 */,    0x618BDB80BD736621LLU   /*  363 */,
- 0x7D29BAD68B574D0BLLU   /*  364 */,    0x81BB613E25E6FE5BLLU   /*  365 */,
- 0x071C9C10BC07913FLLU   /*  366 */,    0xC7BEEB7909AC2D97LLU   /*  367 */,
- 0xC3E58D353BC5D757LLU   /*  368 */,    0xEB017892F38F61E8LLU   /*  369 */,
- 0xD4EFFB9C9B1CC21ALLU   /*  370 */,    0x99727D26F494F7ABLLU   /*  371 */,
- 0xA3E063A2956B3E03LLU   /*  372 */,    0x9D4A8B9A4AA09C30LLU   /*  373 */,
- 0x3F6AB7D500090FB4LLU   /*  374 */,    0x9CC0F2A057268AC0LLU   /*  375 */,
- 0x3DEE9D2DEDBF42D1LLU   /*  376 */,    0x330F49C87960A972LLU   /*  377 */,
- 0xC6B2720287421B41LLU   /*  378 */,    0x0AC59EC07C00369CLLU   /*  379 */,
- 0xEF4EAC49CB353425LLU   /*  380 */,    0xF450244EEF0129D8LLU   /*  381 */,
- 0x8ACC46E5CAF4DEB6LLU   /*  382 */,    0x2FFEAB63989263F7LLU   /*  383 */,
- 0x8F7CB9FE5D7A4578LLU   /*  384 */,    0x5BD8F7644E634635LLU   /*  385 */,
- 0x427A7315BF2DC900LLU   /*  386 */,    0x17D0C4AA2125261CLLU   /*  387 */,
- 0x3992486C93518E50LLU   /*  388 */,    0xB4CBFEE0A2D7D4C3LLU   /*  389 */,
- 0x7C75D6202C5DDD8DLLU   /*  390 */,    0xDBC295D8E35B6C61LLU   /*  391 */,
- 0x60B369D302032B19LLU   /*  392 */,    0xCE42685FDCE44132LLU   /*  393 */,
- 0x06F3DDB9DDF65610LLU   /*  394 */,    0x8EA4D21DB5E148F0LLU   /*  395 */,
- 0x20B0FCE62FCD496FLLU   /*  396 */,    0x2C1B912358B0EE31LLU   /*  397 */,
- 0xB28317B818F5A308LLU   /*  398 */,    0xA89C1E189CA6D2CFLLU   /*  399 */,
- 0x0C6B18576AAADBC8LLU   /*  400 */,    0xB65DEAA91299FAE3LLU   /*  401 */,
- 0xFB2B794B7F1027E7LLU   /*  402 */,    0x04E4317F443B5BEBLLU   /*  403 */,
- 0x4B852D325939D0A6LLU   /*  404 */,    0xD5AE6BEEFB207FFCLLU   /*  405 */,
- 0x309682B281C7D374LLU   /*  406 */,    0xBAE309A194C3B475LLU   /*  407 */,
- 0x8CC3F97B13B49F05LLU   /*  408 */,    0x98A9422FF8293967LLU   /*  409 */,
- 0x244B16B01076FF7CLLU   /*  410 */,    0xF8BF571C663D67EELLU   /*  411 */,
- 0x1F0D6758EEE30DA1LLU   /*  412 */,    0xC9B611D97ADEB9B7LLU   /*  413 */,
- 0xB7AFD5887B6C57A2LLU   /*  414 */,    0x6290AE846B984FE1LLU   /*  415 */,
- 0x94DF4CDEACC1A5FDLLU   /*  416 */,    0x058A5BD1C5483AFFLLU   /*  417 */,
- 0x63166CC142BA3C37LLU   /*  418 */,    0x8DB8526EB2F76F40LLU   /*  419 */,
- 0xE10880036F0D6D4ELLU   /*  420 */,    0x9E0523C9971D311DLLU   /*  421 */,
- 0x45EC2824CC7CD691LLU   /*  422 */,    0x575B8359E62382C9LLU   /*  423 */,
- 0xFA9E400DC4889995LLU   /*  424 */,    0xD1823ECB45721568LLU   /*  425 */,
- 0xDAFD983B8206082FLLU   /*  426 */,    0xAA7D29082386A8CBLLU   /*  427 */,
- 0x269FCD4403B87588LLU   /*  428 */,    0x1B91F5F728BDD1E0LLU   /*  429 */,
- 0xE4669F39040201F6LLU   /*  430 */,    0x7A1D7C218CF04ADELLU   /*  431 */,
- 0x65623C29D79CE5CELLU   /*  432 */,    0x2368449096C00BB1LLU   /*  433 */,
- 0xAB9BF1879DA503BALLU   /*  434 */,    0xBC23ECB1A458058ELLU   /*  435 */,
- 0x9A58DF01BB401ECCLLU   /*  436 */,    0xA070E868A85F143DLLU   /*  437 */,
- 0x4FF188307DF2239ELLU   /*  438 */,    0x14D565B41A641183LLU   /*  439 */,
- 0xEE13337452701602LLU   /*  440 */,    0x950E3DCF3F285E09LLU   /*  441 */,
- 0x59930254B9C80953LLU   /*  442 */,    0x3BF299408930DA6DLLU   /*  443 */,
- 0xA955943F53691387LLU   /*  444 */,    0xA15EDECAA9CB8784LLU   /*  445 */,
- 0x29142127352BE9A0LLU   /*  446 */,    0x76F0371FFF4E7AFBLLU   /*  447 */,
- 0x0239F450274F2228LLU   /*  448 */,    0xBB073AF01D5E868BLLU   /*  449 */,
- 0xBFC80571C10E96C1LLU   /*  450 */,    0xD267088568222E23LLU   /*  451 */,
- 0x9671A3D48E80B5B0LLU   /*  452 */,    0x55B5D38AE193BB81LLU   /*  453 */,
- 0x693AE2D0A18B04B8LLU   /*  454 */,    0x5C48B4ECADD5335FLLU   /*  455 */,
- 0xFD743B194916A1CALLU   /*  456 */,    0x2577018134BE98C4LLU   /*  457 */,
- 0xE77987E83C54A4ADLLU   /*  458 */,    0x28E11014DA33E1B9LLU   /*  459 */,
- 0x270CC59E226AA213LLU   /*  460 */,    0x71495F756D1A5F60LLU   /*  461 */,
- 0x9BE853FB60AFEF77LLU   /*  462 */,    0xADC786A7F7443DBFLLU   /*  463 */,
- 0x0904456173B29A82LLU   /*  464 */,    0x58BC7A66C232BD5ELLU   /*  465 */,
- 0xF306558C673AC8B2LLU   /*  466 */,    0x41F639C6B6C9772ALLU   /*  467 */,
- 0x216DEFE99FDA35DALLU   /*  468 */,    0x11640CC71C7BE615LLU   /*  469 */,
- 0x93C43694565C5527LLU   /*  470 */,    0xEA038E6246777839LLU   /*  471 */,
- 0xF9ABF3CE5A3E2469LLU   /*  472 */,    0x741E768D0FD312D2LLU   /*  473 */,
- 0x0144B883CED652C6LLU   /*  474 */,    0xC20B5A5BA33F8552LLU   /*  475 */,
- 0x1AE69633C3435A9DLLU   /*  476 */,    0x97A28CA4088CFDECLLU   /*  477 */,
- 0x8824A43C1E96F420LLU   /*  478 */,    0x37612FA66EEEA746LLU   /*  479 */,
- 0x6B4CB165F9CF0E5ALLU   /*  480 */,    0x43AA1C06A0ABFB4ALLU   /*  481 */,
- 0x7F4DC26FF162796BLLU   /*  482 */,    0x6CBACC8E54ED9B0FLLU   /*  483 */,
- 0xA6B7FFEFD2BB253ELLU   /*  484 */,    0x2E25BC95B0A29D4FLLU   /*  485 */,
- 0x86D6A58BDEF1388CLLU   /*  486 */,    0xDED74AC576B6F054LLU   /*  487 */,
- 0x8030BDBC2B45805DLLU   /*  488 */,    0x3C81AF70E94D9289LLU   /*  489 */,
- 0x3EFF6DDA9E3100DBLLU   /*  490 */,    0xB38DC39FDFCC8847LLU   /*  491 */,
- 0x123885528D17B87ELLU   /*  492 */,    0xF2DA0ED240B1B642LLU   /*  493 */,
- 0x44CEFADCD54BF9A9LLU   /*  494 */,    0x1312200E433C7EE6LLU   /*  495 */,
- 0x9FFCC84F3A78C748LLU   /*  496 */,    0xF0CD1F72248576BBLLU   /*  497 */,
- 0xEC6974053638CFE4LLU   /*  498 */,    0x2BA7B67C0CEC4E4CLLU   /*  499 */,
- 0xAC2F4DF3E5CE32EDLLU   /*  500 */,    0xCB33D14326EA4C11LLU   /*  501 */,
- 0xA4E9044CC77E58BCLLU   /*  502 */,    0x5F513293D934FCEFLLU   /*  503 */,
- 0x5DC9645506E55444LLU   /*  504 */,    0x50DE418F317DE40ALLU   /*  505 */,
- 0x388CB31A69DDE259LLU   /*  506 */,    0x2DB4A83455820A86LLU   /*  507 */,
- 0x9010A91E84711AE9LLU   /*  508 */,    0x4DF7F0B7B1498371LLU   /*  509 */,
- 0xD62A2EABC0977179LLU   /*  510 */,    0x22FAC097AA8D5C0ELLU   /*  511 */,
- 0xF49FCC2FF1DAF39BLLU   /*  512 */,    0x487FD5C66FF29281LLU   /*  513 */,
- 0xE8A30667FCDCA83FLLU   /*  514 */,    0x2C9B4BE3D2FCCE63LLU   /*  515 */,
- 0xDA3FF74B93FBBBC2LLU   /*  516 */,    0x2FA165D2FE70BA66LLU   /*  517 */,
- 0xA103E279970E93D4LLU   /*  518 */,    0xBECDEC77B0E45E71LLU   /*  519 */,
- 0xCFB41E723985E497LLU   /*  520 */,    0xB70AAA025EF75017LLU   /*  521 */,
- 0xD42309F03840B8E0LLU   /*  522 */,    0x8EFC1AD035898579LLU   /*  523 */,
- 0x96C6920BE2B2ABC5LLU   /*  524 */,    0x66AF4163375A9172LLU   /*  525 */,
- 0x2174ABDCCA7127FBLLU   /*  526 */,    0xB33CCEA64A72FF41LLU   /*  527 */,
- 0xF04A4933083066A5LLU   /*  528 */,    0x8D970ACDD7289AF5LLU   /*  529 */,
- 0x8F96E8E031C8C25ELLU   /*  530 */,    0xF3FEC02276875D47LLU   /*  531 */,
- 0xEC7BF310056190DDLLU   /*  532 */,    0xF5ADB0AEBB0F1491LLU   /*  533 */,
- 0x9B50F8850FD58892LLU   /*  534 */,    0x4975488358B74DE8LLU   /*  535 */,
- 0xA3354FF691531C61LLU   /*  536 */,    0x0702BBE481D2C6EELLU   /*  537 */,
- 0x89FB24057DEDED98LLU   /*  538 */,    0xAC3075138596E902LLU   /*  539 */,
- 0x1D2D3580172772EDLLU   /*  540 */,    0xEB738FC28E6BC30DLLU   /*  541 */,
- 0x5854EF8F63044326LLU   /*  542 */,    0x9E5C52325ADD3BBELLU   /*  543 */,
- 0x90AA53CF325C4623LLU   /*  544 */,    0xC1D24D51349DD067LLU   /*  545 */,
- 0x2051CFEEA69EA624LLU   /*  546 */,    0x13220F0A862E7E4FLLU   /*  547 */,
- 0xCE39399404E04864LLU   /*  548 */,    0xD9C42CA47086FCB7LLU   /*  549 */,
- 0x685AD2238A03E7CCLLU   /*  550 */,    0x066484B2AB2FF1DBLLU   /*  551 */,
- 0xFE9D5D70EFBF79ECLLU   /*  552 */,    0x5B13B9DD9C481854LLU   /*  553 */,
- 0x15F0D475ED1509ADLLU   /*  554 */,    0x0BEBCD060EC79851LLU   /*  555 */,
- 0xD58C6791183AB7F8LLU   /*  556 */,    0xD1187C5052F3EEE4LLU   /*  557 */,
- 0xC95D1192E54E82FFLLU   /*  558 */,    0x86EEA14CB9AC6CA2LLU   /*  559 */,
- 0x3485BEB153677D5DLLU   /*  560 */,    0xDD191D781F8C492ALLU   /*  561 */,
- 0xF60866BAA784EBF9LLU   /*  562 */,    0x518F643BA2D08C74LLU   /*  563 */,
- 0x8852E956E1087C22LLU   /*  564 */,    0xA768CB8DC410AE8DLLU   /*  565 */,
- 0x38047726BFEC8E1ALLU   /*  566 */,    0xA67738B4CD3B45AALLU   /*  567 */,
- 0xAD16691CEC0DDE19LLU   /*  568 */,    0xC6D4319380462E07LLU   /*  569 */,
- 0xC5A5876D0BA61938LLU   /*  570 */,    0x16B9FA1FA58FD840LLU   /*  571 */,
- 0x188AB1173CA74F18LLU   /*  572 */,    0xABDA2F98C99C021FLLU   /*  573 */,
- 0x3E0580AB134AE816LLU   /*  574 */,    0x5F3B05B773645ABBLLU   /*  575 */,
- 0x2501A2BE5575F2F6LLU   /*  576 */,    0x1B2F74004E7E8BA9LLU   /*  577 */,
- 0x1CD7580371E8D953LLU   /*  578 */,    0x7F6ED89562764E30LLU   /*  579 */,
- 0xB15926FF596F003DLLU   /*  580 */,    0x9F65293DA8C5D6B9LLU   /*  581 */,
- 0x6ECEF04DD690F84CLLU   /*  582 */,    0x4782275FFF33AF88LLU   /*  583 */,
- 0xE41433083F820801LLU   /*  584 */,    0xFD0DFE409A1AF9B5LLU   /*  585 */,
- 0x4325A3342CDB396BLLU   /*  586 */,    0x8AE77E62B301B252LLU   /*  587 */,
- 0xC36F9E9F6655615ALLU   /*  588 */,    0x85455A2D92D32C09LLU   /*  589 */,
- 0xF2C7DEA949477485LLU   /*  590 */,    0x63CFB4C133A39EBALLU   /*  591 */,
- 0x83B040CC6EBC5462LLU   /*  592 */,    0x3B9454C8FDB326B0LLU   /*  593 */,
- 0x56F56A9E87FFD78CLLU   /*  594 */,    0x2DC2940D99F42BC6LLU   /*  595 */,
- 0x98F7DF096B096E2DLLU   /*  596 */,    0x19A6E01E3AD852BFLLU   /*  597 */,
- 0x42A99CCBDBD4B40BLLU   /*  598 */,    0xA59998AF45E9C559LLU   /*  599 */,
- 0x366295E807D93186LLU   /*  600 */,    0x6B48181BFAA1F773LLU   /*  601 */,
- 0x1FEC57E2157A0A1DLLU   /*  602 */,    0x4667446AF6201AD5LLU   /*  603 */,
- 0xE615EBCACFB0F075LLU   /*  604 */,    0xB8F31F4F68290778LLU   /*  605 */,
- 0x22713ED6CE22D11ELLU   /*  606 */,    0x3057C1A72EC3C93BLLU   /*  607 */,
- 0xCB46ACC37C3F1F2FLLU   /*  608 */,    0xDBB893FD02AAF50ELLU   /*  609 */,
- 0x331FD92E600B9FCFLLU   /*  610 */,    0xA498F96148EA3AD6LLU   /*  611 */,
- 0xA8D8426E8B6A83EALLU   /*  612 */,    0xA089B274B7735CDCLLU   /*  613 */,
- 0x87F6B3731E524A11LLU   /*  614 */,    0x118808E5CBC96749LLU   /*  615 */,
- 0x9906E4C7B19BD394LLU   /*  616 */,    0xAFED7F7E9B24A20CLLU   /*  617 */,
- 0x6509EADEEB3644A7LLU   /*  618 */,    0x6C1EF1D3E8EF0EDELLU   /*  619 */,
- 0xB9C97D43E9798FB4LLU   /*  620 */,    0xA2F2D784740C28A3LLU   /*  621 */,
- 0x7B8496476197566FLLU   /*  622 */,    0x7A5BE3E6B65F069DLLU   /*  623 */,
- 0xF96330ED78BE6F10LLU   /*  624 */,    0xEEE60DE77A076A15LLU   /*  625 */,
- 0x2B4BEE4AA08B9BD0LLU   /*  626 */,    0x6A56A63EC7B8894ELLU   /*  627 */,
- 0x02121359BA34FEF4LLU   /*  628 */,    0x4CBF99F8283703FCLLU   /*  629 */,
- 0x398071350CAF30C8LLU   /*  630 */,    0xD0A77A89F017687ALLU   /*  631 */,
- 0xF1C1A9EB9E423569LLU   /*  632 */,    0x8C7976282DEE8199LLU   /*  633 */,
- 0x5D1737A5DD1F7ABDLLU   /*  634 */,    0x4F53433C09A9FA80LLU   /*  635 */,
- 0xFA8B0C53DF7CA1D9LLU   /*  636 */,    0x3FD9DCBC886CCB77LLU   /*  637 */,
- 0xC040917CA91B4720LLU   /*  638 */,    0x7DD00142F9D1DCDFLLU   /*  639 */,
- 0x8476FC1D4F387B58LLU   /*  640 */,    0x23F8E7C5F3316503LLU   /*  641 */,
- 0x032A2244E7E37339LLU   /*  642 */,    0x5C87A5D750F5A74BLLU   /*  643 */,
- 0x082B4CC43698992ELLU   /*  644 */,    0xDF917BECB858F63CLLU   /*  645 */,
- 0x3270B8FC5BF86DDALLU   /*  646 */,    0x10AE72BB29B5DD76LLU   /*  647 */,
- 0x576AC94E7700362BLLU   /*  648 */,    0x1AD112DAC61EFB8FLLU   /*  649 */,
- 0x691BC30EC5FAA427LLU   /*  650 */,    0xFF246311CC327143LLU   /*  651 */,
- 0x3142368E30E53206LLU   /*  652 */,    0x71380E31E02CA396LLU   /*  653 */,
- 0x958D5C960AAD76F1LLU   /*  654 */,    0xF8D6F430C16DA536LLU   /*  655 */,
- 0xC8FFD13F1BE7E1D2LLU   /*  656 */,    0x7578AE66004DDBE1LLU   /*  657 */,
- 0x05833F01067BE646LLU   /*  658 */,    0xBB34B5AD3BFE586DLLU   /*  659 */,
- 0x095F34C9A12B97F0LLU   /*  660 */,    0x247AB64525D60CA8LLU   /*  661 */,
- 0xDCDBC6F3017477D1LLU   /*  662 */,    0x4A2E14D4DECAD24DLLU   /*  663 */,
- 0xBDB5E6D9BE0A1EEBLLU   /*  664 */,    0x2A7E70F7794301ABLLU   /*  665 */,
- 0xDEF42D8A270540FDLLU   /*  666 */,    0x01078EC0A34C22C1LLU   /*  667 */,
- 0xE5DE511AF4C16387LLU   /*  668 */,    0x7EBB3A52BD9A330ALLU   /*  669 */,
- 0x77697857AA7D6435LLU   /*  670 */,    0x004E831603AE4C32LLU   /*  671 */,
- 0xE7A21020AD78E312LLU   /*  672 */,    0x9D41A70C6AB420F2LLU   /*  673 */,
- 0x28E06C18EA1141E6LLU   /*  674 */,    0xD2B28CBD984F6B28LLU   /*  675 */,
- 0x26B75F6C446E9D83LLU   /*  676 */,    0xBA47568C4D418D7FLLU   /*  677 */,
- 0xD80BADBFE6183D8ELLU   /*  678 */,    0x0E206D7F5F166044LLU   /*  679 */,
- 0xE258A43911CBCA3ELLU   /*  680 */,    0x723A1746B21DC0BCLLU   /*  681 */,
- 0xC7CAA854F5D7CDD3LLU   /*  682 */,    0x7CAC32883D261D9CLLU   /*  683 */,
- 0x7690C26423BA942CLLU   /*  684 */,    0x17E55524478042B8LLU   /*  685 */,
- 0xE0BE477656A2389FLLU   /*  686 */,    0x4D289B5E67AB2DA0LLU   /*  687 */,
- 0x44862B9C8FBBFD31LLU   /*  688 */,    0xB47CC8049D141365LLU   /*  689 */,
- 0x822C1B362B91C793LLU   /*  690 */,    0x4EB14655FB13DFD8LLU   /*  691 */,
- 0x1ECBBA0714E2A97BLLU   /*  692 */,    0x6143459D5CDE5F14LLU   /*  693 */,
- 0x53A8FBF1D5F0AC89LLU   /*  694 */,    0x97EA04D81C5E5B00LLU   /*  695 */,
- 0x622181A8D4FDB3F3LLU   /*  696 */,    0xE9BCD341572A1208LLU   /*  697 */,
- 0x1411258643CCE58ALLU   /*  698 */,    0x9144C5FEA4C6E0A4LLU   /*  699 */,
- 0x0D33D06565CF620FLLU   /*  700 */,    0x54A48D489F219CA1LLU   /*  701 */,
- 0xC43E5EAC6D63C821LLU   /*  702 */,    0xA9728B3A72770DAFLLU   /*  703 */,
- 0xD7934E7B20DF87EFLLU   /*  704 */,    0xE35503B61A3E86E5LLU   /*  705 */,
- 0xCAE321FBC819D504LLU   /*  706 */,    0x129A50B3AC60BFA6LLU   /*  707 */,
- 0xCD5E68EA7E9FB6C3LLU   /*  708 */,    0xB01C90199483B1C7LLU   /*  709 */,
- 0x3DE93CD5C295376CLLU   /*  710 */,    0xAED52EDF2AB9AD13LLU   /*  711 */,
- 0x2E60F512C0A07884LLU   /*  712 */,    0xBC3D86A3E36210C9LLU   /*  713 */,
- 0x35269D9B163951CELLU   /*  714 */,    0x0C7D6E2AD0CDB5FALLU   /*  715 */,
- 0x59E86297D87F5733LLU   /*  716 */,    0x298EF221898DB0E7LLU   /*  717 */,
- 0x55000029D1A5AA7ELLU   /*  718 */,    0x8BC08AE1B5061B45LLU   /*  719 */,
- 0xC2C31C2B6C92703ALLU   /*  720 */,    0x94CC596BAF25EF42LLU   /*  721 */,
- 0x0A1D73DB22540456LLU   /*  722 */,    0x04B6A0F9D9C4179ALLU   /*  723 */,
- 0xEFFDAFA2AE3D3C60LLU   /*  724 */,    0xF7C8075BB49496C4LLU   /*  725 */,
- 0x9CC5C7141D1CD4E3LLU   /*  726 */,    0x78BD1638218E5534LLU   /*  727 */,
- 0xB2F11568F850246ALLU   /*  728 */,    0xEDFABCFA9502BC29LLU   /*  729 */,
- 0x796CE5F2DA23051BLLU   /*  730 */,    0xAAE128B0DC93537CLLU   /*  731 */,
- 0x3A493DA0EE4B29AELLU   /*  732 */,    0xB5DF6B2C416895D7LLU   /*  733 */,
- 0xFCABBD25122D7F37LLU   /*  734 */,    0x70810B58105DC4B1LLU   /*  735 */,
- 0xE10FDD37F7882A90LLU   /*  736 */,    0x524DCAB5518A3F5CLLU   /*  737 */,
- 0x3C9E85878451255BLLU   /*  738 */,    0x4029828119BD34E2LLU   /*  739 */,
- 0x74A05B6F5D3CECCBLLU   /*  740 */,    0xB610021542E13ECALLU   /*  741 */,
- 0x0FF979D12F59E2ACLLU   /*  742 */,    0x6037DA27E4F9CC50LLU   /*  743 */,
- 0x5E92975A0DF1847DLLU   /*  744 */,    0xD66DE190D3E623FELLU   /*  745 */,
- 0x5032D6B87B568048LLU   /*  746 */,    0x9A36B7CE8235216ELLU   /*  747 */,
- 0x80272A7A24F64B4ALLU   /*  748 */,    0x93EFED8B8C6916F7LLU   /*  749 */,
- 0x37DDBFF44CCE1555LLU   /*  750 */,    0x4B95DB5D4B99BD25LLU   /*  751 */,
- 0x92D3FDA169812FC0LLU   /*  752 */,    0xFB1A4A9A90660BB6LLU   /*  753 */,
- 0x730C196946A4B9B2LLU   /*  754 */,    0x81E289AA7F49DA68LLU   /*  755 */,
- 0x64669A0F83B1A05FLLU   /*  756 */,    0x27B3FF7D9644F48BLLU   /*  757 */,
- 0xCC6B615C8DB675B3LLU   /*  758 */,    0x674F20B9BCEBBE95LLU   /*  759 */,
- 0x6F31238275655982LLU   /*  760 */,    0x5AE488713E45CF05LLU   /*  761 */,
- 0xBF619F9954C21157LLU   /*  762 */,    0xEABAC46040A8EAE9LLU   /*  763 */,
- 0x454C6FE9F2C0C1CDLLU   /*  764 */,    0x419CF6496412691CLLU   /*  765 */,
- 0xD3DC3BEF265B0F70LLU   /*  766 */,    0x6D0E60F5C3578A9ELLU   /*  767 */,
- 0x5B0E608526323C55LLU   /*  768 */,    0x1A46C1A9FA1B59F5LLU   /*  769 */,
- 0xA9E245A17C4C8FFALLU   /*  770 */,    0x65CA5159DB2955D7LLU   /*  771 */,
- 0x05DB0A76CE35AFC2LLU   /*  772 */,    0x81EAC77EA9113D45LLU   /*  773 */,
- 0x528EF88AB6AC0A0DLLU   /*  774 */,    0xA09EA253597BE3FFLLU   /*  775 */,
- 0x430DDFB3AC48CD56LLU   /*  776 */,    0xC4B3A67AF45CE46FLLU   /*  777 */,
- 0x4ECECFD8FBE2D05ELLU   /*  778 */,    0x3EF56F10B39935F0LLU   /*  779 */,
- 0x0B22D6829CD619C6LLU   /*  780 */,    0x17FD460A74DF2069LLU   /*  781 */,
- 0x6CF8CC8E8510ED40LLU   /*  782 */,    0xD6C824BF3A6ECAA7LLU   /*  783 */,
- 0x61243D581A817049LLU   /*  784 */,    0x048BACB6BBC163A2LLU   /*  785 */,
- 0xD9A38AC27D44CC32LLU   /*  786 */,    0x7FDDFF5BAAF410ABLLU   /*  787 */,
- 0xAD6D495AA804824BLLU   /*  788 */,    0xE1A6A74F2D8C9F94LLU   /*  789 */,
- 0xD4F7851235DEE8E3LLU   /*  790 */,    0xFD4B7F886540D893LLU   /*  791 */,
- 0x247C20042AA4BFDALLU   /*  792 */,    0x096EA1C517D1327CLLU   /*  793 */,
- 0xD56966B4361A6685LLU   /*  794 */,    0x277DA5C31221057DLLU   /*  795 */,
- 0x94D59893A43ACFF7LLU   /*  796 */,    0x64F0C51CCDC02281LLU   /*  797 */,
- 0x3D33BCC4FF6189DBLLU   /*  798 */,    0xE005CB184CE66AF1LLU   /*  799 */,
- 0xFF5CCD1D1DB99BEALLU   /*  800 */,    0xB0B854A7FE42980FLLU   /*  801 */,
- 0x7BD46A6A718D4B9FLLU   /*  802 */,    0xD10FA8CC22A5FD8CLLU   /*  803 */,
- 0xD31484952BE4BD31LLU   /*  804 */,    0xC7FA975FCB243847LLU   /*  805 */,
- 0x4886ED1E5846C407LLU   /*  806 */,    0x28CDDB791EB70B04LLU   /*  807 */,
- 0xC2B00BE2F573417FLLU   /*  808 */,    0x5C9590452180F877LLU   /*  809 */,
- 0x7A6BDDFFF370EB00LLU   /*  810 */,    0xCE509E38D6D9D6A4LLU   /*  811 */,
- 0xEBEB0F00647FA702LLU   /*  812 */,    0x1DCC06CF76606F06LLU   /*  813 */,
- 0xE4D9F28BA286FF0ALLU   /*  814 */,    0xD85A305DC918C262LLU   /*  815 */,
- 0x475B1D8732225F54LLU   /*  816 */,    0x2D4FB51668CCB5FELLU   /*  817 */,
- 0xA679B9D9D72BBA20LLU   /*  818 */,    0x53841C0D912D43A5LLU   /*  819 */,
- 0x3B7EAA48BF12A4E8LLU   /*  820 */,    0x781E0E47F22F1DDFLLU   /*  821 */,
- 0xEFF20CE60AB50973LLU   /*  822 */,    0x20D261D19DFFB742LLU   /*  823 */,
- 0x16A12B03062A2E39LLU   /*  824 */,    0x1960EB2239650495LLU   /*  825 */,
- 0x251C16FED50EB8B8LLU   /*  826 */,    0x9AC0C330F826016ELLU   /*  827 */,
- 0xED152665953E7671LLU   /*  828 */,    0x02D63194A6369570LLU   /*  829 */,
- 0x5074F08394B1C987LLU   /*  830 */,    0x70BA598C90B25CE1LLU   /*  831 */,
- 0x794A15810B9742F6LLU   /*  832 */,    0x0D5925E9FCAF8C6CLLU   /*  833 */,
- 0x3067716CD868744ELLU   /*  834 */,    0x910AB077E8D7731BLLU   /*  835 */,
- 0x6A61BBDB5AC42F61LLU   /*  836 */,    0x93513EFBF0851567LLU   /*  837 */,
- 0xF494724B9E83E9D5LLU   /*  838 */,    0xE887E1985C09648DLLU   /*  839 */,
- 0x34B1D3C675370CFDLLU   /*  840 */,    0xDC35E433BC0D255DLLU   /*  841 */,
- 0xD0AAB84234131BE0LLU   /*  842 */,    0x08042A50B48B7EAFLLU   /*  843 */,
- 0x9997C4EE44A3AB35LLU   /*  844 */,    0x829A7B49201799D0LLU   /*  845 */,
- 0x263B8307B7C54441LLU   /*  846 */,    0x752F95F4FD6A6CA6LLU   /*  847 */,
- 0x927217402C08C6E5LLU   /*  848 */,    0x2A8AB754A795D9EELLU   /*  849 */,
- 0xA442F7552F72943DLLU   /*  850 */,    0x2C31334E19781208LLU   /*  851 */,
- 0x4FA98D7CEAEE6291LLU   /*  852 */,    0x55C3862F665DB309LLU   /*  853 */,
- 0xBD0610175D53B1F3LLU   /*  854 */,    0x46FE6CB840413F27LLU   /*  855 */,
- 0x3FE03792DF0CFA59LLU   /*  856 */,    0xCFE700372EB85E8FLLU   /*  857 */,
- 0xA7BE29E7ADBCE118LLU   /*  858 */,    0xE544EE5CDE8431DDLLU   /*  859 */,
- 0x8A781B1B41F1873ELLU   /*  860 */,    0xA5C94C78A0D2F0E7LLU   /*  861 */,
- 0x39412E2877B60728LLU   /*  862 */,    0xA1265EF3AFC9A62CLLU   /*  863 */,
- 0xBCC2770C6A2506C5LLU   /*  864 */,    0x3AB66DD5DCE1CE12LLU   /*  865 */,
- 0xE65499D04A675B37LLU   /*  866 */,    0x7D8F523481BFD216LLU   /*  867 */,
- 0x0F6F64FCEC15F389LLU   /*  868 */,    0x74EFBE618B5B13C8LLU   /*  869 */,
- 0xACDC82B714273E1DLLU   /*  870 */,    0xDD40BFE003199D17LLU   /*  871 */,
- 0x37E99257E7E061F8LLU   /*  872 */,    0xFA52626904775AAALLU   /*  873 */,
- 0x8BBBF63A463D56F9LLU   /*  874 */,    0xF0013F1543A26E64LLU   /*  875 */,
- 0xA8307E9F879EC898LLU   /*  876 */,    0xCC4C27A4150177CCLLU   /*  877 */,
- 0x1B432F2CCA1D3348LLU   /*  878 */,    0xDE1D1F8F9F6FA013LLU   /*  879 */,
- 0x606602A047A7DDD6LLU   /*  880 */,    0xD237AB64CC1CB2C7LLU   /*  881 */,
- 0x9B938E7225FCD1D3LLU   /*  882 */,    0xEC4E03708E0FF476LLU   /*  883 */,
- 0xFEB2FBDA3D03C12DLLU   /*  884 */,    0xAE0BCED2EE43889ALLU   /*  885 */,
- 0x22CB8923EBFB4F43LLU   /*  886 */,    0x69360D013CF7396DLLU   /*  887 */,
- 0x855E3602D2D4E022LLU   /*  888 */,    0x073805BAD01F784CLLU   /*  889 */,
- 0x33E17A133852F546LLU   /*  890 */,    0xDF4874058AC7B638LLU   /*  891 */,
- 0xBA92B29C678AA14ALLU   /*  892 */,    0x0CE89FC76CFAADCDLLU   /*  893 */,
- 0x5F9D4E0908339E34LLU   /*  894 */,    0xF1AFE9291F5923B9LLU   /*  895 */,
- 0x6E3480F60F4A265FLLU   /*  896 */,    0xEEBF3A2AB29B841CLLU   /*  897 */,
- 0xE21938A88F91B4ADLLU   /*  898 */,    0x57DFEFF845C6D3C3LLU   /*  899 */,
- 0x2F006B0BF62CAAF2LLU   /*  900 */,    0x62F479EF6F75EE78LLU   /*  901 */,
- 0x11A55AD41C8916A9LLU   /*  902 */,    0xF229D29084FED453LLU   /*  903 */,
- 0x42F1C27B16B000E6LLU   /*  904 */,    0x2B1F76749823C074LLU   /*  905 */,
- 0x4B76ECA3C2745360LLU   /*  906 */,    0x8C98F463B91691BDLLU   /*  907 */,
- 0x14BCC93CF1ADE66ALLU   /*  908 */,    0x8885213E6D458397LLU   /*  909 */,
- 0x8E177DF0274D4711LLU   /*  910 */,    0xB49B73B5503F2951LLU   /*  911 */,
- 0x10168168C3F96B6BLLU   /*  912 */,    0x0E3D963B63CAB0AELLU   /*  913 */,
- 0x8DFC4B5655A1DB14LLU   /*  914 */,    0xF789F1356E14DE5CLLU   /*  915 */,
- 0x683E68AF4E51DAC1LLU   /*  916 */,    0xC9A84F9D8D4B0FD9LLU   /*  917 */,
- 0x3691E03F52A0F9D1LLU   /*  918 */,    0x5ED86E46E1878E80LLU   /*  919 */,
- 0x3C711A0E99D07150LLU   /*  920 */,    0x5A0865B20C4E9310LLU   /*  921 */,
- 0x56FBFC1FE4F0682ELLU   /*  922 */,    0xEA8D5DE3105EDF9BLLU   /*  923 */,
- 0x71ABFDB12379187ALLU   /*  924 */,    0x2EB99DE1BEE77B9CLLU   /*  925 */,
- 0x21ECC0EA33CF4523LLU   /*  926 */,    0x59A4D7521805C7A1LLU   /*  927 */,
- 0x3896F5EB56AE7C72LLU   /*  928 */,    0xAA638F3DB18F75DCLLU   /*  929 */,
- 0x9F39358DABE9808ELLU   /*  930 */,    0xB7DEFA91C00B72ACLLU   /*  931 */,
- 0x6B5541FD62492D92LLU   /*  932 */,    0x6DC6DEE8F92E4D5BLLU   /*  933 */,
- 0x353F57ABC4BEEA7ELLU   /*  934 */,    0x735769D6DA5690CELLU   /*  935 */,
- 0x0A234AA642391484LLU   /*  936 */,    0xF6F9508028F80D9DLLU   /*  937 */,
- 0xB8E319A27AB3F215LLU   /*  938 */,    0x31AD9C1151341A4DLLU   /*  939 */,
- 0x773C22A57BEF5805LLU   /*  940 */,    0x45C7561A07968633LLU   /*  941 */,
- 0xF913DA9E249DBE36LLU   /*  942 */,    0xDA652D9B78A64C68LLU   /*  943 */,
- 0x4C27A97F3BC334EFLLU   /*  944 */,    0x76621220E66B17F4LLU   /*  945 */,
- 0x967743899ACD7D0BLLU   /*  946 */,    0xF3EE5BCAE0ED6782LLU   /*  947 */,
- 0x409F753600C879FCLLU   /*  948 */,    0x06D09A39B5926DB6LLU   /*  949 */,
- 0x6F83AEB0317AC588LLU   /*  950 */,    0x01E6CA4A86381F21LLU   /*  951 */,
- 0x66FF3462D19F3025LLU   /*  952 */,    0x72207C24DDFD3BFBLLU   /*  953 */,
- 0x4AF6B6D3E2ECE2EBLLU   /*  954 */,    0x9C994DBEC7EA08DELLU   /*  955 */,
- 0x49ACE597B09A8BC4LLU   /*  956 */,    0xB38C4766CF0797BALLU   /*  957 */,
- 0x131B9373C57C2A75LLU   /*  958 */,    0xB1822CCE61931E58LLU   /*  959 */,
- 0x9D7555B909BA1C0CLLU   /*  960 */,    0x127FAFDD937D11D2LLU   /*  961 */,
- 0x29DA3BADC66D92E4LLU   /*  962 */,    0xA2C1D57154C2ECBCLLU   /*  963 */,
- 0x58C5134D82F6FE24LLU   /*  964 */,    0x1C3AE3515B62274FLLU   /*  965 */,
- 0xE907C82E01CB8126LLU   /*  966 */,    0xF8ED091913E37FCBLLU   /*  967 */,
- 0x3249D8F9C80046C9LLU   /*  968 */,    0x80CF9BEDE388FB63LLU   /*  969 */,
- 0x1881539A116CF19ELLU   /*  970 */,    0x5103F3F76BD52457LLU   /*  971 */,
- 0x15B7E6F5AE47F7A8LLU   /*  972 */,    0xDBD7C6DED47E9CCFLLU   /*  973 */,
- 0x44E55C410228BB1ALLU   /*  974 */,    0xB647D4255EDB4E99LLU   /*  975 */,
- 0x5D11882BB8AAFC30LLU   /*  976 */,    0xF5098BBB29D3212ALLU   /*  977 */,
- 0x8FB5EA14E90296B3LLU   /*  978 */,    0x677B942157DD025ALLU   /*  979 */,
- 0xFB58E7C0A390ACB5LLU   /*  980 */,    0x89D3674C83BD4A01LLU   /*  981 */,
- 0x9E2DA4DF4BF3B93BLLU   /*  982 */,    0xFCC41E328CAB4829LLU   /*  983 */,
- 0x03F38C96BA582C52LLU   /*  984 */,    0xCAD1BDBD7FD85DB2LLU   /*  985 */,
- 0xBBB442C16082AE83LLU   /*  986 */,    0xB95FE86BA5DA9AB0LLU   /*  987 */,
- 0xB22E04673771A93FLLU   /*  988 */,    0x845358C9493152D8LLU   /*  989 */,
- 0xBE2A488697B4541ELLU   /*  990 */,    0x95A2DC2DD38E6966LLU   /*  991 */,
- 0xC02C11AC923C852BLLU   /*  992 */,    0x2388B1990DF2A87BLLU   /*  993 */,
- 0x7C8008FA1B4F37BELLU   /*  994 */,    0x1F70D0C84D54E503LLU   /*  995 */,
- 0x5490ADEC7ECE57D4LLU   /*  996 */,    0x002B3C27D9063A3ALLU   /*  997 */,
- 0x7EAEA3848030A2BFLLU   /*  998 */,    0xC602326DED2003C0LLU   /*  999 */,
- 0x83A7287D69A94086LLU   /* 1000 */,    0xC57A5FCB30F57A8ALLU   /* 1001 */,
- 0xB56844E479EBE779LLU   /* 1002 */,    0xA373B40F05DCBCE9LLU   /* 1003 */,
- 0xD71A786E88570EE2LLU   /* 1004 */,    0x879CBACDBDE8F6A0LLU   /* 1005 */,
- 0x976AD1BCC164A32FLLU   /* 1006 */,    0xAB21E25E9666D78BLLU   /* 1007 */,
- 0x901063AAE5E5C33CLLU   /* 1008 */,    0x9818B34448698D90LLU   /* 1009 */,
- 0xE36487AE3E1E8ABBLLU   /* 1010 */,    0xAFBDF931893BDCB4LLU   /* 1011 */,
- 0x6345A0DC5FBBD519LLU   /* 1012 */,    0x8628FE269B9465CALLU   /* 1013 */,
- 0x1E5D01603F9C51ECLLU   /* 1014 */,    0x4DE44006A15049B7LLU   /* 1015 */,
- 0xBF6C70E5F776CBB1LLU   /* 1016 */,    0x411218F2EF552BEDLLU   /* 1017 */,
- 0xCB0C0708705A36A3LLU   /* 1018 */,    0xE74D14754F986044LLU   /* 1019 */,
- 0xCD56D9430EA8280ELLU   /* 1020 */,    0xC12591D7535F5065LLU   /* 1021 */,
- 0xC83223F1720AEF96LLU   /* 1022 */,    0xC3A0396F7363A51FLLU   /* 1023 */
-};
-
-#define sbox1 (table+256*0)
-#define sbox2 (table+256*1)
-#define sbox3 (table+256*2)
-#define sbox4 (table+256*3)
-
-int roar_hash_tiger_init(struct roar_hash_tiger * state) {
- if ( state == NULL )
-  return -1;
-
- memset(state, 0, sizeof(struct roar_hash_tiger));
-
- state->a = 0x0123456789ABCDEFLLU;
- state->b = 0xFEDCBA9876543210LLU;
- state->c = 0xF096A5B4C3B2E187LLU;
-
- state->inlen  = 0;
- state->blocks = 0;
-
- state->is_final = 0;
-
- return 0;
-}
-
-int roar_hash_tiger_uninit(struct roar_hash_tiger * state) {
- (void)state;
- return 0;
-}
-
-int roar_hash_tiger_init_from_pstate(struct roar_hash_tiger * state, void * oldstate) {
- uint64_t blocks;
- unsigned char * p = oldstate;
-
- if ( state == NULL || oldstate == NULL )
-  return -1;
-
- if ( roar_hash_tiger_init(state) == -1 )
-  return -1;
-
-#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
-#define _in(m)  do { m = *(uint64_t*)p;  p += 8; } while(0)
-#elif BYTE_ORDER == LITTLE_ENDIAN
-#define _S(x, n) (((uint64_t)(p[(n)])) << (uint64_t)(x))
-#define _in(m) do { m = (uint64_t)(_S(56, 0) | _S(48, 1) | _S(40, 2) | _S(32, 3) | \
-                                   _S(24, 4) | _S(16, 5) | _S( 8, 6) | _S( 0, 7)   \
-                        ); p += 8; } while (0)
-#else
-  ROAR_ERR("roar_hash_tiger_init_from_pstate(state=%p, ...): Tiger not implemented for non little or big endian systems!", state);
-  return -1;
-#define _in
-#endif
- _in(state->a);
- _in(state->b);
- _in(state->c);
- _in(blocks);
-
- state->blocks = blocks;
-#undef _in
-
- return 0;
-}
-
-static int roar_hash_tiger_export(struct roar_hash_tiger * state, void * newstate, size_t * len, int is_pstate) {
- unsigned char * p = newstate;
- size_t needlen;
- uint64_t blocks;
-
- if ( is_pstate ) {
-  needlen = PSTATE_LEN;
- } else {
-  needlen = STATE_LEN;
- }
-
- if ( state == NULL || newstate == NULL || len == NULL )
-  return -1;
-
- if ( state->inlen != 0 )
-  return -1;
-
- if ( *len < needlen )
-  return -1;
-
- *len = needlen;
-
-#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
-#define _out(m) do { *(uint64_t*)p = m ; p += 8; } while(0)
-#elif BYTE_ORDER == LITTLE_ENDIAN
-#define _out(m) do { *p++ = m >> 56; *p++ = m >> 48; \
-                     *p++ = m >> 40; *p++ = m >> 32; \
-                     *p++ = m >> 24; *p++ = m >> 16; \
-                     *p++ = m >>  8; *p++ = m;       } while(0)
-#else
-  ROAR_ERR("roar_hash_tiger_export(state=%p, ...): Tiger not implemented for non little or big endian systems!", state);
-  return -1;
-#define _out
-#endif
- _out(state->a);
- _out(state->b);
- _out(state->c);
- if ( is_pstate ) {
-  blocks = state->blocks;
-  _out(blocks);
- }
-#undef _out
-
- return 0;
-}
-
-int roar_hash_tiger_to_pstate(struct roar_hash_tiger * state, void * newstate, size_t * len) {
- return roar_hash_tiger_export(state, newstate, len, 1);
-}
-
-ssize_t roar_hash_tiger_statelen(struct roar_hash_tiger * state) {
- (void)state;
- return PSTATE_LEN;
-}
-
-int roar_hash_tiger_finalize(struct roar_hash_tiger * state) {
- uint64_t len;
-
- if ( state == NULL )
-  return -1;
-
- if ( state->is_final )
-  return 0;
-
- len  = state->blocks * BLOCK_LEN + state->inlen;
- len *= 8; // byte -> bit
-
- if ( state->inlen < 56 ) { /* enough room */
-  state->inbuf[state->inlen++] = 0x01; /* pad */
-  while ( state->inlen < 56 )
-   state->inbuf[state->inlen++] = 0;  /* pad */
- } else { /* need one extra block */
-  state->inbuf[state->inlen++] = 0x01; /* pad character */
-  while( state->inlen < 64 )
-   state->inbuf[state->inlen++] = 0;
-
-  roar_hash_tiger_proc_block(state, state->inbuf);
-  memset(state->inbuf, 0, 56); /* fill next block with zeroes */
- }
-
-  state->inbuf[56] = (len >>  0) & 0xFF;
-  state->inbuf[57] = (len >>  8) & 0xFF;
-  state->inbuf[58] = (len >> 16) & 0xFF;
-  state->inbuf[59] = (len >> 24) & 0xFF;
-  state->inbuf[60] = (len >> 32) & 0xFF;
-  state->inbuf[61] = (len >> 40) & 0xFF;
-  state->inbuf[62] = (len >> 48) & 0xFF;
-  state->inbuf[63] = (len >> 56) & 0xFF;
-
- roar_hash_tiger_proc_block(state, state->inbuf);
-
- state->inlen    = 0;
- state->is_final = 1;
-
- return 0;
-}
-
-int roar_hash_tiger_get_digest(struct roar_hash_tiger * state, void * digest, size_t * len) {
- if ( state == NULL || digest == NULL )
-  return -1;
-
- if ( roar_hash_tiger_finalize(state) == -1 )
-  return -1;
-
- return roar_hash_tiger_export(state, digest, len, 0);
-}
-
-static void tiger_round( uint64_t * ra, uint64_t * rb, uint64_t * rc, uint64_t x, uint64_t mul) {
- uint64_t a = *ra;
- uint64_t b = *rb;
- uint64_t c = *rc;
-
- c ^= x;
- a -= (  sbox1[  c        & 0xff ] ^ sbox2[ (c >> 16) & 0xff ]
-       ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]);
- b += (  sbox4[ (c >>  8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ]
-       ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]);
- b *= mul;
-
- *ra = a;
- *rb = b;
- *rc = c;
-
- a = b = c = 0;
-}
-
-static void pass(uint64_t * ra, uint64_t * rb, uint64_t * rc, uint64_t * x, uint64_t mul) {
- tiger_round(ra, rb, rc, x[0], mul);
- tiger_round(rb, rc, ra, x[1], mul);
- tiger_round(rc, ra, rb, x[2], mul);
- tiger_round(ra, rb, rc, x[3], mul);
- tiger_round(rb, rc, ra, x[4], mul);
- tiger_round(rc, ra, rb, x[5], mul);
- tiger_round(ra, rb, rc, x[6], mul);
- tiger_round(rb, rc, ra, x[7], mul);
-}
-
-static void key_schedule(uint64_t * x) {
- x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL;
- x[1] ^= x[0];
- x[2] += x[1];
- x[3] -= x[2] ^ ((~x[1]) << 19 );
- x[4] ^= x[3];
- x[5] += x[4];
- x[6] -= x[5] ^ ((~x[4]) >> 23 );
- x[7] ^= x[6];
- x[0] += x[7];
- x[1] -= x[0] ^ ((~x[7]) << 19 );
- x[2] ^= x[1];
- x[3] += x[2];
- x[4] -= x[3] ^ ((~x[2]) >> 23 );
- x[5] ^= x[4];
- x[6] += x[5];
- x[7] -= x[6] ^ 0x0123456789abcdefLL;
-}
-
-int roar_hash_tiger_proc_block(struct roar_hash_tiger * state, void * block) {
-#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
- uint64_t * block64 = block;
-#endif
- uint64_t a, b, c, aa, bb, cc;
- uint64_t x[8];
-
- ROAR_DBG("roar_hash_tiger_proc_block(state=%p, block=%p) = ?", state, block);
-
- if ( state == NULL || block == NULL )
-  return -1;
-
-#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
-#define MKWORD(d,n) \
-                (  ((uint64_t)(d)[8*(n)+7]) << 56 | ((uint64_t)(d)[8*(n)+6]) << 48  \
-                 | ((uint64_t)(d)[8*(n)+5]) << 40 | ((uint64_t)(d)[8*(n)+4]) << 32  \
-                 | ((uint64_t)(d)[8*(n)+3]) << 24 | ((uint64_t)(d)[8*(n)+2]) << 16  \
-                 | ((uint64_t)(d)[8*(n)+1]) << 8  | ((uint64_t)(d)[8*(n)  ])       )
-  x[0] = MKWORD(block64, 0);
-  x[1] = MKWORD(block64, 1);
-  x[2] = MKWORD(block64, 2);
-  x[3] = MKWORD(block64, 3);
-  x[4] = MKWORD(block64, 4);
-  x[5] = MKWORD(block64, 5);
-  x[6] = MKWORD(block64, 6);
-  x[7] = MKWORD(block64, 7);
-#undef MKWORD
-#elif BYTE_ORDER == LITTLE_ENDIAN
-  memcpy(x, block, 64);
-#else
-  ROAR_ERR("roar_hash_tiger_proc_block(state=%p, block=%p): Tiger not implemented for non little or big endian systems!", state, block);
-  return -1;
-#endif
-
- // save_abc
- aa = a = state->a;
- bb = b = state->b;
- cc = c = state->c;
-
- // main calcs:
- pass(&a, &b, &c, x, 5);
- key_schedule(x);
- pass(&c, &a, &b, x, 7);
- key_schedule(x);
- pass(&b, &c, &a, x, 9);
-
- // feedforward
- state->a = a ^ aa;
- state->b = b - bb;
- state->c = c + cc;
-
- state->blocks++;
-
- a = b = c = aa = bb = cc = 0;
-
- ROAR_DBG("roar_hash_tiger_proc_block(state=%p, block=%p) = 0", state, block);
- return 0;
-}
-
-ssize_t roar_hash_tiger_blocklen(struct roar_hash_tiger * state) {
- (void)state;
- return BLOCK_LEN;
-}
-
-int roar_hash_tiger_proc(struct roar_hash_tiger * state, void * data, size_t len) {
- size_t needlen;
-
- ROAR_DBG("roar_hash_tiger_proc(state=%p, data=%p, len=%llu) = ?", state, data, (long long unsigned int)len);
-
- if ( state == NULL )
-  return -1;
-
- if ( len == 0 )
-  return 0;
-
- if ( data == NULL )
-  return -1;
-
- if ( state->inlen ) {
-  needlen = BLOCK_LEN - state->inlen;
-  ROAR_DBG("roar_hash_tiger_proc(state=%p, ...): adding %llu byte to inbuf block", state, (long long unsigned int)needlen);
-
-  if ( len < needlen ) {
-   ROAR_DBG("roar_hash_tiger_proc(state=%p, ...): inbufblock is short", state);
-   memcpy(state->inbuf + state->inlen, data, len);
-   state->inlen += len;
-   ROAR_DBG("roar_hash_tiger_proc(state=%p, ...) = 0", state);
-   return 0;
-  }
-
-  memcpy(state->inbuf + state->inlen, data, needlen);
-  len  -= needlen;
-  data += needlen;
-
-  state->inlen = 0;
-
-  if ( roar_hash_tiger_proc_block(state, state->inbuf) == -1 )
-   return -1;
- }
-
- for (; len >= BLOCK_LEN; ) {
-  ROAR_DBG("roar_hash_tiger_proc(state=%p, ...): running normal block...", state);
-
-  if ( roar_hash_tiger_proc_block(state, data) == -1 )
-   return -1;
-
-  len  -= BLOCK_LEN;
-  data += BLOCK_LEN;
- }
-
- if ( len ) {
-  ROAR_DBG("roar_hash_tiger_proc(state=%p, ...): adding %llu byte to new inbuf", state, (long long unsigned int)len);
-  memcpy(state->inbuf, data, len);
-  state->inlen = len;
- }
-
- ROAR_DBG("roar_hash_tiger_proc(state=%p, ...) = 0", state);
- return 0;
-}
-
-//ll
Index: libroar/keyval.c
===================================================================
--- libroar/keyval.c	(revision 6052)
+++ 	(revision )
@@ -1,230 +1,0 @@
-//keyval.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-struct roar_keyval * roar_keyval_lookup (struct roar_keyval *  kv, const char * key, ssize_t len, int casesens) {
- int (*sc)(const char *s1, const char *s2) = strcasecmp;
- ssize_t i;
-
- ROAR_DBG("roar_keyval_lookup(kv=%p, key=%p'%s', len=%li, casesens=%i) = ?", kv, key, key, (long int)len, casesens);
-
- if ( kv == NULL || key == NULL ) {
-  ROAR_DBG("roar_keyval_lookup(kv=%p, key=%p'%s', len=%li, casesens=%i) = NULL //error=FAULT", kv, key, key, (long int)len, casesens);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( casesens )
-  sc = strcmp;
-
- for (i = 0; len != -1 ? (i < len) : kv[i].key != NULL; i++) {
-  if ( kv[i].key != NULL && !sc(key, kv[i].key) )
-   return &(kv[i]);
- }
-
- ROAR_DBG("roar_keyval_lookup(kv=%p, key=%p'%s', len=%li, casesens=%i) = NULL //error=NOENT", kv, key, key, (long int)len, casesens);
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-static inline int is_in (const char c, const char * delm) {
- for (; *delm != 0; delm++)
-  if ( *delm == c )
-   return 1;
-
- return 0;
-}
-
-static inline void skip_char(char * str) {
- memmove(str, str+1, roar_mm_strlen(str));
-}
-
-ssize_t              roar_keyval_split  (struct roar_keyval ** kv, char * str, const char * fdel, const char * kdel, int quotes) {
- struct roar_keyval * kvs;
- int    pos = -1;
- size_t len =  0;
- char * sp;
- char quote =  0;
- int last_was_seg = 0;
-
- if ( kv == NULL || str == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( fdel == NULL )
-  fdel = " \t,";
-
- if ( kdel == NULL )
-  kdel = "=:";
-
- // count num of segements:
- for (sp = str; *sp != 0; sp++) {
-  if ( quote ) {
-   if ( *sp == quote )
-    quote = 0;
-  } else if ( quotes && (*sp == '\'' || *sp == '\"') ) {
-   quote = *sp;
-  } else {
-   if ( last_was_seg ) {
-    last_was_seg = !is_in(*sp, fdel);
-   } else {
-    if ( !is_in(*sp, fdel) ) {
-     last_was_seg = 1;
-     len++;
-    }
-   }
-  }
- }
-
- kvs = roar_mm_malloc(sizeof(struct roar_keyval)*(len+1));
-
- if ( kvs == NULL )
-  return -1;
-
- *kv = kvs;
-
- // End of Array Mark:
- kvs[len].key   = NULL;
- kvs[len].value = NULL;
-
- // do the acctual filling:
- last_was_seg = 0;
-
- for (sp = str; *sp != 0; sp++) {
-  if ( quote ) {
-   if ( *sp == quote ) {
-    skip_char(sp);
-    quote = 0;
-   } else {
-    continue;
-   }
-  } else if ( quotes && (*sp == '\'' || *sp == '\"') ) {
-   quote = *sp;
-   skip_char(sp);
-   continue;
-  }
-
-  if ( last_was_seg ) {
-   if ( is_in(*sp, fdel) ) {
-    last_was_seg = 0;
-    *sp = 0;
-   } else {
-    last_was_seg = 1;
-    if ( kvs[pos].value == NULL && is_in(*sp, kdel) ) {
-     *sp = 0;
-     kvs[pos].value = sp+1;
-    }
-   }
-  } else {
-   if ( !is_in(*sp, fdel) ) {
-    last_was_seg = 1;
-    pos++;
-    kvs[pos].key   = sp;
-    kvs[pos].value = NULL;
-   }
-  }
- }
-
- return len;
-}
-
-static inline void _copy_str(char ** dst, const char * src) {
- for (; *src; src++, (*dst)++) **dst = *src;
- *((*dst)++) = 0;
-}
-
-void * roar_keyval_copy(struct roar_keyval ** copy, const struct roar_keyval * src, ssize_t len) {
- size_t buflen = 0;
- ssize_t i;
- void * ret;
- char * p;
- struct roar_keyval * c;
-
- if ( copy == NULL || src == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- // TODO: optimize this.
- if ( len == -1 ) {
-  len = 0;
-  for (i = 0; src[i].key != NULL || src[i].value != NULL; i++)
-   len++;
- }
-
- for (i = 0; i < len; i++) {
-  if ( src[i].key != NULL )
-   buflen += roar_mm_strlen(src[i].key) + 1;
-  if ( src[i].value != NULL )
-   buflen += roar_mm_strlen(src[i].value) + 1;
- }
-
- c   = roar_mm_malloc(len * sizeof(struct roar_keyval));
- if ( c == NULL )
-  return NULL;
-
- memset(c, 0, len * sizeof(struct roar_keyval));
-
- ret = roar_mm_malloc(buflen);
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, buflen);
-
- p = ret;
-
- for (i = 0; i < len; i++) {
-  if ( src[i].key == NULL ) {
-   c[i].key = NULL;
-  } else {
-   c[i].key = p;
-   _copy_str(&p, src[i].key);
-  }
-
-  if ( src[i].value == NULL ) {
-   c[i].value = NULL;
-  } else {
-   c[i].value = p;
-   _copy_str(&p, src[i].value);
-  }
- }
-
- *copy = c;
- return ret;
-}
-
-//ll
Index: libroar/kstore.c
===================================================================
--- libroar/kstore.c	(revision 6079)
+++ 	(revision )
@@ -1,287 +1,0 @@
-//kstore.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define _LEN_DEFAULT 16
-
-struct binkv {
- char * key;
- void * value;
-};
-
-struct roar_kstore {
- size_t refc;
- int (*ref)(void *);
- int (*unref)(void *);
- const char * (*get_key)(void *);
- size_t len;
- struct binkv * kv;
-};
-
-struct roar_kstore * roar_kstore_new(ssize_t len,
-                                     int (*ref)(void *), int (*unref)(void *),
-                                     const char * (*get_key)(void *)) {
- struct roar_kstore * ret = roar_mm_malloc(sizeof(struct roar_kstore));
- int err;
-
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_kstore));
-
- if ( len == -1 )
-  len = _LEN_DEFAULT;
-
- ret->kv = roar_mm_malloc(len*sizeof(struct binkv));
- if ( ret->kv == NULL ) {
-  err = roar_error;
-  roar_mm_free(ret);
-  roar_error = err;
-  return NULL;
- }
-
- memset(ret->kv, 0, len*sizeof(struct binkv));
-
- ret->refc    = 1;
- ret->ref     = ref;
- ret->unref   = unref;
- ret->get_key = get_key;
- ret->len     = len;
-
- return ret;
-}
-
-int                  roar_kstore_ref(struct roar_kstore * store) {
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- store->refc++;
-
- return 0;
-}
-
-int                  roar_kstore_unref(struct roar_kstore * store) {
- size_t i;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- store->refc--;
-
- if ( store->refc )
-  return 0;
-
- if ( store->unref != NULL ) {
-  for (i = 0; i < store->len; i++) {
-   if ( store->kv[i].key == NULL )
-    continue;
-
-   if ( store->unref(store->kv[i].value) == -1 )
-    return -1;
-   roar_mm_free(store->kv[i].key);
-   store->kv[i].key = NULL;
-   store->kv[i].value = NULL;
-  }
- }
-
- roar_mm_free(store->kv);
- roar_mm_free(store);
-
- return 0;
-}
-
-int                  roar_kstore_add(struct roar_kstore * store, void * obj, const char * key) {
- size_t i;
- int err;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( key == NULL && store->get_key != NULL )
-  key = store->get_key(obj);
-
- if ( key == NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- for (i = 0; i < store->len; i++) {
-  if ( store->kv[i].key == NULL )
-   continue;
-  if ( !strcmp(store->kv[i].key, key) ) {
-   roar_err_set(ROAR_ERROR_EXIST);
-   return -1;
-  }
- }
-
- for (i = 0; i < store->len; i++) {
-  if ( store->kv[i].key != NULL )
-   continue;
-
-  store->kv[i].key = roar_mm_strdup(key);
-
-  if ( store->kv[i].key == NULL )
-   return -1;
-
-  store->kv[i].value = obj;
-
-  if ( store->ref != NULL ) {
-   if ( store->ref(obj) == -1 ) {
-    err = roar_error;
-    roar_mm_free(store->kv[i].key);
-    store->kv[i].key = NULL;
-    roar_error = err;
-    return -1;
-   }
-  }
-  return 0;
- }
-
- roar_err_set(ROAR_ERROR_NOSPC);
- return -1;
-}
-
-void *               roar_kstore_get(struct roar_kstore * store, const char * key) {
- size_t i;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- for (i = 0; i < store->len; i++) {
-  if ( store->kv[i].key != NULL && !strcmp(store->kv[i].key, key) ) {
-   if ( store->ref != NULL )
-    if ( store->ref(store->kv[i].value) == -1 )
-     return NULL;
-   return store->kv[i].value;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int                  roar_kstore_delete(struct roar_kstore * store, const char * key) {
- size_t i;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < store->len; i++) {
-  if ( store->kv[i].key != NULL && !strcmp(store->kv[i].key, key) ) {
-   if ( store->unref != NULL )
-    if ( store->unref(store->kv[i].value) == -1 )
-     return -1;
-   roar_mm_free(store->kv[i].key);
-   store->kv[i].key = NULL;
-   store->kv[i].value = NULL;
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char *         roar_kstore_name(struct roar_kstore * store, const void * obj) {
- size_t i;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- for (i = 0; i < store->len; i++) {
-  ROAR_DBG("roar_kstore_name(store=%p, obj=%p): store->kv[%i].key=%p'%s', store->kv[%i].value=%p", store, obj, (int)i, store->kv[i].key, store->kv[i].key, (int)i, store->kv[i].value);
-  if ( store->kv[i].key != NULL && store->kv[i].value == obj )
-   return store->kv[i].key;
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int                  roar_kstore_foreach(struct roar_kstore * store, int (*func)(void *obj, void *userdata), void * userdata) {
- size_t i;
- void *obj;
-
- if ( store == NULL || func == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < store->len; i++) {
-  if ( store->kv[i].key == NULL )
-   continue;
-
-  obj = store->kv[i].value;
-
-  if ( store->ref != NULL )
-   store->ref(obj);
-  func(obj, userdata);
-  if ( store->unref != NULL )
-   store->unref(obj);
- }
-
- return 0;
-}
-
-ssize_t              roar_kstore_length(struct roar_kstore * store) {
- ssize_t ret = 0;
- size_t i;
-
- if ( store == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < store->len; i++)
-  if ( store->kv[i].key != NULL )
-   ret++;
-
- return ret;
-}
-
-//ll
Index: libroar/libroar.c
===================================================================
--- libroar/libroar.c	(revision 6052)
+++ libroar/libroar.c	(revision 0)
@@ -1,391 +1,5 @@
 //libroar.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-/* ckport options:
- * ckport: ignore-symbol: sleep of target win32   -- checked by configure
- */
 
 #include "libroar.h"
 
-#ifndef roar_mm_mlock
-int roar_mm_mlock(const void *addr, size_t len) {
-#if defined(ROAR_TARGET_WIN32)
- /* GlobalLock() generates errors. Maybe we do not use correctly.
-  * We just ignore that at the moment and throw NOSYS.
-  *
-  * return GlobalLock(addr) == addr ? 0 : -1;
-  */
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#elif defined(ROAR_TARGET_MICROCONTROLLER)
- return 0;
-#elif defined(_SC_PAGESIZE)
- long sz = sysconf(_SC_PAGESIZE);
- unsigned long int pos = (unsigned long int) addr;
-
- len += sz - (len % sz);
-
- pos -= pos % sz;
-
- return mlock((void*)pos, len);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-#endif
-
-#ifndef roar_mm_munlock
-int roar_mm_munlock(const void *addr, size_t len) {
-#if defined(ROAR_TARGET_WIN32)
- // TODO: find out what do do here. GlobalUnLock()? does such a function exist?
-// return GlobalLock(addr) == addr ? 0 : -1;
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#elif defined(ROAR_TARGET_MICROCONTROLLER)
- return 0;
-#elif defined(_SC_PAGESIZE)
- long sz = sysconf(_SC_PAGESIZE);
- unsigned long int pos = (unsigned long int) addr;
-
- len += sz - (len % sz);
-
- pos -= pos % sz;
-
- return munlock((void*)pos, len);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-#endif
-
-// for compatibility with old versions:
-int _ROAR_MLOCK(const void *addr, size_t len) {
- roar_debug_warn_obsolete("_ROAR_MLOCK", "roar_mm_mlock", NULL);
- return roar_mm_mlock(addr, len);
-}
-
-int_least32_t roar_str2usec(const char * str) {
- int_least32_t man = 0, expo = 0, extra_expo = 0;
- int_least32_t * cur = &man;
- register unsigned char c;
- int mneg = 0, eneg = 0;
- int * neg = &mneg;
- int after_point = 0;
-
- for (; (c = *str); str++) {
-  if ( c >= '0' && c <= '9' ) {
-   *cur *= 10;
-   *cur += c - '0';
-   if ( after_point )
-    extra_expo--;
-  } else if ( c == '.' ) {
-   after_point = 1;
-  } else if ( c == '-' ) {
-   *neg = 1;
-  } else if ( c == '+' ) {
-   *neg = 0;
-  } else if ( c == 'e' ) {
-   cur = &expo;
-   neg = &eneg;
-   after_point = 0;
-  } else if ( c == 'm' ) {
-   extra_expo += -3;
-  } else if ( c == 'u' || c == 181 ) {
-   extra_expo += -6;
-  } else if ( c == 's' ) {
-   // ignore.
-  }
- }
-
- if ( eneg )
-  expo *= -1;
-
- expo += 6 + extra_expo;
-
- if ( expo < 0 ) {
-  for (; expo; expo++)
-   man /= 10;
- } else if ( expo > 0 ) {
-  for (; expo; expo--)
-   man *= 10;
- }
-
- return mneg ? -man : man;
-}
-
-int roar_usleep(uint_least32_t t) {
-#ifdef ROAR_TARGET_WIN32
- Sleep(t/(uint_least32_t)1000);
- return 0;
-#elif defined(ROAR_HAVE_NANOSLEEP)
- struct timespec tv;
- struct timespec left;
-
- if ( t >= (uint_least32_t)1000000 ) {
-  tv.tv_sec  = t/(uint_least32_t)1000000;
-  t         -= tv.tv_sec*(uint_least32_t)1000000;
- } else {
-  tv.tv_sec  = 0;
- }
-
- tv.tv_nsec = t*(uint_least32_t)1000;
-
- while (nanosleep(&tv, &left) == -1)
-  memcpy(&tv, &left, sizeof(tv));
- return 0;
-#elif defined(ROAR_HAVE_USLEEP)
- usleep(t);
- return 0;
-#else
- ROAR_ERR("roar_usleep(t=%" LIBROAR__ll "u): can not sleep: not implemented", (LIBROAR__longlong unsigned int)t);
- roar_strap(ROAR_TRAP_GROUP_LIBROAR, "usleep.not-implemented");
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-int roar_sleep(int t) {
- if ( t < 0 ) {
-  roar_err_set(ROAR_ERROR_CAUSALITY);
-  return -1;
- }
-
-#ifdef ROAR_TARGET_WIN32
- Sleep(1000L*(long)t);
-#elif defined(ROAR_HAVE_SLEEP)
- while (t)
-  t = sleep(t);
-#else
- while (t) {
-  if ( roar_usleep(500000) == -1 )
-   return -1;
-  if ( roar_usleep(500000) == -1 )
-   return -1;
-  t--;
- }
-#endif
-
- return 0;
-}
-
-static pid_t _libroar_fork(void ** context, void * userdata) {
-#ifdef ROAR_HAVE_FORK
- pid_t ret;
- (void)context, (void)userdata;
- ret = fork();
- if ( ret == -1 )
-  roar_err_from_errno();
- return ret;
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return (pid_t)-1;
-#endif
-}
-
-static const struct roar_libroar_forkapi _libroar_forkapi = {
- .prefork   = NULL,
- .fork      = _libroar_fork,
- .failed    = NULL,
- .parent    = NULL,
- .child     = NULL,
- .userdata  = NULL
-};
-
-pid_t roar_fork(const struct roar_libroar_forkapi * api) {
- void * context = NULL;
- pid_t ret;
-
- if ( api == NULL )
-  api = &_libroar_forkapi;
-
- if ( api->fork == NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( api->prefork != NULL ) {
-  if ( api->prefork(&context, api->userdata) != 0 ) {
-   if ( api->failed != NULL )
-    api->failed(&context, api->userdata);
-
-   if ( context != NULL )
-    roar_mm_free_noerror(context);
-   return (pid_t)-1;
-  }
- }
-
- if ( (ret = api->fork(&context, api->userdata)) == (pid_t)-1 ) {
-  if ( api->failed != NULL )
-   api->failed(&context, api->userdata);
-
-  if ( context != NULL )
-   roar_mm_free_noerror(context);
-  return (pid_t)-1;
- }
-
- if ( ret == (pid_t)0 ) {
-  if ( api->child != NULL )
-   api->child(&context, api->userdata);
- } else {
-  if ( api->parent != NULL )
-   api->parent(&context, api->userdata, ret);
- }
-
- if ( context != NULL )
-  roar_mm_free_noerror(context);
-
- return ret;
-}
-
-int roar_reset(enum roar_reset what) {
- char c;
- int i;
- enum roar_reset subsets = ROAR_RESET_NONE;
-
- roar_err_set(ROAR_ERROR_NONE);
-
- switch (what) {
-  case ROAR_RESET_NONE:
-    return 0;
-   break;
-  case ROAR_RESET_UNKNOWN:
-  case ROAR_RESET_EOL:
-    roar_err_set(ROAR_ERROR_INVAL);
-    return -1;
-   break;
-  case ROAR_RESET_ON_FORK:
-    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_RANDOMPOOL;
-   break;
-  case ROAR_RESET_ON_EXIT:
-  case ROAR_RESET_ON_PRE_EXEC:
-    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_CONFIG;
-   break;
-  default:
-    if ( what & 0x80 ) {
-     subsets |= what;
-    } else {
-     roar_err_set(ROAR_ERROR_INVAL);
-     return -1;
-    }
-   break;
- }
-
- // strip 0x80 so we can easly test on the other bit per subsystem.
- what |= 0x80;
- what -= 0x80;
-
- if ( what & ROAR_RESET_MEMORY ) {
-  (void)roar_mm_reset();
- }
-
- if ( what & ROAR_RESET_CONFIG ) {
-  roar_libroar_reset_config();
- }
-
- if ( what & ROAR_RESET_RANDOMPOOL ) {
-  for (i = 0; i < 16; i++) {
-   roar_random_gen_nonce(&c, 1);
-   roar_random_uint16();
-   roar_random_uint32();
-  }
- }
-
- roar_err_set(ROAR_ERROR_NONE);
- return 0;
-}
-
-void roar_panic_real(enum roar_fatal_error error, const char * info,
-                     unsigned long int line, const char * file, const char * prefix, const char * func) {
- const char * errname = NULL;
-//#define ROAR_ERR(format, args...)  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
-
- // we do not support info-text at the moment.
- (void)info;
-
- if ( func == NULL )
-  func = "<unknown>";
-
- switch (error) {
-  case ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD:
-    roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a guard segment memory corruption was detected. Backup your data and terminate this program. Report this lion to developer. Thanks.", func);
-    return;
-   break;
-  case ROAR_FATAL_ERROR_UNKNOWN:
-    errname = "<unknown error>";
-   break;
-  case ROAR_FATAL_ERROR_MEMORY_CORRUPTION:
-    errname = "Memory corruption";
-   break;
-  case ROAR_FATAL_ERROR_CPU_FAILURE:
-    errname = "CPU failure, replace hardware";
-   break;
-  case ROAR_FATAL_ERROR_MEMORY_USED_AFTER_FREE:
-    errname = "Memory used after free";
-   break;
-  case ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE:
-    errname = "Memory double freed";
-   break;
-  case ROAR_FATAL_ERROR_WATCHDOG:
-    errname = "Watchdog Timeout";
-   break;
-  default:
-    errname = "<unknown error code, BAD>";
-   break;
- }
-
- roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a _FATAL_ error of type \"%s\" was detected. Terminating program. Report this lion to developer. Thanks.", func, errname);
-
-#ifdef SIGKILL
- raise(SIGKILL);
-#endif
- abort();
-#ifdef ROAR_HAVE_U_EXIT
- ROAR_U_EXIT(1);
-#endif
-
- while(1);
-}
-
-const char   * roar_version_string(void) {
- return ROAR_VERSION_STRING;
-}
-
-uint32_t roar_version_num(void) {
- return _ROAR_MKVERSION(ROAR_VERSION_MAJOR, ROAR_VERSION_MINOR, ROAR_VERSION_REV);
-}
-
 //ll
Index: libroar/ltm.c
===================================================================
--- libroar/ltm.c	(revision 6052)
+++ 	(revision )
@@ -1,347 +1,0 @@
-//ltm.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-struct roar_ltm_result {
- int mt;
- int window;
- size_t streams;
- size_t nummt;
- size_t structlen;
- int64_t data[1];
-};
-
-static int roar_ltm_numbits(int f) {
- int found = 0;
-
- while (f) {
-  if ( f & 0x1 )
-   found++;
-
-  f >>= 1;
- }
-
- return found;
-}
-
-static int roar_ltm_pack_req(int mt, int window,
-                             int * streams, size_t slen,
-                             struct roar_message * mes, char ** buf,
-                             int regtype) {
- uint16_t * data;
- size_t i;
-
- if ( mt == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( streams == NULL || slen == 0 || mes == NULL || buf == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(mes, 0, sizeof(struct roar_message));
-
- switch (regtype) {
-  case ROAR_LTM_SST_REGISTER:
-  case ROAR_LTM_SST_UNREGISTER:
-    mes->cmd = ROAR_CMD_SET_STREAM_PARA;
-   break;
-  case ROAR_LTM_SST_GET_RAW:
-    mes->cmd = ROAR_CMD_GET_STREAM_PARA;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- if ( slen == 1 ) {
-  mes->stream  = *streams;
-  mes->datalen = 6 * 2;
- } else {
-  mes->stream = -1;
-  mes->datalen = (6 + slen) * 2;
- }
-
- if ( mes->datalen > LIBROAR_BUFFER_MSGDATA ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- *buf = NULL;
-
- data = (uint16_t*)mes->data;
-
- data[0] = 0;
- data[1] = ROAR_STREAM_PARA_LTM;
- data[2] = regtype;
- data[3] = window;
- data[4] = 0;
- data[5] = mt;
-
- for (i = 0; i < slen; i++) {
-  data[6+i] = streams[i];
- }
-
- for (i = 0; i < (mes->datalen/2); i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- return 0;
-}
-
-static int roar_ltm_regunreg(struct roar_connection * con, int mt, int window, int * streams, size_t slen, int type) {
- struct roar_message mes;
- char * buf = NULL;
- int    ret;
-
- if ( roar_ltm_pack_req(mt, window, streams, slen, &mes, &buf, type) == -1 )
-  return -1;
-
- ret = roar_req(con, &mes, &buf);
-
- if ( buf != NULL )
-  roar_mm_free(buf);
-
- if ( ret != -1 ) {
-  if ( mes.cmd != ROAR_CMD_OK )
-   ret = -1;
- }
-
- return ret;
-}
-
-int roar_ltm_register(struct roar_connection * con, int mt, int window, int * streams, size_t slen) {
- return roar_ltm_regunreg(con, mt, window, streams, slen, ROAR_LTM_SST_REGISTER);
-}
-int roar_ltm_unregister(struct roar_connection * con, int mt, int window, int * streams, size_t slen) {
- return roar_ltm_regunreg(con, mt, window, streams, slen, ROAR_LTM_SST_UNREGISTER);
-}
-
-
-#ifdef DEBUG
-#define HEXDUMP64(x) roar_ltm_hexdump64((x))
-static void roar_ltm_hexdump64(void * p) {
- unsigned char * d = p;
- ROAR_DBG("roar_ltm_hexdump64(p=%p): hex: %.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x", p, d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]);
-}
-#else
-#define HEXDUMP64(x)
-#endif
-
-struct roar_ltm_result * roar_ltm_get(struct roar_connection * con,
-                                      int mt, int window,
-                                      int * streams, size_t slen,
-                                      struct roar_ltm_result * oldresult) {
- struct roar_ltm_result * res = NULL;
- struct roar_message mes;
- size_t needed_structlen = 0;
- int64_t  * d64;
- char * buf = NULL;
- int    ret;
- size_t i;
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( streams == NULL || slen == 0 ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( roar_ltm_pack_req(mt, window, streams, slen, &mes, &buf, ROAR_LTM_SST_GET_RAW) == -1 )
-  return NULL;
-
- ret = roar_req(con, &mes, &buf);
-
- if ( ret == -1 || mes.cmd != ROAR_CMD_OK ) {
-  if ( buf != NULL )
-   roar_mm_free(buf);
-  return NULL;
- }
-
- if ( buf == NULL ) {
-  d64 = ( int64_t*)&(mes.data);
- } else {
-  d64 = ( int64_t*)buf;
- }
-
-
- for (i = 0; i < mes.datalen/8; i++) {
-  ROAR_DBG("roar_ltm_get(*): d64[i=%i]=%lli", i, (long long int)d64[i]);
-  HEXDUMP64(&(d64[i]));
-  d64[i] = ROAR_NET2HOST64(d64[i]);
-  HEXDUMP64(&(d64[i]));
-  ROAR_DBG("roar_ltm_get(*): d64[i=%i]=%lli", i, (long long int)d64[i]);
- }
-
- needed_structlen = sizeof(struct roar_ltm_result) + mes.datalen;
-
- if ( oldresult != NULL ) {
-  if ( oldresult->structlen >= needed_structlen ) {
-   res = oldresult;
-   needed_structlen = oldresult->structlen;
-  } else {
-   roar_ltm_freeres(oldresult);
-  }
- } else {
-  res = roar_mm_malloc(needed_structlen);
- }
-
- if ( res == NULL ) {
-  if ( buf != NULL )
-   roar_mm_free(buf);
-  return NULL;
- }
-
- memset(res, 0, needed_structlen);
- res->structlen = needed_structlen;
-
- res->mt      = mt;
- res->window  = window;
- res->streams = slen;
- res->nummt   = roar_ltm_numbits(mt);
-
- memcpy(res->data, d64, mes.datalen);
-
- if ( buf != NULL )
-  roar_mm_free(buf);
- return res;
-}
-
-#define _CKNULL(x) if ( (x) == NULL ) { roar_err_set(ROAR_ERROR_FAULT); return -1; }
-#define _RETMEMBERCKED(x,m) _CKNULL(x) return (x)->m
-
-int roar_ltm_get_numstreams(struct roar_ltm_result * res) {
- _RETMEMBERCKED(res, streams);
-}
-int roar_ltm_get_mt(struct roar_ltm_result * res) {
- _RETMEMBERCKED(res, mt);
-}
-int roar_ltm_get_window(struct roar_ltm_result * res) {
- _RETMEMBERCKED(res, window);
-}
-
-static int64_t * roar_ltm_get_streamptr(struct roar_ltm_result * res, size_t streamidx) {
- int64_t * ptr;
- int numchans;
- size_t i;
-
- ROAR_DBG("roar_ltm_get_streamptr(res=%p, streamidx=%i) = ?", res, streamidx);
-
- if ( res == NULL || streamidx >= res->streams ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- ptr = res->data;
-
- ROAR_DBG("roar_ltm_get_streamptr(res=%p, streamidx=%i): res->data=%p", res, streamidx, res->data);
-
- for (i = 0; i < streamidx; i++) {
-  numchans = *ptr & 0xFFFF;
-
-  ROAR_DBG("roar_ltm_get_streamptr(res=%p, streamidx=%i): i=%i, numchans=%i", res, streamidx, i, numchans);
-
-  ptr += res->nummt * numchans;
-  ptr++;
- }
-
- ROAR_DBG("roar_ltm_get_streamptr(res=%p, streamidx=%i) = %p", res, streamidx, ptr);
- return ptr;
-}
-
-int roar_ltm_get_numchans(struct roar_ltm_result * res, size_t streamidx) {
- int64_t * ptr = roar_ltm_get_streamptr(res, streamidx);
-
- if ( ptr == NULL )
-  return -1;
-
- return *ptr & 0xFFFF;
-}
-
-int64_t roar_ltm_extract(struct roar_ltm_result * res, int mt, size_t streamidx, int channel) {
- int64_t * ptr = roar_ltm_get_streamptr(res, streamidx);
- int numchans;
- int resmt;
-
- ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i) = ?", res, mt, streamidx, channel);
-
- if ( roar_ltm_numbits(mt) != 1 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i) = ?", res, mt, streamidx, channel);
-
- if ( ptr == NULL )
-  return -1;
-
- numchans = *ptr & 0xFFFF;
-
- ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i): numchans=%i", res, mt, streamidx, channel, numchans);
-
- if ( channel >= numchans ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- ptr++;
-
- ptr += res->nummt * channel;
-
- // now ptr points to the first mt for the given channel.
-
- resmt = res->mt;
-
- while (!(mt & 0x1)) {
-  if ( resmt & 0x1 )
-   ptr++;
-  mt    >>= 1;
-  resmt >>= 1;
- }
-
- ROAR_DBG("roar_ltm_extract(res=%p, mt=?, streamidx=%i, channel=%i): ptr=%p", res, streamidx, channel, ptr);
- ROAR_DBG("roar_ltm_extract(res=%p, mt=?, streamidx=%i, channel=%i) = %lli", res, streamidx, channel, (long long int)*ptr);
-
- return *ptr;
-}
-
-//ll
Index: libroar/memmgr.c
===================================================================
--- libroar/memmgr.c	(revision 6073)
+++ 	(revision )
@@ -1,583 +1,0 @@
-//memmgr.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_USE_MEMMGR
-#define NULL_BUFFER_CONST "RoarAudio"
-static char _libroar_null_buffer[] = NULL_BUFFER_CONST; // A byte sequense >= 8 byte.
-
-static inline void _libroar_null_buffer_check(void) {
- if ( memcmp(_libroar_null_buffer, NULL_BUFFER_CONST, sizeof(_libroar_null_buffer)) != 0 )
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD, NULL);
- memcpy(_libroar_null_buffer, NULL_BUFFER_CONST, sizeof(_libroar_null_buffer));
-}
-#endif
-
-#define _err(x) do { roar_err_set((x)); return NULL; } while (0)
-
-#ifdef ROAR_HAVE_CALLOC
-static void *  __libroar_calloc   (void * userdata, size_t nmemb, size_t size) {
- void * ret;
- roar_err_clear_all();
- ret  = calloc(nmemb, size);
- roar_err_update();
- return ret;
-}
-#endif
-#ifdef ROAR_HAVE_MALLOC
-static void *  __libroar_malloc   (void * userdata, size_t size) {
- void * ret;
- roar_err_clear_all();
- ret  = malloc(size);
- roar_err_update();
- return ret;
-}
-#endif
-#ifdef ROAR_HAVE_FREE
-static int     __libroar_free     (void * userdata, void * ptr) {
- free(ptr);
- return 0;
-}
-#endif
-#ifdef ROAR_HAVE_REALLOC
-static void *  __libroar_realloc  (void * userdata, void * ptr, size_t size) {
- void * ret;
- roar_err_clear_all();
- ret  = realloc(ptr, size);
- roar_err_update();
- return ret;
-}
-#endif
-
-static const struct roar_libroar_memmgrapi __memory_default_api = {
-#ifdef ROAR_HAVE_CALLOC
- .calloc = __libroar_calloc,
-#else
- .calloc = NULL,
-#endif
-#ifdef ROAR_HAVE_MALLOC
- .malloc = __libroar_malloc,
-#else
- .malloc = NULL,
-#endif
-#ifdef ROAR_HAVE_FREE
- .free = __libroar_free,
-#else
- .free = NULL,
-#endif
-#ifdef ROAR_HAVE_REALLOC
- .realloc = __libroar_realloc,
-#else
- .realloc = NULL,
-#endif
- .reset = NULL, // not needed
- .sizeofbuf = NULL, // not supported
-
- // Not yet supported:
- .mlock = NULL,
- .munlock = NULL,
- .mlockall = NULL,
- .munlockall = NULL,
-
- // no need with C API.
- .userdata = NULL
-};
-
-static const struct roar_libroar_memmgrapi * memory_api = &__memory_default_api;
-
-int    roar_libroar_set_memmgrapi(const struct roar_libroar_memmgrapi * api) {
- if ( api == NULL )
-  memory_api = &__memory_default_api;
- memory_api = api;
- return 0;
-}
-
-#ifdef ROAR_USE_MEMMGR
-int     roar_mm_reset(void) {
- // currently this does nothing.
- // we need to free pools and such here later.
-
- if ( memory_api->reset != NULL )
-  return memory_api->reset(memory_api->userdata);
- return 0;
-}
-
-ssize_t roar_mm_sizeof(void * buf) {
- if ( buf == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( buf == _libroar_null_buffer_check )
-  return 0;
-
- if ( memory_api->sizeofbuf != NULL )
-  return memory_api->sizeofbuf(memory_api->userdata, buf);
-
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-}
-
-void * roar_mm_calloc(size_t nmemb, size_t size) {
- void * ret;
-
- if ( nmemb == 0 || size == 0 ) {
-  _libroar_null_buffer_check();
-  return _libroar_null_buffer;
- }
-
- if ( memory_api->calloc != NULL ) {
-  return memory_api->calloc(memory_api->userdata, nmemb, size);
- } else {
-  ret = roar_mm_malloc(nmemb*size);
-  if ( ret == NULL )
-   return NULL;
-
-  memset(ret, 0, nmemb*size);
-
-  return ret;
- }
-}
-
-void * roar_mm_malloc(size_t size) {
- if ( size == 0 ) {
-  _libroar_null_buffer_check();
-  return _libroar_null_buffer;
- }
-
- if ( memory_api->malloc != NULL ) {
-  return memory_api->malloc(memory_api->userdata, size);
- } else if ( memory_api->calloc != NULL ) {
-  return roar_mm_calloc(1, size);
- } else if ( memory_api->realloc != NULL ) {
-  return roar_mm_realloc(NULL, size);
- } else {
-  _err(ROAR_ERROR_NOSYS);
- }
-}
-
-int    roar_mm_free(void *ptr) {
- if ( ptr == NULL )
-  return 0;
-
- if ( ptr == _libroar_null_buffer ) {
-  _libroar_null_buffer_check();
-  return 0;
- }
-
- if ( memory_api->free != NULL ) {
-  return memory_api->free(memory_api->userdata, ptr);
- } else if ( memory_api->realloc != NULL ) {
-  if ( roar_mm_realloc(ptr, 0) != _libroar_null_buffer )
-   return -1;
-  return 0;
- } else {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-}
-
-void * roar_mm_realloc(void *ptr, size_t size) {
- void * ret;
- ssize_t len;
-
- if ( ptr == NULL )
-  return roar_mm_malloc(size);
-
- if ( size == 0 ) {
-  roar_mm_free(ptr);
-  _libroar_null_buffer_check();
-  return _libroar_null_buffer;
- }
-
- if ( memory_api->realloc != NULL ) {
-  return memory_api->realloc(memory_api->userdata, ptr, size);
- } else {
-  len = roar_mm_sizeof(ptr);
-  if ( len == -1 )
-   return NULL;
-
-  ret = roar_mm_malloc(size); 
-  if ( ret == NULL )
-   return NULL;
-
-  memcpy(ret, ptr, len > (ssize_t)size ? size : len);
-
-  return ret;
- }
-}
-#endif
-
-void * roar_mm_memdup(const void * s, size_t len) {
- void * ret;
-
- if ( s == NULL )
-  _err(ROAR_ERROR_FAULT);
-
-#ifdef ROAR_USE_MEMMGR
- if ( len == 0 ) {
-  _libroar_null_buffer_check();
-  return _libroar_null_buffer;
- }
-#endif
-
- ret = roar_mm_malloc(len);
-
- if ( ret == NULL )
-  return NULL;
-
- memcpy(ret, s, len);
-
- return ret;
-}
-
-void roar_mm_free_retvoid(void *ptr) {
- roar_mm_free(ptr);
-}
-
-void roar_mm_free_noerror(void *ptr) {
- struct roar_error_state state;
-
- if ( ptr == NULL )
-  return;
-
- roar_err_store(&state);
- roar_mm_free(ptr);
- roar_err_restore(&state);
-}
-
-#if defined(ROAR_USE_MEMMGR) || !defined(ROAR_HAVE_STRDUP)
-char * roar_mm_strdup(const char *s) {
- void * ret;
-#ifndef ROAR_HAVE_STRDUP
- ssize_t len;
-#endif
-
- if ( s == NULL )
-  _err(ROAR_ERROR_FAULT);
-
-#ifdef ROAR_HAVE_STRDUP
- roar_err_clear_all();
- ret = strdup(s);
-
- if ( ret == NULL )
-  roar_err_update();
-#else
- len = roar_mm_strlen(s);
- if ( len == -1 )
-  return NULL;
-
- ret = roar_mm_memdup(s, len+1);
-#endif
-
- return ret;
-}
-#endif
-
-#if defined(ROAR_USE_MEMMGR) || !defined(ROAR_HAVE_STRNDUP)
-char *roar_mm_strndup(const char *s, size_t n) {
- void * ret;
-#ifndef ROAR_HAVE_STRNDUP
- ssize_t len;
-#endif
-
- if ( s == NULL )
-  _err(ROAR_ERROR_FAULT);
-
-#ifdef ROAR_USE_MEMMGR
- if ( n == 0 ) {
-  _libroar_null_buffer_check();
-  return _libroar_null_buffer;
- }
-#endif
-
-#ifdef ROAR_HAVE_STRNDUP
- roar_err_clear_all();
- ret = strndup(s, n);
-
- if ( ret == NULL )
-  roar_err_update();
-#else
- len = roar_mm_strnlen(s, n);
- if ( len == -1 )
-  return NULL;
-
- ret = roar_mm_memdup(s, len+1);
-#endif
-
- return ret;
-}
-#endif
-
-char * roar_mm_strdup2(const char *s, const char *def) {
- if ( s == NULL )
-  s = def;
- if ( s == NULL ) {
-  roar_err_clear();
-  return NULL;
- }
-
- return roar_mm_strdup(s);
-}
-
-#ifndef ROAR_HAVE_STRLEN
-ssize_t roar_mm_strlen(const char *s) {
- size_t ret = 0;
-
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (; *s != 0; s++, ret++);
-
- return ret;
-}
-#endif
-
-ssize_t roar_mm_strnlen(const char *s, size_t maxlen) {
- size_t ret = 0;
-
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
-#ifdef ROAR_HAVE_STRNLEN
- ret = strnlen(s, maxlen);
-#else
- for (; ret < maxlen && *s != 0; s++, ret++);
-#endif
-
- if ( ret == maxlen ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- return ret;
-}
-
-
-#ifndef ROAR_HAVE_STRLCPY
-ssize_t roar_mm_strlcpy(char *dst, const char *src, size_t size) {
- ssize_t len;
-
- if ( dst == NULL || src == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( size == 0 )
-  return 0;
-
- len = roar_mm_strlen(src);
- if ( len == -1 )
-  return -1;
-
- if ( len < (ssize_t)size ) {
-  memcpy(dst, src, len);
-  dst[len] = 0;
- } else {
-  memcpy(dst, src, size - 1);
-  dst[size-1] = 0;
- }
-
- return len;
-}
-#endif
-
-#ifndef ROAR_HAVE_STRLCAT
-ssize_t roar_mm_strlcat(char *dst, const char *src, size_t size) {
- ssize_t slen;
- ssize_t dlen;
- int err;
-
- if ( dst == NULL || src == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( size == 0 )
-  return 0;
-
- slen = roar_mm_strlen(src);
- if ( slen == -1 )
-  return -1;
-
- dlen = roar_mm_strnlen(dst, size);
- err  = roar_error;
- if ( dlen == -1 && err == ROAR_ERROR_MSGSIZE )
-  dlen = size;
-
- if ( dlen == -1 )
-  return -1;
-
- if ( (dlen + slen) < (ssize_t)size ) {
-  memcpy(dst+dlen, src, slen);
-  dst[dlen+slen] = 0;
- } else if ( dlen != (ssize_t)size ) {
-  memcpy(dst+dlen, src, size-dlen-1);
-  dst[size-1] = 0;
- }
-
- return dlen+slen;
-}
-#endif
-
-#ifndef ROAR_HAVE_STRTOK_R
-char * roar_mm_strtok_r(char *str, const char *delim, char **saveptr) {
- char * next;
-
- if ( delim == NULL || saveptr == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( delim[0] == 0 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return NULL;
- }
-
- if ( delim[1] != 0 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return NULL;
- }
-
- if ( str != NULL ) {
-  next = str;
- } else {
-  next = *saveptr;
- }
-
- if ( next == NULL ) {
-  roar_err_set(ROAR_ERROR_NODATA);
-  return NULL;
- }
-
- *saveptr = strstr(next, delim);
-
- if ( *saveptr != NULL ) {
-  **saveptr = 0;
-  (*saveptr)++;
- }
-
- return next;
-}
-#endif
-
-int roar_mm_strselcmp(const char *s1, const char *s2) {
- register char a, b;
-
- if ( s1 == s2 )
-  return 0;
-
- if ( s1 == NULL || s2 == NULL )
-  return -1;
-
- for (; ; s1++, s2++) {
-  a = *s1;
-  b = *s2;
-
-  if ( a == '*' ) {
-   s1++;
-   a = *s1;
-   if ( a == 0 ) {
-    if ( b == 0 ) {
-     return 1; // no match! ('*' does not mach no-chars)
-    } else {
-     return 0; // match! (string ends with '*' and something not EOS is in b)
-    }
-   } else {
-    for (; *s2 != 0 && *s2 != a; s2++);
-    if ( a != *s2 )
-     return 1; // no match! (did not find correct char)
-   }
-  } else if ( a == 0 || b == 0 ) {
-   if ( a == b ) {
-    return 0; // match!
-   } else {
-    return 1; // no match! (dffrent length)
-   }
-  } else if ( a != b ) {
-   return 1; // no match! (diffrent chars)
-  }
- }
-
- return -1;
-}
-
-ssize_t roar_mm_strseltok(const char *s1, char *s2, char ** tok, size_t toks) {
- register char a, b;
- size_t idx = 0;
-
- if ( s1 == NULL || s2 == NULL )
-  return -1;
-
- for (; ; s1++, s2++) {
-  a = *s1;
-  b = *s2;
-
-  if ( a == 0 || b == 0 ) {
-   if ( a == b ) {
-    return idx;
-   } else {
-    return -1;
-   }
-  } else if ( a == '*' ) {
-   s1++;
-   a = *s1;
-   if ( idx == toks )
-    return -1;
-
-   tok[idx] = s2;
-   idx++;
-
-   for (; *s2 != 0 && *s2 != a; s2++);
-
-   if ( a == 0 )
-    return idx;
-
-   if ( *s1 == 0 )
-    return -1;
-
-   *s2 = 0;
-  }
- }
-
- return -1;
-}
-
-//ll
Index: libroar/meta.c
===================================================================
--- libroar/meta.c	(revision 6052)
+++ 	(revision )
@@ -1,650 +1,0 @@
-//meta.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-/*
-
-grep ^'#define ROAR_META_TYPE_' meta.h | cut -d' ' -f2 | while read line; do printf ' {%-30s     "%-16s},\n' $line, $(echo $line | cut -d_ -f4)\"; done
-
-*/
-
-static struct {
- int    id;
- const char * name;
-} _libroar_meta_typelist[] = {
- {ROAR_META_TYPE_NONE,               "NONE"           },
- {ROAR_META_TYPE_TITLE,              "TITLE"          },
- {ROAR_META_TYPE_ALBUM,              "ALBUM"          },
- {ROAR_META_TYPE_AUTHOR,             "AUTHOR"         },
- {ROAR_META_TYPE_AUTOR,              "AUTOR"          },
- {ROAR_META_TYPE_ARTIST,             "ARTIST"         },
- {ROAR_META_TYPE_VERSION,            "VERSION"        },
- {ROAR_META_TYPE_DATE,               "DATE"           },
- {ROAR_META_TYPE_LICENSE,            "LICENSE"        },
- {ROAR_META_TYPE_TRACKNUMBER,        "TRACKNUMBER"    },
- {ROAR_META_TYPE_ORGANIZATION,       "ORGANIZATION"   },
- {ROAR_META_TYPE_DESCRIPTION,        "DESCRIPTION"    },
- {ROAR_META_TYPE_GENRE,              "GENRE"          },
- {ROAR_META_TYPE_LOCATION,           "LOCATION"       },
- {ROAR_META_TYPE_CONTACT,            "CONTACT"        },
- {ROAR_META_TYPE_STREAMURL,          "STREAMURL"      },
- {ROAR_META_TYPE_HOMEPAGE,           "HOMEPAGE"       },
- {ROAR_META_TYPE_THUMBNAIL,          "THUMBNAIL"      },
- {ROAR_META_TYPE_LENGTH,             "LENGTH"         },
- {ROAR_META_TYPE_COMMENT,            "COMMENT"        },
- {ROAR_META_TYPE_OTHER,              "OTHER"          },
- {ROAR_META_TYPE_FILENAME,           "FILENAME"       },
- {ROAR_META_TYPE_FILEURL,            "FILEURL"        },
- {ROAR_META_TYPE_SERVER,             "SERVER"         },
- {ROAR_META_TYPE_DURATION,           "DURATION"       },
- {ROAR_META_TYPE_WWW,                "WWW"            },
- {ROAR_META_TYPE_WOAF,               "WOAF"           },
- {ROAR_META_TYPE_ENCODER,            "ENCODER"        },
- {ROAR_META_TYPE_ENCODEDBY,          "ENCODEDBY"      },
- {ROAR_META_TYPE_ENCODEDBY,          "ENCODED-BY"     }, // alias
- {ROAR_META_TYPE_YEAR,               "YEAR"           },
- {ROAR_META_TYPE_DISCID,             "DISCID"         },
- {ROAR_META_TYPE_RPG_TRACK_PEAK,     "REPLAYGAIN_TRACK_PEAK" },
- {ROAR_META_TYPE_RPG_TRACK_GAIN,     "REPLAYGAIN_TRACK_GAIN" },
- {ROAR_META_TYPE_RPG_ALBUM_PEAK,     "REPLAYGAIN_ALBUM_PEAK" },
- {ROAR_META_TYPE_RPG_ALBUM_GAIN,     "REPLAYGAIN_ALBUM_GAIN" },
- {ROAR_META_TYPE_HASH,               "HASH"           },
- {ROAR_META_TYPE_SIGNALINFO,         "SIGNALINFO"     },
- {ROAR_META_TYPE_AUDIOINFO,          "AUDIOINFO"      },
- {ROAR_META_TYPE_OFFSET,             "OFFSET"         },
- {ROAR_META_TYPE_PERFORMER,          "PERFORMER"      },
- {ROAR_META_TYPE_COPYRIGHT,          "COPYRIGHT"      },
- {ROAR_META_TYPE_LIKENESS,           "LIKENESS"       },
- {ROAR_META_TYPE_COMPOSER,           "COMPOSER"       },
- {ROAR_META_TYPE_RIGHTS,             "RIGHTS"         },
- {ROAR_META_TYPE_ISRC,               "ISRC"           },
- {ROAR_META_TYPE_LANGUAGE,           "LANGUAGE"       },
- {ROAR_META_TYPE_GTIN,               "GTIN"           },
- {ROAR_META_TYPE_GTIN,               "EAN/UPN"        }, // alias
- {ROAR_META_TYPE_GTIN,               "UPN"            }, // alias
- {ROAR_META_TYPE_ISBN,               "ISBN"           },
- {ROAR_META_TYPE_EAN,                "EAN"            },
- {ROAR_META_TYPE_PUBLISHER,          "PUBLISHER"      },
- {ROAR_META_TYPE_DISCNUMBER,         "DISCNUMBER"     },
- {ROAR_META_TYPE_SOURCEMEDIA,        "SOURCEMEDIA"    },
- {ROAR_META_TYPE_LABEL,              "LABEL"          },
- {ROAR_META_TYPE_LABELNO,            "LABELNO"        },
- 
- {-1, "EOL"}
-};
-
-
-static struct {
- int    id;
- const char * name;
-} _libroar_meta_genrelist[] = {
-{ROAR_META_GENRE_META_NONE,               "meta_none"},
-{ROAR_META_GENRE_META_NONE,               "none"},
-{ROAR_META_GENRE_META_OTHER,              "meta_other"},
-{ROAR_META_GENRE_META_OTHER,              "other"},
-{ROAR_META_GENRE_META_MUSIC,              "meta_music"},
-{ROAR_META_GENRE_META_MUSIC,              "music"},
-{ROAR_META_GENRE_META_MODERATION,         "meta_moderation"},
-{ROAR_META_GENRE_META_MODERATION,         "moderation"},
-{ROAR_META_GENRE_META_TEXT,               "meta_text"},
-{ROAR_META_GENRE_META_TEXT,               "text"},
-{ROAR_META_GENRE_META_COMMERCIAL,         "meta_commercial"},
-{ROAR_META_GENRE_META_COMMERCIAL,         "commercial"},
-{ROAR_META_GENRE_RDS_EU_NONE,             "rds_eu_none"},
-{ROAR_META_GENRE_RDS_EU_NONE,             "none"},
-{ROAR_META_GENRE_RDS_EU_NEWS,             "rds_eu_news"},
-{ROAR_META_GENRE_RDS_EU_NEWS,             "news"},
-{ROAR_META_GENRE_RDS_EU_CURRENT_AFFAIRS,  "rds_eu_current_affairs"},
-{ROAR_META_GENRE_RDS_EU_CURRENT_AFFAIRS,  "current affairs"},
-{ROAR_META_GENRE_RDS_EU_INFORMATION,      "rds_eu_information"},
-{ROAR_META_GENRE_RDS_EU_INFORMATION,      "information"},
-{ROAR_META_GENRE_RDS_EU_SPORT,            "rds_eu_sport"},
-{ROAR_META_GENRE_RDS_EU_SPORT,            "sport"},
-{ROAR_META_GENRE_RDS_EU_EDUCATION,        "rds_eu_education"},
-{ROAR_META_GENRE_RDS_EU_EDUCATION,        "education"},
-{ROAR_META_GENRE_RDS_EU_DRAMA,            "rds_eu_drama"},
-{ROAR_META_GENRE_RDS_EU_DRAMA,            "drama"},
-{ROAR_META_GENRE_RDS_EU_CULTURE,          "rds_eu_culture"},
-{ROAR_META_GENRE_RDS_EU_CULTURE,          "culture"},
-{ROAR_META_GENRE_RDS_EU_SCIENCE,          "rds_eu_science"},
-{ROAR_META_GENRE_RDS_EU_SCIENCE,          "science"},
-{ROAR_META_GENRE_RDS_EU_VARIED,           "rds_eu_varied"},
-{ROAR_META_GENRE_RDS_EU_VARIED,           "varied"},
-{ROAR_META_GENRE_RDS_EU_POP_MUSIC,        "rds_eu_pop_music"},
-{ROAR_META_GENRE_RDS_EU_POP_MUSIC,        "pop music"},
-{ROAR_META_GENRE_RDS_EU_ROCK_MUSIC,       "rds_eu_rock_music"},
-{ROAR_META_GENRE_RDS_EU_ROCK_MUSIC,       "rock music"},
-{ROAR_META_GENRE_RDS_EU_EASY_LISTENING,   "rds_eu_easy_listening"},
-{ROAR_META_GENRE_RDS_EU_EASY_LISTENING,   "easy listening"},
-{ROAR_META_GENRE_RDS_EU_LIGHT_CLASSICAL,  "rds_eu_light_classical"},
-{ROAR_META_GENRE_RDS_EU_LIGHT_CLASSICAL,  "light classical"},
-{ROAR_META_GENRE_RDS_EU_SERIOUS_CLASSICAL, "rds_eu_serious_classical"},
-{ROAR_META_GENRE_RDS_EU_SERIOUS_CLASSICAL, "serious classical"},
-{ROAR_META_GENRE_RDS_EU_OTHER_MUSIC,      "rds_eu_other_music"},
-{ROAR_META_GENRE_RDS_EU_OTHER_MUSIC,      "other music"},
-{ROAR_META_GENRE_RDS_EU_WEATHER,          "rds_eu_weather"},
-{ROAR_META_GENRE_RDS_EU_WEATHER,          "weather"},
-{ROAR_META_GENRE_RDS_EU_FINANCE,          "rds_eu_finance"},
-{ROAR_META_GENRE_RDS_EU_FINANCE,          "finance"},
-{ROAR_META_GENRE_RDS_EU_CHILDREN_S_PROGRAMMES, "rds_eu_children_s_programmes"},
-{ROAR_META_GENRE_RDS_EU_CHILDREN_S_PROGRAMMES, "children s programmes"},
-{ROAR_META_GENRE_RDS_EU_SOCIAL_AFFAIRS,   "rds_eu_social_affairs"},
-{ROAR_META_GENRE_RDS_EU_SOCIAL_AFFAIRS,   "social affairs"},
-{ROAR_META_GENRE_RDS_EU_RELIGION,         "rds_eu_religion"},
-{ROAR_META_GENRE_RDS_EU_RELIGION,         "religion"},
-{ROAR_META_GENRE_RDS_EU_PHONE_IN,         "rds_eu_phone_in"},
-{ROAR_META_GENRE_RDS_EU_PHONE_IN,         "phone in"},
-{ROAR_META_GENRE_RDS_EU_TRAVEL,           "rds_eu_travel"},
-{ROAR_META_GENRE_RDS_EU_TRAVEL,           "travel"},
-{ROAR_META_GENRE_RDS_EU_LEISURE,          "rds_eu_leisure"},
-{ROAR_META_GENRE_RDS_EU_LEISURE,          "leisure"},
-{ROAR_META_GENRE_RDS_EU_JAZZ_MUSIC,       "rds_eu_jazz_music"},
-{ROAR_META_GENRE_RDS_EU_JAZZ_MUSIC,       "jazz music"},
-{ROAR_META_GENRE_RDS_EU_COUNTRY_MUSIC,    "rds_eu_country_music"},
-{ROAR_META_GENRE_RDS_EU_COUNTRY_MUSIC,    "country music"},
-{ROAR_META_GENRE_RDS_EU_NATIONAL_MUSIC,   "rds_eu_national_music"},
-{ROAR_META_GENRE_RDS_EU_NATIONAL_MUSIC,   "national music"},
-{ROAR_META_GENRE_RDS_EU_OLDIES_MUSIC,     "rds_eu_oldies_music"},
-{ROAR_META_GENRE_RDS_EU_OLDIES_MUSIC,     "oldies music"},
-{ROAR_META_GENRE_RDS_EU_FOLK_MUSIC,       "rds_eu_folk_music"},
-{ROAR_META_GENRE_RDS_EU_FOLK_MUSIC,       "folk music"},
-{ROAR_META_GENRE_RDS_EU_DOCUMENTARY,      "rds_eu_documentary"},
-{ROAR_META_GENRE_RDS_EU_DOCUMENTARY,      "documentary"},
-{ROAR_META_GENRE_RDS_EU_ALARM_TEST,       "rds_eu_alarm_test"},
-{ROAR_META_GENRE_RDS_EU_ALARM_TEST,       "alarm test"},
-{ROAR_META_GENRE_RDS_EU_ALARM,            "rds_eu_alarm"},
-{ROAR_META_GENRE_RDS_EU_ALARM,            "alarm"},
-{ROAR_META_GENRE_RDS_EU_EMERGENCY_TEST,   "rds_eu_emergency_test"},
-{ROAR_META_GENRE_RDS_EU_EMERGENCY_TEST,   "emergency test"},
-{ROAR_META_GENRE_RDS_EU_EMERGENCY,        "rds_eu_emergency"},
-{ROAR_META_GENRE_RDS_EU_EMERGENCY,        "emergency"},
-{ROAR_META_GENRE_RDS_NA_NONE,             "rds_na_none"},
-{ROAR_META_GENRE_RDS_NA_NONE,             "none"},
-{ROAR_META_GENRE_RDS_NA_NEWS,             "rds_na_news"},
-{ROAR_META_GENRE_RDS_NA_NEWS,             "news"},
-{ROAR_META_GENRE_RDS_NA_INFORMATION,      "rds_na_information"},
-{ROAR_META_GENRE_RDS_NA_INFORMATION,      "information"},
-{ROAR_META_GENRE_RDS_NA_SPORTS,           "rds_na_sports"},
-{ROAR_META_GENRE_RDS_NA_SPORTS,           "sports"},
-{ROAR_META_GENRE_RDS_NA_TALK,             "rds_na_talk"},
-{ROAR_META_GENRE_RDS_NA_TALK,             "talk"},
-{ROAR_META_GENRE_RDS_NA_ROCK,             "rds_na_rock"},
-{ROAR_META_GENRE_RDS_NA_ROCK,             "rock"},
-{ROAR_META_GENRE_RDS_NA_CLASSIC_ROCK,     "rds_na_classic_rock"},
-{ROAR_META_GENRE_RDS_NA_CLASSIC_ROCK,     "classic rock"},
-{ROAR_META_GENRE_RDS_NA_ADULT_HITS,       "rds_na_adult_hits"},
-{ROAR_META_GENRE_RDS_NA_ADULT_HITS,       "adult hits"},
-{ROAR_META_GENRE_RDS_NA_SOFT_ROCK,        "rds_na_soft_rock"},
-{ROAR_META_GENRE_RDS_NA_SOFT_ROCK,        "soft rock"},
-{ROAR_META_GENRE_RDS_NA_TOP_40,           "rds_na_top_40"},
-{ROAR_META_GENRE_RDS_NA_TOP_40,           "top 40"},
-{ROAR_META_GENRE_RDS_NA_COUNTRY,          "rds_na_country"},
-{ROAR_META_GENRE_RDS_NA_COUNTRY,          "country"},
-{ROAR_META_GENRE_RDS_NA_OLDIES,           "rds_na_oldies"},
-{ROAR_META_GENRE_RDS_NA_OLDIES,           "oldies"},
-{ROAR_META_GENRE_RDS_NA_SOFT,             "rds_na_soft"},
-{ROAR_META_GENRE_RDS_NA_SOFT,             "soft"},
-{ROAR_META_GENRE_RDS_NA_NOSTALGIA,        "rds_na_nostalgia"},
-{ROAR_META_GENRE_RDS_NA_NOSTALGIA,        "nostalgia"},
-{ROAR_META_GENRE_RDS_NA_JAZZ,             "rds_na_jazz"},
-{ROAR_META_GENRE_RDS_NA_JAZZ,             "jazz"},
-{ROAR_META_GENRE_RDS_NA_CLASSICAL,        "rds_na_classical"},
-{ROAR_META_GENRE_RDS_NA_CLASSICAL,        "classical"},
-{ROAR_META_GENRE_RDS_NA_RHYTHM_AND_BLUES, "rds_na_rhythm_and_blues"},
-{ROAR_META_GENRE_RDS_NA_RHYTHM_AND_BLUES, "rhythm and blues"},
-{ROAR_META_GENRE_RDS_NA_SOFT_RHYTHM_AND_BLUES, "rds_na_soft_rhythm_and_blues"},
-{ROAR_META_GENRE_RDS_NA_SOFT_RHYTHM_AND_BLUES, "soft rhythm and blues"},
-{ROAR_META_GENRE_RDS_NA_LANGUAGE,         "rds_na_language"},
-{ROAR_META_GENRE_RDS_NA_LANGUAGE,         "language"},
-{ROAR_META_GENRE_RDS_NA_RELIGIOUS_MUSIC,  "rds_na_religious_music"},
-{ROAR_META_GENRE_RDS_NA_RELIGIOUS_MUSIC,  "religious music"},
-{ROAR_META_GENRE_RDS_NA_RELIGIOUS_TALK,   "rds_na_religious_talk"},
-{ROAR_META_GENRE_RDS_NA_RELIGIOUS_TALK,   "religious talk"},
-{ROAR_META_GENRE_RDS_NA_PERSONALITY,      "rds_na_personality"},
-{ROAR_META_GENRE_RDS_NA_PERSONALITY,      "personality"},
-{ROAR_META_GENRE_RDS_NA_PUBLIC,           "rds_na_public"},
-{ROAR_META_GENRE_RDS_NA_PUBLIC,           "public"},
-{ROAR_META_GENRE_RDS_NA_COLLEGE,          "rds_na_college"},
-{ROAR_META_GENRE_RDS_NA_COLLEGE,          "college"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_0,     "rds_na_unassigned_0"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_0,     "unassigned 0"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_1,     "rds_na_unassigned_1"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_1,     "unassigned 1"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_2,     "rds_na_unassigned_2"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_2,     "unassigned 2"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_3,     "rds_na_unassigned_3"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_3,     "unassigned 3"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_4,     "rds_na_unassigned_4"},
-{ROAR_META_GENRE_RDS_NA_UNASSIGNED_4,     "unassigned 4"},
-{ROAR_META_GENRE_RDS_NA_WEATHER,          "rds_na_weather"},
-{ROAR_META_GENRE_RDS_NA_WEATHER,          "weather"},
-{ROAR_META_GENRE_RDS_NA_EMERGENCY_TEST,   "rds_na_emergency_test"},
-{ROAR_META_GENRE_RDS_NA_EMERGENCY_TEST,   "emergency test"},
-{ROAR_META_GENRE_RDS_NA_EMERGENCY,        "rds_na_emergency"},
-{ROAR_META_GENRE_RDS_NA_EMERGENCY,        "emergency"},
-{ROAR_META_GENRE_RDS_NA_ALARM_TEST,       "rds_na_alarm_test"},
-{ROAR_META_GENRE_RDS_NA_ALARM_TEST,       "alarm test"},
-{ROAR_META_GENRE_RDS_NA_ALARM,            "rds_na_alarm"},
-{ROAR_META_GENRE_RDS_NA_ALARM,            "alarm"},
-{ROAR_META_GENRE_ID3_BLUES,               "id3_blues"},
-{ROAR_META_GENRE_ID3_BLUES,               "blues"},
-{ROAR_META_GENRE_ID3_CLASSIC_ROCK,        "id3_classic_rock"},
-{ROAR_META_GENRE_ID3_CLASSIC_ROCK,        "classic rock"},
-{ROAR_META_GENRE_ID3_COUNTRY,             "id3_country"},
-{ROAR_META_GENRE_ID3_COUNTRY,             "country"},
-{ROAR_META_GENRE_ID3_DANCE,               "id3_dance"},
-{ROAR_META_GENRE_ID3_DANCE,               "dance"},
-{ROAR_META_GENRE_ID3_DISCO,               "id3_disco"},
-{ROAR_META_GENRE_ID3_DISCO,               "disco"},
-{ROAR_META_GENRE_ID3_FUNK,                "id3_funk"},
-{ROAR_META_GENRE_ID3_FUNK,                "funk"},
-{ROAR_META_GENRE_ID3_GRUNGE,              "id3_grunge"},
-{ROAR_META_GENRE_ID3_GRUNGE,              "grunge"},
-{ROAR_META_GENRE_ID3_HIP_HOP,             "id3_hip_hop"},
-{ROAR_META_GENRE_ID3_HIP_HOP,             "hip hop"},
-{ROAR_META_GENRE_ID3_JAZZ,                "id3_jazz"},
-{ROAR_META_GENRE_ID3_JAZZ,                "jazz"},
-{ROAR_META_GENRE_ID3_METAL,               "id3_metal"},
-{ROAR_META_GENRE_ID3_METAL,               "metal"},
-{ROAR_META_GENRE_ID3_NEW_AGE,             "id3_new_age"},
-{ROAR_META_GENRE_ID3_NEW_AGE,             "new age"},
-{ROAR_META_GENRE_ID3_OLDIES,              "id3_oldies"},
-{ROAR_META_GENRE_ID3_OLDIES,              "oldies"},
-{ROAR_META_GENRE_ID3_OTHER,               "id3_other"},
-{ROAR_META_GENRE_ID3_OTHER,               "other"},
-{ROAR_META_GENRE_ID3_POP,                 "id3_pop"},
-{ROAR_META_GENRE_ID3_POP,                 "pop"},
-{ROAR_META_GENRE_ID3_R_AND_B,             "id3_r_and_b"},
-{ROAR_META_GENRE_ID3_R_AND_B,             "r and b"},
-{ROAR_META_GENRE_ID3_RAP,                 "id3_rap"},
-{ROAR_META_GENRE_ID3_RAP,                 "rap"},
-{ROAR_META_GENRE_ID3_REGGAE,              "id3_reggae"},
-{ROAR_META_GENRE_ID3_REGGAE,              "reggae"},
-{ROAR_META_GENRE_ID3_ROCK,                "id3_rock"},
-{ROAR_META_GENRE_ID3_ROCK,                "rock"},
-{ROAR_META_GENRE_ID3_TECHNO,              "id3_techno"},
-{ROAR_META_GENRE_ID3_TECHNO,              "techno"},
-{ROAR_META_GENRE_ID3_INDUSTRIAL,          "id3_industrial"},
-{ROAR_META_GENRE_ID3_INDUSTRIAL,          "industrial"},
-{ROAR_META_GENRE_ID3_ALTERNATIVE,         "id3_alternative"},
-{ROAR_META_GENRE_ID3_ALTERNATIVE,         "alternative"},
-{ROAR_META_GENRE_ID3_SKA,                 "id3_ska"},
-{ROAR_META_GENRE_ID3_SKA,                 "ska"},
-{ROAR_META_GENRE_ID3_DEATH_METAL,         "id3_death_metal"},
-{ROAR_META_GENRE_ID3_DEATH_METAL,         "death metal"},
-{ROAR_META_GENRE_ID3_PRANKS,              "id3_pranks"},
-{ROAR_META_GENRE_ID3_PRANKS,              "pranks"},
-{ROAR_META_GENRE_ID3_SOUNDTRACK,          "id3_soundtrack"},
-{ROAR_META_GENRE_ID3_SOUNDTRACK,          "soundtrack"},
-{ROAR_META_GENRE_ID3_EURO_TECHNO,         "id3_euro_techno"},
-{ROAR_META_GENRE_ID3_EURO_TECHNO,         "euro techno"},
-{ROAR_META_GENRE_ID3_AMBIENT,             "id3_ambient"},
-{ROAR_META_GENRE_ID3_AMBIENT,             "ambient"},
-{ROAR_META_GENRE_ID3_TRIP_HOP,            "id3_trip_hop"},
-{ROAR_META_GENRE_ID3_TRIP_HOP,            "trip hop"},
-{ROAR_META_GENRE_ID3_VOCAL,               "id3_vocal"},
-{ROAR_META_GENRE_ID3_VOCAL,               "vocal"},
-{ROAR_META_GENRE_ID3_JAZZ_FUNK,           "id3_jazz_funk"},
-{ROAR_META_GENRE_ID3_JAZZ_FUNK,           "jazz funk"},
-{ROAR_META_GENRE_ID3_FUSION,              "id3_fusion"},
-{ROAR_META_GENRE_ID3_FUSION,              "fusion"},
-{ROAR_META_GENRE_ID3_TRANCE,              "id3_trance"},
-{ROAR_META_GENRE_ID3_TRANCE,              "trance"},
-{ROAR_META_GENRE_ID3_CLASSICAL,           "id3_classical"},
-{ROAR_META_GENRE_ID3_CLASSICAL,           "classical"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL,        "id3_instrumental"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL,        "instrumental"},
-{ROAR_META_GENRE_ID3_ACID,                "id3_acid"},
-{ROAR_META_GENRE_ID3_ACID,                "acid"},
-{ROAR_META_GENRE_ID3_HOUSE,               "id3_house"},
-{ROAR_META_GENRE_ID3_HOUSE,               "house"},
-{ROAR_META_GENRE_ID3_GAME,                "id3_game"},
-{ROAR_META_GENRE_ID3_GAME,                "game"},
-{ROAR_META_GENRE_ID3_SOUND_CLIP,          "id3_sound_clip"},
-{ROAR_META_GENRE_ID3_SOUND_CLIP,          "sound clip"},
-{ROAR_META_GENRE_ID3_GOSPEL,              "id3_gospel"},
-{ROAR_META_GENRE_ID3_GOSPEL,              "gospel"},
-{ROAR_META_GENRE_ID3_NOISE,               "id3_noise"},
-{ROAR_META_GENRE_ID3_NOISE,               "noise"},
-{ROAR_META_GENRE_ID3_ALTERNROCK,          "id3_alternrock"},
-{ROAR_META_GENRE_ID3_ALTERNROCK,          "alternrock"},
-{ROAR_META_GENRE_ID3_BASS,                "id3_bass"},
-{ROAR_META_GENRE_ID3_BASS,                "bass"},
-{ROAR_META_GENRE_ID3_SOUL,                "id3_soul"},
-{ROAR_META_GENRE_ID3_SOUL,                "soul"},
-{ROAR_META_GENRE_ID3_PUNK,                "id3_punk"},
-{ROAR_META_GENRE_ID3_PUNK,                "punk"},
-{ROAR_META_GENRE_ID3_SPACE,               "id3_space"},
-{ROAR_META_GENRE_ID3_SPACE,               "space"},
-{ROAR_META_GENRE_ID3_MEDITATIVE,          "id3_meditative"},
-{ROAR_META_GENRE_ID3_MEDITATIVE,          "meditative"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL_POP,    "id3_instrumental_pop"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL_POP,    "instrumental pop"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL_ROCK,   "id3_instrumental_rock"},
-{ROAR_META_GENRE_ID3_INSTRUMENTAL_ROCK,   "instrumental rock"},
-{ROAR_META_GENRE_ID3_ETHNIC,              "id3_ethnic"},
-{ROAR_META_GENRE_ID3_ETHNIC,              "ethnic"},
-{ROAR_META_GENRE_ID3_GOTHIC,              "id3_gothic"},
-{ROAR_META_GENRE_ID3_GOTHIC,              "gothic"},
-{ROAR_META_GENRE_ID3_DARKWAVE,            "id3_darkwave"},
-{ROAR_META_GENRE_ID3_DARKWAVE,            "darkwave"},
-{ROAR_META_GENRE_ID3_TECHNO_INDUSTRIAL,   "id3_techno_industrial"},
-{ROAR_META_GENRE_ID3_TECHNO_INDUSTRIAL,   "techno industrial"},
-{ROAR_META_GENRE_ID3_ELECTRONIC,          "id3_electronic"},
-{ROAR_META_GENRE_ID3_ELECTRONIC,          "electronic"},
-{ROAR_META_GENRE_ID3_POP_FOLK,            "id3_pop_folk"},
-{ROAR_META_GENRE_ID3_POP_FOLK,            "pop folk"},
-{ROAR_META_GENRE_ID3_EURODANCE,           "id3_eurodance"},
-{ROAR_META_GENRE_ID3_EURODANCE,           "eurodance"},
-{ROAR_META_GENRE_ID3_DREAM,               "id3_dream"},
-{ROAR_META_GENRE_ID3_DREAM,               "dream"},
-{ROAR_META_GENRE_ID3_SOUTHERN_ROCK,       "id3_southern_rock"},
-{ROAR_META_GENRE_ID3_SOUTHERN_ROCK,       "southern rock"},
-{ROAR_META_GENRE_ID3_COMEDY,              "id3_comedy"},
-{ROAR_META_GENRE_ID3_COMEDY,              "comedy"},
-{ROAR_META_GENRE_ID3_CULT,                "id3_cult"},
-{ROAR_META_GENRE_ID3_CULT,                "cult"},
-{ROAR_META_GENRE_ID3_GANGSTA,             "id3_gangsta"},
-{ROAR_META_GENRE_ID3_GANGSTA,             "gangsta"},
-{ROAR_META_GENRE_ID3_TOP_40,              "id3_top_40"},
-{ROAR_META_GENRE_ID3_TOP_40,              "top 40"},
-{ROAR_META_GENRE_ID3_CHRISTIAN_RAP,       "id3_christian_rap"},
-{ROAR_META_GENRE_ID3_CHRISTIAN_RAP,       "christian rap"},
-{ROAR_META_GENRE_ID3_POP_FUNK,            "id3_pop_funk"},
-{ROAR_META_GENRE_ID3_POP_FUNK,            "pop funk"},
-{ROAR_META_GENRE_ID3_JUNGLE,              "id3_jungle"},
-{ROAR_META_GENRE_ID3_JUNGLE,              "jungle"},
-{ROAR_META_GENRE_ID3_NATIVE_AMERICAN,     "id3_native_american"},
-{ROAR_META_GENRE_ID3_NATIVE_AMERICAN,     "native american"},
-{ROAR_META_GENRE_ID3_CABARET,             "id3_cabaret"},
-{ROAR_META_GENRE_ID3_CABARET,             "cabaret"},
-{ROAR_META_GENRE_ID3_NEW_WAVE,            "id3_new_wave"},
-{ROAR_META_GENRE_ID3_NEW_WAVE,            "new wave"},
-{ROAR_META_GENRE_ID3_PSYCHADELIC,         "id3_psychadelic"},
-{ROAR_META_GENRE_ID3_PSYCHADELIC,         "psychadelic"},
-{ROAR_META_GENRE_ID3_RAVE,                "id3_rave"},
-{ROAR_META_GENRE_ID3_RAVE,                "rave"},
-{ROAR_META_GENRE_ID3_SHOWTUNES,           "id3_showtunes"},
-{ROAR_META_GENRE_ID3_SHOWTUNES,           "showtunes"},
-{ROAR_META_GENRE_ID3_TRAILER,             "id3_trailer"},
-{ROAR_META_GENRE_ID3_TRAILER,             "trailer"},
-{ROAR_META_GENRE_ID3_LO_FI,               "id3_lo_fi"},
-{ROAR_META_GENRE_ID3_LO_FI,               "lo fi"},
-{ROAR_META_GENRE_ID3_TRIBAL,              "id3_tribal"},
-{ROAR_META_GENRE_ID3_TRIBAL,              "tribal"},
-{ROAR_META_GENRE_ID3_ACID_PUNK,           "id3_acid_punk"},
-{ROAR_META_GENRE_ID3_ACID_PUNK,           "acid punk"},
-{ROAR_META_GENRE_ID3_ACID_JAZZ,           "id3_acid_jazz"},
-{ROAR_META_GENRE_ID3_ACID_JAZZ,           "acid jazz"},
-{ROAR_META_GENRE_ID3_POLKA,               "id3_polka"},
-{ROAR_META_GENRE_ID3_POLKA,               "polka"},
-{ROAR_META_GENRE_ID3_RETRO,               "id3_retro"},
-{ROAR_META_GENRE_ID3_RETRO,               "retro"},
-{ROAR_META_GENRE_ID3_MUSICAL,             "id3_musical"},
-{ROAR_META_GENRE_ID3_MUSICAL,             "musical"},
-{ROAR_META_GENRE_ID3_ROCK_AND_ROLL,       "id3_rock_and_roll"},
-{ROAR_META_GENRE_ID3_ROCK_AND_ROLL,       "rock and roll"},
-{ROAR_META_GENRE_ID3_HARD_ROCK,           "id3_hard_rock"},
-{ROAR_META_GENRE_ID3_HARD_ROCK,           "hard rock"},
-
- {-1, "EOL"}
-};
-
-const char * roar_meta_strtype(const int type) {
- int i;
- static char name[ROAR_META_MAX_NAMELEN];
-
- for (i = 0; _libroar_meta_typelist[i].id != -1; i++)
-  if ( _libroar_meta_typelist[i].id == type ) {
-   strncpy(name, _libroar_meta_typelist[i].name, ROAR_META_MAX_NAMELEN);
-   return name;
-  }
-
- return NULL;
-}
-
-int    roar_meta_inttype(const char * type) {
- int i;
-
- for (i = 0; _libroar_meta_typelist[i].id != -1; i++)
-  if ( strcasecmp(_libroar_meta_typelist[i].name, type) == 0 ) {
-   return _libroar_meta_typelist[i].id;
-  }
-
- return -1;
-}
-
-int roar_stream_meta_set (struct roar_connection * con, struct roar_stream * s, int mode, struct roar_meta * meta) {
- struct roar_message m;
- int len;
-
- memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy!
-
- m.cmd     = ROAR_CMD_SET_META;
- m.stream  = s->id;
-// m.datalen = len;
-
- if ( (mode == ROAR_META_MODE_FINALIZE || mode == ROAR_META_MODE_CLEAR) && meta->value == NULL )
-  meta->value = "";
-
- if ( meta->value == NULL )
-   return -1;
-
- m.data[0] = 0;
- m.data[1] = mode;
- m.data[2] = meta->type;
-
- m.data[3] = strlen(meta->key);
- m.data[4] = len = strlen(meta->value);
-
- if ( len > 255 )
-  return -1;
-
- m.datalen = (int) 5 + (int) m.data[3] + len;
- if ( m.datalen > LIBROAR_BUFFER_MSGDATA )
-  return -1;
-
- strncpy(&(m.data[5]), meta->key, ROAR_META_MAX_NAMELEN);
- strncpy(&(m.data[5+m.data[3]]), meta->value, len);
-
- ROAR_DBG("roar_stream_meta_set(*): meta value length is %i byte", len);
- ROAR_DBG("roar_stream_meta_set(*): message data length is %i byte", m.datalen);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd == ROAR_CMD_OK )
-  return 0;
- return -1;
-}
-
-int roar_stream_meta_get (struct roar_connection * con, struct roar_stream * s, struct roar_meta * meta) {
- struct roar_message m;
- char * c;
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_GET_META;
- m.stream  = s->id;
-// m.datalen = len;
-
- m.data[0] = 0;
- m.data[1] = meta->type;
- m.datalen = 2;
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( m.datalen < 2 )
-  return -1;
-
- if ( m.data[0] != 0 )
-  return -1;
-
- if ( (c = roar_mm_malloc(((unsigned) m.data[1]) + 1)) == NULL )
-  return -1;
-
- strncpy(c, &(m.data[2]), (unsigned) m.data[1]);
- c[(unsigned) m.data[1]] = 0;
-
- meta->value  = c;
- meta->key[0] = 0;
-
- return 0;
-}
-
-int roar_stream_meta_list (struct roar_connection * con, struct roar_stream * s, int * types, size_t len) {
- size_t i;
- struct roar_message m;
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_LIST_META;
- m.stream  = s->id;
- m.pos     = 0;
-
- m.data[0] = 0;
- m.datalen = 1;
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- if ( m.datalen < 1 )
-  return -1;
-
- if ( m.data[0] != 0 )
-  return -1;
-
- if ( len < (m.datalen - 1 ) )
-  return -1;
-
- for (i = 1; i < m.datalen; i++)
-  types[i-1] = (unsigned) m.data[i];
-
- return m.datalen - 1;
-}
-
-int roar_meta_free (struct roar_meta * meta) {
- if ( meta->value != NULL )
-  roar_mm_free(meta->value);
-
- return 0;
-}
-
-
-// genere:
-const char * roar_meta_strgenre(const int genre) {
- int i;
-
- for (i = 0; _libroar_meta_genrelist[i].id != -1; i++)
-  if ( _libroar_meta_genrelist[i].id == genre ) {
-   return _libroar_meta_genrelist[i].name;
-  }
-
- return NULL;
-}
-
-int    roar_meta_intgenre(const char * genre) {
- int i;
-
- for (i = 0; _libroar_meta_genrelist[i].id != -1; i++)
-  if ( strcasecmp(_libroar_meta_genrelist[i].name, genre) == 0 ) {
-   return _libroar_meta_genrelist[i].id;
-  }
-
- return -1;
-}
-
-int    roar_meta_parse_audioinfo(struct roar_audio_info * info, const char * str) {
- char * lc;
- char * cur, * next;
- char * k,   * v;
-
- if ( info == NULL || str == NULL )
-  return -1;
-
- memset(info, 0, sizeof(struct roar_audio_info));
-
- info->codec = -1;
-
- if ( (lc = roar_mm_strdup(str)) == NULL )
-  return -1;
-
- cur = lc;
-
- while (cur != NULL) {
-  next = strstr(cur, " ");
-  if ( next != NULL ) {
-   *next = 0;
-    next++;
-  }
-
-  k = cur;
-  v = strstr(cur, ":");
-
-  if ( v != NULL ) {
-   *v = 0;
-    v++;
-  } else {
-    v = "";
-  }
-
-  // we test for the key, unknown keys get ignored.
-  if ( !strcasecmp(k, "rate") ) {
-   info->rate     = roar_str2rate(v);
-  } else if ( !strcasecmp(k, "bits") ) {
-   info->bits     = roar_str2bits(v);
-  } else if ( !strcasecmp(k, "channels") ) {
-   info->channels = roar_str2channels(v);
-  } else if ( !strcasecmp(k, "codec") ) {
-   info->codec    = roar_str2codec(v);
-  }
-
-  cur = next;
- }
-
- roar_mm_free(lc);
-
- return 0;
-}
-
-//ll
Index: libroar/nnode.c
===================================================================
--- libroar/nnode.c	(revision 6052)
+++ 	(revision )
@@ -1,382 +1,0 @@
-//nnode.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define _CHECK(x) if ( (x) == NULL ) return -1
-
-int roar_nnode_new        (struct roar_nnode * nnode, int socktype) {
- _CHECK(nnode);
-
- memset(nnode, 0, sizeof(struct roar_nnode));
-
- nnode->socktype = socktype;
-
- return 0;
-}
-
-int roar_nnode_new_from_af(struct roar_nnode * nnode, int af) {
- int socktype;
-
- _CHECK(nnode);
-
- switch (af) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:   socktype = ROAR_SOCKET_TYPE_INET;   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:  socktype = ROAR_SOCKET_TYPE_INET6;  break;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  case AF_UNIX:   socktype = ROAR_SOCKET_TYPE_UNIX;   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet: socktype = ROAR_SOCKET_TYPE_DECNET; break;
-#endif
-#ifdef ROAR_HAVE_IPX
-  case AF_IPX:    socktype = ROAR_SOCKET_TYPE_IPX;    break;
-#endif
-  default:
-    return -1;
-   break;
- }
-
- if ( roar_nnode_new(nnode, socktype) == -1 )
-  return -1;
-
- return 0;
-}
-
-int roar_nnode_new_from_sockaddr(struct roar_nnode * nnode, struct sockaddr * addr, socklen_t len) {
- _CHECK(nnode);
- _CHECK(addr);
-
- ROAR_DBG("roar_nnode_new_from_sockaddr(nnode=%p, addr=%p, len=%lu) = ?", nnode, addr, (unsigned long)len);
-
- if ( len < sizeof(addr->sa_family) )
-  return -1;
-
- ROAR_DBG("roar_nnode_new_from_sockaddr(nnode=%p, addr=%p, len=%lu) = ?", nnode, addr, (unsigned long)len);
-
- if ( roar_nnode_new_from_af(nnode, addr->sa_family) == -1 )
-  return -1;
-
- ROAR_DBG("roar_nnode_new_from_sockaddr(nnode=%p, addr=%p, len=%lu) = ?", nnode, addr, (unsigned long)len);
-
- switch (addr->sa_family) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:
-    if ( len < sizeof(struct sockaddr_in) )
-     return -1;
-
-    memcpy(nnode->addr.inet4, &(((struct sockaddr_in*)addr)->sin_addr), sizeof(nnode->addr.inet4));
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:
-    if ( len < sizeof(struct sockaddr_in6) )
-     return -1;
-
-    memcpy(nnode->addr.inet6, ((struct sockaddr_in6*)addr)->sin6_addr.s6_addr, sizeof(nnode->addr.inet6));
-   break;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  case AF_UNIX:
-    // nothing to do/save here.
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-    if ( len < sizeof(struct sockaddr_dn) )
-     return -1;
-
-    nnode->addr.decnet.node  =  ((struct sockaddr_dn*)addr)->sdn_add.a_addr[0];
-    nnode->addr.decnet.node |= (((struct sockaddr_dn*)addr)->sdn_add.a_addr[1] & 0x03) << 8;
-    nnode->addr.decnet.area  =  ((struct sockaddr_dn*)addr)->sdn_add.a_addr[1] >> 2;
-   break;
-#endif
-#ifdef ROAR_HAVE_IPX
-  case AF_IPX:
-    return -1;
-   break;
-#endif
-  default:
-    return -1;
-   break;
- }
-
- ROAR_DBG("roar_nnode_new_from_sockaddr(nnode=%p, addr=%p, len=%lu) = 0", nnode, addr, (unsigned long)len);
- return 0;
-}
-
-int roar_nnode_new_from_fh(struct roar_nnode * nnode, int fh, int remote) {
- // TODO: fix this in a nice way
-#ifndef ROAR_TARGET_MICROCONTROLLER
- struct sockaddr_storage sa;
- socklen_t               len = sizeof(sa);
- int                     ret;
-
- _CHECK(nnode);
-
- if ( fh == -1 )
-  return -1;
-
- if ( remote ) {
-  ret = getpeername(fh, (struct sockaddr*)&sa, &len);
- } else {
-  ret = getsockname(fh, (struct sockaddr*)&sa, &len);
- }
-
- if ( ret == -1 )
-  return -1;
-
- return roar_nnode_new_from_sockaddr(nnode, (struct sockaddr*)&sa, len);
-#else
- return -1;
-#endif
-}
-
-int roar_nnode_free       (struct roar_nnode * nnode) {
- _CHECK(nnode);
-
- return 0;
-}
-
-int roar_nnode_get_socktype (struct roar_nnode * nnode) {
- _CHECK(nnode);
-
- return nnode->socktype;
-}
-
-int roar_nnode_to_str     (struct roar_nnode * nnode, char * str, size_t len) {
- // Format: PROTO: nodename[nodeaddr]
- char proto[7]    = "???";
- char nodename[4] = "";
- char nodeaddr[48 /* IPv6 */] = "???";
-
- _CHECK(nnode);
-
- if ( len == 0 )
-  return 0;
-
- _CHECK(str);
-
- if ( len == 1 ) {
-  *str = 0;
-  return 0;
- }
-
- switch (nnode->socktype) {
-  case ROAR_SOCKET_TYPE_UNIX:
-    roar_mm_strscpy(proto,     "UNIX");
-    roar_mm_strscpy(nodeaddr, "LOCAL");
-   break;
-  case ROAR_SOCKET_TYPE_INET:
-    roar_mm_strscpy(proto,     "IPv4");
-    snprintf(nodeaddr, sizeof(nodeaddr), "%i.%i.%i.%i",
-                 nnode->addr.inet4[0], nnode->addr.inet4[1],
-                 nnode->addr.inet4[2], nnode->addr.inet4[3]
-           );
-   break;
-  case ROAR_SOCKET_TYPE_DECNET:
-    roar_mm_strscpy(proto,     "DECnet");
-    snprintf(nodeaddr, sizeof(nodeaddr), "%i.%i", nnode->addr.decnet.area, nnode->addr.decnet.node);
-   break;
-  case ROAR_SOCKET_TYPE_INET6:
-    roar_mm_strscpy(proto,     "IPv6");
-   break;
-  case ROAR_SOCKET_TYPE_IPX:
-    roar_mm_strscpy(proto,     "IPX");
-   break;
-  default:
-    snprintf(proto, sizeof(proto), "P#%i", nnode->socktype);
-   break;
- }
-
- if ( *nodename ) {
-  snprintf(str, len, "%s: %s[%s]", proto, nodename, nodeaddr);
- } else {
-  snprintf(str, len, "%s: %s", proto, nodeaddr);
- }
-
- str[len-1] = 0;
-
- return 0;
-}
-
-int roar_nnode_from_blob  (struct roar_nnode * nnode, void * blob, size_t * len) {
- uint16_t socktype;
-
- _CHECK(nnode);
- _CHECK(blob);
- _CHECK(len);
-
- if ( *len < 2 )
-  return -1;
-
- memcpy(&socktype, blob, 2);
-
- socktype = ROAR_NET2HOST16(socktype);
-
- if ( roar_nnode_new(nnode, socktype) == -1 )
-  return -1;
-
- switch (socktype) {
-  case ROAR_SOCKET_TYPE_UNIX:
-    *len = 2;
-   break;
-  case ROAR_SOCKET_TYPE_INET:
-    if ( *len < 6 )
-     return -1;
-
-    memcpy(nnode->addr.inet4, blob+2, 4);
-
-    *len = 6;
-   break;
-  case ROAR_SOCKET_TYPE_DECNET:
-    if ( *len < 4 )
-     return -1;
-
-    nnode->addr.decnet.node   =  ((unsigned char*)blob)[2];
-    nnode->addr.decnet.node   = (((unsigned char*)blob)[3] & 0x03) << 8;
-    nnode->addr.decnet.area   =  ((unsigned char*)blob)[3] >> 2;
-
-    *len = 4;
-   break;
-  case ROAR_SOCKET_TYPE_INET6:
-    if ( *len < 18 )
-     return -1;
-
-    memcpy(nnode->addr.inet4, blob+2, 16);
-
-    *len = 18;
-   break;
-  case ROAR_SOCKET_TYPE_IPX:
-  default:
-    return -1;
-   break;
- }
-
- return 0;
-}
-
-int roar_nnode_to_blob    (struct roar_nnode * nnode, void * blob, size_t * len) {
- uint16_t socktype_net;
-
- _CHECK(nnode);
- _CHECK(blob);
- _CHECK(len);
-
- if ( *len < 2 )
-  return -1;
-
- socktype_net = ROAR_HOST2NET16(nnode->socktype);
-
- memcpy(blob, &socktype_net, 2);
-
- switch (nnode->socktype) {
-  case ROAR_SOCKET_TYPE_UNIX:
-    // all UNIX sockets allways match.
-    *len = 2;
-   break;
-  case ROAR_SOCKET_TYPE_INET:
-    if ( *len < 6 )
-     return -1;
-
-    memcpy(blob+2, nnode->addr.inet4, 4);
-    *len = 6;
-
-   break;
-  case ROAR_SOCKET_TYPE_DECNET:
-    if ( *len < 4 )
-     return -1;
-
-    ((unsigned char*)blob)[2] =   nnode->addr.decnet.node & 0x00FF;
-    ((unsigned char*)blob)[3] = ((nnode->addr.decnet.node & 0x0300) >> 8) | (nnode->addr.decnet.area << 2);
-    *len = 4;
-
-    return -1;
-   break;
-  case ROAR_SOCKET_TYPE_INET6:
-    if ( *len < 18 )
-     return -1;
-
-    memcpy(blob+2, nnode->addr.inet4, 16);
-    *len = 18;
-
-   break;
-  case ROAR_SOCKET_TYPE_IPX:
-  default:
-    return -1;
-   break;
- }
-
- return 0;
-}
-
-int roar_nnode_cmp        (struct roar_nnode * n0, struct roar_nnode * n1) {
- _CHECK(n0);
- _CHECK(n1);
-
- if ( n0->socktype != n1->socktype )
-  return 1;
-
- switch (n0->socktype) {
-  case ROAR_SOCKET_TYPE_UNIX:
-    // all UNIX sockets allways match.
-   break;
-  case ROAR_SOCKET_TYPE_INET:
-    if ( memcmp(n0->addr.inet4, n1->addr.inet4, sizeof(n0->addr.inet4)) != 0 )
-     return 1;
-   break;
-  case ROAR_SOCKET_TYPE_DECNET:
-    if ( n0->addr.decnet.area != n1->addr.decnet.area ||
-         n0->addr.decnet.node != n1->addr.decnet.node   )
-     return 1;
-   break;
-  case ROAR_SOCKET_TYPE_INET6:
-    if ( memcmp(n0->addr.inet6, n1->addr.inet6, sizeof(n0->addr.inet6)) != 0 )
-     return 1;
-   break;
-  case ROAR_SOCKET_TYPE_IPX:
-  default:
-    return -1;
-   break;
- }
-
- return 0;
-}
-
-//ll
Index: libroar/notify.c
===================================================================
--- libroar/notify.c	(revision 6052)
+++ 	(revision )
@@ -1,541 +1,0 @@
-//notify.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-struct roar_subscriber {
- uint32_t flags;
- uint32_t event;
- int emitter;
- int target;
- int target_type;
- void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata);
- void * userdata;
- size_t refc;
- unsigned int hash;
-// struct roar_subscriber * prev;
- struct roar_subscriber * next;
-};
-
-struct roar_notify_core {
- size_t refc;
- size_t listc;
- struct roar_subscriber ** lists;
- void (*proxy)(struct roar_notify_core * core, struct roar_event * event, void * userdata);
- void * proxy_userdata;
-};
-
-static struct roar_notify_core * _libroar_notify_core = NULL;
-
-#define _CKRCORE(ret) if ( core == NULL ) { if ( _libroar_notify_core == NULL ) { roar_err_set(ROAR_ERROR_INVAL); return (ret); } else { core = _libroar_notify_core; } }
-#define _CKICORE() _CKRCORE(-1)
-
-static unsigned int _hash_event (struct roar_notify_core * core, struct roar_event * event) {
- unsigned int hash = 0;
- unsigned int mask = core->listc - 1;
-
- hash ^= event->event >>  0;
- hash ^= event->event >>  8;
- hash ^= event->event >> 16;
- hash ^= event->event >> 24;
-
- return hash & mask;
-}
-
-struct roar_notify_core * roar_notify_core_new(ssize_t lists) {
- struct roar_notify_core * core = NULL;
-
- switch (lists) {
-  case    1:
-  case    2:
-  case    4:
-  case    8:
-  case   16:
-  case   32:
-  case   64:
-  case  128:
-  case  256:
-  case  512:
-  case 1024:
-    // they all are ok.
-   break;
-  case  -1:
-    // handle defult:
-    lists = 16;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_INVAL);
-    return NULL;
-   break;
- }
-
- if ( (core = roar_mm_malloc(sizeof(struct roar_notify_core))) == NULL ) {
-  return NULL;
- }
-
- memset(core, 0, sizeof(struct roar_notify_core));
-
- core->refc  = 1;
- core->listc = lists;
- core->lists = roar_mm_malloc(lists*sizeof(struct roar_subscriber *));
- core->proxy = NULL;
- core->proxy_userdata = NULL;
-
- if ( core->lists == NULL ) {
-  roar_mm_free(core);
-  return NULL;
- }
-
- memset(core->lists, 0, lists*sizeof(struct roar_subscriber *));
-
- return core;
-}
-
-int roar_notify_core_ref(struct roar_notify_core * core) {
- _CKICORE();
-
- core->refc++;
-
- return 0;
-}
-
-int roar_notify_core_unref(struct roar_notify_core * core) {
- struct roar_subscriber * cur, * next;
- size_t i;
-
- _CKICORE();
-
- if ( core->refc == 0 ) {
-  ROAR_ERR("roar_notify_core_unref(core=%p): refc is zero, must be greater zero. resolving by setting to one.", core);
-  core->refc = 1;
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
- }
-
- core->refc--;
-
- if ( core->refc > 0 ) {
-  return 0;
- }
-
- // if we work on the global core, reset it to NULL if we free it.
- if ( core == _libroar_notify_core ) {
-  _libroar_notify_core = NULL;
- }
-
- for (i = 0; i < core->listc; i++) {
-  cur = core->lists[i];
-  while (cur != NULL) {
-   next = cur->next;
-
-   roar_mm_free(cur);
-
-   cur = next;
-  }
- }
-
- roar_mm_free(core->lists);
- roar_mm_free(core);
- return 0;
-}
-
-int roar_notify_core_new_global(ssize_t lists) {
- if ( _libroar_notify_core != NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( (_libroar_notify_core = roar_notify_core_new(lists)) == NULL )
-  return -1;
-
- return 0;
-}
-
-struct roar_notify_core * roar_notify_core_swap_global(struct roar_notify_core * core) {
- struct roar_notify_core * ret = _libroar_notify_core;
-
- if ( core != NULL )
-  if ( roar_notify_core_ref(core) == -1 )
-   return NULL;
-
- _libroar_notify_core = core;
-
- return ret;
-}
-
-int roar_notify_core_register_proxy(struct roar_notify_core * core, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata) {
- _CKICORE();
-
- core->proxy = cb;
- core->proxy_userdata = userdata;
-
- return 0;
-}
-
-
-struct roar_subscriber * roar_notify_core_subscribe(struct roar_notify_core * core, struct roar_event * event, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata) {
- struct roar_subscriber * subs = NULL;
- struct roar_subscriber * cur, * old;
-
- ROAR_DBG("roar_notify_core_subscribe(core=%p, event=%p, cb=%p, userdata=%p) = ?", core, event, cb, userdata);
-
- _CKRCORE(NULL);
-
- if ( event == NULL || cb == NULL ) {
-  ROAR_DBG("roar_notify_core_subscribe(core=%p, event=%p, cb=%p, userdata=%p) = NULL // errno = EINVAL", core, event, cb, userdata);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( (subs = roar_mm_malloc(sizeof(struct roar_subscriber))) == NULL ) {
-  ROAR_DBG("roar_notify_core_subscribe(core=%p, event=%p, cb=%p, userdata=%p) = NULL // errno = ENOMEM?", core, event, cb, userdata);
-  return NULL;
- }
-
- memset(subs, 0, sizeof(struct roar_subscriber));
-
- subs->flags       = 0;
- subs->event       = event->event;
- subs->emitter     = event->emitter;
- subs->target      = event->target;
- subs->target_type = event->target_type;
- subs->cb          = cb;
- subs->userdata    = userdata;
- subs->refc        = 1;
- subs->hash        = _hash_event(core, event);
- subs->next        = NULL;
-
- if ( (cur = core->lists[subs->hash]) == NULL ) {
-  core->lists[subs->hash] = subs;
- } else {
-  old = cur;
-  while (cur != NULL) {
-   old = cur;
-   cur = cur->next;
-  }
-
-  old->next = subs;
- }
-
- ROAR_DBG("roar_notify_core_subscribe(core=%p, event=%p, cb=%p, userdata=%p) = %p", core, event, cb, userdata, subs);
- return subs;
-}
-
-int roar_notify_core_unsubscribe(struct roar_notify_core * core, struct roar_subscriber * subscriber) {
- struct roar_subscriber * cur, * old;
-
- _CKICORE();
-
- if ( subscriber == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (cur = core->lists[subscriber->hash]) == subscriber ) {
-  core->lists[subscriber->hash] = core->lists[subscriber->hash]->next;
- } else {
-  old = NULL;
-  while (cur != NULL && cur != subscriber ) {
-   old = cur;
-   cur = cur->next;
-  }
-
-  if ( cur != subscriber )
-   return -1;
-
-  old->next = cur->next;
-  roar_mm_free(cur);
- }
-
- return 0;
-}
-
-int roar_notify_core_emit(struct roar_notify_core * core, struct roar_event * event) {
- struct roar_subscriber * cur;
- struct roar_error_state errstate;
-
- _CKICORE();
-
- if ( event == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( core->proxy != NULL && !(event->flags & ROAR_EVENT_FLAG_PROXYEVENT) ) {
-  core->proxy(core, event, core->proxy_userdata);
- }
-
- cur = core->lists[_hash_event(core, event)];
- ROAR_DBG("roar_notify_core_emit(core=%p, event=%p): cur=%p", core, event, cur);
-
- while (cur != NULL) {
-  ROAR_DBG("roar_notify_core_emit(core=%p, event=%p): cur=%p", core, event, cur);
-
-  // test if we can skip this one:
-  if ( !( (cur->event       == ROAR_NOTIFY_SPECIAL || cur->event       == event->event)   &&
-          (cur->emitter     == -1                  || cur->emitter     == event->emitter) &&
-          (cur->target      == -1                  || cur->target      == event->target)  &&
-          (cur->target_type == -1                  || cur->target_type == event->target_type)
-        ) ) {
-   cur = cur->next;
-   continue;
-  }
-
-  if ( cur->cb == NULL ) {
-   ROAR_ERR("roar_notify_core_emit(core=%p, event=%p): cur=%p, cb is set NULL, bad.", core, event, cur);
-  } else {
-   // The callback is started in an clear error context which is destroyed after it finished so it
-   // does not alter our caller's context.
-   roar_err_store(&errstate);
-   roar_err_clear_all();
-
-   cur->cb(core, event, cur->userdata);
-
-   roar_err_restore(&errstate);
-  }
-  cur = cur->next;
- }
-
- return 0;
-}
-
-int roar_notify_core_emit_simple(uint32_t event, int emitter, int target, int target_type, int arg0, int arg1, void * arg2, ssize_t arg2_len) {
- struct roar_event locevent;
-
- memset(&locevent, 0, sizeof(locevent));
-
- locevent.event = event;
- locevent.emitter = emitter;
- locevent.target = target;
- locevent.target_type = target_type;
- locevent.arg0 = arg0;
- locevent.arg1 = arg1;
- locevent.arg2 = arg2;
- locevent.arg2_len = arg2_len;
-
- if ( arg2 == NULL && (arg2_len == 0 || arg2_len == -1) ) {
-  locevent.flags |= ROAR_EVENT_FLAG_NETTRANS; // we guess packages with only int args are network transparent.
- }
-
- return roar_notify_core_emit(NULL, &locevent);
-}
-
-
-int roar_event_to_blob(struct roar_event * event, void * blob, size_t * len) {
- size_t needed_len = (2 * 4) + (4 * 2);
- uint32_t * u32 = blob;
- uint16_t * u16 = blob;
- size_t data_offset_neg = 0;
-
- u16 += 4;
-
- // error checking:
- if ( event == NULL || blob == NULL || len == NULL )
-  return -1;
-
- if ( *len == 0 )
-  return -1;
-
- // calc and check length:
- if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT )
-  needed_len += 4;
-
- if ( event->flags & ROAR_EVENT_FLAG_NETTRANS ) {
-
-  // this is not a real maximum but a value good to detect all kinds of errors.
-  // a notify event should not be longer anyway.
-  if ( event->arg2_len > 32767 )
-   return -1;
-
-  needed_len += 4;
-  if ( event->arg2_len > 0 ) {
-    needed_len += event->arg2_len;
-    data_offset_neg = event->arg2_len;
-  }
- }
-
- if ( *len < needed_len )
-  return -1;
-
- *len = 0;
-
- // fill in the data...
- memset(blob, 0, needed_len);
-
- u32[1] = ROAR_HOST2NET32(0);
-
- if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT ) {
-  u32[0] |= ROAR_HOST2NET32(ROAR_EVENT_NETFLAG_PROXYEVENT);
-  u16 += 2;
- }
-
- if ( event->flags & ROAR_EVENT_FLAG_NETTRANS ) {
-  u32[0] |= ROAR_HOST2NET32(ROAR_EVENT_NETFLAG_DATA);
- }
-
- u32[1] = ROAR_HOST2NET32(event->event);
-
- if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT )
-  u32[2] = ROAR_HOST2NET32(event->event_proxy);
-
- u16[0] = ROAR_HOST2NET16(event->emitter);
- u16[1] = ROAR_HOST2NET16(event->target);
- u16[2] = ROAR_HOST2NET16(event->target_type);
- if ( event->flags & ROAR_EVENT_FLAG_NETTRANS ) {
-  u16[3] = ROAR_HOST2NET16(event->arg2_len);
-  u16[4] = ROAR_HOST2NET16(event->arg0);
-  u16[5] = ROAR_HOST2NET16(event->arg1);
- } else {
-  u16[3] = ROAR_HOST2NET16(0);
- }
-
- memcpy(blob + needed_len - data_offset_neg, event->arg2, event->arg2_len);
-
- *len = needed_len;
-
- return 0;
-}
-
-int roar_event_from_blob(struct roar_event * event, void * blob, size_t * len) {
- size_t needed_len = (2 * 4) + (4 * 2);
- uint32_t * u32 = blob;
- uint16_t * u16 = blob;
- uint32_t flags;
-
- u16 += 4;
-
- // error checking:
- if ( event == NULL || blob == NULL || len == NULL )
-  return -1;
-
- // check for minimum length.
- if ( *len < needed_len )
-  return -1;
-
- flags = ROAR_NET2HOST32(u32[0]);
-
-#if 0
- if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT ) {
-  u32[0] |= ROAR_HOST2NET32(ROAR_EVENT_NETFLAG_PROXYEVENT);
-  u16 += 2;
- }
-
- if ( event->flags & ROAR_EVENT_FLAG_NETTRANS ) {
-  u32[0] |= ROAR_HOST2NET32(ROAR_EVENT_NETFLAG_DATA);
- }
-#endif
-
- if ( flags & ROAR_EVENT_NETFLAG_PROXYEVENT ) {
-  needed_len += 4;
-  u16 += 2;
- }
-
- if ( flags & ROAR_EVENT_NETFLAG_DATA ) {
-  needed_len += 4;
- }
-
- // do we have a full header?
- if ( *len < needed_len )
-  return -1;
-
- needed_len += ROAR_NET2HOST16(u16[3]);
-
- // is all of the event complet?
- if ( *len < needed_len )
-  return -1;
-
- // now we know everything is complet we can start to extract data...
-
- *len = 0;
-
- memset(event, 0, sizeof(struct roar_event));
-
- if ( flags & ROAR_EVENT_NETFLAG_PROXYEVENT ) {
-  flags -= ROAR_EVENT_NETFLAG_PROXYEVENT;
-  event->flags |= ROAR_EVENT_FLAG_PROXYEVENT;
- }
-
- if ( flags & ROAR_EVENT_NETFLAG_DATA ) {
-  flags -= ROAR_EVENT_NETFLAG_DATA;
-  event->flags |= ROAR_EVENT_FLAG_NETTRANS;
- }
-
- // test if there are flags left we do not understand:
- if ( flags ) {
-  return -1;
- }
-
- event->event = ROAR_NET2HOST32(u32[1]);
-
- if ( event->flags & ROAR_EVENT_FLAG_PROXYEVENT )
-  event->event_proxy = ROAR_NET2HOST32(u32[2]);
-
- event->emitter     = ROAR_NET2HOST16(u16[0]);
- event->target      = ROAR_NET2HOST16(u16[1]);
- event->target_type = ROAR_NET2HOST16(u16[2]);
- event->arg2_len    = ROAR_NET2HOST16(u16[3]);
-
- if ( event->emitter == (uint16_t)-1)
-  event->emitter = -1;
-
- if ( event->target == (uint16_t)-1)
-  event->target = -1;
-
- if ( event->target_type == (uint16_t)-1)
-  event->target_type = -1;
-
- if ( event->flags & ROAR_EVENT_FLAG_NETTRANS ) {
-  event->arg0 = ROAR_NET2HOST16(u16[4]);
-  event->arg1 = ROAR_NET2HOST16(u16[5]);
-
-  if ( event->arg0 == (uint16_t)-1)
-   event->arg0 = -1;
-
-  if ( event->arg1 == (uint16_t)-1)
-   event->arg1 = -1;
-
-  event->arg2 = blob + needed_len - event->arg2_len;
- } else {
-  event->arg0 = -1;
-  event->arg1 = -1;
-  event->arg2 = NULL;
- }
-
- *len = needed_len;
-
- return 0;
-}
-
-
-//ll
Index: libroar/notify_proxy.c
===================================================================
--- libroar/notify_proxy.c	(revision 6052)
+++ 	(revision )
@@ -1,105 +1,0 @@
-//notify_proxy.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define MAX_EVENTS_PER_GROUP  4
-#define EOL                   ROAR_NOTIFY_SPECIAL
-
-// TODO: FIXME: ROAR_NOTIFY_EGRP2EVENT() on _OE_ events?
-// TODO: refthink design of this proxy.
-
-void roar_notify_proxy_std(struct roar_notify_core * core, struct roar_event * event, void * userdata) {
- struct {
-  uint32_t event_min, event_max;
-  uint32_t events[MAX_EVENTS_PER_GROUP];
- } * ptr, list[] = {
-  {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_CLIENTS),
-   .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_CLIENTS + 0xff),
-   .events = {
-    ROAR_EGRP_ANY_CLIENT_EVENT,
-    EOL
-   }
-  },
-  {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_STREAMS),
-   .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_STREAMS + 0xff),
-   .events = {
-    ROAR_EGRP_ANY_STREAM_EVENT,
-    EOL
-   }
-  },
-  {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SOURCES),
-   .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SOURCES + 0xff),
-   .events = {
-    ROAR_EGRP_ANY_SOURCE_EVENT,
-    EOL
-   }
-  },
-  {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SAMPLES),
-   .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SAMPLES + 0xff),
-   .events = {
-    ROAR_EGRP_ANY_SAMPLE_EVENT,
-    EOL
-   }
-  }
- };
- struct roar_event locevent;
- size_t i, e;
- register uint32_t oe = event->event;
-
- (void)userdata;
-
- memcpy(&locevent, event, sizeof(locevent));
-
- locevent.event_proxy  = locevent.event;
- locevent.flags       |= ROAR_EVENT_FLAG_PROXYEVENT;
-
- locevent.event = ROAR_EGRP_ANY_EVENT;
-
- roar_notify_core_emit(core, &locevent);
-
-
- for (i = 0; i < sizeof(list)/sizeof(*list); i++) {
-  ptr = &(list[i]);
-  if ( ptr->event_min <= oe && ptr->event_max >= oe ) {
-   for (e = 0; ptr->events[e] != EOL; e++) {
-    locevent.event = ptr->events[e];
-    roar_notify_core_emit(core, &locevent);
-   }
-  }
- }
-}
-
-//ll
Index: libroar/passwordapi.c
===================================================================
--- libroar/passwordapi.c	(revision 6052)
+++ 	(revision )
@@ -1,80 +1,0 @@
-//passwordapi.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-ssize_t roar_passwd_simple_ask_pw (char ** pw, char * prompt, const char * cachetoken) {
-#ifdef ROAR_SUPPORT_PASSWORD_API
- struct roar_pinentry pe;
-
- if ( pw == NULL )
-  return -1;
-
- if ( prompt == NULL ) {
-  ROAR_WARN("roar_passwd_simple_ask_pw(pw=%p, prompt=NULL, cachetoken='%s'): No prompt given. This may be a bug in application.", pw, cachetoken);
-  prompt = "Please enter Password";
- }
-
- *pw = NULL;
-
- // TODO: test for cache here.
-
- if ( *pw == NULL ) {
-  if ( roar_pinentry_simple_open(&pe) != -1 ) {
-   if ( roar_pinentry_getpin(&pe, pw, NULL, prompt) == -1 ) {
-    *pw = NULL;
-   }
-   roar_pinentry_close(&pe);
-  }
- }
-
- if ( *pw == NULL ) {
-  if ( roar_sshaskpass_getpass(pw, prompt) == -1 ) {
-   *pw = NULL;
-  }
- }
-
- if ( *pw == NULL )
-  return -1;
-
- // TODO: save to cache here.
-
- return strlen(*pw);
-#else
- return -1;
-#endif
-}
-
-//ll
Index: libroar/pinentry.c
===================================================================
--- libroar/pinentry.c	(revision 6052)
+++ 	(revision )
@@ -1,375 +1,0 @@
-//pinentry.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-// TODO: need to check: && defined(ROAR_HAVE_TTYNAME)
-#if defined(ROAR_HAVE_FORK) && defined(ROAR_HAVE_PIPE) && defined(ROAR_HAVE_FDOPEN)
-#define _CAN_POSIX
-#endif
-
-#if defined(ROAR_HAVE_BIN_PINENTRY) && defined(ROAR_SUPPORT_PASSWORD_API) && defined(_CAN_POSIX)
-#define _CAN_OPERATE
-#endif
-
-int roar_pinentry_open (struct roar_pinentry * pe, int flags, const char * display, const char * tty, const char * term) {
-#ifdef _CAN_OPERATE
- int in[2], out[2];
- char * bin_pinentry;
-
- if ( pe == NULL )
-  return -1;
-
- memset(pe, 0, sizeof(struct roar_pinentry));
- pe->in  = -1;
- pe->out = -1;
-
- if ( display == NULL )
-  display = roar_env_get("DISPLAY");
-
- if ( display == NULL )
-  display = "(NONE)";
-
- if ( tty == NULL )
-  tty = ttyname(ROAR_STDIN);
-
- if ( tty == NULL )
-#ifdef ROAR_DEFAULT_TTY
-  tty = ROAR_DEFAULT_TTY;
-#else
-  return -1;
-#endif
-
- if ( term == NULL )
-  term = roar_env_get("TERM");
-
- if ( term == NULL )
-  term = "dumb";
-
- // open some pipes...
- if ( pipe(in) != 0 )
-  return -1;
-
- if ( pipe(out) != 0 ) {
-  close(in[0]);
-  close(in[1]);
-  return -1;
- }
-
- pe->pid = roar_fork(NULL);
-
- switch (pe->pid) {
-  case -1:
-    close(in[0]);
-    close(in[1]);
-    close(out[0]);
-    close(out[1]);
-    return -1;
-   break;
-  case 0:
-    roar_watchdog_stop();
-
-    close(in[0]);
-    close(out[1]);
-    close(ROAR_STDIN);
-    close(ROAR_STDOUT);
-
-    if ( dup2(out[0], ROAR_STDIN) == -1 )
-     ROAR_U_EXIT(1);
-
-    if ( dup2(in[1], ROAR_STDOUT) == -1 )
-     ROAR_U_EXIT(1);
-
-    bin_pinentry = roar_libroar_get_path("bin-pinentry", 0, NULL, NULL);
-    if ( bin_pinentry == NULL )
-     ROAR_U_EXIT(1);
-
-    execlp(bin_pinentry, "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL);
-
-    roar_mm_free(bin_pinentry);
-
-    ROAR_U_EXIT(1);
-   break;
- }
-
- close(in[1]);
- close(out[0]);
-
- pe->in  = in[0];
- pe->out = out[1];
-
- pe->fin = fdopen(in[0], "r");
-
- roar_pinentry_recv(pe, NULL, NULL);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_simple_open(struct roar_pinentry * pe) {
- return roar_pinentry_open(pe, 0, NULL, NULL, NULL);
-}
-
-int roar_pinentry_close(struct roar_pinentry * pe) {
-#ifdef _CAN_OPERATE
- int status;
-
- if ( pe == NULL )
-  return -1;
-
- if ( pe->opened == 0 )
-  return 0;
-
- if ( pe->out != -1 )
-  close(pe->out);
-
- if ( pe->fin != NULL )
-  fclose(pe->fin);
-
- if ( pe->in  != -1 )
-  close(pe->in);
-
- waitpid(pe->pid, &status, 0);
-
- memset(pe, 0, sizeof(struct roar_pinentry));
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_send (struct roar_pinentry * pe, char * cmd,  char * args) {
-#ifdef _CAN_OPERATE
- size_t len;
-
- if ( pe == NULL )
-  return -1;
-
- if ( cmd == NULL )
-  return -1;
-
- len = strlen(cmd);
-
- if ( write(pe->out, cmd, len) != (ssize_t)len )
-  return -1;
-
- if ( args != NULL ) {
-  if ( write(pe->out, " ", 1) != 1 )
-   return -1;
-
-  len = strlen(args);
-
-  if ( write(pe->out, args, len) != (ssize_t)len )
-   return -1;
- }
-
- if ( write(pe->out, "\n", 1) != 1 )
-  return -1;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-
-#define MAX_LINE_SIZE 2048
-int roar_pinentry_recv (struct roar_pinentry * pe, char ** line, char ** opts) {
-#ifdef _CAN_OPERATE
- char realbuf[MAX_LINE_SIZE];
- char * tp;
-
- if ( pe == NULL )
-  return -1;
-
- if ( pe->fin == NULL )
-  return -1;
-
- if ( fgets(realbuf, MAX_LINE_SIZE, pe->fin) == NULL )
-  return -1;
-
- tp = realbuf + strlen(realbuf) - 1;
-
- for (; *tp == '\r' || *tp == '\n'; tp--)
-  *tp = 0;
-
- if ( (tp = strstr(realbuf, " ")) == NULL ) {
-  if ( line != NULL )
-   *line = roar_mm_strdup(realbuf);
-
-  if ( opts != NULL )
-   *opts = NULL;
-
-  if ( !strcmp(realbuf, "OK") ) {
-   return 0;
-  } else if ( !strcmp(realbuf, "ERR") ) {
-   return 1;
-  } else {
-   return -1;
-  }
- } else {
-  *tp = 0;
-
-  if ( !strcmp(realbuf, "D") ) {
-   if ( opts != NULL )
-    *opts = roar_mm_strdup(tp+1);
-
-   return roar_pinentry_recv(pe, line, NULL);
-  }
-
-  if ( line != NULL )
-   *line = roar_mm_strdup(realbuf);
-
-  if ( opts != NULL )
-   *opts = NULL;
-
-  if ( !strcmp(realbuf, "OK") ) {
-   return 0;
-  } else if ( !strcmp(realbuf, "ERR") ) {
-   return 1;
-  } else {
-   return -1;
-  }
- }
-
- return -1;
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_req  (struct roar_pinentry * pe, char * cmd,  char * args, char ** line, char ** opts) {
-#ifdef ROAR_SUPPORT_PASSWORD_API
- if ( pe == NULL )
-  return -1;
-
- if ( roar_pinentry_send(pe, cmd, args) != 0 )
-  return -1;
-
- return roar_pinentry_recv(pe, line, opts);
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_set_desc (struct roar_pinentry * pe, char * desc) {
- return roar_pinentry_set(pe, "DESC", desc);
-}
-
-int roar_pinentry_set_prompt(struct roar_pinentry * pe, char * prompt) {
- return roar_pinentry_set(pe, "PROMPT", prompt);
-}
-
-int roar_pinentry_set_yes  (struct roar_pinentry * pe, char * yes) {
- return roar_pinentry_set(pe, "OK", yes);
-}
-
-int roar_pinentry_set_no   (struct roar_pinentry * pe, char * no) {
- return roar_pinentry_set(pe, "CANCEL", no);
-}
-
-int roar_pinentry_set      (struct roar_pinentry * pe, char * obj, char * text) {
-#ifdef ROAR_SUPPORT_PASSWORD_API
- char req[80] = "SET";
-
- if ( pe == NULL )
-  return -1;
-
- if ( obj == NULL )
-  return -1;
-
- if ( strlen(obj) > (80-(1 /* \0 */ + 3 /* "SET" */)) )
-  return -1;
-
- strncat(req, obj, 80-4);
-
- return roar_pinentry_req(pe, req, text, NULL, NULL);
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_getpin   (struct roar_pinentry * pe, char ** pw, char * desc, char * prompt) {
-#ifdef ROAR_SUPPORT_PASSWORD_API
- if ( pe == NULL )
-  return -1;
-
- if ( pw == NULL )
-  return -1;
-
- if ( desc != NULL )
-  if ( roar_pinentry_set_desc(pe, desc) != 0 )
-   return -1;
-
- if ( prompt != NULL )
-  if ( roar_pinentry_set_prompt(pe, prompt) != 0 )
-   return -1;
-
- if ( roar_pinentry_req(pe, "GETPIN", NULL, NULL, pw) == -1 )
-  return -1;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_pinentry_confirm  (struct roar_pinentry * pe, char * desc, char * yes, char * no) {
-#ifdef ROAR_SUPPORT_PASSWORD_API
- if ( pe == NULL )
-  return -1;
-
- if ( desc != NULL )
-  if ( roar_pinentry_set_desc(pe, desc) != 0 )
-   return -1;
-
- if ( yes != NULL )
-  if ( roar_pinentry_set_yes(pe, yes) != 0 )
-   return -1;
-
- if ( no != NULL )
-  if ( roar_pinentry_set_no(pe, no) != 0 )
-   return -1;
-
- return roar_pinentry_req(pe, "CONFIRM", NULL, NULL, NULL);
-#else
- return -1;
-#endif
-}
-
-//ll
Index: libroar/plugincontainer.c
===================================================================
--- libroar/plugincontainer.c	(revision 6052)
+++ 	(revision )
@@ -1,541 +1,0 @@
-//plugincontainer.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define MAX_PLUGINS 64
-
-#define OPT_AUTOAPPSCHED 0x0001
-
-struct roar_plugincontainer {
- size_t refc;
- const struct roar_plugincontainer_callbacks * callbacks;
- void * userdata;
- unsigned int options;
- struct roar_dl_librarypara * default_para;
- struct roar_dl_lhandle * handle[MAX_PLUGINS];
- size_t deprefc[MAX_PLUGINS];
- void * context[MAX_PLUGINS];
- size_t numhandles;
-};
-
-static inline void _unload(struct roar_plugincontainer * cont, size_t index) {
- int err = roar_error;
-
- if ( cont->options & OPT_AUTOAPPSCHED )
-  roar_dl_appsched_trigger(cont->handle[index], ROAR_DL_APPSCHED_FREE);
-
- if ( cont->callbacks != NULL && cont->callbacks->preunload != NULL )
-  cont->callbacks->preunload(cont, &(cont->context[index]), cont->handle[index]);
-
- roar_err_set(err);
- roar_dl_unref(cont->handle[index]);
- err = roar_error;
- cont->handle[index] = NULL;
- cont->numhandles--;
-
- if ( cont->callbacks != NULL && cont->callbacks->postunload != NULL )
-  cont->callbacks->postunload(cont, &(cont->context[index]));
-
- if ( cont->context[index] != NULL )
-  if ( cont->callbacks != NULL && cont->callbacks->freecontext != NULL )
-  cont->callbacks->freecontext(cont, &(cont->context[index]));
-
- if ( cont->context[index] != NULL ) {
-  roar_mm_free(cont->context[index]);
-  cont->context[index] = NULL;
- }
-
- roar_err_set(err);
-}
-
-static int _loader(struct roar_dl_librarypara * lhandle, void * loader_userdata, enum roar_dl_loadercmd cmd, void * argp) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static struct roar_dl_librarypara * _copy_para(struct roar_dl_librarypara * para, struct roar_plugincontainer * cont) {
- struct roar_dl_librarypara * ret = NULL;
- int err;
-
- if ( para == NULL || cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- ret = roar_dl_para_new(NULL, para->binargv, para->appname, para->abiversion);
-
- if ( para->argc && para->argv != NULL ) {
-  ret->argc       = para->argc;
-  ret->args_store = roar_keyval_copy(&(ret->argv), para->argv, para->argc);
-  if ( ret->args_store == NULL ) {
-   err = roar_error;
-   roar_dl_para_unref(ret);
-   roar_error = err;
-   return NULL;
-  }
- }
-
- ret->notifycore      = para->notifycore;
- ret->container       = cont;
- ret->loader          = _loader;
- ret->loader_userdata = NULL;
-
- return ret;
-}
-
-static struct roar_plugincontainer * _new_init(void) {
- struct roar_plugincontainer * ret = roar_mm_malloc(sizeof(struct roar_plugincontainer));
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_plugincontainer));
-
- ret->refc = 1;
-
- return ret;
-}
-
-struct roar_plugincontainer * roar_plugincontainer_new(struct roar_dl_librarypara * default_para) {
- struct roar_plugincontainer * ret = _new_init();
- int err;
-
- if ( ret == NULL )
-  return NULL;
-
- if ( default_para != NULL ) {
-  ret->default_para = _copy_para(default_para, ret);
-  if ( ret->default_para == NULL ) {
-   err = roar_error;
-   roar_plugincontainer_unref(ret);
-   roar_err_set(err);
-   return NULL;
-  }
- }
-
- return ret;
-}
-
-struct roar_plugincontainer * roar_plugincontainer_new_simple(const char * appname, const char * abiversion) {
- struct roar_plugincontainer * ret;
- struct roar_dl_librarypara * para = roar_dl_para_new(NULL, NULL, appname, abiversion);
- int err;
-
- ret = roar_plugincontainer_new(para);
- err = roar_error;
-
- roar_dl_para_unref(para);
-
- roar_err_set(err);
- return ret;
-}
-
-int roar_plugincontainer_ref(struct roar_plugincontainer * cont) {
- if ( cont == NULL ) {
-  ROAR_DBG("roar_plugincontainer_ref(cont=%p) = -1 // error=FAULT", cont);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- cont->refc++;
-
- ROAR_DBG("roar_plugincontainer_ref(cont=%p) = 0", cont);
- return 0;
-}
-
-int roar_plugincontainer_unref(struct roar_plugincontainer * cont) {
- size_t i;
-
- if ( cont == NULL ) {
-  ROAR_DBG("roar_plugincontainer_unref(cont=%p) = -1 // error=FAULT", cont);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- cont->refc--;
-
- if ( cont->refc ) {
-  ROAR_DBG("roar_plugincontainer_unref(cont=%p) = 0", cont);
-  return 0;
- }
-
- if ( cont->callbacks != NULL && cont->callbacks->prefree != NULL )
-  cont->callbacks->prefree(cont, &(cont->userdata));
-
- while (cont->numhandles) {
-  for (i = 0; i < MAX_PLUGINS; i++) {
-   if ( cont->handle[i] == NULL )
-    continue;
-
-   // skip plugins in use by others. We will unload them in a later loop.
-   if ( cont->deprefc[i] )
-    continue;
-
-   _unload(cont, i);
-  }
- }
-
- // try to free user data...
- if ( cont->userdata != NULL ) {
-  if ( cont->callbacks != NULL && cont->callbacks->freeuserdata != NULL ) {
-   cont->callbacks->freeuserdata(cont, &(cont->userdata));
-  }
- }
-
- // if still not freed by caller, free it using memmgr.
- if ( cont->userdata != NULL )
-  roar_mm_free(cont->userdata);
-
- if ( cont->default_para != NULL )
-  roar_dl_para_unref(cont->default_para);
-
- roar_mm_free(cont);
-
- ROAR_DBG("roar_plugincontainer_unref(cont=%p) = 0", cont);
- return 0;
-}
-
-int roar_plugincontainer_set_autoappsched(struct roar_plugincontainer * cont, int val) {
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( val ) {
-  cont->options |= OPT_AUTOAPPSCHED;
-  return 0;
- } else {
-  if ( cont->options & OPT_AUTOAPPSCHED ) {
-   roar_err_set(ROAR_ERROR_BUSY);
-   return -1;
-  } else {
-   return 0;
-  }
- }
-}
-
-int roar_plugincontainer_set_callbacks(struct roar_plugincontainer * cont,
-                                       const struct roar_plugincontainer_callbacks * callbacks) {
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- cont->callbacks = callbacks;
-
- return 0;
-}
-
-int roar_plugincontainer_set_userdata(struct roar_plugincontainer * cont, void * userdata) {
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- cont->userdata = userdata;
-
- return 0;
-}
-
-void * roar_plugincontainer_get_userdata(struct roar_plugincontainer * cont) {
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( cont->userdata == NULL ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return NULL;
- }
-
- return cont->userdata;
-}
-
-struct roar_plugincontainer_plugininfo roar_plugincontainer_get_info_by_name (struct roar_plugincontainer * cont,
-                                                                              const char * name) {
- struct roar_plugincontainer_plugininfo ret;
- const struct roar_dl_libraryname * libname;
- size_t i;
-
- memset(&ret, 0, sizeof(ret));
-
- if ( cont == NULL || name == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return ret;
- }
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( cont->handle[i] == NULL )
-   continue;
-  libname = roar_dl_getlibname(cont->handle[i]);
-  if ( libname == NULL )
-   continue;
-
-  if ( !strcmp(libname->name, name) ) {
-   if ( roar_dl_ref(cont->handle[i]) == -1 )
-    return ret;
-
-   ret.libname  = libname->name;
-   ret.handle   = cont->handle[i];
-   ret.rdepends = cont->deprefc[i];
-   ret.context  = &(cont->context[i]);
-   return ret;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return ret;
-}
-
-struct roar_dl_lhandle * roar_plugincontainer_get_lhandle_by_name (struct roar_plugincontainer * cont,
-                                                                   const char * name) {
- struct roar_plugincontainer_plugininfo info = roar_plugincontainer_get_info_by_name(cont, name);
-
- if ( info.libname == NULL )
-  return NULL;
-
- return info.handle;
-}
-
-// plugin loading and unloading:
-int roar_plugincontainer_load(struct roar_plugincontainer * cont, const char * name, struct roar_dl_librarypara * para) {
- struct roar_dl_lhandle * ret = roar_plugincontainer_load_lhandle(cont, name, ROAR_DL_FLAG_PLUGIN, 1, para);
-
- if ( ret == NULL )
-  return -1;
-
- roar_dl_unref(ret);
-
- return 0;
-}
-
-struct roar_dl_lhandle * roar_plugincontainer_load_lhandle    (struct roar_plugincontainer * cont,
-                                                               const char * name,
-                                                               int flags,
-                                                               int ra_init,
-                                                               struct roar_dl_librarypara * para) {
- ssize_t idx = -1;
- size_t i;
- int err;
-
- if ( cont == NULL || name == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( para == NULL ) {
-  para = cont->default_para;
-  roar_dl_para_ref(para);
- } else {
-  para = _copy_para(para, cont);
- }
-
-
- // search for a free index.
- if ( cont->numhandles == MAX_PLUGINS ) {
-  // return early if we are full.
-  roar_dl_para_unref(para);
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return NULL;
- }
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( cont->handle[i] == NULL ) {
-   idx = i;
-   break;
-  }
- }
-
- if ( idx == -1 ) {
-  roar_dl_para_unref(para);
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return NULL;
- }
-
- cont->context[idx] = NULL; // clear context.
- cont->deprefc[idx] = 0;
-
- if ( cont->callbacks != NULL && cont->callbacks->preload != NULL )
-  cont->callbacks->preload(cont, &(cont->context[idx]), name, flags, para);
-
- cont->handle[idx] = roar_dl_open(name, flags, 0, para);
- if ( cont->handle[idx] == NULL ) {
-  err = roar_error;
-  roar_dl_para_unref(para);
-  roar_error = err;
-  return NULL;
- }
-
- cont->numhandles++;
-
- if ( cont->callbacks != NULL && cont->callbacks->postload != NULL )
-  cont->callbacks->postload(cont, &(cont->context[idx]), cont->handle[idx], name, flags, para);
-
- if ( ra_init ) {
-  if ( cont->callbacks != NULL && cont->callbacks->prera_init != NULL )
-   cont->callbacks->prera_init(cont, &(cont->context[idx]), cont->handle[idx], para);
-  if ( roar_dl_ra_init(cont->handle[idx], NULL, para) == -1 ) {
-   err = roar_error;
-
-   if ( cont->callbacks != NULL && cont->callbacks->postra_init != NULL )
-    cont->callbacks->postra_init(cont, &(cont->context[idx]), cont->handle[idx], para);
-
-   _unload(cont, idx);
-
-   roar_dl_para_unref(para);
-   cont->handle[idx] = NULL;
-   roar_error = err;
-   return NULL;
-  }
-
-  if ( cont->callbacks != NULL && cont->callbacks->postra_init != NULL )
-   cont->callbacks->postra_init(cont, &(cont->context[idx]), cont->handle[idx], para);
-
-  if ( cont->options & OPT_AUTOAPPSCHED )
-   roar_dl_appsched_trigger(cont->handle[idx], ROAR_DL_APPSCHED_INIT);
- }
-
- roar_dl_para_unref(para);
- roar_dl_ref(cont->handle[idx]);
- return cont->handle[idx];
-}
-
-int roar_plugincontainer_unload(struct roar_plugincontainer * cont, const char * name) {
- struct roar_dl_lhandle * lhandle;
-
- if ( cont == NULL || name == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- lhandle = roar_plugincontainer_get_lhandle_by_name(cont, name);
- if ( lhandle == NULL )
-  return -1;
-
- roar_dl_unref(lhandle); // we can do this early here as the handle stay valid in the container's array.
-
- return roar_plugincontainer_unload_lhandle(cont, lhandle);
-}
-
-int roar_plugincontainer_unload_lhandle(struct roar_plugincontainer * cont, struct roar_dl_lhandle * lhandle) {
- size_t i;
-
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( lhandle == NULL ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( cont->handle[i] == lhandle ) {
-   if ( cont->deprefc[i] ) {
-    // still in use.
-    roar_err_set(ROAR_ERROR_BUSY);
-    return -1;
-   }
-   _unload(cont, i);
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-int                      roar_plugincontainer_ra_init         (struct roar_plugincontainer * cont) {
- size_t i;
-
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( cont->handle[i] == NULL )
-   continue;
-
-  if ( cont->callbacks != NULL && cont->callbacks->prera_init != NULL )
-   cont->callbacks->prera_init(cont, &(cont->context[i]), cont->handle[i], cont->default_para);
-
-  roar_dl_ra_init(cont->handle[i], NULL, cont->default_para);
-
-  if ( cont->callbacks != NULL && cont->callbacks->postra_init != NULL )
-   cont->callbacks->postra_init(cont, &(cont->context[i]), cont->handle[i], cont->default_para);
-
-  if ( cont->options & OPT_AUTOAPPSCHED )
-   roar_dl_appsched_trigger(cont->handle[i], ROAR_DL_APPSCHED_INIT);
- }
-
- return 0;
-}
-
-// appsched:
-int roar_plugincontainer_appsched_trigger(struct roar_plugincontainer * cont, enum roar_dl_appsched_trigger trigger) {
- size_t i;
- int ret = -1;
- int rv;
-
- if ( cont == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( cont->numhandles == 1 ) {
-  for (i = 0; i < MAX_PLUGINS; i++) {
-   if ( cont->handle[i] == NULL )
-    continue;
-   return roar_dl_appsched_trigger(cont->handle[i], trigger);
-  }
-  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( cont->handle[i] == NULL )
-   continue;
-
-  rv = roar_dl_appsched_trigger(cont->handle[i], trigger);
-  if ( rv == 0 )
-   ret = 0;
- }
-
- return ret;
-}
-
-//ll
Index: libroar/proto.c
===================================================================
--- libroar/proto.c	(revision 6052)
+++ 	(revision )
@@ -1,375 +1,0 @@
-//proto.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define _ROAR_MESS_BUF_LEN_V0  (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */)
-#define _ROAR_MESS_BUF_LEN_V1  (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */ + \
-                                1 /* flags */)
-#define _ROAR_MESS_BUF_LEN_V2  (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 8 /* pos */ + 2 /* datalen */ + \
-                                4 /* flags */   + 2 /* seq */)
-#define _ROAR_MESS_BUF_LEN     _ROAR_MESS_BUF_LEN_V0
-#define _ROAR_MESS_BUF_LEN_MAX ROAR_MAX3(_ROAR_MESS_BUF_LEN_V0, _ROAR_MESS_BUF_LEN_V1, _ROAR_MESS_BUF_LEN_V2)
-
-#define _ROAR_MESS_CRC_LEN_V0  0 /* No CRC */
-#define _ROAR_MESS_CRC_LEN_V1  1
-#define _ROAR_MESS_CRC_LEN_V2  4
-#define _ROAR_MESS_CRC_LEN_MAX ROAR_MAX3(_ROAR_MESS_CRC_LEN_V0, _ROAR_MESS_CRC_LEN_V1, _ROAR_MESS_CRC_LEN_V2)
-
-int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) {
- struct roar_vio_calls * vio;
-
- if ( (vio = roar_get_connection_vio2(con)) == NULL )
-  return -1;
-
- return roar_vsend_message(vio, mes, data);
-}
-
-int roar_vsend_message(struct roar_vio_calls * vio, struct roar_message * mes, char *  data) {
- char buf[_ROAR_MESS_BUF_LEN_MAX];
- char crc[_ROAR_MESS_CRC_LEN_MAX];
- size_t headerlen = 0;
- size_t crclen    = 0;
- char * bufptr;
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
-
- ROAR_DBG("roar_send_message(*): try to send an request...");
-
- headerlen = _ROAR_MESS_BUF_LEN;
-
- buf[0] = mes->version; // first byte is always the version.
-
- switch (mes->version) {
-  case 0:
-    buf[1]              = (unsigned char) mes->cmd;
-    *(uint16_t*)(buf+2) = ROAR_HOST2NET16(mes->stream);
-    *(uint32_t*)(buf+4) = ROAR_HOST2NET32(mes->pos);
-    *(uint16_t*)(buf+8) = ROAR_HOST2NET16(mes->datalen);
-    headerlen           = _ROAR_MESS_BUF_LEN_V0;
-   break;
-  case 1:
-    buf[1]              = (unsigned char) (mes->flags & 0xFF);
-    buf[2]              = (unsigned char)  mes->cmd;
-    // ...
-    roar_err_set(ROAR_ERROR_NSVERSION);
-    return -1;
-   break;
-  case 2:
-    headerlen           = 16;
-    buf[1]              = (unsigned char) mes->cmd;
-    *(uint16_t*)(buf+2) = ROAR_HOST2NET16(mes->stream);
-    *(uint32_t*)(buf+4) = ROAR_HOST2NET32(mes->flags);
-    if ( mes->flags & ROAR_MF_LSPOS ) {
-     *(uint64_t*)(buf+8) = ROAR_HOST2NET64(mes->pos64);
-     bufptr = buf+16;
-     headerlen          += 4;
-    } else {
-     *(uint32_t*)(buf+8) = ROAR_HOST2NET32(mes->pos);
-     bufptr = buf+12;
-    }
-    *(uint16_t*)(bufptr+0) = ROAR_HOST2NET16(mes->datalen);
-    *(uint16_t*)(bufptr+2) = ROAR_HOST2NET16(mes->seq);
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_BADVERSION);
-    return -1;
- }
-
- if ( roar_vio_write(vio, buf, headerlen) != (ssize_t)headerlen ) {
-  return -1;
- }
-
- if ( mes->datalen != 0 ) {
-  if ( roar_vio_write(vio, data == NULL ? mes->data : data, mes->datalen) != (ssize_t)mes->datalen ) {
-   return -1;
-  }
- }
-
- if ( crclen != 0 ) {
-  if ( roar_vio_write(vio, crc, crclen) != (ssize_t)crclen ) {
-   return -1;
-  }
- }
-
- roar_err_clear();
-
- ROAR_DBG("roar_send_message(*) = 0");
- return 0;
-}
-
-int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) {
- return roar_recv_message2(con, mes, data, NULL);
-}
-int roar_recv_message2 (struct roar_connection * con, struct roar_message * mes, char ** data,
-                        struct roar_error_frame * errorframe) {
- struct roar_vio_calls * vio;
-
- if ( (vio = roar_get_connection_vio2(con)) == NULL )
-  return -1;
-
- return roar_vrecv_message2(vio, mes, data, errorframe);
-}
-
-int roar_vrecv_message(struct roar_vio_calls * vio, struct roar_message * mes, char ** data) {
- return roar_vrecv_message2(vio, mes, data, NULL);
-}
-
-static inline int _libroar_msgresyncer(struct roar_vio_calls  * vio, size_t len) {
- char buffer[2*LIBROAR_BUFFER_MSGDATA]; // this is always called with len > LIBROAR_BUFFER_MSGDATA.
- ssize_t ret;
- size_t errorc = 0;
-
- while (len && errorc < 4) {
-  ret = roar_vio_read(vio, buffer, len > sizeof(buffer) ? sizeof(buffer) : len);
-  if ( ret == (size_t)-1 ) {
-   errorc++;
-  } else {
-   errorc = 0;
-   len -= ret;
-  }
- }
-
- if ( len )
-  return -1; // last error is still set.
- return 0;
-}
-
-int roar_vrecv_message2(struct roar_vio_calls  * vio, struct roar_message * mes, char ** data,
-                        struct roar_error_frame * errorframe) {
- // TODO: add CRC support.
- char buf[_ROAR_MESS_BUF_LEN_MAX];
-// char crc[_ROAR_MESS_CRC_LEN_MAX];
- size_t headerlen = 0;
-// size_t crclen    = 0;
- size_t needlen;
- char * bufptr;
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
-
- ROAR_DBG("roar_vrecv_message2(vio=%p, mes=%p, data=%p, errorframe=%p) = ?", vio, mes, data, errorframe);
-
- ROAR_DBG("roar_vrecv_message2(*): try to get a response form the server...");
-
- if ( vio == NULL || mes == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( data != NULL )
-  *data = NULL;
-
- memset(mes, 0, sizeof(struct roar_message));
-
- if ( roar_vio_read(vio, buf, _ROAR_MESS_BUF_LEN_V0) != _ROAR_MESS_BUF_LEN_V0 ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return -1;
- }
-
- ROAR_DBG("roar_vrecv_message2(*): Got a header");
-
- mes->version = buf[0];
- headerlen    = _ROAR_MESS_BUF_LEN_V0;
-
- switch (mes->version) {
-  case 0:
-    // we already have all data, so create the struct
-    mes->cmd     = (unsigned char)buf[1];
-    mes->stream  = ROAR_NET2HOST16(*(uint16_t*)(buf+2));
-    mes->pos     = ROAR_NET2HOST32(*(uint32_t*)(buf+4));
-    mes->pos64   = mes->pos;
-    mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(buf+8));
-   break;
-  case 2:
-    mes->cmd     = (unsigned char)buf[1];
-    mes->stream  = ROAR_NET2HOST16(*(uint16_t*)(buf+2));
-    mes->flags   = ROAR_NET2HOST32(*(uint32_t*)(buf+4));
-    if ( mes->flags & ROAR_MF_LSPOS ) {
-     headerlen = 20;
-    } else {
-     headerlen = 16;
-    }
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NSVERSION);
-    return -1;
-   break;
- }
-
- // check special case where headerlen < _ROAR_MESS_BUF_LEN_V0, this means that we need to put
- // some data we read as header into the data part of the message.
- if ( headerlen > _ROAR_MESS_BUF_LEN_V0 ) {
-  needlen = headerlen - _ROAR_MESS_BUF_LEN_V0;
-  if ( roar_vio_read(vio, buf+_ROAR_MESS_BUF_LEN_V0, needlen) != (ssize_t)needlen ) {
-   roar_err_set(ROAR_ERROR_PROTO);
-   return -1;
-  }
- }
-
- switch (mes->version) {
-  case 2:
-    if ( mes->flags & ROAR_MF_LSPOS ) {
-     mes->pos64   = ROAR_NET2HOST32(*(uint64_t*)(buf+8));
-     mes->pos     = mes->pos64 & (uint64_t)0x0FFFFFFFFLLU;
-     bufptr       = buf+16;
-    } else {
-     mes->pos     = ROAR_NET2HOST32(*(uint32_t*)(buf+8));
-     mes->pos64   = mes->pos;
-     bufptr       = buf+12;
-    }
-    mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(bufptr+0));
-    mes->seq     = ROAR_NET2HOST16(*(uint16_t*)(bufptr+2));
-   break;
- }
-
- if ( (int16_t)mes->stream == -1 )
-  mes->stream = -1;
-
- ROAR_DBG("roar_vrecv_message2(*): command=%i(%s)", mes->cmd,
-           mes->cmd == ROAR_CMD_OK ? "OK" : (mes->cmd == ROAR_CMD_ERROR ? "ERROR" : "UNKNOWN"));
-
-// Below we only have data handling, handling of header is finished:
-
- if ( mes->datalen == 0 ) {
-  ROAR_DBG("roar_vrecv_message2(*): no data in this pkg");
-  if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) {
-   roar_err_init(errorframe);
-  }
-  roar_err_clear();
-  ROAR_DBG("roar_vrecv_message2(*) = 0");
-  return 0;
- }
-
- if ( mes->datalen <= LIBROAR_BUFFER_MSGDATA ) {
-  if ( roar_vio_read(vio, mes->data, mes->datalen) == (ssize_t)mes->datalen ) {
-   ROAR_DBG("roar_vrecv_message2(*): Got data!");
-   roar_err_clear();
-   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) {
-    if ( roar_err_parsemsg(mes, *data, errorframe) != 0 ) {
-     roar_err_init(errorframe);
-    }
-   }
-   ROAR_DBG("roar_vrecv_message2(*) = 0");
-   return 0;
-  }
-
-  return -1;
- } else {
-  if ( data == NULL ) {
-   if ( _libroar_msgresyncer(vio, mes->datalen) == -1 ) {
-    roar_err_set(ROAR_ERROR_BADCKSUM);
-   } else {
-    roar_err_set(ROAR_ERROR_MSGSIZE);
-   }
-   return -1;
-  }
-
-  if ( (*data = roar_mm_malloc(mes->datalen)) == NULL ) {
-   if ( _libroar_msgresyncer(vio, mes->datalen) == -1 ) {
-    roar_err_set(ROAR_ERROR_BADCKSUM);
-   } else {
-    roar_err_set(ROAR_ERROR_NOMEM);
-   }
-   return -1;
-  }
-
-  if ( mes->datalen == 0 ) {
-   roar_err_clear();
-   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) {
-    roar_err_init(errorframe);
-   }
-   return 0;
-  }
-
-  if ( roar_vio_read(vio, *data, mes->datalen) == (ssize_t)mes->datalen ) {
-   ROAR_DBG("roar_vrecv_message2(*): Got data!");
-
-   roar_err_clear();
-   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) {
-    if ( roar_err_parsemsg(mes, *data, errorframe) != 0 ) {
-     roar_err_init(errorframe);
-    }
-   }
-   ROAR_DBG("roar_vrecv_message2(*) = 0");
-   return 0;
-  }
-
-  // error is still set (by roar_vio_read()).
-  return -1;
- }
-
- // what happened here?
- return -1;
-}
-
-int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) {
- return roar_req2(con, mes, data, NULL);
-}
-
-int roar_req2          (struct roar_connection * con, struct roar_message * mes, char ** data,
-                        struct roar_error_frame * errorframe) {
- struct roar_vio_calls * vio;
-
- if ( (vio = roar_get_connection_vio2(con)) == NULL )
-  return -1;
-
- if ( mes->version == _ROAR_MESSAGE_VERSION )
-  mes->version = con->version;
-
- if ( mes->version == 2 ) {
-  mes->seq = roar_message_genseq(con, -1);
- }
-
- return roar_vreq2(vio, mes, data, errorframe);
-}
-
-int roar_vreq         (struct roar_vio_calls * vio, struct roar_message * mes, char ** data) {
- return roar_vreq2(vio, mes, data, NULL);
-}
-
-int roar_vreq2         (struct roar_vio_calls  * vio, struct roar_message * mes, char ** data,
-                        struct roar_error_frame * errorframe) {
- if ( roar_vsend_message(vio, mes, data != NULL ? *data : NULL) != 0 )
-  return -1;
-
- if ( data != NULL )
-  roar_mm_free(*data);
-
- roar_vio_sync(vio); // we need to do this becasue of ssl/compressed links
-
- return roar_vrecv_message2(vio, mes, data, errorframe);
-}
-
-//ll
Index: libroar/random.c
===================================================================
--- libroar/random.c	(revision 6052)
+++ 	(revision )
@@ -1,257 +1,0 @@
-//random.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_LIBGCRYPT
-#include <gcrypt.h>
-#endif
-
-#ifdef ROAR_HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-
-static void roar_random_init (void) {
- static int inited = 0;
-
- if (inited)
-  return;
-
- // add stuff here needed to bring up random source.
- roar_crypto_init();
-
- inited = 1;
-}
-
-#define TIGER_BLOCKLEN  64
-#define TIGER_DIGESTLEN (3*8)
-
-static size_t roar_nonce_salt_len = 0;
-static void * roar_nonce_salt     = NULL;
-
-static unsigned char roar_nonce_pool[TIGER_DIGESTLEN];
-static size_t        roar_nonce_pool_len = 0;
-
-int roar_random_gen_nonce(void * buffer, size_t len) {
- static uint32_t buf[TIGER_BLOCKLEN/4];
- static int inited = 0;
- static int idx = 0;
- volatile pid_t pid = getpid();
- size_t i, writelen;
- void * off = buf;
-#ifdef ROAR_HAVE_TIME
- volatile uint32_t now = time(NULL);
-#endif
-#ifdef ROAR_HAVE_UNAME
- static struct utsname utsname;
-#endif
-
- roar_random_init();
-
- if ( !inited ) {
-  for (i = 0; i < (sizeof(buf)/sizeof(*buf)); i++) {
-#ifdef ROAR_HAVE_RAND
-   buf[i] = rand() + pid;
-#else
-   buf[i] = pid;
-#endif
-  }
-
-#ifdef ROAR_HAVE_TIME
-  buf[11] += now;
-#endif
-
-  roar_hash_buffer(off,                 buf, TIGER_BLOCKLEN, ROAR_HT_TIGER);
-  roar_hash_buffer(off+TIGER_DIGESTLEN, buf, TIGER_BLOCKLEN, ROAR_HT_TIGER);
-
-  // init is now done:
-  inited = 1;
-
-  // do additional seeding:
-
-#ifdef ROAR_HAVE_UNAME
-  if ( uname(&utsname) == 0 ) {
-   roar_random_salt_nonce(&utsname, sizeof(utsname));
-  }
-#endif
- }
-
- while (len) {
-
-#ifdef ROAR_HAVE_TIME
-  buf[12] += now;
-#endif
-
-#ifdef ROAR_HAVE_RAND
-  buf[12] += rand();
-#endif
-
-  buf[12] += pid;
-  buf[13] += pid;
-
-  off = buf;
-  if ( idx ) {
-   off += TIGER_DIGESTLEN;
-   idx  = 0;
-  } else {
-   idx  = 1;
-  }
-
-  ROAR_DBG("roar_random_gen_nonce(*): buf={0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x, 0x%.8x}",
-           (unsigned int)buf[0], (unsigned int)buf[1], (unsigned int)buf[2], (unsigned int)buf[3], (unsigned int)buf[4], (unsigned int)buf[5], (unsigned int)buf[6], (unsigned int)buf[7], (unsigned int)buf[8], (unsigned int)buf[9], (unsigned int)buf[10], (unsigned int)buf[11], (unsigned int)buf[12], (unsigned int)buf[13], (unsigned int)buf[14], (unsigned int)buf[15]);
-
-  roar_hash_salted_buffer(off, buf, TIGER_BLOCKLEN, ROAR_HT_TIGER, roar_nonce_salt, roar_nonce_salt_len);
-
-  writelen = len >= TIGER_DIGESTLEN ? TIGER_DIGESTLEN : len;
-  memcpy(buffer, off, writelen);
-
-  buffer += writelen;
-  len    -= writelen;
- }
-
- return 0;
-}
-
-int roar_random_salt_nonce (void * salt, size_t len) {
- char buf[1];
- int ret;
-
- roar_nonce_salt     = salt;
- roar_nonce_salt_len = len;
-
- ret = roar_random_gen_nonce(buf, sizeof(buf));
-
- roar_nonce_salt     = NULL;
- roar_nonce_salt_len = 0;
-
- return ret;
-}
-
-uint16_t roar_random_uint16(void) {
- uint16_t ret;
-
- if ( roar_nonce_pool_len < 2 ) {
-  roar_random_gen_nonce(roar_nonce_pool, sizeof(roar_nonce_pool));
-  roar_nonce_pool_len = sizeof(roar_nonce_pool);
- }
-
- ret  = roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+0] <<  0;
- ret |= roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+1] <<  8;
-
- roar_nonce_pool_len -= 2;
-
- return ret;
-}
-
-uint32_t roar_random_uint32(void) {
- uint32_t ret;
-
- if ( roar_nonce_pool_len < 4 ) {
-  roar_random_gen_nonce(roar_nonce_pool, sizeof(roar_nonce_pool));
-  roar_nonce_pool_len = sizeof(roar_nonce_pool);
- }
-
- ret  = (uint32_t)roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+0] <<  0;
- ret |= (uint32_t)roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+1] <<  8;
- ret |= (uint32_t)roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+2] << 16;
- ret |= (uint32_t)roar_nonce_pool[sizeof(roar_nonce_pool)-roar_nonce_pool_len+3] << 24;
-
- roar_nonce_pool_len -= 4;
-
- return ret;
-}
-
-int roar_random_gen(void * buffer, size_t len, int quality) {
- if ( len == 0 )
-  return 0;
-
- if ( buffer == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_random_init();
-
- switch (quality) {
-  case ROAR_RANDOM_NONE:
-    // no entropy:
-    memset(buffer, 0, len);
-   break;
-  case ROAR_RANDOM_VERY_WEAK:
-    return roar_random_gen_nonce(buffer, len);
-   break;
-#ifdef ROAR_HAVE_LIBGCRYPT
-  case ROAR_RANDOM_WEAK:
-    gcry_create_nonce(buffer, len);
-   break;
-  case ROAR_RANDOM_NORMAL:
-  case ROAR_RANDOM_STRONG:
-    gcry_randomize(buffer, len, GCRY_STRONG_RANDOM);
-   break;
-  case ROAR_RANDOM_VERY_STRONG:
-    gcry_randomize(buffer, len, GCRY_VERY_STRONG_RANDOM);
-   break;
-#endif
-  default:
-    roar_err_set(ROAR_ERROR_NOENT);
-    return -1;
-   break;
- }
-
- return 0;
-}
-
-void * roar_random_genbuf(size_t len, int quality, int locked) {
- void * ret = roar_mm_malloc(len);
-
- if (ret == NULL)
-  return NULL;
-
- if ( locked ) {
-  if ( roar_mm_mlock(ret, len) == -1 ) {
-   roar_mm_free_noerror(ret);
-   return NULL;
-  }
- }
-
- if ( roar_random_gen(ret, len, quality) == -1 ) {
-  roar_mm_free_noerror(ret);
-  return NULL;
- }
-
- return ret;
-}
-
-//ll
Index: libroar/roardl.c
===================================================================
--- libroar/roardl.c	(revision 6052)
+++ 	(revision )
@@ -1,1296 +1,0 @@
-//roardl.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_H_DIRENT
-#include <dirent.h>
-#endif
-
-#if defined(ROAR_HAVE_H_DLFCN) && !defined(RTLD_NEXT)
-#define RTLD_NEXT ((void *) -1L)
-#endif
-
-#define RTF_RA_INITED       0x0001
-#define RTF_APPSCHED_INITED 0x0002
-#define RTF_APPSCHED_FREED  0x0004
-
-struct roar_dl_lhandle {
- size_t refc; // currently unused.
- int flags;
- char * libname; // only used for ROAR_DL_FLAG_STATIC.
- struct roar_dl_librarypara * para;
- struct roar_dl_libraryinst * lib;
- struct {
-  struct roar_error_state error_state;
-  void *  global_data;
-  void *  global_data_state;
-  struct roar_notify_core * notifycore;
-  struct roar_vio_calls * stdvios[3];
- } context;
- unsigned int runtime_flags;
-#if defined(ROAR_HAVE_H_DLFCN)
- void * handle;
-#elif defined(ROAR_TARGET_WIN32)
- HMODULE handle;
-#endif
-};
-
-// TODO: this should be removed on next SONAME change.
-static struct roar_dl_lhandle * __currently_inited    = NULL;
-static int                      __currently_inited_fn = -1;
-
-struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv,
-                                              const char * appname, const char * abiversion) {
- struct roar_dl_librarypara * ret = roar_mm_malloc(sizeof(struct roar_dl_librarypara));
- ssize_t argc;
- int err;
-
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_dl_librarypara));
-
- ret->version    = ROAR_DL_LIBPARA_VERSION;
- ret->len        = sizeof(struct roar_dl_librarypara);
- ret->refc       = 1;
- ret->argc       = 0;
- ret->argv       = NULL;
- ret->args_store = NULL;
- ret->binargv    = binargv;
- ret->appname    = appname;
- ret->abiversion = abiversion;
-
- if ( args != NULL ) {
-  ret->args_store = roar_mm_strdup(args);
-  if ( ret->args_store == NULL ) {
-   roar_mm_free_noerror(ret);
-   return NULL;
-  }
-
-  argc = roar_keyval_split(&(ret->argv), ret->args_store, NULL, NULL, 1);
-  if ( argc == -1 ) {
-   err = roar_error;
-   roar_mm_free(ret->args_store);
-   roar_mm_free(ret);
-   roar_error = err;
-   return NULL;
-  }
-
-  ret->argc = argc;
- }
-
- return ret;
-}
-
-int roar_dl_para_ref                    (struct roar_dl_librarypara * para) {
- if ( para == NULL ) {
-  ROAR_DBG("roar_dl_para_ref(para=%p) = -1 // error=FAULT", para);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- para->refc++;
-
- ROAR_DBG("roar_dl_para_ref(para=%p) = 0", para);
- return 0;
-}
-
-int roar_dl_para_unref                  (struct roar_dl_librarypara * para) {
- if ( para == NULL ) {
-  ROAR_DBG("roar_dl_para_unref(para=%p) = -1 // error=FAULT", para);
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- para->refc--;
-
- if ( para->refc ) {
-  ROAR_DBG("roar_dl_para_unref(para=%p) = 0", para);
-  return 0;
- }
-
- if ( para->notifycore != NULL )
-  roar_notify_core_unref(para->notifycore);
-
- if ( para->args_store != NULL ) {
-  roar_mm_free(para->args_store);
-  roar_mm_free(para->argv);
- }
-
- roar_mm_free(para);
-
- ROAR_DBG("roar_dl_para_unref(para=%p) = 0", para);
- return 0;
-}
-int roar_dl_para_check_version          (struct roar_dl_librarypara * para,
-                                         const char * appname, const char * abiversion) {
- if ( para == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- // check if both appnames are NULL or non-NULL.
- if ( (para->appname == NULL && appname != NULL) || (para->appname != NULL && appname == NULL) ) {
-  roar_err_set(ROAR_ERROR_BADHOST);
-  return -1;
- }
-
- // check if the appname matches if given.
- if ( para->appname != NULL && !!strcmp(para->appname, appname) ) {
-  roar_err_set(ROAR_ERROR_BADHOST);
-  return -1;
- }
-
- // check if both ABI versions are NULL or non-NULL.
- if ( (para->abiversion == NULL && abiversion != NULL) || (para->abiversion != NULL && abiversion == NULL) ) {
-  roar_err_set(ROAR_ERROR_BADVERSION);
-  return -1;
- }
-
- // check if the ABI versions matches if given.
- if ( para->abiversion != NULL && !!strcmp(para->abiversion, abiversion) ) {
-  roar_err_set(ROAR_ERROR_BADVERSION);
-  return -1;
- }
-
- return 0;
-}
-
-
-#if defined(ROAR_HAVE_H_DLFCN)
-static void * _roardl2ldl (struct roar_dl_lhandle * lhandle) {
- ROAR_DBG("_roardl2ldl(lhandle=%p) = ?", lhandle);
-
- if ( (void*)lhandle < (void*)128 ) {
-  switch ((int)(void*)lhandle) {
-   case (int)(void*)ROAR_DL_HANDLE_DEFAULT:
-   case (int)(void*)ROAR_DL_HANDLE_LIBROAR:
-   case (int)(void*)ROAR_DL_HANDLE_APPLICATION:
-     ROAR_DBG("_roardl2ldl(lhandle=%p) = %p", lhandle, (void*)RTLD_DEFAULT);
-     return RTLD_DEFAULT;
-    break;
-   case (int)(void*)ROAR_DL_HANDLE_NEXT:
-     ROAR_DBG("_roardl2ldl(lhandle=%p) = %p", lhandle, (void*)RTLD_NEXT);
-     return RTLD_NEXT;
-    break;
-  }
- }
-
- ROAR_DBG("_roardl2ldl(lhandle=%p) = %p", lhandle, (void*)(lhandle->handle));
- return lhandle->handle;
-}
-#elif defined(ROAR_TARGET_WIN32)
-static HMODULE _roardl2winhandle(struct roar_dl_lhandle * lhandle) {
- if ( (void*)lhandle < (void*)128 ) {
-  return NULL;
- }
- return lhandle->handle;
-}
-#endif
-
-#ifdef ROAR_HAVE_H_DIRENT
-// pvn = prefix, host vendor, host name
-static struct roar_dl_lhandle * _load_from_path_pvn(const char * name,
-                                                    int flags, int ra_init,
-                                                    struct roar_dl_librarypara * para,
-                                                    const char * prefix,
-                                                    const char * hostvendor,
-                                                    const char * hostname) {
- struct roar_dl_lhandle * ret = NULL;
- int i, j;
- char path[1024];
- const char * path_format[] = {"%s/%s/%s", "%s/%s/universal", "%s/universal/universal"};
- DIR * dir;
- struct dirent * dirent;
- char file[1024];
- const char * file_format[] = {"%s/%s/%s", "%s/%s/%s" ROAR_SHARED_SUFFIX, "%s/%s/lib%s" ROAR_SHARED_SUFFIX};
-//  cont->handle[idx] = roar_dl_open(name, ROAR_DL_FLAG_DEFAULTS, 1, para);
-//#vars: $PREFIX_PLUGINS, $hostvendor, $hostname, $name
-//#search order: $PREFIX_PLUGINS/{$hostvendor/{$hostname,universal},universal/universal}/*/{,lib}$name.so
-
- for (i = 0; i < 3; i++) {
-  snprintf(path, sizeof(path), path_format[i], prefix, hostvendor, hostname);
-  dir = opendir(path);
-  if ( dir == NULL )
-   continue;
-
-  while ((dirent = readdir(dir)) != NULL) {
-   if ( !strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..") )
-    continue;
-
-   for (j = 0; j < 3; j++) {
-    snprintf(file, sizeof(file), file_format[j], path, dirent->d_name, name);
-    ret = roar_dl_open(file, flags, ra_init, para);
-    if ( ret != NULL ) {
-     closedir(dir);
-     return ret;
-    }
-   }
-  }
-
-  closedir(dir);
- }
-
- return NULL;
-}
-
-static struct roar_dl_lhandle * _load_from_path(const char * name, int flags, int ra_init,
-                                                struct roar_dl_librarypara * para) {
- struct roar_dl_lhandle * ret = NULL;
- char * host = NULL;
- char * hostvendor_buffer = NULL;
- char * hostvendor = NULL;
- char * hostname = NULL;
- size_t hostvendor_len;
- char * c, * d;
-
- if ( para != NULL && para->appname != NULL && para->appname[0] != 0 ) {
-  host = roar_mm_strdup(para->appname);
-
-  // if we are out of memory we will likely not pass the rest, so just return in error.
-  if ( host == NULL )
-   return NULL;
-
-  hostname = host;
-  c = strstr(host, "<");
-  if ( c != NULL ) {
-   while (c[-1] == ' ') c--;
-   *c = 0;
-   c++;
-   while (*c == ' ' || *c == '<') c++;
-   if ( *c ) {
-    d = strstr(c, ">");
-    if ( d != NULL )
-     *d = 0;
-
-    d = strstr(c, "/");
-    if ( d != NULL ) {
-     *d = '-';
-     hostvendor = c;
-    } else {
-     hostvendor_len = roar_mm_strlen(c) + 1 /* tailing \0 */ + 6 /* "unreg-" */;
-     hostvendor_buffer = roar_mm_malloc(hostvendor_len);
-
-     // see above
-     if ( hostvendor_buffer == NULL ) {
-      roar_mm_free(host);
-      return NULL;
-     }
-
-     roar_mm_strlcpy(hostvendor_buffer, "unreg-", hostvendor_len);
-     roar_mm_strlcat(hostvendor_buffer, c, hostvendor_len);
-     hostvendor = hostvendor_buffer;
-    }
-   }
-  }
- }
-
- if ( hostvendor == NULL )
-  hostvendor = "universal";
-
- if ( hostname == NULL )
-  hostname = "universal";
-
- ret = _load_from_path_pvn(name, flags, ra_init, para, ROAR_PREFIX_PLUGINS, hostvendor, hostname);
-
- if ( host != NULL )
-  roar_mm_free(host);
- if ( hostvendor_buffer != NULL )
-  roar_mm_free(hostvendor_buffer);
- return ret;
-}
-#endif
-
-static struct roar_dl_lhandle * _roar_dl_open_pluginpath(const char * filename, int flags,
-                                      int ra_init, struct roar_dl_librarypara * para) {
- flags |= ROAR_DL_FLAG_PLUGINPATH;
- flags -= ROAR_DL_FLAG_PLUGINPATH;
-
-#ifdef ROAR_HAVE_H_DIRENT
- // do normal open for everything with a path name.
- if ( strstr(filename, "/") != NULL )
-  return roar_dl_open(filename, flags, ra_init, para);
-
- return _load_from_path(filename, flags, ra_init, para);
-#else
- // fall back to system open function.
- return roar_dl_open(filename, flags, ra_init, para);
-#endif
-}
-
-struct roar_dl_lhandle * roar_dl_open(const char * filename, int flags,
-                                      int ra_init, struct roar_dl_librarypara * para) {
- struct roar_dl_lhandle * ret = NULL;
-#if defined(ROAR_HAVE_H_DLFCN)
-#if defined(RTLD_DEEPBIND) && 0
- // FIXME: This is currently disabled. See #296.
- int libdl_flags = RTLD_DEEPBIND;
-#else
- int libdl_flags = 0;
-#endif
-#endif
- int err;
-
- switch (flags) {
-  case ROAR_DL_FLAG_DEFAULTS: flags = ROAR_DL_FLAG_NONE;       break;
-  case ROAR_DL_FLAG_PLUGIN:   flags = ROAR_DL_FLAG_PLUGINPATH; break;
- }
-
- if ( flags & ROAR_DL_FLAG_PLUGINPATH )
-  return _roar_dl_open_pluginpath(filename, flags, ra_init, para);
-
-#if defined(ROAR_HAVE_H_DLFCN)
- if ( flags & ROAR_DL_FLAG_LAZY ) {
-  libdl_flags |= RTLD_LAZY;
- } else {
-  libdl_flags |= RTLD_NOW;
- }
-#endif
-
- if ( (ret = roar_mm_malloc(sizeof(struct roar_dl_lhandle))) == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_dl_lhandle));
-
- roar_err_initstore(&(ret->context.error_state));
-
- ret->flags = flags;
- ret->refc  = 1;
-
- if ( flags & ROAR_DL_FLAG_STATIC ) {
-  if ( filename == NULL ) {
-   ret->libname = NULL;
-  } else {
-   ret->libname = roar_mm_strdup(filename);
-  }
- } else {
-#if defined(ROAR_HAVE_H_DLFCN)
-  ret->handle = dlopen(filename, libdl_flags);
-
-  if ( ret->handle == NULL ) {
-   ROAR_DBG("roar_dl_open(filename='%s', flags=%i, ra_init=%i, para=%p): Can not load library: %s", filename, flags, ra_init, para, roar_dl_errstr(ret));
-   roar_mm_free(ret);
-   return NULL;
-  }
-#elif defined(ROAR_TARGET_WIN32)
-  ret->handle = LoadLibrary(filename);
-
-  if ( ret->handle == NULL ) {
-   roar_mm_free(ret);
-   return NULL;
-  }
-#else
-  roar_mm_free(ret);
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return NULL;
-#endif
- }
-
- ret->para = para;
-
- if ( roar_vio_ref(roar_stdin) == 0 )
-  ret->context.stdvios[0] = roar_stdin;
- if ( roar_vio_ref(roar_stdout) == 0 )
-  ret->context.stdvios[1] = roar_stdout;
- if ( roar_vio_ref(roar_stderr) == 0 )
-  ret->context.stdvios[2] = roar_stderr; 
-
- if ( ra_init ) {
-  if ( roar_dl_ra_init(ret, NULL, para) == -1 ) {
-   err = roar_error;
-   ROAR_WARN("roar_dl_open(filename='%s', flags=%i, ra_init=%i, para=%p): Can not init RA lib: %s", filename, flags, ra_init, para, roar_error2str(err));
-#if defined(ROAR_HAVE_H_DLFCN)
-   if ( ret->handle != NULL )
-    dlclose(ret->handle);
-#elif defined(ROAR_TARGET_WIN32)
-   if ( ret->handle != NULL )
-    FreeLibrary(ret->handle);
-#endif
-   roar_vio_unref(ret->context.stdvios[0]);
-   roar_vio_unref(ret->context.stdvios[1]);
-   roar_vio_unref(ret->context.stdvios[2]);
-   roar_mm_free(ret);
-   roar_error = err;
-   return NULL;
-  }
- }
-
- if ( para != NULL )
-  roar_dl_para_ref(para);
-
- return ret;
-}
-
-int                      roar_dl_ref    (struct roar_dl_lhandle * lhandle) {
- if ( (void*)lhandle < (void*)128 ) {
-  ROAR_DBG("roar_dl_ref(lhandle=%p) = -1 // error=BADFH", lhandle);
-  roar_err_set(ROAR_ERROR_BADFH);
-  return -1;
- }
-
- lhandle->refc++;
-
- ROAR_DBG("roar_dl_ref(lhandle=%p) = 0", lhandle);
- return 0;
-}
-
-int                      roar_dl_unref  (struct roar_dl_lhandle * lhandle) {
- int ret = -1;
-
- if ( (void*)lhandle < (void*)128 ) {
-  ROAR_DBG("roar_dl_unref(lhandle=%p) = -1 // error=BADFH", lhandle);
-  roar_err_set(ROAR_ERROR_BADFH);
-  return -1;
- }
-
- lhandle->refc--;
-
- if ( lhandle->refc ) {
-  ROAR_DBG("roar_dl_unref(lhandle=%p) = 0", lhandle);
-  return 0;
- }
-
- roar_dl_unregister_fn(lhandle);
-
- if ( lhandle->lib != NULL && lhandle->lib->unload != NULL ) {
-  roar_dl_context_restore(lhandle);
-  lhandle->lib->unload(lhandle->para, lhandle->lib);
-  roar_dl_context_store(lhandle);
- }
-
-#if defined(ROAR_HAVE_H_DLFCN)
- if ( lhandle->handle == NULL ) {
-  ret = 0;
- } else {
-  ret = dlclose(_roardl2ldl(lhandle));
- }
-#elif defined(ROAR_TARGET_WIN32)
- if ( lhandle->handle == NULL ) {
-  ret = 0;
- } else {
-  if ( FreeLibrary(_roardl2winhandle(lhandle)) ) {
-   ret = 0;
-  } else {
-   ret = -1;
-  }
- }
-#else
- ret = -1;
-#endif
-
- roar_vio_unref(lhandle->context.stdvios[0]);
- roar_vio_unref(lhandle->context.stdvios[1]);
- roar_vio_unref(lhandle->context.stdvios[2]);
-
- if ( lhandle->context.global_data != NULL )
-  roar_mm_free(lhandle->context.global_data);
-
- if ( lhandle->para != NULL )
-  roar_dl_para_unref(lhandle->para);
-
- if ( lhandle->libname != NULL )
-  roar_mm_free(lhandle->libname);
-
- roar_mm_free(lhandle);
-
- ROAR_DBG("roar_dl_unref(lhandle=%p) = %i", lhandle, ret);
- return ret;
-}
-
-void                   * roar_dl_getsym(struct roar_dl_lhandle * lhandle, const char * sym, int type) {
-#if defined(ROAR_HAVE_H_DLFCN)
- void * ret = dlsym(_roardl2ldl(lhandle), sym);
-
- (void)type;
-
- ROAR_DBG("roar_dl_getsym(lhandle=%p, sym='%s', type=%i): ret=%p, errno=%s(%i), dlerror()='%s'", lhandle, sym, type, ret, strerror(errno), errno, dlerror());
- ROAR_DBG("roar_dl_getsym(lhandle=%p, sym='%s', type=%i) = %p", lhandle, sym, type, ret);
-
- return ret;
-#elif defined(ROAR_TARGET_WIN32)
- FARPROC ret = GetProcAddress(_roardl2winhandle(lhandle), sym);
- return (void*)ret;
-#else
- ROAR_DBG("roar_dl_getsym(lhandle=%p, sym='%s', type=%i) = NULL // errno=NOSYS", lhandle, sym, type, ret);
- roar_err_set(ROAR_ERROR_NOSYS);
- return NULL;
-#endif
-}
-
-int                      roar_dl_ra_init(struct roar_dl_lhandle * lhandle,
-                                         const char * prefix,
-                                         struct roar_dl_librarypara * para) {
- struct roar_dl_lhandle * old_init;
- int old_fn;
-#define _SUFFIX "_roaraudio_library_init"
- char name[80] = _SUFFIX;
- struct roar_dl_libraryinst * (*func)(struct roar_dl_librarypara * para);
- struct roar_dl_libraryinst * lib;
- struct roar_dl_lhandle     * getsymhandle = lhandle;
- void * global_data_state = NULL;
- int i;
-
- if ( (void*)lhandle < (void*)128 ) {
-  if ( prefix == NULL )
-   return -1;
- } else {
-  if ( lhandle->runtime_flags & RTF_RA_INITED )
-   return 0;
-
-  if ( prefix == NULL )
-   prefix = lhandle->libname;
-
-  if ( para == NULL )
-   para = lhandle->para;
-
-  if ( lhandle->flags & ROAR_DL_FLAG_STATIC )
-   getsymhandle = ROAR_DL_HANDLE_DEFAULT;
- }
-
-
- if ( prefix != NULL ) {
-  roar_mm_strscpy(name, "_");
-  roar_mm_strscat(name, prefix);
-  roar_mm_strscat(name, _SUFFIX);
- }
-
- ROAR_DBG("roar_dl_ra_init(lhandle=%p, prefix='%s'): name='%s'", lhandle, prefix, name);
-
- if ( (func = roar_dl_getsym(getsymhandle, name, -1)) == NULL ) {
-  ROAR_DBG("roar_dl_ra_init(lhandle=%p, prefix='%s') = -1", lhandle, prefix);
-  return -1;
- }
-
- ROAR_DBG("roar_dl_ra_init(lhandle=%p, prefix='%s'): func=%p", lhandle, prefix, func);
-
- roar_err_set(ROAR_ERROR_BADLIB); // set a default error in case it returns NULL but not set an error code.
- lib = func(para);
-
- if ( lib == NULL )
-  return -1;
-
- if ( lib->version != ROAR_DL_LIBINST_VERSION )
-  return -1;
-
- if ( sizeof(struct roar_dl_libraryinst) > lib->len )
-  return -1;
-
- if ( lib->host_appname != NULL || lib->host_abiversion != NULL ) {
-  // check for correct host.
-  if ( para == NULL ) {
-   roar_err_set(ROAR_ERROR_INVAL);
-   return -1;
-  }
-  if ( roar_dl_para_check_version(para, lib->host_appname, lib->host_abiversion) == -1 )
-   return -1;
- }
-
- if ( (lib->libdep == NULL && lib->libdep_len) || (lib->libdep != NULL && !lib->libdep_len) ) {
-  roar_err_set(ROAR_ERROR_BADLIB);
-  return -1;
- }
-
- if ( lib->libdep != NULL && lib->libdep_len ) {
-  // dynamic loader infos are currently not supported.
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- if ( !((void*)lhandle < (void*)128) ) {
-  lhandle->lib = lib;
-
-  if ( lib->global_data_len ) {
-   lhandle->context.global_data = roar_mm_malloc(lib->global_data_len);
-   if ( lhandle->context.global_data == NULL )
-    return -1;
-
-   if ( lib->global_data_init == NULL ) {
-    memset(lhandle->context.global_data, 0, lib->global_data_len);
-   } else {
-    memcpy(lhandle->context.global_data, lib->global_data_init, lib->global_data_len);
-   }
-  }
- }
-
- if ( lib->global_data_pointer != NULL ) {
-  global_data_state = *(lib->global_data_pointer);
-  if ( (void*)lhandle < (void*)128 ) {
-   *(lib->global_data_pointer) = lib->global_data_init;
-  } else {
-   *(lib->global_data_pointer) = lhandle->context.global_data;
-  }
- }
-
- roar_dl_context_restore(lhandle);
-
- old_init = __currently_inited;
- old_fn   = __currently_inited_fn;
- __currently_inited = lhandle;
- for (i = 0; i < ROAR_DL_FN_MAX; i++) {
-  __currently_inited_fn = i;
-  if ( lib->func[i] != NULL )
-   lib->func[i](para, lib);
- }
- __currently_inited_fn = old_fn;
- __currently_inited = old_init;
-
- roar_dl_context_store(lhandle);
-
- if ( lib->global_data_pointer != NULL ) {
-  if ( !((void*)lhandle < (void*)128) ) {
-   *(lib->global_data_pointer) = global_data_state;
-  }
- }
-
- if ( !((void*)lhandle < (void*)128) )
-  lhandle->runtime_flags |= RTF_RA_INITED;
-
- return 0;
-}
-
-const char * roar_dl_errstr(struct roar_dl_lhandle * lhandle) {
-#if defined(ROAR_HAVE_H_DLFCN)
- (void)lhandle;
- return dlerror();
-#elif defined(ROAR_TARGET_WIN32)
- roar_err_from_errno();
- return roar_error2str(roar_error);
-#else
- return NULL;
-#endif
-}
-
-struct roar_dl_librarypara       * roar_dl_getpara(struct roar_dl_lhandle * lhandle) {
- if ( (void*)lhandle < (void*)128 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return NULL;
- }
-
- if ( lhandle->para == NULL ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return NULL;
- }
-
- if ( roar_dl_para_ref(lhandle->para) == -1 )
-  return NULL;
-
- return lhandle->para;
-}
-
-const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle) {
- if ( (void*)lhandle < (void*)128 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return NULL;
- }
-
- if ( lhandle->lib == NULL ) {
-  roar_err_set(ROAR_ERROR_BADLIB);
-  return NULL;
- }
-
- if ( lhandle->lib->libname == NULL ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return NULL;
- }
-
- if ( lhandle->lib->libname->version != ROAR_DL_LIBNAME_VERSION ) {
-  roar_err_set(ROAR_ERROR_BADVERSION);
-  return NULL;
- }
-
- if ( lhandle->lib->libname->len != sizeof(struct roar_dl_libraryname) ) {
-  roar_err_set(ROAR_ERROR_HOLE);
-  return NULL;
- }
-
- return lhandle->lib->libname;
-}
-
-static inline void __swap_stdvios(struct roar_dl_lhandle * lhandle) {
- struct roar_vio_calls * vio;
-
- vio = roar_stdin;
- roar_stdin = lhandle->context.stdvios[0];
- lhandle->context.stdvios[0] = vio;
- vio = roar_stdout;
- roar_stdout = lhandle->context.stdvios[1];
- lhandle->context.stdvios[1] = vio;
- vio = roar_stderr;
- roar_stderr = lhandle->context.stdvios[2];
- lhandle->context.stdvios[2] = vio;
-}
-
-int                      roar_dl_context_restore(struct roar_dl_lhandle * lhandle) {
- struct roar_error_state error_state;
-
- ROAR_DBG("roar_dl_context_restore(lhandle=%p) = ?", lhandle);
-
- if ( (void*)lhandle < (void*)128 ) {
-  ROAR_DBG("roar_dl_context_restore(lhandle=%p) = -1 // errno=NOTSUP", lhandle);
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- roar_err_store(&error_state);
- roar_err_restore(&(lhandle->context.error_state));
- lhandle->context.error_state = error_state;
-
- __swap_stdvios(lhandle);
-
- if ( lhandle->lib->global_data_pointer != NULL ) {
-  ROAR_DBG("roar_dl_context_restore(lhandle=%p): gptr(%p): %p -> %p", lhandle,
-           lhandle->lib->global_data_pointer, *(lhandle->lib->global_data_pointer), lhandle->context.global_data);
-  lhandle->context.global_data_state = *(lhandle->lib->global_data_pointer);
-  *(lhandle->lib->global_data_pointer) = lhandle->context.global_data;
- }
-
- if ( lhandle->para != NULL && lhandle->para->notifycore != NULL )
-  lhandle->context.notifycore = roar_notify_core_swap_global(lhandle->para->notifycore);
-
- ROAR_DBG("roar_dl_context_restore(lhandle=%p) = 0", lhandle);
- return 0;
-}
-
-int                      roar_dl_context_store(struct roar_dl_lhandle * lhandle) {
- struct roar_error_state error_state;
-
- ROAR_DBG("roar_dl_context_store(lhandle=%p) = ?", lhandle);
-
- if ( (void*)lhandle < (void*)128 ) {
-  ROAR_DBG("roar_dl_context_store(lhandle=%p) = -1 // errno=NOTSUP", lhandle);
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- if ( lhandle->para != NULL && lhandle->para->notifycore != NULL ) {
-  roar_notify_core_unref(roar_notify_core_swap_global(lhandle->context.notifycore));
-  roar_notify_core_unref(lhandle->context.notifycore);
-  lhandle->context.notifycore = NULL;
- }
-
- if ( lhandle->lib->global_data_pointer != NULL ) {
-  ROAR_DBG("roar_dl_context_store(lhandle=%p): gptr(%p): %p -> %p", lhandle,
-           lhandle->lib->global_data_pointer, *(lhandle->lib->global_data_pointer), lhandle->context.global_data_state);
-  *(lhandle->lib->global_data_pointer) = lhandle->context.global_data_state;
- }
-
- __swap_stdvios(lhandle);
-
- roar_err_store(&error_state);
- roar_err_restore(&(lhandle->context.error_state));
- lhandle->context.error_state = error_state;
-
- ROAR_DBG("roar_dl_context_store(lhandle=%p) = 0", lhandle);
- return 0;
-}
-
-int                      roar_dl_appsched_trigger__handle_about(struct roar_dl_lhandle * lhandle) {
- libroar_dl_service_apitype(roar_service_about) api;
- int ret, err;
-
- if ( roar_dl_service_get_api(NULL, ROAR_SERVICE_ABOUT_NAME, ROAR_SERVICE_ABOUT_ABI, &api) == -1 )
-  return -1;
-
- ret = libroar_dl_service_run_func(api, show, int, roar_dl_getlibname(lhandle));
- err = roar_error;
-
- libroar_dl_service_free_api(api);
-
- roar_error = err;
- return ret;
-}
-
-int                      roar_dl_appsched_trigger__handle_help(struct roar_dl_lhandle * lhandle) {
- libroar_dl_service_apitype(roar_service_help) api;
- int ret, err;
-
- if ( roar_dl_service_get_api(NULL, ROAR_SERVICE_HELP_NAME, ROAR_SERVICE_HELP_ABI, &api) == -1 )
-  return -1;
-
- ret = libroar_dl_service_run_func(api, show, int, roar_dl_getlibname(lhandle), NULL);
- err = roar_error;
-
- libroar_dl_service_free_api(api);
-
- roar_error = err;
- return ret;
-}
-
-int                      roar_dl_appsched_trigger__handle_preferences(struct roar_dl_lhandle * lhandle) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-int                      roar_dl_appsched_trigger(struct roar_dl_lhandle * lhandle, enum roar_dl_appsched_trigger trigger) {
- int (*func)  (struct roar_dl_librarypara * para) = NULL;
- int ret;
-
- if ( (void*)lhandle < (void*)128 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- if ( lhandle->lib == NULL ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- if ( lhandle->lib->appsched == NULL ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- switch (trigger) {
-#define _trig(lname,uname) \
-  case ROAR_DL_APPSCHED_ ## uname :             \
-    func = lhandle->lib->appsched->lname;       \
-   break;
-  _trig(init, INIT);
-  _trig(free, FREE);
-  _trig(update, UPDATE);
-  _trig(tick, TICK);
-  _trig(wait, WAIT);
-
-  // not yet supported by struct roar_dl_appsched.
-  case ROAR_DL_APPSCHED_ABOUT:
-  case ROAR_DL_APPSCHED_HELP:
-  case ROAR_DL_APPSCHED_PREFERENCES:
-    func = NULL;
-   break;
-// use ifndef here so warnings of unhandled enum values will be shown in DEBUG mode.
-#ifndef DEBUG
-  default:
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
-#endif
- }
-
- if ( func == NULL ) {
-  if ( trigger == ROAR_DL_APPSCHED_INIT ) {
-   lhandle->runtime_flags |= RTF_APPSCHED_INITED|RTF_APPSCHED_FREED;
-   lhandle->runtime_flags -= RTF_APPSCHED_FREED;
-  } else if ( trigger == ROAR_DL_APPSCHED_FREE ) {
-   lhandle->runtime_flags |= RTF_APPSCHED_INITED|RTF_APPSCHED_FREED;
-   lhandle->runtime_flags -= RTF_APPSCHED_INITED;
-  }
-  switch (trigger) {
-   case ROAR_DL_APPSCHED_ABOUT:
-     return roar_dl_appsched_trigger__handle_about(lhandle);
-    break;
-   case ROAR_DL_APPSCHED_HELP:
-     return roar_dl_appsched_trigger__handle_help(lhandle);
-    break;
-   case ROAR_DL_APPSCHED_PREFERENCES:
-     return roar_dl_appsched_trigger__handle_preferences(lhandle);
-    break;
-   default:
-     roar_err_set(ROAR_ERROR_NOENT);
-     return -1;
-    break;
-  }
- }
-
- if ( trigger == ROAR_DL_APPSCHED_INIT ) {
-  if ( lhandle->runtime_flags & RTF_APPSCHED_INITED ) {
-   roar_err_set(ROAR_ERROR_BUSY);
-   return -1;
-  }
- } else {
-  if ( !(lhandle->runtime_flags & RTF_APPSCHED_INITED) ) {
-   roar_err_set(ROAR_ERROR_BUSY);
-   return -1;
-  }
- }
-
- roar_dl_context_restore(lhandle);
- ret = func(lhandle->para);
- roar_dl_context_store(lhandle);
-
- if ( trigger == ROAR_DL_APPSCHED_INIT ) {
-  lhandle->runtime_flags |= RTF_APPSCHED_INITED|RTF_APPSCHED_FREED;
-  lhandle->runtime_flags -= RTF_APPSCHED_FREED;
- } else if ( trigger == ROAR_DL_APPSCHED_FREE ) {
-  lhandle->runtime_flags |= RTF_APPSCHED_INITED|RTF_APPSCHED_FREED;
-  lhandle->runtime_flags -= RTF_APPSCHED_INITED;
- }
-
- return ret;
-}
-
-
-#define __MAX_FNREGS 24
-static struct __fnregs {
- struct roar_dl_lhandle * lhandle;
- int subtype;
- const void * object;
- size_t objectlen;
- int version;
- int options;
-} __fnrefs[ROAR_DL_FN_MAX][__MAX_FNREGS];
-
-static int  __fnreg_check_trigger(const struct __fnregs * handle) {
- if ( handle->subtype != ROAR_DL_FNREG_SUBTYPE )
-  return -1;
- if ( handle->version != ROAR_DL_FNREG_VERSION )
-  return -1;
- if ( handle->objectlen != ROAR_DL_FNREG_SIZE )
-  return -1;
-
- return 0;
-}
-
-static void __fnreg_trigger_if_match(const struct roar_dl_fnreg * callback,
-                                     const struct __fnregs * reg,
-                                     int fn,
-                                     enum roar_dl_fnreg_action action) {
- if ( callback->fn != -1 && callback->fn != fn )
-  return;
- if ( callback->subtype != -1 && callback->subtype != reg->subtype )
-  return;
- if ( callback->version != -1 && callback->version != reg->version )
-  return;
-
- if ( callback->callback == NULL )
-  return;
-
- callback->callback(action, fn, reg->subtype, reg->object, reg->objectlen, reg->version, reg->options, callback->userdata, reg->lhandle);
-}
-
-static void __fnreg_trigger_by_reg(const struct __fnregs * reg, enum roar_dl_fnreg_action action, int fn) {
- size_t j;
-
- for (j = 0; j < __MAX_FNREGS; j++) {
-  if ( __fnrefs[ROAR_DL_FN_REGFN][j].lhandle != NULL ) {
-   if ( __fnreg_check_trigger(&(__fnrefs[ROAR_DL_FN_REGFN][j])) == -1 )
-    continue;
-   __fnreg_trigger_if_match(__fnrefs[ROAR_DL_FN_REGFN][j].object, reg, fn, action);
-  }
- }
-}
-
-static void __fnreg_trigger_by_handler(const struct __fnregs * handle, enum roar_dl_fnreg_action action) {
- size_t i, j;
-
- if ( __fnreg_check_trigger(handle) == -1 )
-  return;
-
- for (i = 0; i < ROAR_DL_FN_MAX; i++) {
-  for (j = 0; j < __MAX_FNREGS; j++) {
-   if ( __fnrefs[i][j].lhandle != NULL ) {
-    __fnreg_trigger_if_match(handle->object, &(__fnrefs[i][j]), i, action);
-   }
-  }
- }
-}
-
-int roar_dl_register_fn(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options) {
- struct __fnregs * c = NULL;
- size_t i;
-
- if ( lhandle == NULL )
-  lhandle = __currently_inited;
-
- if ( fn == -1 )
-  fn = __currently_inited_fn;
-
- if ( lhandle == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( fn < 0 || fn >= ROAR_DL_FN_MAX ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- if ( object == NULL || objectlen == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- for (i = 0; i < __MAX_FNREGS; i++) {
-  if ( __fnrefs[fn][i].lhandle != NULL )
-   continue;
-  c = &(__fnrefs[fn][i]);
-  break;
- }
-
- if ( c == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- c->lhandle   = lhandle;
- c->subtype   = subtype;
- c->object    = object;
- c->objectlen = objectlen;
- c->version   = version;
-
- if ( fn == ROAR_DL_FN_REGFN ) {
-  __fnreg_trigger_by_handler(c, ROAR_DL_FNREG);
- } else {
-  __fnreg_trigger_by_reg(c, ROAR_DL_FNREG, fn);
- }
-
- return 0;
-}
-
-int                      roar_dl_unregister_fn2(struct roar_dl_lhandle * lhandle, int fn, int subtype, const void * object, size_t objectlen, int version, int options) {
- struct __fnregs * c = NULL;
- size_t i, j;
-
- if ( lhandle == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < ROAR_DL_FN_MAX; i++) {
-  if ( fn != -1 && fn != i )
-   continue;
-
-  for (j = 0; j < __MAX_FNREGS; j++) {
-   c = &(__fnrefs[i][j]);
-
-   if ( c->lhandle != lhandle )
-    continue;
-
-   if ( subtype != -1 && subtype != c->subtype )
-    continue;
-   if ( object != NULL && object != c->object )
-    continue;
-   if ( objectlen != (size_t)-1 && objectlen != c->objectlen )
-    continue;
-   if ( version != -1 && version != c->version )
-    continue;
-   if ( options != -1 && options != c->options )
-    continue;
-
-   if ( i == ROAR_DL_FN_REGFN ) {
-    __fnreg_trigger_by_handler(&(__fnrefs[i][j]), ROAR_DL_FNUNREG);
-   } else {
-    __fnreg_trigger_by_reg(&(__fnrefs[i][j]), ROAR_DL_FNUNREG, i);
-   }
-   memset(&(__fnrefs[i][j]), 0, sizeof(__fnrefs[i][j]));
-   __fnrefs[i][j].lhandle = NULL;
-  }
- }
-
- return 0;
-}
-
-int roar_dl_unregister_fn(struct roar_dl_lhandle * lhandle) {
- return roar_dl_unregister_fn2(lhandle, -1, -1, NULL, (size_t)-1, -1, -1);
-}
-
-
-int roar_dl_query_fn(struct roar_dl_lhandle ** lhandle, int fn, int subtype, const void ** object, size_t * objectlen, int version, int * options, ssize_t index) {
- struct __fnregs * c = NULL;
- ssize_t found = 0;
- size_t j;
-
- if ( lhandle == NULL || object == NULL || objectlen == NULL || options == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( fn <= 0 || fn >= ROAR_DL_FN_MAX || index < 0 || index >= __MAX_FNREGS ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- for (j = 0; j < __MAX_FNREGS; j++) {
-  c = &(__fnrefs[fn][j]);
-
-  if ( c->lhandle == NULL )
-   continue;
-  if ( c->subtype != subtype )
-   continue;
-  if ( c->version != version )
-   continue;
-
-  if ( index == found++ ) {
-   *lhandle   = c->lhandle;
-   *object    = c->object;
-   *objectlen = c->objectlen;
-   *options   = c->options;
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-static inline int __load_plugin_any_get_api(struct roar_dl_librarypara * para, const char * appname, const char * appabi, const char * servicename, const char * serviceabi, int universal, struct roar_dl_service_api * api) {
- struct roar_dl_lhandle * lhandle = NULL;
- struct roar_dl_librarypara * mypara = NULL;
- char name[80];
- int err;
- int ret;
-
- mypara = roar_dl_para_new(NULL, NULL, LIBROAR_DL_APPNAME, LIBROAR_DL_ABIVERSION);
- if ( mypara == NULL )
-  return -1;
-
- if ( serviceabi != NULL ) {
-  snprintf(name, sizeof(name), "service-%s-%s", servicename, serviceabi);
-  lhandle = roar_dl_open(name, ROAR_DL_FLAG_PLUGIN, 1, mypara);
- }
-
- if ( lhandle == NULL ) {
-  snprintf(name, sizeof(name), "service-%s", servicename);
-  lhandle = roar_dl_open(name, ROAR_DL_FLAG_PLUGIN, 1, mypara);
- }
-
- err = roar_error;
- roar_dl_para_unref(mypara);
- roar_error = err;
-
- if ( lhandle == NULL )
-  return -1;
-
- roar_dl_appsched_trigger(lhandle, ROAR_DL_APPSCHED_INIT);
-
- ret = libroar_dl_service_get_api_real(para, appname, appabi, servicename, serviceabi, universal, api, 0);
-
- err = roar_error;
- roar_dl_appsched_trigger(lhandle, ROAR_DL_APPSCHED_FREE);
- roar_dl_unref(lhandle);
- roar_error = err;
-
- return ret;
-}
-
-int libroar_dl_service_get_api_real(struct roar_dl_librarypara * para, const char * appname, const char * appabi, const char * servicename, const char * serviceabi, int universal, struct roar_dl_service_api * api, int retry) {
- const struct roar_dl_service * s;
- struct __fnregs * c = NULL;
- size_t i;
- int err;
-
- if ( servicename == NULL || serviceabi == NULL || api == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( para != NULL ) {
-  if ( roar_dl_para_ref(para) == -1 )
-   return -1;
- } else {
-  para = roar_dl_para_new(NULL, NULL, NULL, NULL);
-  if ( para == NULL )
-   return -1;
- }
-
- memset(api, 0, sizeof(struct roar_dl_service_api));
-
- for (i = 0; i < __MAX_FNREGS; i++) {
-  c = &(__fnrefs[ROAR_DL_FN_SERVICE][i]);
-  s = c->object;
-
-  if ( c->lhandle == NULL )
-   continue;
-
-  if ( c->subtype != ROAR_DL_SERVICE_SUBTYPE )
-   continue;
-  if ( c->objectlen != ROAR_DL_SERVICE_SIZE )
-   continue;
-  if ( c->version != ROAR_DL_SERVICE_VERSION )
-   continue;
-
-  if ( !universal && s->appname == NULL )
-   continue;
-  if ( universal == 2 && s->appname != NULL )
-   continue;
-  if ( s->appname != NULL && !!strcmp(s->appname, appname) )
-   continue;
-  if ( (s->appabi == NULL && appabi != NULL) || (s->appabi != NULL && appabi == NULL) ||
-       (s->appabi != NULL && appabi != NULL && !!strcmp(s->appabi, appabi) ) )
-   continue;
-  if ( s->servicename == NULL || !!strcmp(s->servicename, servicename) )
-   continue;
-  if ( s->serviceabi == NULL || !!strcmp(s->serviceabi, serviceabi) )
-   continue;
-
-  if ( s->get_api == NULL )
-   continue;
-
-  if ( roar_dl_ref(c->lhandle) != 0 )
-   continue;
-
-  api->service = s;
-  api->lhandle = c->lhandle;
-
-  api->api = s->get_api(s, para);
-  if ( api->api == NULL ) {
-   err = roar_error;
-   roar_dl_unref(c->lhandle);
-   roar_dl_para_unref(para);
-   api->lhandle = NULL;
-   roar_error = err;
-   return -1;
-  }
-
-  roar_dl_para_unref(para);
-  return 0;
- }
-
- if ( retry ) {
-  if ( __load_plugin_any_get_api(para, appname, appabi, servicename, serviceabi, universal, api) == 0 ) {
-   roar_dl_para_unref(para);
-   return 0;
-  }
- }
-
- roar_dl_para_unref(para);
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-int libroar_dl_service_free_api_real(struct roar_dl_service_api * api) {
- if ( api == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_dl_unref(api->lhandle);
-
- memset(api, 0, sizeof(struct roar_dl_service_api));
-
- return 0;
-}
-
-//ll
Index: libroar/roarfloat.c
===================================================================
--- libroar/roarfloat.c	(revision 6052)
+++ 	(revision )
@@ -1,155 +1,0 @@
-//roarfloat.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_LIBM
-#include <math.h>
-#endif
-
-union c4f {
- unsigned char c[4];
- roarfloat32 f;
-};
-
-roarfloat32 roar_ufloat32_build(const uint16_t mul, const uint16_t scale) {
- union c4f ret;
-
- ROAR_DBG("roar_ufloat32_build(mul=%u, scale=%u) = ?", (unsigned int)mul, (unsigned int)scale);
-
- ret.c[0] = (scale & 0xFF00) >> 8;
- ret.c[1] = (scale & 0x00FF) >> 0;
- ret.c[2] = (mul   & 0xFF00) >> 8;
- ret.c[3] = (mul   & 0x00FF) >> 0;
-
- return ret.f;
-}
-
-uint16_t roar_ufloat32_scale(const roarfloat32 f) {
- const union c4f p = {.f = f};
-
- ROAR_DBG("roar_ufloat32_scale(f=?): p.c[] = {%u, %u, %u, %u}", (unsigned int)p.c[0], (unsigned int)p.c[1], (unsigned int)p.c[2], (unsigned int)p.c[3]);
-
- return (p.c[0] << 8) | p.c[1];
-}
-
-uint16_t roar_ufloat32_mul(const roarfloat32 f) {
- const union c4f p = {.f = f};
-
- return (p.c[2] << 8) | p.c[3];
-}
-
-roarfloat32 roar_ufloat32_from_float(const float       f) {
- uint16_t scale;
-
- if ( f < 0 )
-  return ROAR_UFLOAT32_NNAN;
-
- if ( f == 0 )
-  return ROAR_UFLOAT32_ZERO;
-
- if ( f > ROAR_UFLOAT32_MAX )
-  return ROAR_UFLOAT32_PINF;
-
- if ( f <= 1 ) {
-  scale = ROAR_UFLOAT32_MAX;
- } else {
-  scale = (float)ROAR_UFLOAT32_MAX/f;
- }
-
- ROAR_DBG("roar_ufloat32_from_float(f=%f): scale=%u", f, (unsigned int)scale);
-
- return roar_ufloat32_build(f*(float)scale, scale);
-}
-
-float       roar_ufloat32_to_float  (const roarfloat32 f) {
- float mul   = roar_ufloat32_mul(f);
- float scale = roar_ufloat32_scale(f);
-
- ROAR_DBG("roar_ufloat32_to_float(f=?): mul=%f, scale=%f", mul, scale);
-
- if ( roar_float32_iszero(f) )
-  return 0;
-
-#ifdef INFINITY
- if ( roar_float32_isinf(f) )
-  return INFINITY;
-#endif
-
-#ifdef NAN
- if ( roar_float32_isnan(f) )
-  return NAN;
-#endif
-
- return mul/scale;
-}
-
-int roar_float32_iszero(const roarfloat32 f) {
- const union c4f p = {.f = f};
-
- return p.c[2] == 0 && p.c[3] == 0;
-}
-
-int roar_float32_isinf(const roarfloat32 f) {
- const union c4f p = {.f = f};
-
- if ( p.c[0] != 0 || p.c[1] != 0 )
-  return 0;
-
- if ( p.c[2] == 0x00 && p.c[3] == 0x01 ) {
-  return  1;
- } else if ( p.c[2] == 0xFF && p.c[3] == 0xFF ) {
-  return -1;
- } else {
-  return 0;
- }
-}
-
-int roar_float32_isnan(const roarfloat32 f) {
- const union c4f p = {.f = f};
-
- if ( p.c[0] != 0 || p.c[1] != 0 )
-  return 0;
-
- if ( p.c[2] == 0x7F && p.c[3] == 0xFF ) {
-  return  1;
- } else if ( p.c[2] == 0x80 && p.c[3] == 0x00 ) {
-  return -1;
- } else {
-  return 0;
- }
-}
-
-//ll
Index: libroar/roarx11.c
===================================================================
--- libroar/roarx11.c	(revision 6052)
+++ 	(revision )
@@ -1,185 +1,0 @@
-//roarx11.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-struct roar_x11_connection * roar_x11_connect(char * display) {
-#ifdef ROAR_HAVE_LIBX11
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_x11_connection * con;
-
- if ( display == NULL )
-  display = config->x11.display;
-
- if ( (con = roar_mm_malloc(sizeof(struct roar_x11_connection))) == NULL )
-  return NULL;
-
- if ( (con->display = XOpenDisplay(display)) == NULL ) {
-  roar_mm_free(con);
-  return NULL;
- }
-
- con->close = 1;
-
- return con;
-#else
- return NULL;
-#endif
-}
-
-struct roar_x11_connection * roar_x11_connect_display(_ROAR_X11_DISPLAY * display) {
-#ifdef ROAR_HAVE_LIBX11
- struct roar_x11_connection * con;
-
- if ( display == NULL )
-  return NULL;
-
- if ( (con = roar_mm_malloc(sizeof(struct roar_x11_connection))) == NULL )
-  return NULL;
-
- con->close   = 0;
- con->display = display;
-
- return con;
-#else
- return NULL;
-#endif
-}
-
-int roar_x11_disconnect(struct roar_x11_connection * con) {
-#ifdef ROAR_HAVE_LIBX11
- int ret = 0;
-
- if ( con == NULL )
-  return -1;
-
- if ( con->close )
-  ret = XCloseDisplay(con->display);
-
- roar_mm_free(con);
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-int    roar_x11_flush(struct roar_x11_connection * con) {
-#ifdef ROAR_HAVE_LIBX11
- if ( con == NULL )
-  return -1;
-
- return XFlush(con->display);
-#else
- return -1;
-#endif
-}
-
-int roar_x11_set_prop(struct roar_x11_connection * con, const char * key, const char * val) {
-#ifdef ROAR_HAVE_LIBX11
- Atom a;
-
- if ( con == NULL )
-  return -1;
-
- a = XInternAtom(con->display, key, False);
-
- XChangeProperty(con->display, RootWindow(con->display, 0), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) val, strlen(val)+1);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_x11_delete_prop(struct roar_x11_connection * con, const char * key) {
-#ifdef ROAR_HAVE_LIBX11
- Atom a;
- if ( con == NULL )
-  return -1;
-
- a = XInternAtom(con->display, key, False);
- XDeleteProperty(con->display, RootWindow(con->display, 0), a);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-char * roar_x11_get_prop(struct roar_x11_connection * con, const char * key) {
-#ifdef ROAR_HAVE_LIBX11
- unsigned long   nitems;
- unsigned long   nbytes_after;
- unsigned char * prop = NULL;
- char          * ret = NULL;
- int             actual_format;
- Atom            actual_type;
- Atom            a;
-
- a = XInternAtom(con->display, key, False);
-
- if ( XGetWindowProperty(con->display, RootWindow(con->display, 0), a,
-                         0, 256, False, XA_STRING, &actual_type,
-                         &actual_format, &nitems, &nbytes_after, &prop) != Success ) {
-  if ( prop != NULL )
-   XFree(prop);
-
-  return NULL;
- }
-
- if ( prop == NULL )
-  return NULL;
-
- if (actual_type != XA_STRING) {
-  XFree(prop);
-
-  return NULL;
- }
-
- ret = roar_mm_malloc(nitems+1);
-
- memcpy(ret, prop, nitems);
- ret[nitems] = 0;
-
- XFree(prop);
-
- return ret;
-#else
- return NULL;
-#endif
-}
-
-//ll
Index: libroar/scheduler.c
===================================================================
--- libroar/scheduler.c	(revision 6052)
+++ 	(revision )
@@ -1,732 +1,0 @@
-//scheduler.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define INIT_SIZE   8
-#define MAX_PROTOS 16
-
-struct protocol {
- const struct roar_keyval * para;
- ssize_t paralen;
- struct roar_dl_lhandle * lhandle;
- const struct roar_dl_proto * impl;
-};
-
-struct roar_scheduler {
- size_t refc;
- int flags;
- enum roar_scheduler_strategy strategy;
- struct roar_scheduler_source ** sources;
- size_t sources_len;
- struct roar_vio_select * vios;
- size_t vios_len;
- struct roar_dl_fnreg callback;
- struct protocol protos[MAX_PROTOS];
-};
-
-static int __update_cpi_listen_client (struct roar_scheduler * sched, struct roar_scheduler_source * source);
-
-struct roar_scheduler * roar_scheduler_new(int flags, enum roar_scheduler_strategy strategy) {
- struct roar_scheduler * sched = roar_mm_malloc(sizeof(struct roar_scheduler));
-
- if ( sched == NULL )
-  return NULL;
-
- if ( flags == ROAR_SCHEDULER_FLAG_DEFAULT )
-  flags = ROAR_SCHEDULER_FLAG_NONE;
-
- memset(sched, 0, sizeof(struct roar_scheduler));
- sched->refc = 1;
- sched->flags = flags;
- sched->strategy = strategy;
-
- sched->sources = roar_mm_malloc(INIT_SIZE*sizeof(struct roar_scheduler_source *));
- if ( sched->sources != NULL ) {
-  sched->sources_len = INIT_SIZE;
-  memset(sched->sources, 0, INIT_SIZE*sizeof(struct roar_scheduler_source *));
- }
-
- sched->vios = roar_mm_malloc(sched->sources_len*sizeof(struct roar_vio_select));
- if ( sched->vios != 0 )
-  sched->vios_len = sched->sources_len;
-
- return sched;
-}
-
-#define _CHKSCHED(extra) if ( sched == NULL || (extra) ) { roar_err_set(ROAR_ERROR_FAULT); return -1; }
-
-int                     roar_scheduler_ref(struct roar_scheduler * sched) {
- _CHKSCHED(0);
-
- sched->refc++;
-
- return 0;
-}
-
-int                     roar_scheduler_unref(struct roar_scheduler * sched) {
- size_t i;
-
- _CHKSCHED(0);
-
- sched->refc--;
-
- if (sched->refc)
-  return 0;
-
- for (i = 0; i < sched->sources_len; i++)
-  if ( sched->sources[i] != NULL )
-   roar_scheduler_source_del(sched, sched->sources[i]);
-
- if ( sched->vios != NULL )
-  roar_mm_free(sched->vios);
- if ( sched->sources != NULL )
-  roar_mm_free(sched->sources);
- roar_mm_free(sched);
- return 0;
-}
-
-static void __delete_cpi_client(struct roar_scheduler * sched, struct roar_scheduler_source * cur, struct roar_dl_librarypara * para) {
- if ( cur->handle.cpi.impl->unset_proto != NULL )
-  cur->handle.cpi.impl->unset_proto(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para);
-
- roar_vio_close(cur->vio);
- cur->vio = NULL;
-
- if ( cur->handle.cpi.obuffer != NULL ) {
-  roar_buffer_free(cur->handle.cpi.obuffer);
-  cur->handle.cpi.obuffer = NULL;
- }
-
- if ( cur->handle.cpi.userdata != NULL ) {
-  roar_mm_free(cur->handle.cpi.userdata);
-  cur->handle.cpi.userdata = NULL;
- }
-
- roar_scheduler_source_del(sched, cur);
-}
-
-static int __flush_cpi_client(struct roar_scheduler * sched, struct roar_scheduler_source * cur, struct roar_dl_librarypara * para) {
- size_t len;
- ssize_t ret;
- void * buf;
-
- if ( roar_buffer_get_len(cur->handle.cpi.obuffer, &len) == -1 )
-  return 0;
-
- if ( roar_buffer_get_data(cur->handle.cpi.obuffer, &buf) == -1 )
-  return 0;
-
- if ( len != 0 ) {
-  ret = roar_vio_write(cur->vio, buf, len);
-
-  if ( ret < 1 )
-   return -1;
- } else {
-  ret = len;
- }
-
- if ( ret == (ssize_t)len ) {
-  if ( roar_buffer_next(&(cur->handle.cpi.obuffer)) == -1 )
-   return -1;
- } else {
-  if ( roar_buffer_set_offset(cur->handle.cpi.obuffer, ret) == -1 )
-   return -1;
- }
-
- return 0;
-}
-
-static int __run_waits(struct roar_scheduler * sched) {
- struct roar_scheduler_source * cur;
- size_t i;
- int ret = -1;
-
- for (i = 0; ret == -1 && i < sched->sources_len; i++) {
-  if ( (cur = sched->sources[i]) == NULL )
-   continue;
-  switch (cur->type) {
-   case ROAR_SCHEDULER_PLUGIN:
-     ret = roar_dl_appsched_trigger(cur->lhandle, ROAR_DL_APPSCHED_WAIT);
-    break;
-   case ROAR_SCHEDULER_PLUGINCONTAINER:
-     ret = roar_plugincontainer_appsched_trigger(cur->handle.container, ROAR_DL_APPSCHED_WAIT);
-    break;
-#ifndef DEBUG
-   default: /* noop */ break;
-#endif
-  }
- }
-
- return ret;
-}
-
-// what to do?:
-// 0. get all VIOs.
-// 1. get timeout or use internal default.
-// 2. run roar_vio_select().
-// 3. send all events based on results.
-// 4. send UPDATE to all plugins and containers.
-int                     roar_scheduler_iterate(struct roar_scheduler * sched) {
- enum roar_scheduler_strategy strategy;
- struct roar_vio_selecttv timeout = {8, 0}; // default: 8 sec. Just a random value.
- struct roar_scheduler_source * cur, * new_client;
- struct roar_dl_librarypara * para;
- struct roar_dl_lhandle * lhandle;
- ssize_t ret;
- size_t i;
- int have_timeout = 0;
- size_t todo = 0, vios = 0;
- int tmp;
-
- _CHKSCHED(0);
-
- strategy = sched->strategy;
- if ( strategy == ROAR_SCHEDULER_STRATEGY_DEFAULT )
-  strategy = ROAR_SCHEDULER_STRATEGY_SELECTORWAIT;
-
- if ( sched->vios == NULL || sched->vios_len < sched->sources_len ) {
-  if ( sched->vios != NULL ) {
-   roar_mm_free(sched->vios);
-   sched->vios = NULL;
-   sched->vios_len = 0;
-  }
-
-  sched->vios = roar_mm_malloc(sched->sources_len*sizeof(struct roar_vio_select));
-  if ( sched->vios != NULL )
-   sched->vios_len = sched->sources_len;
- }
-
- // error from roar_mm_malloc() is still set.
- if ( sched->vios == NULL )
-  return -1;
-
- memset(sched->vios, 0, sched->vios_len*sizeof(struct roar_vio_select));
- for (i = 0; i < sched->vios_len; i++)
-  sched->vios[i].eventsq = ROAR_VIO_SELECT_NO_RETEST;
-
- for (i = 0; i < sched->sources_len; i++) {
-  if ( (cur = sched->sources[i]) == NULL )
-   continue;
-  switch (cur->type) {
-   case ROAR_SCHEDULER_VIO:
-     ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), cur->vio, cur->handle.eventsq);
-     todo++;
-     vios++;
-    break;
-   case ROAR_SCHEDULER_TIMEOUT:
-     timeout = cur->handle.timeout;
-     have_timeout = 1;
-     todo++;
-    break;
-   case ROAR_SCHEDULER_CPI_LISTEN:
-     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB )
-      __update_cpi_listen_client(sched, cur);
-
-     if ( !(cur->flags & ROAR_SCHEDULER_FLAG_STUB) ) {
-      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), cur->vio, ROAR_VIO_SELECT_READ);
-      todo++;
-      vios++;
-     }
-    break;
-   case ROAR_SCHEDULER_CPI_CLIENT:
-     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB )
-      __update_cpi_listen_client(sched, cur);
-
-     if ( !(cur->flags & ROAR_SCHEDULER_FLAG_STUB) ) {
-      tmp = 0;
-
-      if ( cur->handle.cpi.impl->status != NULL ) {
-       if ( cur->lhandle != NULL )
-        roar_dl_context_restore(cur->lhandle);
-
-       para = roar_dl_getpara(cur->lhandle);
-       if ( cur->handle.cpi.impl->status(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para) & ROAR_DL_PROTO_STATUS_RX_READY )
-        tmp |= ROAR_VIO_SELECT_READ;
-       if ( para != NULL )
-        roar_dl_para_unref(para);
-
-       if ( cur->lhandle != NULL )
-        roar_dl_context_store(cur->lhandle);
-      } else {
-       tmp |= ROAR_VIO_SELECT_READ;
-      }
-
-      if ( sched->sources[i]->handle.cpi.obuffer != NULL )
-       tmp |= ROAR_VIO_SELECT_WRITE;
-
-      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), sched->sources[i]->vio, tmp);
-      todo++;
-      vios++;
-     }
-    break;
-   case ROAR_SCHEDULER_PLUGIN:
-   case ROAR_SCHEDULER_PLUGINCONTAINER:
-     todo++;
-    break;
-#ifndef DEBUG
-   default: /* noop */ break;
-#endif
-  }
- }
-
- if (!todo) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return 0;
- }
-
- if ( strategy == ROAR_SCHEDULER_STRATEGY_WAITORSELECT || strategy == ROAR_SCHEDULER_STRATEGY_WAIT ) {
-  ret = __run_waits(sched);
-  if ( ret == 0 || strategy == ROAR_SCHEDULER_STRATEGY_WAIT )
-   ret = 1;
- } else {
-  ret = -1;
- }
-
- if ( ret == -1 && !(strategy == ROAR_SCHEDULER_STRATEGY_SELECTORWAIT && vios == 0) ) {
-  ret = roar_vio_select(sched->vios, sched->vios_len, &timeout, NULL);
- }
-
- if ( ret < 0 && strategy == ROAR_SCHEDULER_STRATEGY_SELECTORWAIT ) {
-  ret = __run_waits(sched);
-  if ( ret == 0 )
-   ret = 1;
-
-  if ( ret == -1 && vios == 0 ) {
-   if ( sched->flags & ROAR_SCHEDULER_FLAG_KEEP_RUNNING ) {
-    ret = roar_vio_select(sched->vios, sched->vios_len, &timeout, NULL);
-   } else {
-    return 0;
-   }
-  }
- }
-
- if ( ret == -1 )
-  return -1;
- if ( ret == 0 && !have_timeout )
-  return 1;
-
- for (i = 0; i < sched->sources_len; i++) {
-  if ( (cur = sched->sources[i]) == NULL )
-   continue;
-  switch (cur->type) {
-   case ROAR_SCHEDULER_VIO:
-     if ( sched->vios[i].eventsa )
-      if ( cur->cb != NULL )
-       cur->cb(sched->sources[i], sched->sources[i]->userdata, sched->vios[i].eventsa);
-    break;
-   case ROAR_SCHEDULER_TIMEOUT:
-     if ( ret == 0 )
-      if ( cur->cb != NULL )
-       cur->cb(sched->sources[i], sched->sources[i]->userdata, 0);
-    break;
-   case ROAR_SCHEDULER_PLUGIN:
-     roar_dl_appsched_trigger(cur->lhandle, ROAR_DL_APPSCHED_UPDATE);
-    break;
-   case ROAR_SCHEDULER_PLUGINCONTAINER:
-     roar_plugincontainer_appsched_trigger(cur->handle.container, ROAR_DL_APPSCHED_UPDATE);
-    break;
-   case ROAR_SCHEDULER_CPI_LISTEN:
-     if ( !sched->vios[i].eventsa )
-      continue;
-
-     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB )
-      continue;
-
-     if ( cur->cb != NULL )
-      cur->cb(sched->sources[i], sched->sources[i]->userdata, sched->vios[i].eventsa);
-
-     new_client = roar_mm_malloc(sizeof(struct roar_scheduler_source));
-     if ( new_client == NULL )
-      continue;
-     memcpy(new_client, cur, sizeof(struct roar_scheduler_source));
-     new_client->type = ROAR_SCHEDULER_CPI_CLIENT;
-     new_client->flags = ROAR_SCHEDULER_FLAG_FREE;
-     new_client->vio   = roar_mm_malloc(sizeof(struct roar_vio_calls));
-
-     if ( new_client->vio == NULL ) {
-      roar_mm_free(new_client);
-      continue;
-     }
-
-     if ( roar_vio_accept(new_client->vio, cur->vio) == -1 ) {
-      roar_mm_free(new_client->vio);
-      roar_mm_free(new_client);
-      continue;
-     }
-
-     new_client->vio->flags |= ROAR_VIO_FLAGS_FREESELF;
-
-     if ( roar_scheduler_source_add(sched, new_client) == -1 ) {
-      roar_vio_close(new_client->vio);
-      roar_mm_free(new_client);
-     }
-     roar_vio_unref(new_client->vio);
-
-     if ( new_client->cb != NULL )
-      new_client->cb(new_client, new_client->userdata, 0);
-
-     if ( cur->handle.cpi.impl->set_proto != NULL ) {
-      lhandle = new_client->lhandle;
-      para = roar_dl_getpara(lhandle);
-
-      if ( lhandle != NULL )
-       roar_dl_context_restore(lhandle);
-      new_client->handle.cpi.impl->set_proto(new_client->handle.cpi.client, new_client->vio, &(new_client->handle.cpi.obuffer), &(new_client->handle.cpi.userdata), new_client->handle.cpi.protopara, new_client->handle.cpi.protoparalen, para);
-      if ( lhandle != NULL )
-       roar_dl_context_store(lhandle);
-
-      if ( para != NULL )
-       roar_dl_para_unref(para);
-     }
-    break;
-   case ROAR_SCHEDULER_CPI_CLIENT:
-     if ( !sched->vios[i].eventsa )
-      continue;
-
-     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB )
-      continue;
-
-     if ( cur->cb != NULL )
-      cur->cb(sched->sources[i], sched->sources[i]->userdata, sched->vios[i].eventsa);
-
-     lhandle = cur->lhandle;
-     para = roar_dl_getpara(lhandle);
-     tmp = 0;
-
-     if ( sched->vios[i].eventsa & ROAR_VIO_SELECT_WRITE ) {
-      if ( cur->handle.cpi.impl->flush != NULL ) {
-       if ( lhandle != NULL )
-        roar_dl_context_restore(lhandle);
-
-       cur->handle.cpi.impl->flush(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para);
-
-       if ( lhandle != NULL )
-        roar_dl_context_store(lhandle);
-      } else {
-        tmp = __flush_cpi_client(sched, cur, para);
-      }
-
-      if ( tmp == 0 && cur->handle.cpi.obuffer == NULL && cur->handle.cpi.impl->flushed != NULL ) {
-       if ( lhandle != NULL )
-        roar_dl_context_restore(lhandle);
-
-       if ( cur->handle.cpi.impl->flushed(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para) == -1 )
-        tmp = -1;
-
-       if ( lhandle != NULL )
-        roar_dl_context_store(lhandle);
-      }
-     }
-
-     if ( sched->vios[i].eventsa & ROAR_VIO_SELECT_READ ) {
-      if ( cur->handle.cpi.impl->handle != NULL ) {
-       if ( lhandle != NULL )
-        roar_dl_context_restore(lhandle);
-
-       if ( cur->handle.cpi.impl->handle(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para) == -1 ) {
-        tmp = -1;
-       }
-
-       if ( lhandle != NULL )
-        roar_dl_context_store(lhandle);
-      }
-     }
-
-     if ( tmp == -1 ) {
-      if ( lhandle != NULL )
-       roar_dl_context_restore(lhandle);
-      __delete_cpi_client(sched, cur, para);
-      if ( lhandle != NULL )
-       roar_dl_context_store(lhandle);
-     }
-
-     if ( para != NULL )
-      roar_dl_para_unref(para);
-    break;
-#ifndef DEBUG
-   default: /* noop */ break;
-#endif
-  }
- }
-
- return 1;
-}
-
-int                     roar_scheduler_run(struct roar_scheduler * sched) {
- int ret;
-
- _CHKSCHED(0);
-
- while ((ret = roar_scheduler_iterate(sched)) > 0);
-
- return ret;
-}
-
-static int __cpi_callback(enum roar_dl_fnreg_action action, int fn, int subtype, const void * object, size_t objectlen, int version, int options, void * userdata, struct roar_dl_lhandle * lhandle) {
- const struct roar_dl_proto * impl = object;
- struct roar_scheduler * sched = userdata;
- struct roar_dl_librarypara * para;
- size_t i;
-
- (void)fn, (void)subtype, (void)version, (void)options;
-
- if ( sched == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( objectlen != ROAR_DL_PROTO_SIZE ) {
-  ROAR_WARN("__cpi_callback(*): Library %p tries to register protocol with bad object length.", lhandle);
-  roar_err_set(ROAR_ERROR_BADLIB);
-  return -1;
- }
-
- switch (action)  {
-  case ROAR_DL_FNREG:
-    for (i = 0; i < MAX_PROTOS; i++) {
-     if ( sched->protos[i].impl == NULL ) {
-      memset(&(sched->protos[i]), 0, sizeof(sched->protos[i]));
-      sched->protos[i].para = NULL;
-      sched->protos[i].paralen = -1;
-      sched->protos[i].lhandle = lhandle;
-      sched->protos[i].impl = impl;
-      return 0;
-     }
-    }
-   break;
-  case ROAR_DL_FNUNREG:
-    for (i = 0; i < sched->sources_len; i++) {
-     if ( sched->sources[i] == NULL )
-      continue;
-     if ( sched->sources[i]->type != ROAR_SCHEDULER_CPI_LISTEN && sched->sources[i]->type != ROAR_SCHEDULER_CPI_CLIENT )
-      continue;
-     if ( sched->sources[i]->handle.cpi.proto != impl->proto )
-      continue;
-
-     para = roar_dl_getpara(lhandle);
-
-     if ( lhandle != NULL )
-      roar_dl_context_restore(lhandle);
-     __delete_cpi_client(sched, sched->sources[i], para);
-     if ( lhandle != NULL )
-      roar_dl_context_store(lhandle);
-
-     if ( para != NULL )
-      roar_dl_para_unref(para);
-    }
-
-    for (i = 0; i < MAX_PROTOS; i++) {
-     if ( sched->protos[i].impl != NULL && sched->protos[i].lhandle == lhandle ) {
-      memset(&(sched->protos[i]), 0, sizeof(sched->protos[i]));
-      sched->protos[i].impl = NULL;
-     }
-    }
-    return 0;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_NOSPC);
- return -1;
-}
-
-static int __update_cpi_service (struct roar_scheduler * sched, struct roar_scheduler_source * source, int del) {
- if ( del ) {
-  return roar_dl_unregister_fn2(ROAR_DL_HANDLE_LIBROAR, ROAR_DL_FN_REGFN, ROAR_DL_FNREG_SUBTYPE, &(sched->callback), sizeof(sched->callback), ROAR_DL_FNREG_VERSION, ROAR_DL_FNREG_OPT_NONE);
- }
-
- sched->callback.fn = ROAR_DL_FN_PROTO;
- sched->callback.subtype = ROAR_DL_PROTO_SUBTYPE;
- sched->callback.version = ROAR_DL_PROTO_VERSION;
- sched->callback.callback = __cpi_callback;
- sched->callback.userdata = sched;
-
- ROAR_DL_RFNREG(ROAR_DL_HANDLE_LIBROAR, sched->callback);
-
- return -1;
-}
-
-static int __update_cpi_listen_client (struct roar_scheduler * sched, struct roar_scheduler_source * source) {
- size_t i;
-
- ROAR_DBG("__update_cpi_listen_client(sched=%p, source=%p): proto=%i, impl=%p", sched, source, source->handle.cpi.proto, source->handle.cpi.impl);
-
- if ( source->handle.cpi.proto < 1 && source->handle.cpi.impl != NULL )
-  source->handle.cpi.proto = source->handle.cpi.impl->proto;
-
- if ( source->handle.cpi.proto > 0 && source->handle.cpi.impl == NULL ) {
-  for (i = 0; i < MAX_PROTOS; i++) {
-   if ( sched->protos[i].impl == NULL )
-    continue;
-   ROAR_DBG("__update_cpi_listen_client(sched=%p, source=%p): proto=%i<->%i", sched, source, sched->protos[i].impl->proto, source->handle.cpi.proto);
-   if ( sched->protos[i].impl->proto != source->handle.cpi.proto )
-    continue;
-   source->handle.cpi.impl = sched->protos[i].impl;
-   if ( source->lhandle == NULL && sched->protos[i].lhandle != NULL )
-    if ( roar_dl_ref(sched->protos[i].lhandle) == 0 )
-     source->lhandle = sched->protos[i].lhandle;
-   break;
-  }
- }
-
- if ( source->handle.cpi.proto > 0 ) {
-  source->flags |= ROAR_SCHEDULER_FLAG_STUB;
-  if ( source->handle.cpi.impl == NULL )
-   return 0;
-  source->flags -= ROAR_SCHEDULER_FLAG_STUB;
-  return 0;
- }
-
- roar_err_set(ROAR_ERROR_INVAL);
- return -1;
-}
-
-int                     roar_scheduler_source_add(struct roar_scheduler * sched,
-                                                  struct roar_scheduler_source * source) {
- size_t i;
- struct roar_scheduler_source ** next = NULL;
- int err;
- 
- _CHKSCHED(source == NULL);
-
- ROAR_DBG("roar_scheduler_source_add(sched=%p, source=%p): proto=%i, impl=%p", sched, source, source->handle.cpi.proto, source->handle.cpi.impl);
-
- for (i = 0; i < sched->sources_len; i++) {
-  if ( sched->sources[i] != NULL )
-   continue;
-  next = &(sched->sources[i]);
-  break;
- }
-
- if ( next == NULL ) {
-  // TODO: re-allocate some space here.
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- if ( source->flags == ROAR_SCHEDULER_FLAG_DEFAULT )
-  source->flags = ROAR_SCHEDULER_FLAG_NONE;
-
- switch (source->type) {
-  case ROAR_SCHEDULER_CPI_LISTEN:
-  case ROAR_SCHEDULER_CPI_CLIENT:
-    if ( __update_cpi_listen_client(sched, source) == -1 )
-     return -1;
-   break;
-  case ROAR_SCHEDULER_CPI_SERVICE:
-    if ( __update_cpi_service(sched, source, 0) == -1 )
-     return -1;
-   break;
-#ifndef DEBUG
-   default: /* noop */ break;
-#endif
- }
-
- if ( source->lhandle != NULL )
-  if ( roar_dl_ref(source->lhandle) == -1 )
-   return -1;
-
- if ( source->vio != NULL ) {
-  if ( roar_vio_ref(source->vio) == -1 ) {
-   err = roar_error;
-   if ( source->lhandle != NULL )
-    roar_dl_unref(source->lhandle);
-   roar_err_set(err);
-   return -1;
-  }
- }
-
- if ( source->type == ROAR_SCHEDULER_PLUGINCONTAINER ) {
-  if ( roar_plugincontainer_ref(source->handle.container) == -1 ) {
-   err = roar_error;
-   if ( source->lhandle != NULL )
-    roar_dl_unref(source->lhandle);
-   if ( source->vio != NULL )
-    roar_vio_unref(source->vio);
-   roar_err_set(err);
-   return -1;
-  }
- }
-
- *next = source;
-
- return 0;
-}
-
-int                     roar_scheduler_source_del(struct roar_scheduler * sched,
-                                                  struct roar_scheduler_source * source) {
- size_t i;
- struct roar_scheduler_source ** next = NULL;
-
- _CHKSCHED(source == NULL);
-
- for (i = 0; i < sched->sources_len; i++) {
-  if ( sched->sources[i] != source )
-   continue;
-  next = &(sched->sources[i]);
-  break;
- }
-
- if ( next == NULL ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- switch (source->type) {
-  case ROAR_SCHEDULER_PLUGINCONTAINER:
-    roar_plugincontainer_ref(source->handle.container);
-   break;
-  case ROAR_SCHEDULER_CPI_SERVICE:
-    if ( __update_cpi_service(sched, source, 1) == -1 )
-     return -1;
-   break;
-#ifndef DEBUG
-   default: /* noop */ break;
-#endif
- }
-
- if ( source->lhandle != NULL )
-  roar_dl_unref(source->lhandle);
- if ( source->vio != NULL )
-  roar_vio_unref(source->vio);
-
- if ( source->flags & ROAR_SCHEDULER_FLAG_FREE )
-  roar_mm_free(source);
-
- *next = NULL;
- return 0;
-}
-
-//ll
Index: libroar/serverinfo.c
===================================================================
--- libroar/serverinfo.c	(revision 6052)
+++ 	(revision )
@@ -1,403 +1,0 @@
-//serverinfo.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-// include for uname() used by roar_library_info()
-#ifdef ROAR_HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-
-struct ie {
- int type;
- size_t len;
- const char * buf;
-};
-
-struct roar_server_info * roar_server_info(struct roar_connection * con) {
- struct roar_server_info * ret;
- struct roar_message mes;
- uint16_t * d16;
- char * data = NULL;
-
- memset(&mes, 0, sizeof(mes));
-
- mes.cmd = ROAR_CMD_SERVER_INFO;
- mes.datalen = 2*2;
- d16 = (uint16_t*)mes.data;
-
- d16[0] = ROAR_HOST2NET16(0); // version
- d16[1] = ROAR_HOST2NET16(ROAR_IT_SERVER);
-
- if ( roar_req(con, &mes, &data) != 0 )
-  return NULL;
-
- if ( mes.cmd != ROAR_CMD_OK )
-  return NULL;
-
- ret = roar_server_info_from_mes(&mes, data);
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- return ret;
-}
-
-#ifdef ROAR_HAVE_GETHOSTID
-#define _HOSTID_BUFLEN 64
-#else
-#define _HOSTID_BUFLEN 0
-#endif
-struct roar_server_info * roar_library_info(void) {
- struct roar_server_info * ret = roar_mm_malloc(sizeof(struct roar_server_info) + _HOSTID_BUFLEN);
-#ifdef ROAR_HAVE_UNAME
- static struct utsname utsname;
- static int utsname_inited = 0;
-#endif
-#ifdef ROAR_HAVE_GETHOSTID
- long hostid;
- char * hostidbuf = ((void*)ret) + sizeof(*ret);
-#endif
-
- if ( ret == NULL )
-  return NULL;
-
- memset(ret, 0, sizeof(struct roar_server_info));
-
-#if 0
-+ const char * version;
-X const char * location;
-X const char * description;
-X const char * contact;
-X const char * serial;
-X const char * address;
-X const char * uiurl;
- const char * hostid;
-+ const char * license;
-+ const char * build;
-+ struct {
-+  const char * sysname;
-+  const char * release;
-+  const char * nodename;
-+  const char * machine;
-+ } un;
-#endif
-
- if ( ROAR_VERSION_DISTRIBUTION_STRING[0] == 0 ) {
-  ret->version = "libroar/" ROAR_VERSION_STRING " <" ROAR_DEV_VENDOR_STRING ">";
- } else {
-  ret->version = "libroar/" ROAR_VERSION_STRING " <" ROAR_DEV_VENDOR_STRING "> (" ROAR_VERSION_DISTRIBUTION_STRING ")";
- }
-#ifdef ROAR_HAVE_GETHOSTID
- hostid = gethostid();
- roar_random_salt_nonce(&hostid, sizeof(hostid));
- snprintf(hostidbuf, _HOSTID_BUFLEN, sizeof(long) == 8 ? "0x%.16lx" : "0x%.8lx", hostid);
- ret->hostid = hostidbuf;
-#endif
- ret->license = ROAR_LICENSE_GPLv3_0;
- ret->build   = ROAR_BUILD_STAMP;
-
-#ifdef ROAR_HAVE_UNAME
- if ( !utsname_inited )
-  if ( uname(&utsname) == 0 ) {
-   utsname_inited = 1;
-   roar_random_salt_nonce(&utsname, sizeof(utsname));
-  }
-
- if ( utsname_inited ) {
-  ret->un.sysname  = utsname.sysname;
-  ret->un.release  = utsname.release;
-  ret->un.nodename = utsname.nodename;
-  ret->un.machine  = utsname.machine;
- }
-#endif
-#ifdef ROAR_HAVE_GETVERSIONEX
- ret->un.sysname = "Windows";
-#endif
-
- return ret;
-}
-
-int roar_server_info_free(struct roar_server_info * info) {
- if ( info == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_mm_free(info);
-
- return 0;
-}
-
-#define _add(t, m) do { if ( info->m != NULL && (sl = strlen(info->m)) != 0 ) { iebuf[idx].type = (t); iebuf[idx].len = sl; iebuf[idx].buf = (info->m); idx++; needlen += 4 + sl; } } while (0)
-
-int roar_server_info_to_mes(struct roar_message * mes, struct roar_server_info * info, void ** data) {
- size_t needlen = 4;
- size_t sl;
- int idx = 0;
- struct ie iebuf[sizeof(struct roar_server_info)/sizeof(char*)];
- uint16_t * d16, * dptr;
- char * textpart;
- int i;
- char * mesdata;
-
- if ( mes == NULL || info == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- _add(ROAR_ITST_VERSION, version);
- _add(ROAR_ITST_LOCATION, location);
- _add(ROAR_ITST_DESCRIPTION, description);
- _add(ROAR_ITST_CONTACT, contact);
- _add(ROAR_ITST_SERIAL, serial);
- _add(ROAR_ITST_ADDRESS, address);
- _add(ROAR_ITST_UIURL, uiurl);
- _add(ROAR_ITST_LICENSE, license);
- _add(ROAR_ITST_HOSTID, hostid);
- _add(ROAR_ITST_BUILD, build);
- _add(ROAR_ITST_UN_SYSNAME, un.sysname);
- _add(ROAR_ITST_UN_RELEASE, un.release);
- _add(ROAR_ITST_UN_NODENAME, un.nodename);
- _add(ROAR_ITST_UN_MACHINE, un.machine);
-
- if ( needlen > LIBROAR_BUFFER_MSGDATA ) {
-  if ( data == NULL ) {
-   roar_err_set(ROAR_ERROR_MSGSIZE);
-   return -1;
-  }
-
-  mesdata = roar_mm_malloc(needlen);
-
-  if ( mesdata == NULL )
-   return -1;
-
-  *data = mesdata;
- } else {
-  mesdata = mes->data;
- }
-
- memset(mes, 0, sizeof(struct roar_message));
-
- mes->datalen = needlen;
-
- d16 = (uint16_t*)mesdata;
-
- mesdata[0] = 0; // version
- mesdata[1] = 0; // reserved
-
- d16[1] = ROAR_HOST2NET16(idx);
-
- dptr = &(d16[2]);
-
- for (i = 0; i < idx; i++) {
-  dptr[0] = ROAR_HOST2NET16(iebuf[i].type & 0xFF);
-  dptr[1] = ROAR_HOST2NET16(iebuf[i].len);
-  dptr += 2;
- }
-
- textpart = mesdata + (4 + 4*idx);
-
- for (i = 0; i < idx; i++) {
-  memcpy(textpart, iebuf[i].buf, iebuf[i].len);
-  textpart += iebuf[i].len;
- }
-
- return 0;
-}
-
-struct roar_server_info * roar_server_info_from_mes(struct roar_message * mes, void * data) {
- struct ie iebuf[sizeof(struct roar_server_info)/sizeof(char*)];
- struct ie * ieptr;
- struct roar_server_info * ret = NULL;
- uint16_t * d16, * dptr;
- size_t idx;
- size_t i;
- size_t needlen = 4;
- char * textpart;
- char * textbuf;
- const char ** tptr;
- char * mesdata;
-
- ROAR_DBG("roar_server_info(mes=%p{.datalen=%llu) = ?", mes, (long long unsigned int)mes->datalen);
-
- if ( mes == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- if ( data == NULL ) {
-  mesdata = mes->data;
- } else {
-  mesdata = data;
- }
-
- memset(iebuf, 0, sizeof(iebuf));
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- // some basic texts like version:
- if ( mes->datalen < needlen ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- if ( mesdata[0] != 0 ) { /* version */
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- if ( mesdata[1] != 0 ) { /* reserved */
-  roar_err_set(ROAR_ERROR_PROTO);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- d16 = (uint16_t*)mesdata;
-
- idx = ROAR_NET2HOST16(d16[1]);
-
- ROAR_DBG("roar_server_info(mes=%p): idx=%i", mes, idx);
-
- // return error if our index buffer is too short.
- if ( idx > (sizeof(iebuf)/sizeof(*iebuf)) ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen);
-
- needlen += 4*idx;
-
- // recheck if we have a complet index.
- if ( mes->datalen < needlen ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- d16 = (uint16_t*)mesdata;
- dptr = &(d16[2]);
-
- textpart = mesdata + (4 + 4*idx);
-
- ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen);
-
- for (i = 0; i < idx; i++) {
-  iebuf[i].type = ROAR_NET2HOST16(dptr[0]) & 0xFF;
-  iebuf[i].len  = ROAR_NET2HOST16(dptr[1]);
-  iebuf[i].buf  = textpart;
-  needlen  += iebuf[i].len;
-  textpart += iebuf[i].len;
-  dptr += 2;
-  ROAR_DBG("roar_server_info(mes=%p): iebuf[i]={.len=%llu,...}", mes, (long long unsigned int)iebuf[i].len);
- }
-
- ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen);
-
- // recheck if we have all the data...
- if ( mes->datalen < needlen ) {
-  roar_err_set(ROAR_ERROR_PROTO);
-  return NULL;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- // alloc the needed space. this can be reduced in future to the actual needed value.
- ret = roar_mm_malloc(2*sizeof(struct roar_server_info) + mes->datalen);
-
- if ( ret == NULL )
-  return NULL;
-
- ROAR_DBG("roar_server_info(mes=%p) = ?", mes);
-
- // for the size see the alloc call above.
- memset(ret, 0, 2*sizeof(struct roar_server_info) + mes->datalen);
-
- textbuf = (char*)ret + sizeof(struct roar_server_info);
-
- for (i = 0; i < idx; i++) {
-  ieptr = &(iebuf[i]);
-
-   // ignore empty fields
-  if ( ieptr->len == 0 )
-   continue;
-  if ( ieptr->len == 1 && ieptr->buf[0] == 0 )
-   continue;
-
-#define _ck(TYPE,member) case TYPE: tptr = &(ret->member); break;
-  switch (ieptr->type) {
-   _ck(ROAR_ITST_VERSION, version);
-   _ck(ROAR_ITST_LOCATION, location);
-   _ck(ROAR_ITST_DESCRIPTION, description);
-   _ck(ROAR_ITST_CONTACT, contact);
-   _ck(ROAR_ITST_SERIAL, serial);
-   _ck(ROAR_ITST_ADDRESS, address);
-   _ck(ROAR_ITST_UIURL, uiurl);
-   _ck(ROAR_ITST_HOSTID, hostid);
-   _ck(ROAR_ITST_LICENSE, license);
-   _ck(ROAR_ITST_BUILD, build);
-   _ck(ROAR_ITST_UN_SYSNAME, un.sysname);
-   _ck(ROAR_ITST_UN_RELEASE, un.release);
-   _ck(ROAR_ITST_UN_NODENAME, un.nodename);
-   _ck(ROAR_ITST_UN_MACHINE, un.machine);
-   default:
-     continue;
-    break;
-  }
-#undef _ck
-
-  *tptr = textbuf;
-   memcpy(textbuf, ieptr->buf, ieptr->len);
-   textbuf += ieptr->len;
-   *textbuf = 0; // set \0
-   textbuf++;
- }
-
- ROAR_DBG("roar_server_info(mes=%p) = %p", mes, ret);
-
- return ret;
-}
-
-
-//ll
Index: libroar/simple.c
===================================================================
--- libroar/simple.c	(revision 6052)
+++ libroar/simple.c	(revision 0)
@@ -1,61 +1,22 @@
 //simple.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroar.h"
 
-static int roar_simple_stream_obj  (struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, const char * server, int dir, const char * name, int mixer);
-
-int roar_simple_connect (struct roar_connection * con, const char * server, const char * name) {
- return roar_simple_connect2(con, server, name, 0, 0);
-}
-
-int roar_simple_connect2(struct roar_connection * con, const char * server, const char * name, int flags, uint_least32_t timeout) {
+int roar_simple_connect (struct roar_connection * con, char * server, char * name) {
 
  ROAR_DBG("roar_simple_connect(*): trying to connect...");
 
- if ( roar_connect(con, server, flags, timeout) == -1 ) {
-  ROAR_DBG("roar_simple_connect(*): roar_connect() faild: %s", roar_errorstring);
+ if ( roar_connect(con, server) == -1 ) {
+  ROAR_DBG("roar_simple_connect(*): roar_connect() faild!");
   return -1;
  }
 
  if ( roar_identify(con, name) == -1 ) {
-  ROAR_DBG("roar_simple_connect(*): roar_identify() faild: %s", roar_errorstring);
+  ROAR_DBG("roar_simple_connect(*): roar_identify() faild!");
   return -1;
  }
 
  if ( roar_auth(con) == -1 ) {
-  ROAR_DBG("roar_simple_connect(*): roar_auth() faild: %s", roar_errorstring);
+  ROAR_DBG("roar_simple_connect(*): roar_auth() faild!");
   return -1;
  }
@@ -64,125 +25,58 @@
 }
 
-static int roar_simple_stream_obj  (struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, const char * server, int dir, const char * name, int mixer) {
+int roar_simple_stream(int rate, int channels, int bits, int codec, char * server, int dir, char * name) {
  struct roar_connection con;
- int ret;
- int safe_error;
-
- roar_debug_warn_sysio("roar_simple_stream_obj", NULL, NULL);
+ struct roar_stream     s;
 
  if ( roar_simple_connect(&con, server, name) == -1 ) {
-  ROAR_DBG("roar_simple_stream_obj(*): roar_simple_connect() faild!");
-  ROAR_ERR("roar_simple_stream_obj(*): Can not connect to server");
+  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
   return -1;
  }
 
- if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) {
-  safe_error = roar_error;
+ if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) {
   roar_disconnect(&con);
-  roar_err_set(safe_error);
   return -1;
  }
 
- if ( roar_stream_connect(&con, s, dir, mixer) == -1 ) {
-  safe_error = roar_error;
+ if ( roar_stream_connect(&con, &s, dir) == -1 ) {
   roar_disconnect(&con);
-  roar_err_set(safe_error);
   return -1;
  }
 
- if ( roar_stream_exec(&con, s) == -1 ) {
-  safe_error = roar_error;
+ if ( roar_stream_exec(&con, &s) == -1 ) {
   roar_disconnect(&con);
-  roar_err_set(safe_error);
   return -1;
  }
 
- roar_libroar_nowarn();
- if ( (ret = roar_get_connection_fh(&con)) == -1 ) {
-  safe_error = roar_error;
-  roar_libroar_warn();
-  roar_disconnect(&con);
-  roar_err_set(safe_error);
-  return -1;
- }
- roar_libroar_warn();
-
- if ( dir == ROAR_DIR_PLAY ) {
-  (void)ROAR_SHUTDOWN(ret, SHUT_RD);
- } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) {
-  (void)ROAR_SHUTDOWN(ret, SHUT_WR);
- }
-
- return ret;
+ return con.fh;
 }
 
-int roar_simple_new_stream_attachexeced_obj (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer) {
- int fh;
-
- if ( (fh = roar_simple_stream_obj(s, rate, channels, bits, codec, roar_get_connection_server(con),
-                                   dir, "libroar temp stream", mixer)) == -1 )
-  return -1;
-
- if ( roar_stream_attach_simple(con, s, roar_get_clientid(con)) == -1 ) {
-#ifdef ROAR_HAVE_IO_POSIX
-  close(fh);
-#endif /* no else as we return -1 anyway */
-  return -1;
- }
-
- s->fh = fh;
-
- return fh;
+int roar_simple_play(int rate, int channels, int bits, int codec, char * server, char * name) {
+ return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_PLAY, name);
 }
 
-int roar_simple_play_file(const char * file, const char * server, const char * name) {
- roar_vs_t * vss;
- int err;
-
- vss = roar_vs_new_from_file(server, name, file, &err);
-
- if ( vss == NULL ) {
-  roar_err_set(err);
-  return -1;
- }
-
- if ( roar_vs_run(vss, &err) == -1 ) {
-  roar_vs_close(vss, ROAR_VS_TRUE, NULL);
-  roar_err_set(err);
-  return -1;
- }
-
- roar_vs_sync(vss, ROAR_VS_WAIT, NULL);
- roar_vs_close(vss, ROAR_VS_FALSE, NULL);
-
- return 0;
+int roar_simple_monitor(int rate, int channels, int bits, int codec, char * server, char * name) {
+ return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_MONITOR, name);
 }
 
-int roar_simple_connect_virtual(struct roar_connection * con, struct roar_stream * s, int parent, int dir) {
- struct roar_stream parent_stream;
+int roar_simple_record(int rate, int channels, int bits, int codec, char * server, char * name) {
+ return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_RECORD, name);
+}
 
- if ( con == NULL || s == NULL || parent < 0 )
-  return -1;
+int roar_simple_filter(int rate, int channels, int bits, int codec, char * server, char * name) {
+ return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_FILTER, name);
+}
 
- if ( dir == -1 ) {
-  if ( roar_get_stream(con, &parent_stream, parent) == -1 )
-   return -1;
 
-  if ( (dir = roar_stream_get_dir(&parent_stream)) == -1 )
-   return -1;
- }
+int roar_simple_close(int fh) {
+ return close(fh);
+}
 
- if ( roar_stream_set_rel_id(s, parent) == -1 )
-  return -1;
+int roar_simple_get_standby (int fh) {
+ struct roar_connection con;
 
- if ( roar_stream_connect(con, s, dir, -1) == -1 )
-  return -1;
+ con.fh = fh;
 
- if ( roar_stream_set_flags(con, s, ROAR_FLAG_VIRTUAL, ROAR_SET_FLAG) == -1 ) {
-  roar_kick(con, ROAR_OT_STREAM, roar_stream_get_id(s));
-  return -1;
- }
-
- return 0;
+ return roar_get_standby(&con);
 }
 
Index: libroar/slp.c
===================================================================
--- libroar/slp.c	(revision 6052)
+++ 	(revision )
@@ -1,221 +1,0 @@
-//slp.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#if defined(ROAR_HAVE_LIBSLP) && defined(ROAR_HAVE_TIME)
-#define _CAN_OPERATE
-#endif
-
-SLPBoolean roar_slp_url_callback(SLPHandle        hslp,
-                                 const char     * srvurl,
-                                 unsigned short   lifetime,
-                                 SLPError         errcode,
-                                 void           * cookie) {
-#ifdef _CAN_OPERATE
- struct roar_slp_cookie * self = cookie;
-
- (void)hslp;
-
- ROAR_DBG("roar_slp_url_callback(*) = ?");
-
- if (errcode == SLP_OK || errcode == SLP_LAST_CALL) {
-  self->callbackerr = SLP_OK;
-
-  if ( srvurl == NULL ) /* hu? */
-   return SLP_TRUE;
-
-  if ( self->matchcount == ROAR_SLP_MAX_MATCHES )
-   return SLP_FALSE;
-
-  strncpy(self->match[self->matchcount].url, srvurl, ROAR_SLP_MAX_URL_LEN);
-
-  self->match[self->matchcount].url[ROAR_SLP_MAX_URL_LEN-1] = 0;
-
-  self->match[self->matchcount].tod  = time(NULL);
-  self->match[self->matchcount].tod += lifetime;
-
-  self->matchcount++;
- } else {
-  self->callbackerr = errcode;
- }
-
-
- /* return SLP_TRUE because we want to be called again */
- /* if more services were found                        */
-
- return SLP_TRUE;
-#else
- return SLP_FALSE;
-#endif
-}
-
-int roar_slp_search          (struct roar_slp_cookie * cookie, char * type) {
-#ifdef _CAN_OPERATE
- SLPError err;
- SLPHandle hslp;
-
- ROAR_DBG("roar_slp_search(cookie=%p, type='%s') = ?", cookie, type);
-
- if ( cookie->search != NULL ) /* currently only non-search filter mode supported */
-  return -1;
-
- err = SLPOpen("en", SLP_FALSE, &hslp);
- if (err != SLP_OK) {
-  return -1;
- }
-
- ROAR_DBG("roar_slp_search(*) = ?");
-
- err = SLPFindSrvs(hslp,
-                   type,
-                   0,                    /* use configured scopes */
-                   0,                    /* no attr filter        */
-                   roar_slp_url_callback,
-                   cookie);
-
- ROAR_DBG("roar_slp_search(*) = ?");
-
-  /* err may contain an error code that occurred as the slp library    */
-  /* _prepared_ to make the call.                                     */
-  if (err != SLP_OK) {
-   return -1;
-  }
-
- /* callbackerr may contain an error code (that was assigned through */
- /* the callback cookie) that occurred as slp packets were sent on    */
- /* the wire */
- if (cookie->callbackerr != SLP_OK) {
-  return -1;
- }
-
- ROAR_DBG("roar_slp_search(*) = ?");
-
- /* Now that we're done using slp, close the slp handle */
- //SLPClose(hslp);
-
- ROAR_DBG("roar_slp_search(*) = ?");
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int roar_slp_cookie_init     (struct roar_slp_cookie * cookie, struct roar_slp_search * search) {
- if ( cookie == NULL )
-  return -1;
-
- memset(cookie, 0, sizeof(struct roar_slp_cookie));
-
- cookie->search = search;
-
- return 0;
-}
-
-
-char * roar_slp_find_roard   (int nocache) {
- static char addr[80];
-
- if ( roar_slp_find_roard_r(addr, sizeof(addr), nocache) == -1 )
-  return NULL;
-
- return addr;
-}
-
-int    roar_slp_find_roard_r (char * addr, size_t len, int nocache) {
-#ifdef _CAN_OPERATE
- static struct roar_slp_match    cache  = {"", 0};
-        struct roar_slp_cookie   cookie;
- int                             offset = 0;
- char                          * url;
-
- ROAR_DBG("roar_slp_find_roard_r(addr=%p, len=%i) = ?", addr, len);
-
- if ( addr == NULL || len == 0 )
-  return -1;
-
- *addr = 0; // just in case...
-
- if ( nocache || cache.tod < time(NULL) ) {
-#ifdef DEBUG
-  if ( nocache ) {
-   ROAR_DBG("roar_slp_find_roard_r(*): forced ignoring of cache, doing a new lookup.");
-  }
-#endif
-  ROAR_DBG("roar_slp_find_roard_r(*): cache too old, searching for a new server...");
-  ROAR_DBG("roar_slp_find_roard_r(*) = ?");
-
-  if ( roar_slp_cookie_init(&cookie, NULL) == -1 )
-   return -1;
-
-  ROAR_DBG("roar_slp_find_roard_r(*) = ?");
-
-  if ( roar_slp_search(&cookie, ROAR_SLP_URL_TYPE) == -1 )
-   return -1;
-
-  ROAR_DBG("roar_slp_find_roard_r(*) = ?");
-
-  if ( cookie.matchcount == 0 )
-   return -1;
-
-  ROAR_DBG("roar_slp_find_roard_r(*) = ?");
-
-  url = cookie.match[0].url;
-
-  ROAR_DBG("roar_slp_find_roard_r(*): found new server, caching it");
-  memcpy(&cache, &(cookie.match[0]), sizeof(cache));
- } else {
-  ROAR_DBG("roar_slp_find_roard_r(*): cache within TTL, no need to search for server, using cache.");
-  url = cache.url;
- }
-
- if ( !strncmp(url, ROAR_SLP_URL_TYPE "://", ROAR_SLP_URL_TYPE_LEN + 3) )
-  offset = 28;
-
- ROAR_DBG("roar_slp_find_roard_r(*): url='%s'", cookie.match[0].url);
-
- strncpy(addr, &(url[offset]), len);
- addr[len-1] = 0; // also just in case.
-
- ROAR_DBG("roar_slp_find_roard_r(*): addr='%s'", addr);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-//ll
Index: libroar/socket.c
===================================================================
--- libroar/socket.c	(revision 6052)
+++ libroar/socket.c	(revision 0)
@@ -1,217 +1,34 @@
 //socket.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#define _LIBROAR_NOATTR_TO_STATIC /* ignore warnings for TO_STATIC functions */
 #include "libroar.h"
 
-#if defined(ROAR_SUPPORT_PROXY) && !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
-#include <pwd.h>
-#endif
+#define MODE_LISTEN  1
+#define MODE_CONNECT 2
 
-#define MODE_LISTEN  ROAR_SOCKET_MODE_LISTEN
-#define MODE_CONNECT ROAR_SOCKET_MODE_CONNECT
+int roar_socket_new_tcp (void) {
+ int fh;
+// int extra_flags = TCP_NODELAY;
 
-static int roar_socket_open_file  (int mode, const char * host, int port);
+ fh = socket(PF_INET, SOCK_STREAM, 0);
 
-#ifdef ROAR_SUPPORT_PROXY
-static int roar_socket_open_proxy (int mode, int type, const char * host, int port, const char * proxy_type);
-
-static int roar_socket_open_socks4 (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts);
-static int roar_socket_open_socks4a(int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts);
-static int roar_socket_open_socks4d(int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts);
-static int roar_socket_open_socks4x(int mode, int fh, char host[4], int port, const char * app, size_t app_len, const char * user);
-
-static int roar_socket_open_http   (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts);
-
-#ifdef ROAR_HAVE_BIN_SSH
-static int roar_socket_open_ssh    (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts);
-#endif
-#endif
-
-
-#ifdef ROAR_TARGET_WIN32
-void roar_socket_win32_init (void) {
- static int inited = 0;
- WSADATA wsadata;
-
- if ( !inited ) {
-  WSAStartup(MAKEWORD(1,1) , &wsadata);
-  inited++;
- }
-}
-#else
-#define roar_socket_win32_init()
-#endif
-
-#ifdef ROAR_HAVE_LIBDNET
-static int roar_socket_decnet_set_timeout (int fh, time_t sec, int_least32_t usec) {
- struct timeval timeout = {sec, usec};
-
- return setsockopt(fh, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
-}
-#endif
-
-static int roar_socket_set_tos(int fh) {
-#if defined(ROAR_HAVE_BSDSOCKETS) && !defined(ROAR_TARGET_WIN32)
- int opt = IPTOS_LOWDELAY;
- int ret;
-
- roar_err_clear_errno();
- ret = setsockopt(fh, IPPROTO_IP, IP_TOS, &opt, sizeof(int));
- if ( ret < 0 )
-  roar_err_from_errno();
-
- return ret;
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
+ return fh;
 }
 
-int roar_socket_new        (int type) {
-#ifdef ROAR_HAVE_BSDSOCKETS
- int sys_domain = -1, sys_type = -1, sys_protocol = 0;
+int roar_socket_new_unix (void) {
  int fh;
-#if defined(ROAR_HAVE_IPV4) && defined(TCP_NODELAY) && !defined(ROAR_TARGET_WIN32)
- int t   = 1;
-#endif
 
- switch (type) {
-  case ROAR_SOCKET_TYPE_NONE:
-  case ROAR_SOCKET_TYPE_GENSTR:
-    roar_err_set(ROAR_ERROR_INVAL);
-    return -1;
-   break;
-  case ROAR_SOCKET_TYPE_FILE:
-  case ROAR_SOCKET_TYPE_FORK:
-    roar_err_set(ROAR_ERROR_PERM);
-    return -1;
-   break;
-#ifdef ROAR_HAVE_IPV4
-  case ROAR_SOCKET_TYPE_TCP:
-    sys_domain = AF_INET; sys_type = SOCK_STREAM;
-   break;
-  case ROAR_SOCKET_TYPE_UDP:
-    sys_domain = AF_INET; sys_type = SOCK_DGRAM;
-   break;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  case ROAR_SOCKET_TYPE_UNIX:
-    sys_domain = AF_UNIX; sys_type = SOCK_STREAM;
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case ROAR_SOCKET_TYPE_DECNET:
-    sys_domain = AF_DECnet; sys_type = SOCK_STREAM; sys_protocol = DNPROTO_NSP;
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case ROAR_SOCKET_TYPE_TCP6:
-    sys_domain = AF_INET6; sys_type = SOCK_STREAM;
-   break;
-  case ROAR_SOCKET_TYPE_UDP6:
-    sys_domain = AF_INET6; sys_type = SOCK_DGRAM;
-   break;
-#endif
-#ifdef ROAR_HAVE_IPX
-  case ROAR_SOCKET_TYPE_IPX:
-    sys_domain = AF_IPX; sys_type = SOCK_DGRAM; sys_protocol = AF_IPX;
-   break;
-#endif
-  case ROAR_SOCKET_TYPE_IPXSPX:
-  case ROAR_SOCKET_TYPE_LAT_SERVICE:
-  case ROAR_SOCKET_TYPE_LAT_REVERSE_PORT:
-  default:
-    roar_err_set(ROAR_ERROR_AFNOTSUP);
-    return -1;
-   break;
- }
-
- roar_socket_win32_init();
-
- roar_err_clear_all();
- fh = socket(sys_domain, sys_type, sys_protocol);
- if ( fh == -1 ) {
-  roar_err_update();
-  return -1;
- }
-
- // do the extra work we need to do for some socket types:
- switch (type) {
-#ifdef ROAR_HAVE_IPV4
-  case ROAR_SOCKET_TYPE_TCP:
-#if defined(TCP_NODELAY) && !defined(ROAR_TARGET_WIN32)
-   setsockopt(fh, IPPROTO_TCP, TCP_NODELAY, &t, sizeof(int));
-#endif
-  case ROAR_SOCKET_TYPE_UDP:
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case ROAR_SOCKET_TYPE_TCP6:
-  case ROAR_SOCKET_TYPE_UDP6:
-#endif
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
-    roar_socket_set_tos(fh);
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case ROAR_SOCKET_TYPE_DECNET:
-    roar_socket_decnet_set_timeout(fh, 300, 0);
-   break;
-#endif
- }
+ fh = socket(AF_UNIX, SOCK_STREAM, 0);
 
  return fh;
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
 }
 
-
 int roar_socket_nonblock(int fh, int state) {
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) && defined(ROAR_HAVE_FCNTL)
  int flags;
 
  if ( (flags = fcntl(fh, F_GETFL, 0)) == -1 ) {
-  roar_err_from_errno();
   ROAR_ERR("roar_socket_nonblock(fh=%i, state=%i): Can not read flags: %s", fh, state, strerror(errno));
   ROAR_DBG("roar_socket_nonblock(fh=%i, state=%i) = -1", fh, state);
   return -1;
  }
-
- if ( !(flags & O_NONBLOCK) && state == ROAR_SOCKET_BLOCK )
-  return 0;
 
  flags |= O_NONBLOCK;
@@ -221,5 +38,4 @@
 
  if ( fcntl(fh, F_SETFL, flags) == -1 ) {
-  roar_err_from_errno();
   ROAR_ERR("roar_socket_nonblock(fh=%i, state=%i): Can not set flags: %s", fh, state, strerror(errno));
   ROAR_DBG("roar_socket_nonblock(fh=%i, state=%i) = -1", fh, state);
@@ -229,334 +45,21 @@
  ROAR_DBG("roar_socket_nonblock(fh=%i, state=%i) = 0", fh, state);
  return 0;
-#else
- ROAR_WARN("roar_socket_nonblock(*): no nonblocking IO support on win32, use a real OS");
- return -1;
-#endif
 }
 
-int roar_socket_dup_udp_local_end (int fh) {
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) && defined(ROAR_HAVE_FCNTL)
- int                  n              = -1;
- int                  flags          = -1;
- struct sockaddr_in   socket_addr;
- socklen_t            len            = sizeof(struct sockaddr_in);
-
- if ( (flags = fcntl(fh, F_GETFL, 0)) == -1 ) {
-  ROAR_WARN("roar_socket_dup_udp_local_end(fh=%i): Can not read flags: %s", fh, strerror(errno));
- }
-
- if ( getsockname(fh, (struct sockaddr *)&socket_addr, &len) == -1 ) {
-  roar_err_from_errno();
-  return -1;
- }
-
- if ( socket_addr.sin_family != AF_INET ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- n = roar_socket_new(ROAR_SOCKET_TYPE_UDP);
-
- if ( n == -1 )
-  return -1;
-
-//  if ( mode_func(fh, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)) == -1 ) {
- if ( bind(n, (struct sockaddr *)&socket_addr, len) == -1 ) {
-  roar_err_from_errno();
-  close(n);
-  return -1;
- }
-
- if ( flags != -1 ) {
-  if ( fcntl(fh, F_SETFL, flags) == -1 ) {
-   ROAR_WARN("roar_socket_dup_udp_local_end(fh=%i): Can not set flags: %s", fh, strerror(errno));
-   return -1;
-  }
- }
-
-
- return n;
-#else
- ROAR_WARN("roar_socket_dup_udp_local_end(*): this function is not supported on win32, use a real OS");
- return -1;
-#endif
-}
-
-
-#define _SCMR_CONTROLLEN (sizeof(struct cmsghdr) + sizeof(int))
-int roar_socket_send_fh (int sock, int fh, char * mes, size_t len) {
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_OS_SUNOS) && !defined(ROAR_TARGET_OPENVMS)
- struct iovec     iov[1];
- struct msghdr    msg;
- char             cmptr_buf[_SCMR_CONTROLLEN];
- struct cmsghdr * cmptr = (struct cmsghdr *) cmptr_buf;
- char             localmes[1] = {0};
- int *            fhptr;
-
- ROAR_DBG("roar_socket_send_fh(sock=%i, fh=%i, mes=%p, len=%u) = ?", sock, fh, mes, len);
-
- if ( sock < 0 || fh < 0 )
-  return -1;
-
- if ( len == 0 ) {
-  len = 1;
-  mes = localmes;
- }
-
- memset(&msg,  0, sizeof(msg));
- memset(cmptr, 0, _SCMR_CONTROLLEN);
-
- iov[0].iov_base = mes;
- iov[0].iov_len  = len;
- msg.msg_iov     = iov;
- msg.msg_iovlen  = 1;
- msg.msg_name    = NULL;
- msg.msg_namelen = 0;
-
- cmptr->cmsg_level        = SOL_SOCKET;
- cmptr->cmsg_type         = SCM_RIGHTS;
- cmptr->cmsg_len          = _SCMR_CONTROLLEN;
- msg.msg_control          = (caddr_t) cmptr;
- msg.msg_controllen       = _SCMR_CONTROLLEN;
- fhptr                    = (int *)CMSG_DATA(cmptr);
- *fhptr = fh;
-
- return sendmsg(sock, &msg, 0);
-#else
- ROAR_ERR("roar_socket_send_fh(*): There is no UNIX Domain Socket support in win32, download a real OS.");
- return -1;
-#endif
-}
-
-int roar_socket_recv_fh (int sock,         char * mes, size_t * len) {
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_OS_SUNOS) && !defined(ROAR_TARGET_OPENVMS)
- struct iovec     iov[1];
- struct msghdr    msg;
- char             cmptr_buf[_SCMR_CONTROLLEN];
- struct cmsghdr * cmptr = (struct cmsghdr *) cmptr_buf;
- char             localmes[1];
- size_t           locallen[1] = {1};
- int *            fhptr;
-
- ROAR_DBG("roar_socket_recv_fh(sock=%i, mes=%p, len=%p) = ?", sock, mes, len);
-
- if ( sock < 0 ) {
-  ROAR_DBG("roar_socket_recv_fh(sock=%i, mes=%p, len=%p) = -1 // invalid socket", sock, mes, len);
-  return -1;
- }
-
- if ( len == NULL ) {
-  len = locallen;
-  mes = localmes;
- }
-
- iov[0].iov_base = mes;
- iov[0].iov_len  = *len;
- msg.msg_iov     = iov;
- msg.msg_iovlen  = 1;
- msg.msg_name    = NULL;
- msg.msg_namelen = 0;
-
- msg.msg_control    = (caddr_t) cmptr;
- msg.msg_controllen = _SCMR_CONTROLLEN;
-
- if ( (*len = recvmsg(sock, &msg, 0)) == -1 ) {
-  ROAR_DBG("roar_socket_recv_fh(sock=%i, mes=%p, len=%p) = -1 // can not read from socket", sock, mes, len);
-  return -1;
- }
-
- if ( msg.msg_controllen  < _SCMR_CONTROLLEN ||
-      cmptr->cmsg_len    != _SCMR_CONTROLLEN  ) {
-  ROAR_DBG("roar_socket_recv_fh(sock=%i, mes=%p, len=%p) = -1 // control len is wrong", sock, mes, len);
-  return -1;
- }
-
- fhptr = (int *)CMSG_DATA(cmptr);
- ROAR_DBG("roar_socket_recv_fh(sock=%i, mes=%p, len=%p) = %i", sock, mes, len, *fhptr);
- return *fhptr;
-#else
- ROAR_ERR("roar_socket_recv_fh(*): There is no UNIX Domain Socket support in win32, download a real OS.");
- return -1;
-#endif
-}
-
-int roar_socket_listen  (int type, const char * host, int port) {
+int roar_socket_listen  (int type, char * host, int port) {
  return roar_socket_open(MODE_LISTEN, type, host, port);
 }
 
-int roar_socket_connect (int type, const char * host, int port) {
- const char * proxy_type = roar_env_get("ROAR_PROXY");
-
- ROAR_DBG("roar_socket_connect(host='%s', port=%i) = ?", host, port);
-
- if ( proxy_type == NULL || strcmp(proxy_type, "") == 0 ) {
-  return roar_socket_open(MODE_CONNECT, type, host, port);
- } else {
-#ifdef ROAR_SUPPORT_PROXY
-  return roar_socket_open_proxy(MODE_CONNECT, type, host, port, proxy_type);
-#else
-  ROAR_ERR("roar_socket_connect(host='%s', port=%i): no support for proxy code (proxy_type=%s)", host, port, proxy_type);
-  return -1;
-#endif
- }
+int roar_socket_connect (char * host, int port) {
+ return roar_socket_open(MODE_CONNECT, ROAR_SOCKET_TYPE_UNKNOWN, host, port);
 }
 
-
-#ifdef ROAR_HAVE_LIBDNET
-static int roar_socket_listen_decnet (const char * object, int num) {
- int fh = roar_socket_new(ROAR_SOCKET_TYPE_DECNET);
- struct sockaddr_dn bind_sockaddr;
-
- if ( fh == -1 )
-  return -1;
-
- if ( object != NULL && !*object )
-  object = NULL;
-
- if ( (object != NULL && num) || (object != NULL && !*object && !num) || (object == NULL && !num) ) {
-  ROAR_WARN("roar_socket_listen_decnet(object='%s', num=%i): illegal address!", object, num);
-  close(fh);
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- memset((void*)&bind_sockaddr, 0, sizeof(struct sockaddr_dn));
-
- bind_sockaddr.sdn_family    = AF_DECnet;
- bind_sockaddr.sdn_flags     = 0;
- bind_sockaddr.sdn_objnum    = num;
-
- if ( num ) {
-  bind_sockaddr.sdn_objnamel = 0;
- } else {
-  bind_sockaddr.sdn_objnamel  = ROAR_HOST2LE16(strlen(object));
-  if ( bind_sockaddr.sdn_objnamel > DN_MAXOBJL )
-   bind_sockaddr.sdn_objnamel = DN_MAXOBJL;
-  strncpy((char*)bind_sockaddr.sdn_objname, object, DN_MAXOBJL);
- }
-
- if ( bind(fh, (struct sockaddr *) &bind_sockaddr, sizeof(bind_sockaddr)) == -1 ) {
-  roar_err_from_errno();
-  close(fh);
-  return -1;
- }
-
- if ( listen(fh, 8) == -1 ) {
-  roar_err_from_errno();
-  close(fh);
-  return -1;
- }
-
- return fh;
-}
-#endif
-
-const char * roar_socket_get_local_nodename(void) {
-#ifdef ROAR_HAVE_LIBDNET
- static char node[16] = {0};
- struct dn_naddr      *binaddr;
- struct nodeent       *dp;
-
- if ( !node[0] ) {
-
- // TODO: This does this function not use getnodename()?
-
- // Those strange workarounds for the error codes are because those functions currently
- // don't set errno. This way we will use errno as soon as it starts to set it.
-
-  roar_err_update();
-  if ( (binaddr=getnodeadd()) == NULL) {
-   roar_err_update();
-   if ( roar_error == ROAR_ERROR_NONE )
-    roar_err_set(ROAR_ERROR_NOENT);
-   return NULL;
-  }
-
-  roar_err_update();
-  if ( (dp=getnodebyaddr((char*)binaddr->a_addr, binaddr->a_len, AF_DECnet)) == NULL ) {
-   roar_err_update();
-   if ( roar_error == ROAR_ERROR_NONE )
-    roar_err_set(ROAR_ERROR_NOENT);
-   return NULL;
-  }
-
-  strncpy(node, dp->n_name, 15);
-  node[15] = 0;
- }
-
- return node;
-#else
- roar_err_set(ROAR_ERROR_AFNOTSUP);
- return NULL;
-#endif
-}
-
-int roar_socket_open (int mode, int type, const char * host, int port) {
+int roar_socket_open (int mode, int type, char * host, int port) {
 // int type = ROAR_SOCKET_TYPE_INET;
  int fh;
-#ifdef ROAR_HAVE_IPX
-#define _NEED_OBJ
-#endif
-#if defined(ROAR_HAVE_IPX) || defined(ROAR_HAVE_GETADDRINFO)
- int ret;
-#endif
-#ifdef ROAR_HAVE_IPX
- unsigned int ipx_port;
-#endif
-#ifdef ROAR_HAVE_UNIX
- int abstract = 0;
-#endif
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) || defined(ROAR_HAVE_UNIX) || defined(ROAR_HAVE_IPX)
- union {
-  struct sockaddr     sa;
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
-  struct sockaddr_in  in;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  struct sockaddr_un  un;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  struct sockaddr_in6 in6;
-#endif
-#ifdef ROAR_HAVE_IPX
-  struct sockaddr_ipx ipx;
-#endif
- } socket_addr;
- socklen_t addrlen;
-#endif
-#if (defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)) && !defined(ROAR_HAVE_GETADDRINFO)
- struct hostent     * he = NULL;
-#endif
-#ifdef ROAR_TARGET_WIN32
- int PASCAL (*mode_func)(SOCKET,const struct sockaddr*,int) = connect; // default is to connect
-#else
+ struct sockaddr_in   socket_addr;
+ struct hostent     * he;
+ //unsigned int host_div = 0;
  int (*mode_func)(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) = connect; // default is to connect
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-#define _NEED_OBJ
- char * dnet_node_buf;
- char * del;
-#endif
-#ifdef _NEED_OBJ
- char obj[80];
-#endif
-#ifdef ROAR_HAVE_GETADDRINFO
- int af_guessed = 0;
- struct addrinfo hints, *res = NULL;
- char port_as_string[32];
-#endif
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
- int is_numerical = 1;
- const char * numptr;
-#endif
-
- ROAR_DBG("roar_socket_open(mode=%i, type=%i, host='%s', port=%i) = ?", mode, type, host, port);
-
- if ( host == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_err_set(ROAR_ERROR_UNKNOWN);
 
  if ( mode == MODE_LISTEN )
@@ -564,640 +67,53 @@
 
  if ( type == ROAR_SOCKET_TYPE_UNKNOWN ) {
-#ifdef ROAR_HAVE_GETADDRINFO
-  af_guessed = 1;
-#endif
   type = ROAR_SOCKET_TYPE_INET;
-  if ( *host == '/' ) {
+  if ( *host == '/' )
    type = ROAR_SOCKET_TYPE_UNIX;
-  } else if ( strcmp(host, "+fork") == 0 ) {
-   type = ROAR_SOCKET_TYPE_FORK;
-  } else if ( strcmp(host, "+abstract") == 0 ) {
-   type = ROAR_SOCKET_TYPE_UNIX;
-#ifdef ROAR_HAVE_UNIX
-   abstract = 1;
-#endif
-  } else if ( strstr(host, "::") != NULL ) {
-   type = ROAR_SOCKET_TYPE_DECNET;
-  } else if ( host[strlen(host)-1] == ')' ) {
-   type = ROAR_SOCKET_TYPE_IPX;
-  }
  }
 
 
- ROAR_DBG("roar_socket_open(mode=%i, type=%i, host='%s', port=%i) = ?", mode, type, host, port);
+ ROAR_DBG("roar_socket_open(*): type=%s, host='%s', port=%i",
+             type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "INET", host, port);
 
- ROAR_DBG("roar_socket_open(*): type=%s, host='%s', port=%i",
-             type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "???", host, port);
-
- if ( type == ROAR_SOCKET_TYPE_DECNET ) {
-#ifdef ROAR_HAVE_LIBDNET
-   ROAR_DBG("roar_socket_open(*): nodename for DECnet: host(%p)=%s", host, host);
-   dnet_node_buf = roar_mm_strdup(host);
-   // roar_error is still set.
-   if ( dnet_node_buf == NULL )
-    return -1;
-
-   host = dnet_node_buf;
-
-   del = strstr(host, "::");
-   ROAR_DBG("roar_socket_open(*): nodename for DECnet: del(%p)=%s", del, del);
-
-   if ( del == NULL ) {
-    ROAR_WARN("roar_socket_open(*): invalid nodename for DECnet: %s", host);
-    roar_mm_free(dnet_node_buf);
-    roar_err_set(ROAR_ERROR_INVAL);
-    return -1;
-   }
-
-   *del = 0;
-
-   if ( *(del+2) == '#' ) { // assume we have node::#num
-    port = atoi(del+3);
-   }
-
-   if ( port ) {
-    snprintf(obj, sizeof(obj), "%i", port); // no need for snprintf() as dec(port) is smaller than obj[]
-   } else {
-    roar_mm_strlcpy(obj, del+2, sizeof(obj));
-   }
-
-  ROAR_DBG("roar_socket_open(*): obj='%s', port=%i", obj, port);
-
-  if ( mode == MODE_LISTEN ) {
-   fh = roar_socket_listen_decnet(obj, port);
-   roar_mm_free(dnet_node_buf);
-   return fh;
-  } else {
-   // There is nothing wrong in this case to use dnet_conn() so we do.
-   ROAR_DBG("roar_socket_open(*): CALL dnet_conn('%s', '%s', SOCK_STREAM, 0 ,0 ,0 , 0)", dnet_node_buf, obj);
-   fh = dnet_conn(dnet_node_buf, obj, SOCK_STREAM, 0, 0, 0, 0);
-   ROAR_DBG("roar_socket_open(*): RET %i", fh);
-   roar_mm_free(dnet_node_buf);
-   return fh;
-  }
-#else
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
-  return -1; // no decnet support
-#endif
- }
-
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
- memset(&socket_addr,    0, sizeof(socket_addr));
-#endif
+ memset(&socket_addr, 0, sizeof(socket_addr));
+ memset(&he,          0, sizeof(he));
 
 
- if ( type == ROAR_SOCKET_TYPE_INET || type == ROAR_SOCKET_TYPE_INET6 ) {
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
+ if ( type == ROAR_SOCKET_TYPE_INET ) {
 
-  ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port);
-
-  roar_socket_win32_init(); // we need to do this early as gethostbyname() requires this.
-
-  ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port);
-
-  if ( !!strcmp(host, "0.0.0.0") ) {
-   for (numptr = host; is_numerical && *numptr != 0; numptr++)
-    if ( ! ((*numptr >= '0' && *numptr <= '9') || *numptr == '.')  )
-     is_numerical = 0;
-
-   if ( is_numerical && roar_libroar_iswarn(NULL) ) {
-    ROAR_WARN("roar_socket_open(*): Hostname \"%s\" is numerical. Do not use IP addresses directly. Use Hostnames.", host);
-   }
-  }
-
-#ifdef ROAR_HAVE_GETADDRINFO
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_socktype = SOCK_STREAM;
-  if ( af_guessed ) {
-   hints.ai_family   = AF_UNSPEC;
-  } else {
-   hints.ai_family   = type == ROAR_SOCKET_TYPE_INET ? AF_INET : AF_INET6;
-  }
-
-  snprintf(port_as_string, sizeof(port_as_string), "%i", port);
-
-  ret = getaddrinfo(host, port_as_string, &hints, &res);
-  if ( ret == EAI_SYSTEM ) {
-   roar_err_from_errno();
-   return -1;
-  } else if ( ret != 0 ) {
-   roar_err_convert(&roar_error, ROAR_ERROR_TYPE_ROARAUDIO, ret, ROAR_ERROR_TYPE_EAI);
+  if ( (he = gethostbyname(host)) == NULL ) {
+   ROAR_ERR("roar_socket_open(*): Can\'t resolve host name '%s'",
+                     host);
    return -1;
   }
 
-  if ( af_guessed ) {
-   type = res->ai_family == AF_INET ? ROAR_SOCKET_TYPE_INET : ROAR_SOCKET_TYPE_INET6;
-  }
+  memcpy((struct in_addr *)&socket_addr.sin_addr, he->h_addr, sizeof(struct in_addr));
 
-  if ( type == ROAR_SOCKET_TYPE_INET ) {
-   fh = roar_socket_new(ROAR_SOCKET_TYPE_TCP);
-  } else {
-   fh = roar_socket_new(ROAR_SOCKET_TYPE_TCP6);
-  }
+  /* set the connect information */
+  socket_addr.sin_family = AF_INET;
+  socket_addr.sin_port = htons( port );
 
-  memcpy(&(socket_addr.sa), res->ai_addr, res->ai_addrlen);
-  addrlen = res->ai_addrlen;
+  fh = roar_socket_new_tcp();
 
-  if ( res != NULL )
-   freeaddrinfo(res);
-#else
-  if ( (he = gethostbyname(host)) == NULL ) {
-   ROAR_ERR("roar_socket_open(*): Can\'t resolve host name '%s'",
-                     host);
-   roar_err_from_errno();
-   return -1;
-  }
-
-   ROAR_DBG("roar_socket_open(*): he=%p", he);
-
-   memcpy((struct in_addr *)&(socket_addr.in.sin_addr), he->h_addr, sizeof(struct in_addr));
-
-   /* set the connect information */
-   socket_addr.in.sin_family = AF_INET;
-   socket_addr.in.sin_port   = ROAR_HOST2NET16(port);
-
-  fh = roar_socket_new(ROAR_SOCKET_TYPE_TCP);
-  addrlen = sizeof(struct sockaddr_in);
-#endif
-
-  ROAR_DBG("roar_socket_open(*): fh=%i", fh);
-
-  if ( fh == -1 ) {
-   ROAR_ERR("roar_socket_open(*): Can\'t create TCP socket: %s", strerror(errno));
-   return -1;
-  }
-
-  ROAR_DBG("roar_socket_open(*) = ?");
-
-  ROAR_DBG("roar_socket_open(*): fh=%i", fh);
-
-   if ( mode_func(fh, (struct sockaddr *)&socket_addr.sa, addrlen) == -1 ) {
-    ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno));
-    roar_err_from_errno();
-    close(fh);
-    return -1;
-   }
-
-  ROAR_DBG("roar_socket_open(*): fh=%i", fh);
-
-  // hey! we have a socket...
-  ROAR_DBG("roar_socket_open(*) = ? // we have a socket :)");
-#else
-  ROAR_DBG("roar_socket_open(*) = -1 // no IPv4 or IPv6 support");
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
-  return -1;
-#endif
- } else if ( type == ROAR_SOCKET_TYPE_UNIX ) {
-#ifdef ROAR_HAVE_UNIX
-  socket_addr.un.sun_family = AF_UNIX;
-
-  if ( abstract ) {
-   memset(socket_addr.un.sun_path, 0, sizeof(socket_addr.un.sun_path));
-   snprintf(socket_addr.un.sun_path+1, sizeof(socket_addr.un.sun_path)-1, "RoarAudio/UNIX/Abstract/%i", abstract);
-  } else {
-   strncpy(socket_addr.un.sun_path, host, sizeof(socket_addr.un.sun_path) - 1);
-  }
-
-  fh = roar_socket_new(ROAR_SOCKET_TYPE_UNIX);
-
-  if ( mode_func(fh, (struct sockaddr *)&socket_addr.un, sizeof(struct sockaddr_un)) == -1 ) {
+  if ( mode_func(fh, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)) == -1 ) {
    ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno));
-   roar_err_from_errno();
    close(fh);
    return -1;
   }
-#else
-  ROAR_ERR("roar_socket_open(*): There is no UNIX Domain Socket support in win32, download a real OS.");
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
-  return -1;
-#endif
- } else if ( type == ROAR_SOCKET_TYPE_IPX ) {
-#ifdef ROAR_HAVE_IPX
-  socket_addr.ipx.sipx_family = AF_IPX;
-
-  obj[0] = 0;
-
-  if ( (ret = sscanf(host, "%8x.%12s(%x)", &socket_addr.ipx.sipx_network, obj, &ipx_port)) < 2 ) {
-   return -1;
-   socket_addr.ipx.sipx_port = ipx_port;
-  } else if ( ret == 2 ) {
-   socket_addr.ipx.sipx_port = port; // Network Byte Order?
-  }
-
-  memset(socket_addr.ipx.sipx_node, 0, IPX_NODE_LEN);
-  ret = strlen(obj);
-
-  if ( ret % 2 )  // needs to be even at the moment
-   return -1;
-
-  fh = roar_socket_new(ROAR_SOCKET_TYPE_IPX);
-
+  // hey! we have a socket...
+ } else {
+  fh = roar_socket_new_unix();
   close(fh);
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
-  return -1;
-#else
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
-  return -1;
-#endif
- } else if ( type == ROAR_SOCKET_TYPE_FORK ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- } else if ( type == ROAR_SOCKET_TYPE_FILE ) {
-  return roar_socket_open_file(mode, host, port);
- } else {
-  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1;
  }
 
- if ( mode == MODE_LISTEN ) {
-#if defined(ROAR_HAVE_BSDSOCKETS) || defined(ROAR_TARGET_WIN32)
+ if ( mode == MODE_LISTEN )
   if ( listen(fh, ROAR_SOCKET_QUEUE_LEN) == -1 ) {
-   roar_err_from_errno();
    close(fh);
    return -1;
   }
-#else
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
-#endif
- }
 
  return fh;
 }
 
-static int roar_socket_open_file  (int mode, const char * host, int port) {
-#ifdef ROAR_HAVE_IO_POSIX
- int fh;
-
- if ( mode == MODE_LISTEN )
-  return -1;
-
- if ( (fh = open(host, O_RDONLY, 0644)) == -1 ) {
-  ROAR_ERR("roar_socket_open_file(*): Can not open file %s: %s", host, strerror(errno));
- }
-
- return fh;
-#else
- return -1;
-#endif
-}
-
-// --- [ PROXY CODE ] ---
-
-#ifndef ROAR_HAVE_IO_POSIX
-#ifdef  ROAR_SUPPORT_PROXY
-#undef  ROAR_SUPPORT_PROXY
-#endif
-#endif
-
-// generic proxy code:
-
-#ifdef ROAR_SUPPORT_PROXY
-static int roar_socket_open_proxy (int mode, int type, const char * host, int port, const char * proxy_type) {
- int    proxy_port = -1;
- char   proxy_host[ROAR_SOCKET_MAX_HOSTNAMELEN];
- const char * proxy_addr = NULL;
- int    i;
- int    fh = -1;
- const char * user = NULL, * pw = NULL, * opts = NULL;
- char * sep;
- int    no_fh = 0;
- char   proxy_addr_buf[1024];
- static struct passwd * passwd;
- int (* code)(int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) = NULL;
-
- if ( passwd == NULL ) {
-  passwd = getpwuid(getuid());
- }
-
-// TODO: fix this in a good way
-#ifndef ROAR_TARGET_MICROCONTROLLER
- if ( passwd != NULL )
-  user = passwd->pw_name;
-#endif
-
- if ( user == NULL )
-  user = roar_env_get("USER");
-
- // TODO: change this so we support listen() proxys (ssh -R)
- if ( mode != MODE_CONNECT )
-  return -1;
-
- if ( !strncmp(proxy_type, "socks", 5) ) {
-  proxy_addr = roar_env_get("socks_proxy");
-
-  proxy_port = 9050; // TOR's default port
- } else if ( !strcmp(proxy_type, "http") || !strcmp(proxy_type, "https") ) {
-  proxy_port = 8080;
-
-  if ( (proxy_addr = roar_env_get("http_proxy")) == NULL )
-   proxy_addr = roar_env_get("https_proxy");
-
-  if ( proxy_addr == NULL )
-   return -1;
-
-  if ( !strncmp(proxy_addr, "http://", 7) )
-   proxy_addr += 7;
- } else if ( !strncmp(proxy_type, "ssh", 3) ) {
-  proxy_port = 22;
-  proxy_addr = roar_env_get("ssh_proxy");
-  no_fh      = 1;
- }
-
- proxy_addr_buf[1023] = 0;
- strncpy(proxy_addr_buf, proxy_addr, 1023);
- proxy_addr = proxy_addr_buf;
-
- if ( (sep = strstr(proxy_type, "/")) != NULL )
-  opts = sep+1;
-
- if ( proxy_addr == NULL )
-  return -1;
-
- if ( (sep = strstr(proxy_addr, "@")) != NULL ) {
-  *sep = 0;
-  user = proxy_addr;
-  proxy_addr = sep+1;
-
-  if ( (sep = strstr(user, ":")) != NULL ) {
-   *sep = 0;
-   pw = sep+1;
-  }
- }
-
- ROAR_DBG("roar_socket_open_proxy(*): proxy_type='%s', opts='%s', user='%s', pw=(not shown), proxy_addr='%s'", proxy_type, opts, user, proxy_addr);
-
- for (i = 0; proxy_addr[i] != 0 && proxy_addr[i] != ':' && i < (ROAR_SOCKET_MAX_HOSTNAMELEN - 1); i++)
-  proxy_host[i] = proxy_addr[i];
- proxy_host[i] = 0;
-
- if ( i == 0 ) // no hostname found
-  return -1;
-
- if ( proxy_addr[i] == ':' )
-  proxy_port = atoi(&proxy_addr[i+1]);
-
- if ( ! no_fh ) {
-  if ( (fh = roar_socket_open(mode, type, proxy_host, proxy_port)) == -1) {
-   return -1;
-  }
- }
-
- if ( !strcmp(proxy_type, "socks4a") ) { // for TOR, the only supported type at the moment
-  code = roar_socket_open_socks4a;
- } else if ( !strcmp(proxy_type, "socks4d") ) { // DECnet
-  code = roar_socket_open_socks4d;
- } else if ( !strcmp(proxy_type, "socks4") ) { // good old SOCKS4
-  code = roar_socket_open_socks4;
- } else if ( !strcmp(proxy_type, "http") ) { // HTTP CONNECT
-  code = roar_socket_open_http;
- } else if ( !strncmp(proxy_type, "ssh", 3) ) { // SSH...
-#ifdef ROAR_HAVE_BIN_SSH
-  code = roar_socket_open_ssh;
-#else
-  ROAR_ERR("roar_socket_open_proxy(*): No SSH support compiled in");
-#endif
- } else {
-  return -1; // unknown type
- }
-
- if ( code != NULL ) {
-  if ( no_fh ) {
-   fh = code(mode, fh, host, port, user, pw, opts);
-  } else {
-   if ( code(mode, fh, host, port, user, pw, opts) == -1 ) {
-    close(fh);
-    return -1;
-   }
-  }
-
-  return fh;
- }
-
- close(fh);
- return -1;
-}
-
-// protocoll dependet proxy code:
-
-static int roar_socket_open_socks4 (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) {
-#ifndef ROAR_TARGET_MICROCONTROLLER
- struct hostent     * he;
-
- if ( (he = gethostbyname(host)) == NULL ) {
-  ROAR_ERR("roar_socket_open_socks4(*): Can\'t resolve host name '%s'", host);
-  return -1;
- }
-
- return roar_socket_open_socks4x(mode, fh, he->h_addr, port, NULL, 0, user);
-#else
- return -1;
-#endif
-}
-
-static int roar_socket_open_socks4a(int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) {
- return roar_socket_open_socks4x(mode, fh, "\0\0\0\1", port, host, strlen(host)+1, user);
-}
-
-static int roar_socket_open_socks4d(int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) {
- size_t len = strlen(host)+1;
- char * dp;
-
- if ( port == 0 ) {
-  if ( (dp = strstr(host, "::")) == NULL )
-   return -1;
-
-  len--;
-  *dp = 0;
-  memmove(dp+1, dp+2, len - (dp-host) - 1);
- }
-
- return roar_socket_open_socks4x(mode, fh, "\0\2\0\0", port, host, len, user);
-}
-
-static int roar_socket_open_socks4x(int mode, int fh, char host[4], int port, const char * app, size_t app_len, const char * user) {
- char buf[9];
- int len;
-
- buf[0] = 0x04;
- buf[1] = mode == MODE_CONNECT ? 0x01 : 0x02;
- *((uint16_t*)&buf[2]) = htons(port);
- memcpy(buf+4, host, 4);
-
- if ( user == NULL ) {
-  buf[8] = 0x00;
-  len = 9;
- } else {
-  len = 8;
- }
-
- if ( write(fh, buf, len) != len )
-  return -1;
-
- if ( user != NULL ) {
-  len = strlen(user) + 1;
-  if ( write(fh, user, len) != len )
-   return -1;
- }
-
- if ( app_len > 0 )
-  if ( write(fh, app, app_len) != (ssize_t)app_len )
-   return -1;
-
- if ( read(fh, buf, 8) != 8 )
-  return -1;
-
- if ( buf[1] != 0x5a )
-  return -1;
-
- return 0;
-}
-
-static int roar_socket_open_http   (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) {
- char buf[1024];
- int len;
-
- if ( port == 0 || host == NULL )
-  return -1;
-
- if ( *host == '/' ) // AF_UNIX
-  return -1;
-
- if ( (len = snprintf(buf, sizeof(buf), "CONNECT %s:%i HTTP/1.0\r\nUser-Agent: libroar\r\n\r\n", host, port)) == -1 )
-  return -1;
-
- if ( write(fh, buf, len) != len )
-  return -1;
-
- while ( (len = read(fh, buf, sizeof(buf))) ) {
-  if ( len == sizeof(buf) ) { // overlong lion
-   return -1;
-  } else if ( len == 2 && buf[0] == '\r' && buf[1] == '\n' ) {
-   break;
-  } else if ( len == 1 && (buf[0] == '\r' || buf[0] == '\n') ) { // bad proxy or devel trying to debug ;)
-   break;
-  } else if ( len >= 4 && buf[len-4] == '\r' && buf[len-3] == '\n' && buf[len-2] == '\r' && buf[len-1] == '\n' ) {
-   break;
-  }
- }
-
- return 0;
-}
-
-
-#ifdef ROAR_HAVE_BIN_SSH
-static int roar_socket_open_ssh    (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) {
- const char * proxy_addr = roar_env_get("ssh_proxy");
- char * sep;
- char * bin_ssh;
- char   cmd[1024] = "", rcmd[1024] = "";
- int    proxy_port = 22;
- int    use_socat = 0;
- int r;
- int socks[2];
-
- if ( host == NULL )
-  return -1;
-
- if ( *host == '/' )
-  use_socat = 1;
-
- if ( mode == MODE_LISTEN )
-  return -1;
-
- if ( proxy_addr == NULL )
-  return -1;
-
- if ( opts != NULL ) {
-  if ( !strcmp(opts, "socat") ) {
-   use_socat = 1;
-  } else if ( !strcmp(opts, "netcat") ) {
-   use_socat = 0;
-  } else {
-   return -1;
-  }
- }
-
- ROAR_DBG("roar_socket_open_ssh(*): proxy_addr='%s'", proxy_addr);
-
- if ( (sep = strstr(proxy_addr, "@")) != NULL )
-  proxy_addr = sep+1;
-
- if ( (sep = strstr(proxy_addr, ":")) != NULL ) {
-  *sep = 0;
-  proxy_port = atoi(sep+1);
- }
-
-
- if ( !strcmp(host, "+fork") ) {
-  strncpy(rcmd, "roard --no-listen --client-fh 0", 32);
- } else {
-  if ( use_socat ) {
-   if ( *host == '/' ) {
-    snprintf(rcmd, sizeof(rcmd)-1, "socat stdio unix-connect:\"%s\"", host);
-   } else {
-    snprintf(rcmd, sizeof(rcmd)-1, "socat stdio tcp:\"%s\":%i", host, port);
-   }
-  } else {
-   snprintf(rcmd, sizeof(rcmd)-1, "$(which netcat nc 2> /dev/null | grep -v \" \" | head -n 1) \"%s\" %i", host, port);
-  }
-
-  rcmd[sizeof(rcmd)-1] = 0;
- }
-
- ROAR_DBG("roar_socket_open_ssh(*): proxy_port=%i, user='%s', proxy_addr='%s'", proxy_port, user, proxy_addr);
- ROAR_DBG("roar_socket_open_ssh(*): rcmd: %s", rcmd);
- bin_ssh = roar_libroar_get_path("bin-ssh", 0, NULL, NULL);
- if ( bin_ssh == NULL )
-  return -1;
-
- snprintf(cmd, sizeof(cmd)-1, "%s -p %i -l '%s' '%s' '%s'", bin_ssh, proxy_port, user, proxy_addr, rcmd);
- cmd[sizeof(cmd)-1] = 0;
-
- roar_mm_free(bin_ssh);
-
-
-// TODO: get this more portable!
-#ifdef AF_UNIX
- if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) {
-  return -1;
- }
-#else
- return -1;
-#endif
-
- r = roar_fork(NULL);
-
- if ( r == -1 ) { // error!
-  ROAR_ERR("roar_socket_open_ssh(*): Can not fork: %s", strerror(errno));
-  close(socks[0]);
-  close(socks[1]);
-  return -1;
- } else if ( r == 0 ) { // we are the child
-  roar_watchdog_stop();
-
-  close(socks[0]);
-
-  close(ROAR_STDIN ); // we do not want roard to have any standard input
-  close(ROAR_STDOUT); // STDOUT is also not needed, so we close it,
-                      // but STDERR we keep open for error messages.
-
-  dup2(socks[1], 0);
-  dup2(socks[1], 1);
-
-  execlp("sh", "sh", "-c", cmd, (_LIBROAR_GOOD_CAST char*)NULL);
-
-  // we are still alive?
-  ROAR_ERR("roar_socket_open_ssh(*): alive after exec(), that's bad!");
-  ROAR_U_EXIT(1);
- } else { // we are the parent
-  close(socks[1]);
-  return socks[0];
- }
- return -1;
-}
-#endif
-
-#endif // ROAR_SUPPORT_PROXY
-
 //ll
Index: libroar/sshaskpass.c
===================================================================
--- libroar/sshaskpass.c	(revision 6052)
+++ 	(revision )
@@ -1,95 +1,0 @@
-//sshaskpass.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef _ASKPASS
-#undef _ASKPASS
-#endif
-
-#ifdef ROAR_HAVE_BIN_SSH_ASKPASS
-#define _ASKPASS ROAR_HAVE_BIN_SSH_ASKPASS
-#elif defined(ROAR_HAVE_BIN_GTK_LED_ASKPASS)
-#define _ASKPASS ROAR_HAVE_BIN_GTK_LED_ASKPASS
-#elif defined(ROAR_HAVE_BIN_X11_SSH_ASKPASS)
-#define _ASKPASS ROAR_HAVE_BIN_X11_SSH_ASKPASS
-#elif defined(ROAR_HAVE_BIN_GNOME_SSH_ASKPASS)
-#define _ASKPASS ROAR_HAVE_BIN_GNOME_SSH_ASKPASS
-#endif
-
-int roar_sshaskpass_getpass   (char ** pw, char * desc) {
-#if defined(_ASKPASS) && defined(ROAR_SUPPORT_PASSWORD_API) && defined(ROAR_HAVE_POPEN) && defined(ROAR_HAVE_PCLOSE)
- FILE * cpipe;
- char   buf[1024];
- int    pos;
- int    i;
-
- if ( pw == NULL )
-  return -1;
-
- if ( (cpipe = popen(_ASKPASS, "r")) == NULL ) {
-  return -1;
- }
-
- if ( fgets(buf, 1024, cpipe) == NULL ) {
-  fclose(cpipe);
-  return -1;
- }
-
- pclose(cpipe);
-
- pos = strlen(buf);
-
- ROAR_DBG("roar_sshaskpass_getpass(pw=%p, desc='%s'): pos=%i", pw, desc, pos);
-
- for (i = pos - 1; i >= 0 && (buf[i] == '\r' || buf[i] == '\n'); i--, pos--) {
-  buf[i] = 0;
- }
-
- ROAR_DBG("roar_sshaskpass_getpass(pw=%p, desc='%s'): pos=%i", pw, desc, pos);
-
- if ( pos == 0 )
-  return -1;
-
- *pw = roar_mm_strdup(buf);
-
- return 0;
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-//ll
Index: libroar/stack.c
===================================================================
--- libroar/stack.c	(revision 6052)
+++ 	(revision )
@@ -1,158 +1,0 @@
-//stack.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static void __free(void * v) {
- roar_mm_free(v);
-}
-
-int roar_stack_new(struct roar_stack * stack) {
- if ( stack == NULL )
-  return -1;
-
- memset(stack, 0, sizeof(struct roar_stack));
-
- stack->flags = ROAR_STACK_FLAG_FREE_DATA;
- stack->free  = __free;
-
- return 0;
-}
-
-struct roar_stack * roar_stack_newalloc(void) {
- struct roar_stack * stack = roar_mm_malloc(sizeof(struct roar_stack));
-
- if ( stack == NULL )
-  return NULL;
-
- if ( roar_stack_new(stack) == -1 ) {
-  roar_mm_free(stack);
-  return NULL;
- }
-
- if ( roar_stack_set_flag(stack, ROAR_STACK_FLAG_FREE_SELF, 0) == -1 ) {
-  roar_mm_free(stack);
-  return NULL;
- }
-
- return stack;
-}
-
-int roar_stack_free(struct roar_stack * stack) {
- int i;
-
- if ( stack == NULL )
-  return -1;
-
- if ( (stack->flags & ROAR_STACK_FLAG_FREE_DATA) && stack->free != NULL ) {
-  for (i = 0; i < stack->next; i++)
-   stack->free(stack->slot[i]);
- }
-
- if ( stack->flags & ROAR_STACK_FLAG_FREE_SELF ) {
-  roar_mm_free(stack);
- } else {
-  memset(stack, 0, sizeof(struct roar_stack)); // just to be sure...
- }
-
- return 0;
-}
-
-int roar_stack_set_free(struct roar_stack * stack, void (*func)(void*)) {
- if ( stack == NULL )
-  return -1;
-
- stack->free = func;
-
- return 0;
-}
-
-int roar_stack_set_flag(struct roar_stack * stack, int flag, int reset) {
- if ( stack == NULL )
-  return -1;
-
- stack->flags  |= flag;
-
- if ( reset )
-  stack->flags -= flag;
-
- return 0;
-}
-
-int roar_stack_push    (struct roar_stack * stack, void *  ptr) {
- if ( stack == NULL )
-  return -1;
-
- if ( stack->next == ROAR_STACK_SIZE ) /* stack is full */
-  return -1;
-
- stack->slot[stack->next++] = ptr;
-
- return 0;
-}
-
-int roar_stack_pop     (struct roar_stack * stack, void ** ptr) {
- if ( stack == NULL ) /* it is valid to have ptr = NULL, */
-  return -1;          /* to just pop a value without want to take it */
-
- if ( ptr != NULL ) /* just to be sure */
-  *ptr = NULL;
-
- if ( stack->next == 0 ) /* nothing in stack */
-  return -1;
-
- stack->next--;
-
- if ( ptr != NULL )
-  *ptr = stack->slot[stack->next];
-
- return 0;
-}
-
-int roar_stack_get_cur (struct roar_stack * stack, void ** ptr) {
- if ( stack == NULL || ptr == NULL )
-  return -1;
-
- *ptr = NULL; /* just to be sure */
-
- if ( stack->next == 0 ) /* nothing in the stack */
-  return -1;
-
- *ptr = stack->slot[stack->next - 1];
-
- return 0;
-}
-
-//ll
Index: libroar/stream.c
===================================================================
--- libroar/stream.c	(revision 6052)
+++ libroar/stream.c	(revision 0)
@@ -1,67 +1,18 @@
 //stream.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroar.h"
 
-int roar_stream_connect(struct roar_connection * con, struct roar_stream * s, int dir, int mixer) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- struct roar_stream  ms;
+int roar_stream_connect (struct roar_connection * con, struct roar_stream * s, int dir) {
  struct roar_message m;
 
  s->dir = dir;
 
- memset(&m,  0, sizeof(m));
- memcpy(&ms, s, sizeof(ms));
-
  m.cmd     = ROAR_CMD_NEW_STREAM;
- m.stream  = mixer;
+ m.stream  = -1;
  m.pos     = 0;
 
- if ( config != NULL ) {
-  if ( config->info.rate )
-   ms.info.rate = config->info.rate;
-  if ( config->info.bits )
-   ms.info.bits = config->info.bits;
-  if ( config->info.channels )
-   ms.info.channels = config->info.channels;
-  if ( config->info.codec )
-   ms.info.codec = config->info.codec;
- }
+ roar_stream_s2m(s, &m);
 
- roar_stream_s2m(&ms, &m);
-
- if ( roar_req3(con, &m, NULL) != 0 )
+ if ( roar_req(con, &m, NULL) != 0 )
   return -1;
 
@@ -81,20 +32,17 @@
                      unsigned int channels, unsigned int bits, unsigned int codec) {
 
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( bits > ROAR_BITS_MAX ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
 
  s->fh         = -1;
  s->id         = -1;
- s->pos        =  0;
+ s->pos        = 0;
  s->pos_rel_id = -1;
 
  s->dir        = ROAR_DIR_DEFAULT;
+
+ s->datalen    = 0;
+ s->offset     = 0;
+
+ s->database   = NULL;
+ s->dataoff    = NULL;
 
  s->info.rate     = rate;
@@ -103,136 +51,12 @@
  s->info.codec    = codec;
 
- return 0;
-}
-
-int roar_stream_new_by_info (struct roar_stream * s, const struct roar_audio_info * info) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
+ if ( bits > ROAR_BITS_MAX )
   return -1;
- }
-
- if ( info->bits > ROAR_BITS_MAX ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- s->fh         = -1;
- s->id         = -1;
- s->pos        =  0;
- s->pos_rel_id = -1;
-
- s->dir        = ROAR_DIR_DEFAULT;
-
- s->info = *info;
 
  return 0;
 }
 
-int roar_stream_set_rel_id(struct roar_stream * s, int id) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- s->pos_rel_id = id;
-
- return 0;
-}
-
-int roar_stream_get_rel_id(struct roar_stream * s) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return s->pos_rel_id;
-}
-
-int roar_stream_new_by_id(struct roar_stream * s, int id) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( roar_stream_new_empty(s) == -1 )
-  return -1;
-
- return roar_stream_set_id(s, id);
-}
-
-int roar_stream_new_empty(struct roar_stream * s) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return roar_stream_new(s, 0, 0, 0, 0);
-}
-
-int roar_stream_set_id (struct roar_stream * s, int id) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- s->id = id;
-
- return 0;
-}
-
-int roar_stream_get_id (struct roar_stream * s) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return s->id;
-}
-
-int roar_stream_set_fh (struct roar_stream * s, int fh) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- s->fh = fh;
-
- return 0;
-}
-
-int roar_stream_get_fh (struct roar_stream * s) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return s->fh;
-}
-
-int roar_stream_set_dir (struct roar_stream * s, int dir) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- s->dir = dir;
-
- return 0;
-}
-
-int roar_stream_get_dir (struct roar_stream * s) {
- if ( s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return s->dir;
-}
-
-
 int roar_stream_exec    (struct roar_connection * con, struct roar_stream * s) {
  struct roar_message m;
-
- memset(&m,  0, sizeof(m));
 
  m.cmd     = ROAR_CMD_EXEC_STREAM;
@@ -249,8 +73,15 @@
 }
 
-int roar_stream_connect_to (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) {
+
+int roar_stream_add_data (struct roar_connection * con, struct roar_stream * s, char * data, size_t len) {
  struct roar_message m;
 
- if ( roar_stream_connect_to_ask(con, s, type, host, port) == -1 )
+ m.cmd     = ROAR_CMD_ADD_DATA;
+ m.stream  = s->id;
+ m.datalen = len;
+
+// if ( roar_req(con, &m, (void**)&data) == -1 )
+//  return -1;
+ if ( roar_send_message(con, &m, data) != 0 )
   return -1;
 
@@ -263,669 +94,4 @@
 }
 
-int roar_stream_connect_to_ask (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) {
- struct roar_message m;
- int len = 0;
-
- if ( host == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- ROAR_DBG("roar_stream_connect_to_ask(*): Ask the server to connect to: %s:%i", host, port);
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_CON_STREAM;
- m.stream  = s->id;
- m.pos     = 0;
-
- m.data[0] = 0;
- m.data[1] = type;
- ((uint16_t*)&(m.data))[1] = ROAR_HOST2NET16(port);
-
- len = strlen(host);
-
- if ( len > 76 ) {
-  roar_err_set(ROAR_ERROR_NAMETOOLONG);
-  return -1;
- }
-
- strncpy(&(m.data[4]), host, len);
-
- m.datalen = len + 4;
-
- if ( roar_send_message(con, &m, NULL) == -1 )
-  return -1;
-
- return 0;
-}
-
-int roar_stream_connect_to_advanced (struct roar_connection * con, struct roar_stream * s,
-                                     int version, int ask_only, uint_least32_t flags,
-                                     int socket_type, ssize_t socket_len, const void * socketaddr,
-                                     int transport_protocol, ssize_t tranport_len, const void * transportsetup,
-                                     uint16_t clientsetup_flags, struct roar_client * clientsetup) {
- struct roar_message m;
- char buf[80];
- int port;
- uint16_t tmp;
-
- if ( con == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( transport_protocol == ROAR_PROTO_NONE && (tranport_len != -1 || transportsetup ) ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( !((s == NULL) ^ (clientsetup == NULL)) ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- switch (version) {
-  case 0:
-    if ( transport_protocol != ROAR_PROTO_NONE || s == NULL) {
-     roar_err_set(ROAR_ERROR_INVAL);
-     return -1;
-    }
-    switch (socket_type) {
-     case ROAR_SOCKET_TYPE_TCP:
-     case ROAR_SOCKET_TYPE_UDP:
-       if ( socket_len != 6 ) {
-        roar_err_set(ROAR_ERROR_FAULT);
-        return -1;
-       }
-       snprintf(buf, sizeof(buf), "%i.%i.%i.%i",
-                ((const unsigned char*)socketaddr)[0], ((const unsigned char*)socketaddr)[1],
-                ((const unsigned char*)socketaddr)[2], ((const unsigned char*)socketaddr)[3]);
-       port = ROAR_NET2HOST16(((const uint16_t*)socketaddr)[3]);
-       if ( roar_stream_connect_to_ask(con, s, socket_type, buf, port) == -1 )
-        return -1;
-      break;
-     case ROAR_SOCKET_TYPE_DECNET:
-       if ( socket_len < 3 ) {
-        roar_err_set(ROAR_ERROR_FAULT);
-        return -1;
-       }
-       tmp  = ((const uint16_t*)socketaddr)[0];
-       port = ((const unsigned char*)socketaddr)[2];
-       snprintf(buf, sizeof(buf), "%i.%i::%*s", tmp >> 10, tmp & 0x03FF, (int)socket_len - 3, (const char*)socketaddr + 3);
-       if ( roar_stream_connect_to_ask(con, s, socket_type, buf, port) == -1 )
-        return -1;
-      break;
-     default:
-       if ( ((const char *)socketaddr)[socket_len-1] == 0 ) {
-        if ( socket_len > sizeof(buf) ) {
-         roar_err_set(ROAR_ERROR_MSGSIZE);
-         return -1;
-        }
-        memcpy(buf, socketaddr, socket_len);
-        if ( roar_stream_connect_to_ask(con, s, socket_type, buf, 0) == -1 )
-         return -1;
-       } else {
-        roar_err_set(ROAR_ERROR_FAULT);
-        return -1;
-       }
-      break;
-    }
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NSVERSION);
-    return -1;
-   break;
- }
-
-
- if ( ask_only )
-  return 0;
-
- if ( roar_recv_message(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd == ROAR_CMD_OK )
-  return 0;
- return -1;
-}
-
-int roar_stream_passfh  (struct roar_connection * con, struct roar_stream * s, int fh) {
- struct roar_message m;
- int confh;
-
- if ( con == NULL || s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( fh < 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_PASSFH;
- m.stream  = s->id;
- m.pos     = 0;
- m.datalen = 0;
-
- ROAR_DBG("roar_stream_passfh(con=%p{...}, s={.id=%i,...}, fh=%i) = ?", con, s->id, fh);
-
- roar_libroar_nowarn();
- if ( (confh = roar_get_connection_fh(con)) == -1 ) {
-  roar_libroar_warn();
-  return -1;
- }
- roar_libroar_warn();
-
- if ( roar_send_message(con, &m, NULL) == -1 ) {
-  ROAR_DBG("roar_stream_passfh(con=%p{...}, s={.id=%i,...}, fh=%i) = -1 // can not send message", con, s->id, fh);
-  return -1;
- }
-
- ROAR_DBG("roar_stream_passfh(*): msg send");
-
- if ( roar_socket_send_fh(confh, fh, NULL, 0) == -1 )
-  return -1;
-
- ROAR_DBG("roar_stream_passfh(*): fh send");
-
- if ( roar_recv_message(con, &m, NULL) == -1 )
-  return -1;
-
- ROAR_DBG("roar_stream_passfh(*): mes recved");
-
- if ( m.cmd == ROAR_CMD_OK )
-  return 0;
-
- return -1;
-}
-
-int roar_stream_attach_simple (struct roar_connection * con, struct roar_stream * s, int client) {
- struct roar_message m;
- uint16_t * info = (uint16_t *) m.data;
- int i;
-
- if ( con == NULL || s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( client < 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_ATTACH;
- m.stream  = s->id;
- m.pos     = 0;
- m.datalen = 6;
-
- info[0] = 0;
- info[1] = ROAR_ATTACH_SIMPLE;
- info[2] = client;
-
- for (i = 0; i < m.datalen/2; i++) {
-  info[i] = ROAR_HOST2NET16(info[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_stream_get_info (struct roar_connection * con, struct roar_stream * s, struct roar_stream_info * info) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
- int i;
-
- if ( con == NULL || s == NULL || info == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_GET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 4;
- m.pos     = 0;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_INFO; // stream
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_NET2HOST16(data[i]);
- }
-
- if ( m.datalen < 7*2 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- if ( data[0] != 0 || data[1] != 1 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- memset(info, 0, sizeof(struct roar_stream_info));
- info->mixer = -1;
- info->role  = ROAR_ROLE_UNKNOWN;
-
- info->block_size     = data[2];
- info->pre_underruns  = data[3];
- info->post_underruns = data[4];
- info->codec          = data[5];
- info->flags          = data[6];
- info->delay          = data[7]*1000;
-
- if ( m.datalen < 9*2 ) {
-  info->state         = ROAR_STREAMSTATE_UNKNOWN;
-  return 0;
- } else {
-  info->state         = data[8];
- }
-
- if ( m.datalen < 10*2 ) {
-  return 0;
- } else {
-  info->flags        |= ((uint32_t)data[9]) << 16;
- }
-
- if ( m.datalen < 11*2 ) {
-  return 0;
- } else {
-  info->mixer         = data[10];
- }
-
- if ( m.datalen < 12*2 ) {
-  return 0;
- } else {
-  info->role          = data[11];
- }
-
- return 0;
-}
-
-int roar_stream_get_name (struct roar_connection * con, struct roar_stream * s, char * name, size_t len) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
-
- if ( con == NULL || s == NULL || name == NULL || len == 0 ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- name[0] = 0; // just in case...
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_GET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 4;
- m.pos     = 0;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_NAME; // stream
-
- data[0] = ROAR_HOST2NET16(data[0]);
- data[1] = ROAR_HOST2NET16(data[1]);
-
- ROAR_DBG("roar_stream_get_name(*) = ?");
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- ROAR_DBG("roar_stream_get_name(*) = ?");
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- ROAR_DBG("roar_stream_get_name(*) = ?");
-
- if ( m.datalen < 4 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- data[0] = ROAR_NET2HOST16(data[0]);
- data[1] = ROAR_NET2HOST16(data[1]);
-
- ROAR_DBG("roar_stream_get_name(*) = ?");
-
- if ( data[0] != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- if ( data[1] != (uint16_t)ROAR_STREAM_PARA_NAME ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- m.datalen -= 4;
-
- len--;
-
- if ( len > m.datalen )
-  len = m.datalen;
-
- strncpy(name, ((char*)m.data)+4, len);
- name[len] = 0;
-
- ROAR_DBG("roar_stream_get_name(*) = 0");
-
- return 0;
-}
-
-int roar_stream_get_chanmap (struct roar_connection * con, struct roar_stream * s, char * map, size_t * len) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p, map=%p, len=%p) = ?", con, s, map, len);
-
- if ( con == NULL || s == NULL || map == NULL || len == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( *len == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- memset(&m, 0, sizeof(m));
-
- m.cmd     = ROAR_CMD_GET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 2*2;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_CHANMAP;
-
- data[0] = ROAR_HOST2NET16(data[0]);
- data[1] = ROAR_HOST2NET16(data[1]);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len);
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len);
-
- if ( m.datalen < 4 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- data[0] = ROAR_NET2HOST16(data[0]);
- data[1] = ROAR_NET2HOST16(data[1]);
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len);
-
- if ( data[0] != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- if ( data[1] != ROAR_STREAM_PARA_CHANMAP ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len);
-
- m.datalen -= 4;
-
- if ( m.datalen > *len ) {
-  roar_err_set(ROAR_ERROR_NOMEM);
-  return -1;
- }
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len);
-
- memcpy(map, &(m.data[4]), m.datalen);
-
- *len = m.datalen;
-
- ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = 0", con, s, s->id, map, len);
- return 0;
-}
-
-int roar_stream_set_chanmap (struct roar_connection * con, struct roar_stream * s, char * map, size_t   len) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
-
- if ( con == NULL || s == NULL || map == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( len == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return 0;
- }
-
- memset(&m, 0, sizeof(m));
-
- m.cmd     = ROAR_CMD_SET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 2*2 + len;
-
- if ( m.datalen > sizeof(m.data) )
-  return -1;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_CHANMAP;
-
- data[0] = ROAR_HOST2NET16(data[0]);
- data[1] = ROAR_HOST2NET16(data[1]);
-
- memcpy(&(m.data[4]), map, len);
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-
-int roar_stream_set_flags (struct roar_connection * con, struct roar_stream * s, uint32_t flags, int action) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
- int i;
-
- if ( con == NULL || s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_SET_STREAM_PARA;
- m.stream  = s->id;
- m.pos     = 0;
-
- if ( flags & 0xFFFF0000 ) {
-  m.datalen = 2*5;
- } else {
-  m.datalen = 2*4;
- }
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_FLAGS; // flags
- data[2] = action;
- data[3] = flags & 0x0000FFFF;
-
- if ( flags & 0xFFFF0000 ) {
-  data[4] = (flags & 0xFFFF0000) >> 16;
- }
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_stream_set_role  (struct roar_connection * con, struct roar_stream * s, int role) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
- int i;
-
- if ( con == NULL || s == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_SET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 6;
- m.pos     = 0;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_ROLE; // flags
- data[2] = role;
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-int roar_stream_get_rpg   (struct roar_connection * con, struct roar_stream * s, struct roar_stream_rpg * rpg) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
- size_t i;
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_GET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = 2*2;
- m.pos     = 0;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_RPG; // flags
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_NET2HOST16(data[i]);
- }
-
- if ( m.datalen != 10 ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- if ( data[0] != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- if ( data[1] != ROAR_STREAM_PARA_RPG ) {
-  roar_err_set(ROAR_ERROR_BADRQC);
-  return -1;
- }
-
- memset(rpg, 0, sizeof(struct roar_stream_rpg));
-
- rpg->mode = data[2];
- rpg->mul  = data[3];
- rpg->div  = data[4];
-
- if ( rpg->mode == 0xFFFF )
-  rpg->mode = -1;
-
- return 0;
-}
-
-int roar_stream_set_rpg   (struct roar_connection * con, struct roar_stream * s, const struct roar_stream_rpg * rpg) {
- struct roar_message m;
- uint16_t * data = (uint16_t *) m.data;
- size_t i;
-
- memset(&m,  0, sizeof(m));
-
- m.cmd     = ROAR_CMD_SET_STREAM_PARA;
- m.stream  = s->id;
- m.datalen = (2+3)*2;
- m.pos     = 0;
-
- data[0] = 0; // Version and reserved
- data[1] = ROAR_STREAM_PARA_RPG; // flags
- data[2] = rpg->mode;
- data[3] = rpg->mul;
- data[4] = rpg->div;
-
- for (i = 0; i < m.datalen/2; i++) {
-  data[i] = ROAR_HOST2NET16(data[i]);
- }
-
- if ( roar_req(con, &m, NULL) == -1 )
-  return -1;
-
- if ( m.cmd != ROAR_CMD_OK )
-  return -1;
-
- return 0;
-}
-
-#ifdef DEBUG
-static inline void _roar_debug_audio_info_print (struct roar_audio_info * info) {
- ROAR_DBG("_roar_debug_audio_info_print(*): Rate    : %i", info->rate);
- ROAR_DBG("_roar_debug_audio_info_print(*): Channels: %i", info->channels);
- ROAR_DBG("_roar_debug_audio_info_print(*): Bits    : %i", info->bits);
- ROAR_DBG("_roar_debug_audio_info_print(*): Codec   : %i", info->codec);
-}
-#endif
 
 #define _ROAR_STREAM_MESSAGE_LEN ((5+1)*4)
@@ -935,8 +101,6 @@
  int i;
 
- if ( s == NULL || m == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
+ if ( !(s && m) )
   return -1;
- }
 
  m->datalen = _ROAR_STREAM_MESSAGE_LEN;
@@ -953,11 +117,6 @@
   data[i] = ROAR_HOST2NET32(data[i]);
 
-#ifdef DEBUG
  ROAR_DBG("roar_stream_s2m(*): s->info:");
- _roar_debug_audio_info_print(&(s->info));
-#endif
-
- m->pos   = s->pos;
- m->pos64 = s->pos;
+ roar_debug_audio_info_print(&s->info);
 
  return 0;
@@ -967,19 +126,9 @@
  int i;
 
- if ( s == NULL || m == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
+ if ( !(s && m) )
   return -1;
- }
 
- if ( m->datalen != _ROAR_STREAM_MESSAGE_LEN ) {
-  roar_err_set(ROAR_ERROR_MSGSIZE);
+ if ( m->datalen != _ROAR_STREAM_MESSAGE_LEN )
   return -1;
- }
-
- if ( m->flags & ROAR_MF_LSPOS ) {
-  s->pos = m->pos64;
- } else {
-  s->pos = m->pos;
- }
 
  data = (uint32_t*) m->data;
@@ -988,5 +137,4 @@
   data[i] = ROAR_NET2HOST32(data[i]);
 
- s->id            = m->stream;
  s->dir           = data[0];
  s->pos_rel_id    = data[1];
@@ -996,503 +144,9 @@
  s->info.codec    = data[5];
 
-#ifdef DEBUG
  ROAR_DBG("roar_stream_m2s(*): s->info:");
- _roar_debug_audio_info_print(&(s->info));
-#endif
+ roar_debug_audio_info_print(&s->info);
 
  return 0;
 }
 
-// stream direction funcs:
-static const struct {
- const int    dir;
- const char * name;
-} _libroar_dir[] = {
- {ROAR_DIR_PLAY,        "play"       },
- {ROAR_DIR_RECORD,      "record"     },
- {ROAR_DIR_MONITOR,     "monitor"    },
- {ROAR_DIR_FILTER,      "filter"     },
- {ROAR_DIR_OUTPUT,      "output"     },
- {ROAR_DIR_MIXING,      "mixing"     },
- {ROAR_DIR_META,        "meta"       },
- {ROAR_DIR_BIDIR,       "bidir"      },
- {ROAR_DIR_THRU,        "thru"       },
- {ROAR_DIR_BRIDGE,      "bridge"     },
- {ROAR_DIR_MIDI_IN,     "midi_in"    },
- {ROAR_DIR_MIDI_OUT,    "midi_out"   },
- {ROAR_DIR_LIGHT_IN,    "light_in"   },
- {ROAR_DIR_LIGHT_OUT,   "light_out"  },
- {ROAR_DIR_RAW_IN,      "raw_in"     },
- {ROAR_DIR_RAW_OUT,     "raw_out"    },
- {ROAR_DIR_COMPLEX_IN,  "complex_in" },
- {ROAR_DIR_COMPLEX_OUT, "complex_out"},
- {ROAR_DIR_RDTCS_IN,    "rdtcs_in"   },
- {ROAR_DIR_RDTCS_OUT,   "rdtcs_out"  },
- {ROAR_DIR_RECPLAY,     "recplay"    },
- {-1,                   "unknown"    }
-};
-
-const char * roar_dir2str (const int dir) {
- int i;
-
- for (i = 0; _libroar_dir[i].dir != -1; i++)
-  if ( _libroar_dir[i].dir == dir )
-   return _libroar_dir[i].name;
-
- return _libroar_dir[i].name;
-}
-
-int roar_str2dir (const char * name) {
- int i;
-
- for (i = 0; _libroar_dir[i].dir != -1; i++)
-  if ( !strcmp(_libroar_dir[i].name, name) )
-   return _libroar_dir[i].dir;
-
- return _libroar_dir[i].dir;
-}
-
-// codec funcs:
-
-/*
-#define roar_codec2str(x) ((x) == ROAR_CODEC_PCM_S_LE  ? "pcm_s_le"  : (x) == ROAR_CODEC_PCM_S_BE  ? "pcm_s_be"  : \
-                           (x) == ROAR_CODEC_PCM_S_PDP ? "pcm_s_pdp" : (x) == ROAR_CODEC_MIDI_FILE ? "midi_file" : \
-                           "unknown" )
-*/
-
-static const struct {
- const uint32_t codec;
- const char   * name;
- const char   * mime;
-} _libroar_codec[] = {
- // PCM:
- {ROAR_CODEC_PCM_S_LE,    "pcm_s_le",    NULL},
- {ROAR_CODEC_PCM_S_BE,    "pcm_s_be",    NULL},
- {ROAR_CODEC_PCM_S_PDP,   "pcm_s_pdp",   NULL},
- {ROAR_CODEC_PCM_U_LE,    "pcm_u_le",    NULL},
- {ROAR_CODEC_PCM_U_BE,    "pcm_u_be",    NULL},
- {ROAR_CODEC_PCM_U_PDP,   "pcm_u_pdp",   NULL},
- {ROAR_CODEC_DEFAULT,     "default",     NULL}, // alias
- {ROAR_CODEC_DEFAULT,     "pcm",         NULL}, // alias
- {ROAR_CODEC_DEFAULT,     "raw",         NULL}, // alias
- {ROAR_CODEC_PCM_S,       "pcm_s",       NULL}, // alias
- {ROAR_CODEC_PCM_U,       "pcm_u",       NULL}, // alias
-
- // MIDI:
- {ROAR_CODEC_MIDI_FILE,   "midi_file",   NULL},
- {ROAR_CODEC_MIDI,        "midi",        NULL},
- {ROAR_CODEC_ROARMIDI,    "roarmidi",    NULL},
-
- // XIPH:
- {ROAR_CODEC_OGG_VORBIS,  "ogg_vorbis",  "application/ogg"},
- {ROAR_CODEC_OGG_VORBIS,  "vorbis",      "application/ogg"}, // alias
- {ROAR_CODEC_FLAC,        "flac",        "audio/x-flac"},
- {ROAR_CODEC_OGG_SPEEX,   "ogg_speex",   "audio/ogg; codecs=speex"},
- {ROAR_CODEC_OGG_SPEEX,   "speex",       "audio/ogg; codecs=speex"}, // alias
- {ROAR_CODEC_OGG_FLAC,    "ogg_flac",    "audio/ogg; codecs=flac"},
- {ROAR_CODEC_OGG_GENERAL, "ogg_general", "application/ogg"},
- {ROAR_CODEC_OGG_CELT,    "ogg_celt",    "audio/ogg; codecs=celt"},
- {ROAR_CODEC_OGG,         "ogg",         "application/ogg"},
- {ROAR_CODEC_OGG_OPUS,    "ogg_opus",    NULL},
- {ROAR_CODEC_ROAR_OPUS,   "roar_opus",   NULL},
- {ROAR_CODEC_ROAR_CELT,   "roar_celt",   NULL},
- {ROAR_CODEC_ROAR_SPEEX,  "roar_speex",  NULL},
-
- // RAUM:
- {ROAR_CODEC_RAUM,        "raum",        NULL},
- {ROAR_CODEC_RAUM_VORBIS, "raum_vorbis", NULL},
- {ROAR_CODEC_RAUM_FLAC,   "raum_flac",   NULL},
-
- // RIFF/WAVE like:
- {ROAR_CODEC_RIFF_WAVE,   "riff_wave",   "audio/x-wav"},
- {ROAR_CODEC_RIFF_WAVE,   "wave",        "audio/x-wav"}, // alias
- {ROAR_CODEC_RIFF_WAVE,   "wav",         "audio/x-wav"}, // alias
- {ROAR_CODEC_RIFX,        "rifx",        NULL},
- {ROAR_CODEC_AU,          "au",          "audio/basic"},
- {ROAR_CODEC_AIFF,        "aiff",        "audio/aiff"},
-
- //Log codecs:
- {ROAR_CODEC_ALAW,        "alaw",        NULL},
- {ROAR_CODEC_AUTLAW_LE,   "autlaw_le",   NULL},
- {ROAR_CODEC_AUTLAW_BE,   "autlaw_be",   NULL},
- {ROAR_CODEC_AUTLAW,      "autlaw",      NULL}, // alias
- {ROAR_CODEC_MULAW,       "mulaw",       NULL},
- {ROAR_CODEC_MULAW,       "ulaw",        NULL}, // alias
- {ROAR_CODEC_MUUTLAW_LE,  "muutlaw_le",  NULL},
- {ROAR_CODEC_MUUTLAW_BE,  "muutlaw_be",  NULL},
- {ROAR_CODEC_MUUTLAW,     "muutlaw",     NULL}, // alias
-
- //GSM:
- {ROAR_CODEC_GSM,         "gsm",         NULL},
- {ROAR_CODEC_GSM49,       "gsm49",       NULL},
-
- //SPC-700 Bit Rate Reduction of
- //Super Nintendo Entertainment System (SNES)
- {ROAR_CODEC_BRR,         "brr",         NULL},
-
- // Meta Codecs:
- {ROAR_CODEC_META_VCLT,     "meta_vclt",     NULL},
- {ROAR_CODEC_META_RALT,     "meta_ralt",     NULL},
- {ROAR_CODEC_META_RALB,     "meta_ralb",     NULL},
- {ROAR_CODEC_META_RALB_LE,  "meta_ralb_le",  NULL},
- {ROAR_CODEC_META_RALB_BE,  "meta_ralb_be",  NULL},
- {ROAR_CODEC_META_RALB_PDP, "meta_ralb_pdp", NULL},
-
- // light control:
- {ROAR_CODEC_DMX512,      "dmx512",      NULL},
- {ROAR_CODEC_ROARDMX,     "roardmx",     NULL},
-
- // Radio Data and Transmitter Control System:
- {ROAR_CODEC_RDS,         "rds",         NULL},
-
- // User specific:
- {ROAR_CODEC_USER0,       "user0",       NULL},
- {ROAR_CODEC_USER1,       "user1",       NULL},
- {ROAR_CODEC_USER2,       "user2",       NULL},
- {ROAR_CODEC_USER3,       "user3",       NULL},
- {ROAR_CODEC_USER4,       "user4",       NULL},
- {ROAR_CODEC_USER5,       "user5",       NULL},
- {ROAR_CODEC_USER6,       "user6",       NULL},
- {ROAR_CODEC_USER7,       "user7",       NULL},
- {ROAR_CODEC_USER8,       "user8",       NULL},
- {ROAR_CODEC_USER9,       "user9",       NULL},
- {ROAR_CODEC_USER10,      "user10",      NULL},
- {ROAR_CODEC_USER11,      "user11",      NULL},
- {ROAR_CODEC_USER12,      "user12",      NULL},
- {ROAR_CODEC_USER13,      "user13",      NULL},
- {ROAR_CODEC_USER14,      "user14",      NULL},
- {ROAR_CODEC_USER15,      "user15",      NULL},
- {-1, NULL, NULL}
-};
-
-int32_t roar_str2codec(const char * codec) {
- size_t i;
- int guess;
-
- if ( codec == NULL || *codec == 0 )
-  return ROAR_CODEC_DEFAULT;
-
- if ( (guess = atoi(codec)) > 0 )
-  return guess;
-
- for (i = 0; _libroar_codec[i].codec != (uint32_t)-1; i++)
-  if ( strcasecmp(_libroar_codec[i].name, codec) == 0 )
-   return _libroar_codec[i].codec;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-
-const char * roar_codec2str (const uint32_t codec) {
- int i;
-
- for (i = 0; _libroar_codec[i].codec != (uint32_t)-1; i++)
-  if ( _libroar_codec[i].codec == codec )
-   return _libroar_codec[i].name;
-
- return "unknown";
-}
-
-int32_t  roar_mime2codec (const char * mime) {
- size_t i;
-
- if ( mime == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( *mime == 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- for (i = 0; _libroar_codec[i].codec != (uint32_t)-1; i++)
-  if ( _libroar_codec[i].mime != NULL )
-   if ( strcasecmp(_libroar_codec[i].mime, mime) == 0 )
-    return _libroar_codec[i].codec;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-const char * roar_codec2mime (const uint32_t   codec) {
- size_t i;
-
- for (i = 0; _libroar_codec[i].codec != (uint32_t)-1; i++)
-  if ( _libroar_codec[i].codec == codec )
-   return _libroar_codec[i].mime;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int32_t roar_str2rate(const char * rate) {
- struct roar_audio_info info;
- int ret;
-
- if ( roar_profile2info(&info, rate) != -1 ) {
-  return info.rate;
- }
-
- ret = atoi(rate);
-
- if ( ret == 0 && rate[0] != '0' ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- return ret;
-}
-
-int32_t roar_str2bits(const char * bits) {
- struct roar_audio_info info;
- int ret;
-
- if ( roar_profile2info(&info, bits) != -1 ) {
-  return info.bits;
- }
-
- ret = atoi(bits);
-
- if ( ret == 0 && bits[0] != '0' ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- return ret;
-}
-
-int32_t roar_str2channels(const char * channels) {
- struct roar_audio_info info;
- int ret;
-
- if ( !strcasecmp(channels, "mono") ) {
-  return 1;
- } else if ( !strcasecmp(channels, "stereo") ) {
-  return 2;
- }
-
- if ( roar_profile2info(&info, channels) != -1 ) {
-  return info.channels;
- }
-
- ret = atoi(channels);
-
- if ( ret == 0 && channels[0] != '0' ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- return ret;
-}
-
-
-const char * roar_streamstate2str(int streamstate) {
- switch (streamstate) {
-  case ROAR_STREAMSTATE_UNUSED:  return "unused";  break;
-  case ROAR_STREAMSTATE_INITING: return "initing"; break;
-  case ROAR_STREAMSTATE_NEW:     return "new";     break;
-  case ROAR_STREAMSTATE_OLD:     return "old";     break;
-  case ROAR_STREAMSTATE_CLOSING: return "closing"; break;
- }
-
- return "unknown";
-}
-
-static const struct {
- int    role;
- const char * name;
-} _libroar_role[] = {
- {ROAR_ROLE_UNKNOWN,          "unknown"         },
- {ROAR_ROLE_NONE,             "none"            },
- {ROAR_ROLE_MUSIC,            "music"           },
- {ROAR_ROLE_VIDEO,            "video"           },
- {ROAR_ROLE_GAME,             "game"            },
- {ROAR_ROLE_EVENT,            "event"           },
- {ROAR_ROLE_BEEP,             "beep"            },
- {ROAR_ROLE_PHONE,            "phone"           },
- {ROAR_ROLE_BACKGROUND_MUSIC, "background music"},
- {ROAR_ROLE_BACKGROUND_MUSIC, "background_music"}, // alias
- {ROAR_ROLE_VOICE,            "voice"           },
- {ROAR_ROLE_INSTRUMENT,       "instrument"      },
- {ROAR_ROLE_RHYTHM,           "rhythm"          },
- {ROAR_ROLE_CLICK,            "click",          },
- {ROAR_ROLE_MIXED,            "mixed",          },
- {-1, NULL}
-};
-
-int    roar_str2role  (const char * role) {
- int i;
-
- roar_err_clear();
-
- for (i = 0; _libroar_role[i].name != NULL; i++)
-  if ( !strcasecmp(_libroar_role[i].name, role) )
-   return _libroar_role[i].role;
-
- roar_err_set(ROAR_ERROR_NOENT);
- return ROAR_ROLE_UNKNOWN;
-}
-
-const char * roar_role2str  (const int    role) {
- int i;
-
- for (i = 0; _libroar_role[i].name != NULL; i++)
-  if ( _libroar_role[i].role == role )
-   return _libroar_role[i].name;
-
- return "unknown";
-}
-
-const char * roar_rpgmode2str(const int rpgmode) {
- switch (rpgmode) {
-  case ROAR_RPGMODE_DEFAULT:    return "default"; break;
-  case ROAR_RPGMODE_NONE:       return "none"; break;
-  case ROAR_RPGMODE_USER:       return "user"; break;
-  case ROAR_RPGMODE_ALBUM:      return "album"; break;
-  case ROAR_RPGMODE_TRACK:      return "track"; break;
-  case ROAR_RPGMODE_ALBUMTRACK: return "albumtrack"; break;
-  case ROAR_RPGMODE_TRACKALBUM: return "trackalbum"; break;
-  default:
-    roar_err_set(ROAR_ERROR_NOENT);
-    return NULL;
-   break;
- }
-}
-
-ssize_t roar_info2samplesize (struct roar_audio_info * info) {
- if ( info == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-  case ROAR_CODEC_PCM_S_BE:
-  case ROAR_CODEC_PCM_S_PDP:
-  case ROAR_CODEC_PCM_U_LE:
-  case ROAR_CODEC_PCM_U_BE:
-  case ROAR_CODEC_PCM_U_PDP:
-    return info->bits;
-   break;
-  case ROAR_CODEC_ALAW:
-  case ROAR_CODEC_MULAW:
-    return 8;
-   break;
-  case ROAR_CODEC_DMX512:
-    return 8;
-   break;
-  case ROAR_CODEC_RDS:
-    return 26;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_INVAL);
-    return -1;
-   break;
- }
-}
-
-ssize_t roar_info2framesize  (struct roar_audio_info * info) {
- ssize_t ret = roar_info2samplesize(info);
-
- if ( ret == -1 )
-  return -1;
-
- ret *= info->channels;
-
- return ret;
-}
-
-ssize_t roar_info2bitspersec(struct roar_audio_info * info) {
- ssize_t ret = roar_info2samplesize(info);
-
- if ( ret == -1 )
-  return -1;
-
- ret *= info->channels * info->rate;
-
- return ret;
-}
-
-static const struct {
- const char * name;
- struct roar_audio_info info;
-} _libroar_aiprofiles[] = {
- {"default",   {.rate     = ROAR_RATE_DEFAULT,
-                .bits     = ROAR_BITS_DEFAULT,
-                .channels = ROAR_CHANNELS_DEFAULT,
-                .codec    = ROAR_CODEC_DEFAULT}},
- {"default-server",
-               {.rate     = ROAR_RATE_DEFAULT,
-                .bits     = ROAR_ROARD_BITS,
-                .channels = ROAR_CHANNELS_DEFAULT,
-                .codec    = ROAR_CODEC_DEFAULT}},
- {"wav",       {.rate     = ROAR_RATE_DEFAULT,
-                .bits     = ROAR_BITS_DEFAULT,
-                .channels = ROAR_CHANNELS_DEFAULT,
-                .codec    = ROAR_CODEC_RIFF_WAVE}},
- {"au",        {.rate     = ROAR_RATE_DEFAULT,
-                .bits     = ROAR_BITS_DEFAULT,
-                .channels = ROAR_CHANNELS_DEFAULT,
-                .codec    = ROAR_CODEC_AU}},
- {"cd",        {.rate =  44100, .bits = 16, .channels =  2, .codec = ROAR_CODEC_DEFAULT}},
- {"cdr",       {.rate =  44100, .bits = 16, .channels =  2, .codec = ROAR_CODEC_PCM_S_BE}},
- {"dat",       {.rate =  48000, .bits = 16, .channels =  2, .codec = ROAR_CODEC_PCM_S_LE}},
- {"isdn-eu",   {.rate =   8000, .bits =  8, .channels =  1, .codec = ROAR_CODEC_ALAW}},
- {"isdn-na",   {.rate =   8000, .bits =  8, .channels =  1, .codec = ROAR_CODEC_MULAW}},
- {"speex-nb",  {.rate =   8000, .bits = 16, .channels =  2, .codec = ROAR_CODEC_ROAR_SPEEX}},
- {"speex-wb",  {.rate =  16000, .bits = 16, .channels =  2, .codec = ROAR_CODEC_ROAR_SPEEX}},
- {"speex-uwb", {.rate =  32000, .bits = 16, .channels =  2, .codec = ROAR_CODEC_ROAR_SPEEX}},
- {"ogg-vorbis",{.rate =  44100, .bits = 16, .channels =  2, .codec = ROAR_CODEC_OGG_VORBIS}},
- {"gsm",       {.rate =   8000, .bits = 16, .channels =  1, .codec = ROAR_CODEC_GSM}},
- {"brr",       {.rate =   8000, .bits = 32, .channels =  1, .codec = ROAR_CODEC_BRR}},
- {"brr6k",     {.rate =   6000, .bits = 32, .channels =  1, .codec = ROAR_CODEC_BRR}},
- {"rds",       {.rate =      0, .bits =  0, .channels =  0, .codec = ROAR_CODEC_RDS}},
- {"midi",      {.rate =      0, .bits =  8, .channels = 16, .codec = ROAR_CODEC_MIDI}},
- {"dmx512",    {.rate =      0, .bits =  8, .channels =  0, .codec = ROAR_CODEC_DMX512}},
- {NULL,        {.rate =      0, .bits =  0, .channels =  0, .codec = 0}}
-};
-
-int     roar_profile2info    (struct roar_audio_info * info, const char * profile) {
- int i;
-
- if ( info == NULL || profile == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; _libroar_aiprofiles[i].name != NULL; i++) {
-  if ( !strcasecmp(_libroar_aiprofiles[i].name, profile) ) {
-   memcpy(info, &(_libroar_aiprofiles[i].info), sizeof(struct roar_audio_info));
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-ssize_t   roar_profiles_list   (const char ** list, size_t len, size_t offset) {
- size_t i;
- ssize_t idx = 0;
-
- if ( list == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( len == 0 )
-  return 0;
-
- if ( offset >= (sizeof(_libroar_aiprofiles)/sizeof(*_libroar_aiprofiles)) )
-  return 0;
-
- for (i = offset; idx < len && _libroar_aiprofiles[i].name != NULL; i++) {
-  list[idx++] = _libroar_aiprofiles[i].name;
- }
-
- return idx;
-}
-
 //ll
Index: libroar/time.c
===================================================================
--- libroar/time.c	(revision 6052)
+++ 	(revision )
@@ -1,199 +1,0 @@
-//time.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_H_SYS_TIME
-#include <sys/time.h>
-#endif
-#ifdef ROAR_HAVE_H_TIME
-#include <time.h>
-#endif
-
-int roar_time_to_msg(struct roar_message * mes,  struct roar_time    * time) {
- uint64_t * data;
-
- if ( mes == NULL || time == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(mes, 0, sizeof(struct roar_message));
-
- data = (uint64_t*)mes->data;
-
- data[0] = ROAR_HOST2NET64(0);
- data[1] = ROAR_HOST2NET64(time->t_sec);
- data[2] = ROAR_HOST2NET64(time->t_ssec);
- data[3] = ROAR_HOST2NET64(time->c_freq);
- data[4] = ROAR_HOST2NET64(time->c_drift);
-
- mes->datalen = 5*8;
-
- if ( time->c_drift == 0 ) {
-  mes->datalen -= 8;
-  if ( time->c_freq == 0 ) {
-   mes->datalen -= 8;
-   if ( time->t_ssec == 0 ) {
-    mes->datalen -= 8;
-   }
-  }
- }
-
- return 0;
-}
-
-int roar_time_from_msg(struct roar_time  * time, struct roar_message * mes) {
- uint64_t * data;
-
- if ( mes == NULL || time == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- data = (uint64_t*)mes->data;
-
- if ( mes->datalen < 8 ) {
-  roar_err_set(ROAR_ERROR_BADMSG);
-  return -1;
- }
-
- if ( mes->datalen % 8 ) {
-  roar_err_set(ROAR_ERROR_BADMSG);
-  return -1;
- }
-
- if ( ROAR_NET2HOST64(data[0]) != 0 ) {
-  roar_err_set(ROAR_ERROR_NSVERSION);
-  return -1;
- }
-
- memset(time, 0, sizeof(struct roar_time));
-
- if ( mes->datalen >= 16 ) {
-  time->t_sec = ROAR_NET2HOST64(data[1]);
-  if ( mes->datalen >= 24 ) {
-   time->t_ssec = ROAR_NET2HOST64(data[2]);
-   if ( mes->datalen >= 32 ) {
-    time->c_freq = ROAR_NET2HOST64(data[3]);
-    if ( mes->datalen >= 40 ) {
-     time->c_drift = ROAR_NET2HOST64(data[4]);
-    }
-   }
-  }
- }
-
- return 0;
-}
-
-int roar_get_time  (struct roar_connection * con, struct roar_time * time) {
- struct roar_message mes;
-
- if ( con == NULL || time == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(&mes, 0, sizeof(mes));
-
- mes.cmd     = ROAR_CMD_GETTIMEOFDAY;
- mes.stream  = -1;
- mes.datalen = 8; /* 64 bit */
- // mes.data is already cleared.
-
- if ( roar_req(con, &mes, NULL) == -1 )
-  return -1;
-
- if ( mes.cmd != ROAR_CMD_OK ) {
-  return -1;
- }
-
- if ( roar_time_from_msg(time, &mes) == -1 )
-  return -1;
-
- return 0;
-}
-
-int roar_clock_gettime(struct roar_time * rt, int clock) {
-#ifdef ROAR_HAVE_GETTIMEOFDAY
- struct timeval tv;
-#elif defined(ROAR_HAVE_TIME)
- time_t now;
-#endif
-
- ROAR_DBG("roar_clock_gettime(rt=%p, clock=%i) = ?", rt, clock);
-
- if ( rt == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(rt, 0, sizeof(struct roar_time));
-
- if ( clock == ROAR_CLOCK_DEFAULT )
-  clock = ROAR_CLOCK_REALTIME;
-
- switch (clock) {
-  case ROAR_CLOCK_REALTIME:
-    ROAR_DBG("roar_clock_gettime(rt=%p, clock=(%i)ROAR_CLOCK_REALTIME) = ?", rt, clock);
-#ifdef ROAR_HAVE_GETTIMEOFDAY
-    if ( gettimeofday(&tv, NULL) == -1 ) {
-     roar_err_from_errno();
-     ROAR_DBG("roar_clock_gettime(rt=%p, clock=(%i)ROAR_CLOCK_REALTIME) = -1 //error=%i", rt, clock, roar_error);
-     return -1;
-    }
-    rt->t_sec  = tv.tv_sec;
-    rt->t_ssec = (uint64_t)tv.tv_usec * (uint64_t)18446744073709ULL;
-    rt->c_freq = 1000000LLU*1000000000LLU;
-#elif defined(ROAR_HAVE_TIME)
-    now = time(NULL);
-    rt->t_sec  = now;
-    rt->c_freq = 1000000000LLU;
-#else
-    ROAR_DBG("roar_clock_gettime(rt=%p, clock=(%i)ROAR_CLOCK_REALTIME) = -1 // error=NOTSUP", rt, clock);
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-#endif
-    ROAR_DBG("roar_clock_gettime(rt=%p, clock=(%i)ROAR_CLOCK_REALTIME) = 0", rt, clock);
-    return 0;
-   break;
- }
-
- ROAR_DBG("roar_clock_gettime(rt=%p, clock=%i) = -1 // error=NOTSUP", rt, clock);
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-}
-
-//ll
Index: libroar/trap.c
===================================================================
--- libroar/trap.c	(revision 6052)
+++ 	(revision )
@@ -1,141 +1,0 @@
-//*.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static struct _group {
- unsigned int id;
- const char * name;
-} _libroar_trap_groups[] = {
- {ROAR_TRAP_GROUP_LIBROAR, "libroar"},
- {ROAR_TRAP_GROUP_ROARD,   "roard"},
- {ROAR_TRAP_GROUP_APP,     "app"},
- {ROAR_TRAP_GROUP_LIB,     "lib"},
- {ROAR_TRAP_GROUP_NETWORK, "network"},
- {ROAR_TRAP_GROUP_PROTO,   "proto"},
- {-1, NULL}
-};
-
-unsigned int roar_trap_register_group(const char * name) {
- static unsigned int state = ROAR_TRAP_GROUP_USER_MIN;
- unsigned int ret;
- size_t i;
-
- for (i = 0;
-      i < (sizeof(_libroar_trap_groups)/sizeof(*_libroar_trap_groups)) && _libroar_trap_groups[i].id != (unsigned int)-1;
-      i++);
- if ( i == (sizeof(_libroar_trap_groups)/sizeof(*_libroar_trap_groups)) )
-  return -1;
-
- ret = state++;
- _libroar_trap_groups[i].id   = ret;
- _libroar_trap_groups[i].name = name;
-
- return ret;
-}
-
-const char * roar_trap_get_groupname(const unsigned int group) {
- size_t i;
-
- for (i = 0;
-      i < (sizeof(_libroar_trap_groups)/sizeof(*_libroar_trap_groups)) && _libroar_trap_groups[i].id != (unsigned int)-1;
-      i++) {
-  if ( _libroar_trap_groups[i].id == group )
-   return _libroar_trap_groups[i].name;
- }
-
- return NULL;
-}
-
-unsigned int roar_trap_get_groupid(const char * name) {
- size_t i;
-
- for (i = 0;
-      i < (sizeof(_libroar_trap_groups)/sizeof(*_libroar_trap_groups)) && _libroar_trap_groups[i].id != (unsigned int)-1;
-      i++) {
-  if ( !strcasecmp(_libroar_trap_groups[i].name, name) )
-   return _libroar_trap_groups[i].id;
- }
-
- return -1;
-}
-
-void roar_strap_impl(const unsigned int group, const char * name, unsigned int line, const char * file, const char * prefix) {
-#ifdef ROAR_SUPPORT_TRAP
- struct roar_libroar_config * config = roar_libroar_get_config();
- enum roar_trap_policy policy = config->trap_policy;
-
- // need to search for the correct policy for this specific trap.
-
- switch (policy) {
-  case ROAR_TRAP_IGNORE:
-    return;
-   break;
-  case ROAR_TRAP_WARN:
-    ROAR_DBG("roar_strap_impl(group=%u(\"%s\"), name='%s', line=%u, file='%s') = (void)",
-               group, roar_trap_get_groupname(group), name, line, file);
-    roar_debug_msg(ROAR_DEBUG_TYPE_WARNING, line, file, prefix, "Trap %s of group %s.",
-                   name, roar_trap_get_groupname(group));
-   break;
-  case ROAR_TRAP_ABORT:
-    abort();
-   break;
-#ifdef SIGKILL
-  case ROAR_TRAP_KILL:
-    raise(SIGKILL);
-   break;
-#endif
-#ifdef SIGSTOP
-  case ROAR_TRAP_STOP:
-    raise(SIGSTOP);
-   break;
-#endif
-  case ROAR_TRAP_DIE:
-    roar_debug_msg(ROAR_DEBUG_TYPE_WARNING, line, file, prefix, "Trap %s of group %s, terminating program.",
-                   name, roar_trap_get_groupname(group));
-#ifdef SIGKILL
-    raise(SIGKILL);
-#else
-    abort();
-#endif
-   break;
- }
-#else
- (void)group, (void)name, (void)line, (void)file, (void)prefix;
- return;
-#endif
-}
-
-//ll
Index: libroar/uuid.c
===================================================================
--- libroar/uuid.c	(revision 6052)
+++ 	(revision )
@@ -1,170 +1,0 @@
-//uuid.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_uuid_eq(const roar_uuid_t a, const roar_uuid_t b) {
- if ( a == NULL || b == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( memcmp(a, b, sizeof(roar_uuid_t)) == 0 )
-  return 1;
-
- return 0;
-}
-
-int roar_uuid2str(char * str, const roar_uuid_t uuid, ssize_t len) {
- if ( str == NULL || uuid == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( len < 1 ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- snprintf(str, len, "%.2x%.2x%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x%.2x%.2x%.2x%.2x",
-          uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
-          uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]
-         );
-
- return 0;
-}
-
-int roar_str2uuid(roar_uuid_t uuid, const char * str) {
- unsigned int inbuf[16];
- int i;
-
- if ( sscanf(str, "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
-             &(inbuf[0]), &(inbuf[1]), &(inbuf[2]), &(inbuf[3]), &(inbuf[4]), &(inbuf[5]),
-             &(inbuf[6]), &(inbuf[7]), &(inbuf[8]), &(inbuf[9]), &(inbuf[10]), &(inbuf[11]),
-             &(inbuf[12]), &(inbuf[13]), &(inbuf[14]), &(inbuf[15])) != 16 ) {
-  roar_err_set(ROAR_ERROR_ILLSEQ);
-  return -1;
- }
-
- for (i = 0; i < 16; i++)
-  uuid[i] = inbuf[i];
-
- return 0;
-}
-
-const roar_uuid_t * roar_uuid_get_ns_real(const char * ns) {
- static const roar_uuid_t
-  nulluuid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
-  dns      = {0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8},
-  url      = {0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8},
-  oid      = {0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8},
-  x500     = {0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8};
- static const void * null_ptr = NULL;
-
- if ( ns == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return (const roar_uuid_t *)&null_ptr;
- }
-
- if ( !strcasecmp(ns, "null") ) {
-  return &nulluuid;
- } else if ( !strcasecmp(ns, "dns") ) {
-  return &dns;
- } else if ( !strcasecmp(ns, "url") ) {
-  return &url;
- } else if ( !strcasecmp(ns, "iso oid") || !strcasecmp(ns, "oid") ) {
-  return &oid;
- } else if ( !strcasecmp(ns, "X.500 DN") || !strcasecmp(ns, "X500 DN") || !strcasecmp(ns, "x500") ) {
-  return &x500;
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return (const roar_uuid_t *)&null_ptr;
-}
-
-int roar_uuid_gen(roar_uuid_t uuid, enum roar_uuid_type type, const roar_uuid_t ns, const void * argp, ssize_t arglen) {
- unsigned char digest[20];
-
- if ( uuid == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- switch (type) {
-  case ROAR_UUID_TYPE_NULL:
-    memset(uuid, 0, sizeof(roar_uuid_t));
-    return 0;
-   break;
-  case ROAR_UUID_TYPE_RANDOM:
-    roar_random_gen_nonce(uuid, sizeof(roar_uuid_t));
-    uuid[6] = (uuid[8] & 0x0F) | 0x40; // Version
-    uuid[8] = (uuid[8] & 0x3F) | 0x80; // Variant
-    return 0;
-   break;
-  case ROAR_UUID_TYPE_MD5:
-  case ROAR_UUID_TYPE_SHA1:
-    if ( ns == NULL || argp == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    if ( arglen < 1 ) {
-     roar_err_set(ROAR_ERROR_INVAL);
-     return -1;
-    }
-
-    if ( roar_hash_salted_buffer(digest, ns, sizeof(roar_uuid_t),
-                                 type == ROAR_UUID_TYPE_MD5 ? ROAR_HT_MD5 : ROAR_HT_SHA1,
-                                 argp, arglen) == -1 )
-     return -1;
-
-    memcpy(uuid, digest, sizeof(roar_uuid_t));
-    uuid[6] = (uuid[8] & 0x0F) | (type << 4); // Version
-    uuid[8] = (uuid[8] & 0x3F) | 0x80; // Variant
-
-    return 0;
-   break;
-  case ROAR_UUID_TYPE_DCE_SECURITY:
-  case ROAR_UUID_TYPE_TIME:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-//ll
Index: libroar/vio.c
===================================================================
--- libroar/vio.c	(revision 6052)
+++ 	(revision )
@@ -1,840 +1,0 @@
-//vio.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#define _LIBROAR_NOATTR_TO_STATIC /* ignore warnings for TO_STATIC functions */
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_H_SYS_IOCTL
-#include <sys/ioctl.h>
-#endif
-
-#ifdef ROAR_HAVE_IO_POSIX
-#define _CAN_OPERATE
-#endif
-
-int roar_vio_clear_calls (struct roar_vio_calls * calls) {
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset((void*)calls, 0, sizeof(struct roar_vio_calls));
- calls->flags = ROAR_VIO_FLAGS_NONE;
- calls->refc  = 1;
-
- return 0;
-}
-
-static int roar_vio_get_fh   (struct roar_vio_calls * vio) {
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return ((int)(ROAR_INSTINT)vio->inst) - 1;
-}
-
-
-ssize_t roar_vio_read (struct roar_vio_calls * vio, void *buf, size_t count) {
- ssize_t ret;
-
- ROAR_DBG("roar_vio_read(vio=%p, buf=%p, count=%u) = ?", vio, buf, (unsigned int)count);
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->read == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- roar_err_clear_all();
- ret = vio->read(vio, buf, count);
- roar_err_update();
-
- return ret;
-}
-
-ssize_t roar_vio_write(struct roar_vio_calls * vio, void *buf, size_t count) {
- ssize_t ret;
-
- // This function MUST NOT call ROAR_{DBG,WARN,ERR,INFO}() because that would result
- // in an infinit loop.
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->write == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- roar_err_clear_all();
- ret = vio->write(vio, buf, count);
- roar_err_update();
-
- return ret;
-}
-
-roar_off_t   roar_vio_lseek(struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- roar_off_t ret;
-
- ROAR_DBG("roar_vio_lseek(vio=%p, offset=%li, whence=%i) = ?", vio, (long int)offset, whence);
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->lseek == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- roar_err_clear_all();
- ret = vio->lseek(vio, offset, whence);
- roar_err_update();
-
- return ret;
-}
-
-int     roar_vio_nonblock(struct roar_vio_calls * vio, int state) {
- ROAR_DBG("roar_vio_nonblock(vio=%p, state=%i) = ?", vio, state);
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return roar_vio_ctl(vio, ROAR_VIO_CTL_NONBLOCK, &state);
-}
-
-int     roar_vio_sync    (struct roar_vio_calls * vio) {
- int ret;
-
- // This function MUST NOT call ROAR_{DBG,WARN,ERR,INFO}() because that would result
- // in an infinit loop.
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->sync == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- roar_err_clear_all();
- ret = vio->sync(vio);
- roar_err_update();
-
- return ret;
-}
-
-int     roar_vio_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- int ret;
-
- ROAR_DBG("roar_vio_ctl(vio=%p, cmd=%i(0x%.8x), data=%p) = ?", vio, cmd, cmd, data);
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_ctl(vio=%p, cmd=0x%.8x, data=%p): vio->ctl=%p", vio, cmd, data, vio->ctl);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_CONFLICTING_ID_0:
-  case ROAR_VIO_CTL_CONFLICTING_ID_1:
-    ROAR_ERR("roar_vio_ctl(vio=%p, cmd=0x%.8x, data=%p): Your progam uses a VIO ctl call with a conflicting ID.", vio, cmd, data);
-    ROAR_ERR("roar_vio_ctl(vio=%p, cmd=0x%.8x, data=%p): Please recompile your program to fix this. (No additional steps are required beside that.)", vio, cmd, data);
-    ROAR_DBG("roar_vio_ctl(vio=%p, cmd=0x%.8x, data=%p) = -1", vio, cmd, data);
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
- }
-
- if ( vio->ctl == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- roar_err_clear_all();
- ret = vio->ctl(vio, cmd, data);
- roar_err_update();
-
- return ret;
-}
-
-
-int     roar_vio_ref      (struct roar_vio_calls * vio) {
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- vio->refc++;
-
- return 0;
-}
-
-int     roar_vio_unref    (struct roar_vio_calls * vio) {
- int ret;
- int err;
-
- ROAR_DBG("roar_vio_unref(vio=%p) = ?", vio);
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->refc == 1 && vio->close == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- vio->refc--;
-
- if ( vio->refc )
-  return 0;
-
- roar_err_clear_all();
- ret = vio->close(vio);
- roar_err_update();
-
- err = roar_error;
-
- if ( vio->flags & ROAR_VIO_FLAGS_FREESELF ) {
-  roar_vio_clear_calls(vio);
-  roar_mm_free(vio);
- } else {
-  roar_vio_clear_calls(vio);
- }
-
- roar_error = err;
- return ret;
-}
-
-// special commands:
-int     roar_vio_accept  (struct roar_vio_calls * calls, struct roar_vio_calls * dst) {
- if (dst == NULL || calls == NULL) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return roar_vio_ctl(dst, ROAR_VIO_CTL_ACCEPT, calls);
-}
-
-int     roar_vio_shutdown(struct roar_vio_calls * vio,   int how) {
- if (vio == NULL) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( ( (how | ROAR_VIO_SHUTDOWN_READ|ROAR_VIO_SHUTDOWN_WRITE|ROAR_VIO_SHUTDOWN_LISTEN) -
-        (ROAR_VIO_SHUTDOWN_READ|ROAR_VIO_SHUTDOWN_WRITE|ROAR_VIO_SHUTDOWN_LISTEN) ) != 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- return roar_vio_ctl(vio, ROAR_VIO_CTL_SHUTDOWN, &how);
-}
-
-// converters:
-int     roar_vio_open_fh       (struct roar_vio_calls * calls, int fh) {
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset((void*)calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- calls->read     = roar_vio_basic_read;
- calls->write    = roar_vio_basic_write;
- calls->lseek    = roar_vio_basic_lseek;
- calls->sync     = roar_vio_basic_sync;
- calls->ctl      = roar_vio_basic_ctl;
- calls->close    = roar_vio_basic_close;
-
- calls->inst     = (void*)(ROAR_INSTINT)(fh + 1);
-
- return 0;
-}
-
-int     roar_vio_open_fh_socket(struct roar_vio_calls * calls, int fh) {
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( roar_vio_open_fh(calls, fh) == -1 )
-  return -1;
-
-#ifdef ROAR_TARGET_WIN32
- calls->read     = roar_vio_winsock_read;
- calls->write    = roar_vio_winsock_write;
- calls->sync     = roar_vio_winsock_sync;
- calls->ctl      = roar_vio_winsock_ctl;
- calls->close    = roar_vio_winsock_close;
-#else
- calls->sync     = roar_vio_null_sync;
-#endif
-
- return 0;
-}
-
-int     roar_vio_open_socket   (struct roar_vio_calls * calls, const char * host, int port) {
- int fh;
-
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (fh = roar_socket_connect(ROAR_SOCKET_TYPE_UNKNOWN, host, port)) == -1 )
-  return -1;
-
- return roar_vio_open_fh_socket(calls, fh);
-}
-
-int     roar_vio_open_socket_listen(struct roar_vio_calls * calls, int type, const char * host, int port) {
- int fh;
-
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (fh = roar_socket_listen(type, host, port)) == -1 )
-  return -1;
-
- return roar_vio_open_fh_socket(calls, fh);
-}
-
-
-// VIOs:
-
-// basic
-ssize_t roar_vio_basic_read (struct roar_vio_calls * vio, void *buf, size_t count) {
-#ifdef _CAN_OPERATE
- return read(roar_vio_get_fh(vio), buf, count);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-ssize_t roar_vio_basic_write(struct roar_vio_calls * vio, void *buf, size_t count) {
-#ifdef _CAN_OPERATE
- return write(roar_vio_get_fh(vio), buf, count);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-roar_off_t   roar_vio_basic_lseek(struct roar_vio_calls * vio, roar_off_t offset, int whence) {
-#ifdef _CAN_OPERATE
- return lseek(roar_vio_get_fh(vio), offset, whence);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-int     roar_vio_basic_sync    (struct roar_vio_calls * vio) {
-#ifdef ROAR_FDATASYNC
- return ROAR_FDATASYNC(roar_vio_get_fh(vio));
-#else
- return 0;
-#endif
-}
-
-int     roar_vio_basic_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
-#ifdef ROAR_HAVE_H_SYS_IOCTL
- struct roar_vio_sysio_ioctl * sysioctl;
-#endif
-#if defined(ROAR_HAVE_GETSOCKOPT) || defined(ROAR_HAVE_SETSOCKOPT)
- struct roar_vio_sysio_sockopt  * syssockopt;
-#endif
- int tmp;
- int s_r = 0, s_w = 0;
-#if defined(ROAR_HAVE_GETSOCKNAME) || defined(ROAR_HAVE_GETPEERNAME)
- union {
-  struct sockaddr     sa;
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
-  struct sockaddr_in  in;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  struct sockaddr_un  un;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  struct sockaddr_dn  dn;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  struct sockaddr_in6 in6;
-#endif
-#ifdef ROAR_HAVE_IPX
-  struct sockaddr_ipx ipx;
-#endif
- } sockaddr;
- socklen_t socklen;
- struct roar_sockname * rsockname;
-#endif
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( cmd == -1 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_basic_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    *(char**)data = "basic";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-    ROAR_DBG("roar_vio_basic_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_*FH(0x%.8x), data=%p) = 0 // fh=%i", vio, cmd, data, roar_vio_get_fh(vio));
-    *(int*)data = roar_vio_get_fh(vio);
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NOSYNC:
-    vio->sync = NULL;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_ACCEPT:
-#ifdef ROAR_HAVE_ACCEPT
-    tmp = ROAR_ACCEPT(roar_vio_get_fh(vio), NULL, 0);
-    if ( tmp == -1 )
-     return -1;
-
-    // most proably a socket.
-    if ( roar_vio_open_fh_socket(data, tmp) == -1 ) {
-#ifdef ROAR_TARGET_WIN32
-     closesocket(tmp);
-#else
-     close(tmp);
-#endif
-     return -1;
-    }
-
-    return 0;
-#else
-    roar_err_set(ROAR_ERROR_NOSYS);
-    return -1;
-#endif
-   break;
-  case ROAR_VIO_CTL_SHUTDOWN:
-    tmp = *(int*)data;
-
-    if ( tmp & ROAR_VIO_SHUTDOWN_READ ) {
-     s_r = 1;
-     tmp -= ROAR_VIO_SHUTDOWN_READ;
-    }
-
-    if ( tmp & ROAR_VIO_SHUTDOWN_WRITE ) {
-     s_w = 1;
-     tmp -= ROAR_VIO_SHUTDOWN_WRITE;
-    }
-
-    if ( tmp != 0 ) { /* we currently only support R and W shutdowns */
-     roar_err_set(ROAR_ERROR_NOTSUP);
-     return -1;
-    }
-
-    if ( s_r && s_w ) {
-     tmp = SHUT_RDWR;
-    } else if ( s_r ) {
-     tmp = SHUT_RD;
-    } else if ( s_w ) {
-     tmp = SHUT_WR;
-    } else {
-     return 0; // nothing to do.
-    }
-
-    return ROAR_SHUTDOWN(roar_vio_get_fh(vio), tmp);
-   break;
-#if defined(ROAR_HAVE_GETSOCKNAME) || defined(ROAR_HAVE_GETPEERNAME)
-  case ROAR_VIO_CTL_GET_SOCKNAME:
-  case ROAR_VIO_CTL_GET_PEERNAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    rsockname = data;
-
-    socklen = sizeof(sockaddr);
-    memset(&sockaddr, 0, socklen); // to make sure nothing will break.
-                                   // getsockname() and getpeername()
-                                   // seem to be broken on lost of systems.
-
-    if ( cmd == ROAR_VIO_CTL_GET_SOCKNAME ) {
-     ROAR_DBG("roar_vio_basic_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_SOCKNAME, data=%p) = ?", vio, data);
-#ifdef ROAR_HAVE_GETSOCKNAME
-     tmp = getsockname(roar_vio_get_fh(vio), &(sockaddr.sa), &socklen);
-#else
-     roar_err_set(ROAR_ERROR_NOSYS);
-     return -1;
-#endif
-    } else if ( cmd == ROAR_VIO_CTL_GET_PEERNAME ) {
-     ROAR_DBG("roar_vio_basic_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_PEERNAME, data=%p) = ?", vio, data);
-#ifdef ROAR_HAVE_GETPEERNAME
-     tmp = getpeername(roar_vio_get_fh(vio), &(sockaddr.sa), &socklen);
-#else
-     roar_err_set(ROAR_ERROR_NOSYS);
-     return -1;
-#endif
-    } else {
-     // memory corruption:
-     roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL);
-     roar_err_set(ROAR_ERROR_CHERNOBYL);
-     return -1;
-    }
-
-    ROAR_DBG("roar_vio_basic_ctl(vio=%p, cmd=0x%.8x, data=%p): tmp=%i", vio, cmd, data, tmp);
-    if ( tmp == -1 )
-     return -1;
-
-    memset(rsockname, 0, sizeof(struct roar_sockname));
-
-    switch (sockaddr.sa.sa_family) {
-#if defined(AF_UNIX) && defined(ROAR_HAVE_UNIX)
-     case AF_UNIX:
-       rsockname->type = ROAR_SOCKET_TYPE_UNIX;
-       if ( sockaddr.un.sun_path[0] == 0 ) {
-        rsockname->addr = roar_mm_malloc(sizeof(sockaddr.un.sun_path));
-        if ( rsockname->addr == NULL )
-         return -1;
-        memcpy(rsockname->addr, sockaddr.un.sun_path, sizeof(sockaddr.un.sun_path));
-       } else {
-        rsockname->addr = roar_mm_strdup(sockaddr.un.sun_path);
-       }
-      break;
-#endif
-#if defined(AF_DECnet) && defined(ROAR_HAVE_LIBDNET)
-     case AF_DECnet:
-       rsockname->type = ROAR_SOCKET_TYPE_DECNET;
-
-       if ( sockaddr.dn.sdn_add.a_len != 2 ) {
-        roar_err_set(ROAR_ERROR_NOTSUP);
-        return -1;
-       }
-
-       rsockname->addr = roar_mm_malloc(28);
-       if ( rsockname->addr == NULL )
-        return -1;
-
-       snprintf(rsockname->addr, 28, "%i.%i::",
-                 sockaddr.dn.sdn_add.a_addr[1] >> 2,
-                 sockaddr.dn.sdn_add.a_addr[0] + ((sockaddr.dn.sdn_add.a_addr[1] & 0x03) << 8));
-
-       rsockname->port = sockaddr.dn.sdn_objnum;
-       if ( sockaddr.dn.sdn_objnum == 0 ) {
-        tmp = strlen(rsockname->addr);
-        memcpy(rsockname->addr + tmp, sockaddr.dn.sdn_objname, sockaddr.dn.sdn_objnamel);
-        rsockname->addr[tmp + sockaddr.dn.sdn_objnamel] = 0;
-       }
-      break;
-#endif
-#if defined(AF_INET) && (defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6))
-     case AF_INET:
-       rsockname->type = ROAR_SOCKET_TYPE_INET;
-       rsockname->port = ntohs(sockaddr.in.sin_port);
-       rsockname->addr = roar_mm_strdup(inet_ntoa(sockaddr.in.sin_addr));
-      break;
-#endif
-#if defined(AF_INET6) && defined(ROAR_HAVE_IPV6)
-     case AF_INET6:
-       rsockname->type = ROAR_SOCKET_TYPE_INET6;
-       rsockname->port = ntohs(sockaddr.in6.sin6_port);
-      break;
-#endif
-     default:
-       roar_err_set(ROAR_ERROR_NOTSUP);
-       return -1;
-    }
-    return 0;
-#endif
-   break;
-#ifdef ROAR_HAVE_H_SYS_IOCTL
-  case ROAR_VIO_CTL_SYSIO_IOCTL:
-    sysioctl = data;
-    return ioctl(roar_vio_get_fh(vio), sysioctl->cmd, sysioctl->argp);
-   break;
-#endif
-#ifdef ROAR_HAVE_GETSOCKOPT
-  case ROAR_VIO_CTL_GET_SYSIO_SOCKOPT:
-    syssockopt = data;
-    return getsockopt(roar_vio_get_fh(vio), syssockopt->level, syssockopt->optname, syssockopt->optval, &(syssockopt->optlen));
-   break;
-#endif
-#ifdef ROAR_HAVE_SETSOCKOPT
-  case ROAR_VIO_CTL_SET_SYSIO_SOCKOPT:
-    syssockopt = data;
-    return setsockopt(roar_vio_get_fh(vio), syssockopt->level, syssockopt->optname, syssockopt->optval, syssockopt->optlen);
-   break;
-#endif
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( roar_socket_nonblock(roar_vio_get_fh(vio), *(int*)data) == -1 )
-     return -1;
-
-    if ( *(int*)data == ROAR_SOCKET_NONBLOCK )
-     return 0;
-
-    roar_vio_sync(vio);
-    return 0;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-int     roar_vio_basic_close    (struct roar_vio_calls * vio) {
-#ifdef _CAN_OPERATE
- if ( roar_vio_get_fh(vio) != -1 )
-  return close(roar_vio_get_fh(vio));
-
- return 0;
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-// null
-ssize_t roar_vio_null_rw    (struct roar_vio_calls * vio, void *buf, size_t count) {
- (void)count;
-
- if ( vio == NULL || buf == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return 0;
-}
-
-int     roar_vio_null_sync    (struct roar_vio_calls * vio) {
- (void)vio;
- return 0;
-}
-
-// pass
-int     roar_vio_open_pass    (struct roar_vio_calls * calls, struct roar_vio_calls * dst) {
- if ( calls == NULL || dst == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset((void*)calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- calls->read     = roar_vio_pass_read;
- calls->write    = roar_vio_pass_write;
- calls->lseek    = roar_vio_pass_lseek;
- calls->sync     = roar_vio_pass_sync;
- calls->ctl      = roar_vio_pass_ctl;
- calls->close    = roar_vio_pass_close;
-
- calls->inst     = dst;
-
- return 0;
-}
-
-ssize_t roar_vio_pass_read (struct roar_vio_calls * vio, void *buf, size_t count) {
- return roar_vio_read((struct roar_vio_calls *) vio->inst, buf, count);
-}
-
-ssize_t roar_vio_pass_write(struct roar_vio_calls * vio, void *buf, size_t count) {
- return roar_vio_write((struct roar_vio_calls *) vio->inst, buf, count);
-}
-
-roar_off_t   roar_vio_pass_lseek(struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- return roar_vio_lseek((struct roar_vio_calls *) vio->inst, offset, whence);
-}
-
-int     roar_vio_pass_sync    (struct roar_vio_calls * vio) {
- return roar_vio_sync((struct roar_vio_calls *) vio->inst);
-}
-
-int     roar_vio_pass_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if (vio == NULL) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if (cmd == -1) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_pass_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    // dirty trick to get real name...
-    if ( vio->read == roar_vio_re_read ) {
-     *(char**)data = "re";
-    } else {
-     *(char**)data = "pass";
-    }
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = vio->inst;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NEXT:
-    vio->inst = *(struct roar_vio_calls **)data;
-    return 0;
-   break;
- }
-
- return roar_vio_ctl((struct roar_vio_calls *) vio->inst, cmd, data);
-}
-
-int     roar_vio_pass_close   (struct roar_vio_calls * vio) {
- return roar_vio_close((struct roar_vio_calls *) vio->inst);
-}
-
-
-// re
-int     roar_vio_open_re (struct roar_vio_calls * calls, struct roar_vio_calls * dst) {
- if ( roar_vio_open_pass(calls, dst) == -1 )
-  return -1;
-
- calls->read  = roar_vio_re_read;
- calls->write = roar_vio_re_write;
- calls->lseek = roar_vio_re_lseek;
-
- return 0;
-}
-ssize_t roar_vio_re_read (struct roar_vio_calls * vio, void *buf, size_t count) {
-  size_t len =  0;
- ssize_t r   = -1;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->inst == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_err_clear_all();
-
- while ( (r = roar_vio_read((struct roar_vio_calls *) vio->inst, buf, count)) > 0 ) {
-  len   += r;
-  buf   += r;
-  count -= r;
-  if ( count == 0 )
-   break;
- }
-
- if ( len == 0 && r == -1 )
-  return -1;
-
- return len;
-}
-
-ssize_t roar_vio_re_write(struct roar_vio_calls * vio, void *buf, size_t count) {
-  size_t len =  0;
- ssize_t r   = -1;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( vio->inst == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- roar_err_clear_all();
-
- while ( (r = roar_vio_write((struct roar_vio_calls *) vio->inst, buf, count)) > 0 ) {
-  len   += r;
-  buf   += r;
-  count -= r;
-  if ( count == 0 )
-   break;
- }
-
- if ( len == 0 && r == -1 )
-  return -1;
-
- return len;
-}
-
-// TODO: we should do a some more intelgent thing here.
-roar_off_t   roar_vio_re_lseek(struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- return roar_vio_lseek((struct roar_vio_calls *) vio->inst, offset, whence);
-}
-
-//ll
Index: libroar/vio_bio.c
===================================================================
--- libroar/vio_bio.c	(revision 6052)
+++ 	(revision )
@@ -1,50 +1,0 @@
-//vio_bio.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_bio      (struct roar_vio_calls * calls, void * bio) {
- (void)calls, (void)bio;
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-void *  roar_vio_to_bio        (struct roar_vio_calls * calls) {
- (void)calls;
- roar_err_set(ROAR_ERROR_NOSYS);
- return NULL;
-}
-
-//ll
Index: libroar/vio_buffer.c
===================================================================
--- libroar/vio_buffer.c	(revision 6052)
+++ 	(revision )
@@ -1,352 +1,0 @@
-//vio_buffer.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_buffer    (struct roar_vio_calls * calls, struct roar_vio_calls * dst, ssize_t minsize, int use_re) {
- struct roar_vio_buffer * self;;
-
- if ( calls == NULL || dst == NULL )
-  return -1;
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_vio_buffer))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct roar_vio_buffer));
-
- self->backend     = dst;
- self->min_bufsize = minsize;
- self->use_re      = use_re;
-
- if ( use_re ) {
-  if ( roar_vio_open_re(&(self->re_vio), dst) == -1 ) {
-   roar_mm_free(self);
-   return -1;
-  }
- }
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- calls->inst     = self;
- calls->close    = roar_vio_buffer_close;
- calls->write    = roar_vio_buffer_write;
- calls->ctl      = roar_vio_buffer_ctl;
- calls->sync     = roar_vio_buffer_sync;
- calls->lseek    = roar_vio_buffer_lseek;
-
- return 0;
-}
-
-int     roar_vio_buffer_close   (struct roar_vio_calls * vio) {
- struct roar_vio_buffer * self = vio->inst;
- int ret;
-
- if ( self->buf_old != NULL )
-  roar_buffer_free(self->buf_old);
-
- if ( self->buf_cur != NULL )
-  roar_buffer_free(self->buf_cur);
-
- if ( self->use_re ) {
-  ret = roar_vio_close(&(self->re_vio));
- } else {
-  ret = roar_vio_close(self->backend);
- }
-
- roar_mm_free(self);
-
- return ret;
-}
-
-ssize_t roar_vio_buffer_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_buffer * self = vio->inst;
- size_t                   havelen;
- size_t                   buflen;
- ssize_t                  ret;
-
- if ( count == 0 )
-  return 0;
-
- if ( buf == NULL )
-  return -1;
-
- if ( self->offset.is_old ) {
-  havelen = (self->len_old + self->len_cur) - self->offset.offset;
- } else {
-  havelen = self->len_cur - self->offset.offset;
- }
-
- if ( havelen == 0 ) {
-  if ( self->use_re ) {
-   ret = roar_vio_read(&(self->re_vio), buf, count);
-  } else {
-   ret = roar_vio_read(self->backend, buf, count);
-  }
-  // TODO...
-  return ret;
- } else if ( count == havelen ) {
-  if (self->offset.is_old) {
-   buflen = count;
-   if ( roar_buffer_shift_out(&(self->buf_old), buf, &buflen) == -1 )
-    return -1;
-
-   if ( self->buf_old != NULL ) // strange error
-    return buflen;
-
-   buf   += buflen;
-   count -= buflen;
-
-   self->len_old       = 0;
-   self->offset.is_old = 0;
-   self->offset.offset = 0;
-  }
-
-  return -1;
-
- } else if ( count <  havelen ) {
- } else if ( count >  havelen ) {
- }
-
- return -1;
-}
-
-int     roar_vio_buffer_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_buffer * self = vio->inst;
- struct roar_vio_calls  * backend;
- roar_off_t dst = 0;
-
- if ( self->use_re ) {
-  backend = &(self->re_vio);
- } else {
-  backend = self->backend;
- }
-
- // bring backend in sync state, if this fails we do not need to continue...
- if ( self->use_re ) {
-  if ( roar_vio_sync(backend) == -1 )
-   return -1;
- } else {
-  if ( roar_vio_sync(backend) == -1 )
-   return -1;
- }
-
- if ( self->buf_old == NULL && self->buf_cur == NULL )
-  return 0; // we are in sync in case no buffers are currently used.
-
- if (self->buf_old != NULL && self->buf_cur == NULL ) {
-  // we just finished the segment
-  roar_buffer_free(self->buf_old);
-  return 0;
- }
-
- // calc seek pos:
- if ( self->offset.is_old ) {
-  dst = (self->len_cur + self->len_old) - self->offset.offset;
- } else {
-  dst = self->len_cur - self->offset.offset;
- }
-
- dst = -dst;
-
- // do the seek:
- if ( roar_vio_lseek(backend, dst, SEEK_CUR) == (roar_off_t)-1 )
-  return -1;
-
- // free all internal buffers:
- if ( self->buf_old != NULL )
-  roar_buffer_free(self->buf_old);
-
- if ( self->buf_cur != NULL )
-  roar_buffer_free(self->buf_cur);
-
- self->offset.is_old = 0;
- self->offset.offset = 0;
-
- // funally bring the backend in sync state again, to be sure all changes are done.
- if ( self->use_re ) {
-  if ( roar_vio_sync(backend) == -1 )
-   return -1;
- } else {
-  if ( roar_vio_sync(backend) == -1 )
-   return -1;
- }
-
- return 0;
-}
-
-roar_off_t   roar_vio_buffer_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- struct roar_vio_buffer * self = vio->inst;
- size_t newoff;
- roar_off_t  ret;
- roar_off_t  invoff;
-
- // in-memory seeking is only supported for SEEK_CUR:
- if ( whence == SEEK_CUR ) {
-  if ( offset == 0 ) {
-   return 0;
-  } else if ( offset > 0 ) {
-   newoff = self->offset.offset + offset;
-
-   if ( self->offset.is_old ) {
-    if ( newoff == self->len_old ) {
-     self->offset.is_old = 0;
-     self->offset.offset = 0;
-     self->abspos += offset;
-     return self->abspos;
-    } else if ( newoff < self->len_old ) {
-     self->offset.offset = newoff;
-     self->abspos += offset;
-     return self->abspos;
-    } else if ( newoff > self->len_old ) {
-     if ( newoff < (self->len_old + self->len_cur ) ) {
-      self->offset.is_old = 0;
-      self->offset.offset = offset + self->offset.offset - self->len_old;
-      self->abspos += offset;
-      return self->abspos;
-     }
-    }
-   } else {
-    if ( newoff == self->len_cur ) {
-     roar_buffer_free(self->buf_old);
-     self->buf_old = self->buf_cur;
-     self->buf_cur = NULL;
-     self->offset.offset = 0;
-     self->abspos += offset;
-     return self->abspos;
-    } else if ( newoff < self->len_cur ) {
-     self->offset.offset = newoff;
-     self->abspos += offset;
-     return self->abspos;
-    }
-   }
-  } else {
-   invoff = -offset;
-
-   if ( invoff <= self->offset.offset ) {
-    self->offset.offset = 0;
-    self->abspos -= invoff;
-    return self->abspos;
-   }
-
-   if ( !self->offset.is_old ) {
-    if ( invoff > self->offset.offset ) {
-     if ( invoff <= (self->len_old + self->offset.offset) ) {
-      self->offset.is_old = 1;
-      self->offset.offset = (self->len_old + self->offset.offset) - invoff;
-      self->abspos -= invoff;
-      return self->abspos;
-     }
-    }
-   }
-  }
- }
-
- // we need to do a physical seek;
- // get in sync with current position, flush all buffers,...
- if ( roar_vio_buffer_sync(vio) == -1 )
-  return -1;
-
- // do the seek:
- if ( self->use_re ) {
-  ret = roar_vio_lseek(&(self->re_vio), offset, whence);
- } else {
-  ret = roar_vio_lseek(self->backend, offset, whence);
- }
-
- if (ret != (roar_off_t)-1)
-  self->abspos = ret;
-
- return ret;
-}
-
-int     roar_vio_buffer_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_buffer * self;
-
- if (vio == NULL || cmd == -1)
-  return -1;
-
- ROAR_DBG("roar_vio_buffer_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "buffer";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    if ( self->use_re ) {
-     *(struct roar_vio_calls **)data = &(self->re_vio);
-    } else {
-     *(struct roar_vio_calls **)data = self->backend;
-    }
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NEXT:
-    if ( self->use_re ) {
-     return roar_vio_ctl(&(self->re_vio), ROAR_VIO_CTL_SET_NEXT, data);
-    } else {
-     self->backend = *(struct roar_vio_calls **)data;
-    }
-    return 0;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( self->use_re ) {
-     return roar_vio_ctl(&(self->re_vio), ROAR_VIO_CTL_NONBLOCK, data);
-    } else {
-     return roar_vio_ctl(self->backend, ROAR_VIO_CTL_NONBLOCK, data);
-    }
-   break;
- }
-
- return roar_vio_ctl((struct roar_vio_calls *) vio->inst, cmd, data);
-}
-
-ssize_t roar_vio_buffer_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_buffer * self = vio->inst;
-
- if ( self->use_re ) {
-  return roar_vio_write(&(self->re_vio), buf, count);
- } else {
-  return roar_vio_write(self->backend, buf, count);
- }
-}
-
-//ll
Index: libroar/vio_buffer_store.c
===================================================================
--- libroar/vio_buffer_store.c	(revision 6052)
+++ 	(revision )
@@ -1,167 +1,0 @@
-//vio_buffer_store.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_buffer_store    (struct roar_vio_calls * calls, struct roar_vio_buffer_store ** inst) {
- struct roar_vio_buffer_store * self;
-
- if ( calls == NULL )
-  return -1;
-
- self = roar_mm_malloc(sizeof(struct roar_vio_buffer_store));
-
- if ( self == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct roar_vio_buffer_store));
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- if ( inst != NULL )
-  *inst = self;
-
- calls->inst     = self;
- calls->close    = roar_vio_buffer_store_close;
- calls->sync     = roar_vio_buffer_store_sync;
- calls->ctl      = roar_vio_buffer_store_ctl;
- calls->write    = roar_vio_buffer_store_write;
- calls->read     = roar_vio_buffer_store_read;
- calls->lseek    = roar_vio_buffer_store_lseek;
-
- return 0;
-}
-
-int     roar_vio_buffer_store_close   (struct roar_vio_calls * vio) {
- struct roar_vio_buffer_store * self = vio->inst;
- int ret = 0;
-
- if ( self->in != NULL )
-  if ( roar_buffer_free(self->in) != 0 )
-   ret = -1;
-
- if ( self->out != NULL )
-  if ( roar_buffer_free(self->out) != 0 )
-   ret = -1;
-
- return ret;
-}
-
-ssize_t roar_vio_buffer_store_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_buffer_store * self = vio->inst;
-
- ROAR_DBG("roar_vio_buffer_store_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- if ( count == 0 )
-  return 0;
-
- if ( buf == NULL )
-  return -1;
-
- if ( self->out == NULL )
-  return 0;
-
- ROAR_DBG("roar_vio_buffer_store_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- if ( roar_buffer_shift_out(&(self->out), buf, &count) == -1 )
-  return -1;
-
- ROAR_DBG("roar_vio_buffer_store_read(*) = %llu", (long long unsigned int)count);
-
- return count;
-}
-
-ssize_t roar_vio_buffer_store_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_buffer_store * self = vio->inst;
- struct roar_buffer * nbuf;
- void * data;
-
- if ( count == 0 )
-  return 0;
-
- if ( buf == NULL )
-  return -1;
-
- if ( roar_buffer_new_data(&nbuf, count, &data) == -1 )
-  return -1;
-
- memcpy(data, buf, count);
-
- if ( self->in == NULL ) {
-  self->in = nbuf;
- } else {
-  if ( roar_buffer_moveinto(self->in, &nbuf) == -1 ) {
-   roar_buffer_free(nbuf);
-   return -1;
-  }
- }
-
- return count;
-}
-
-roar_off_t   roar_vio_buffer_store_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- // TODO: implement support to seek forward as wide as the buffer allows us to seek.
- return (roar_off_t)-1;
-}
-
-int     roar_vio_buffer_store_sync    (struct roar_vio_calls * vio) {
- return 0; // we are always sync.
-}
-
-int     roar_vio_buffer_store_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if (vio == NULL || cmd == -1)
-  return -1;
-
- ROAR_DBG("roar_vio_buffer_store_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "buffer_store";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    return 0; // if we are in nonblock or not is the same for us.
-   break;
- }
-
- return -1;
-}
-
-//ll
Index: libroar/vio_cmd.c
===================================================================
--- libroar/vio_cmd.c	(revision 6052)
+++ 	(revision )
@@ -1,704 +1,0 @@
-//vio_cmd.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_vio_open_cmd(struct roar_vio_calls * calls, struct roar_vio_calls * dst,
-                      char * reader, char * writer, int options) {
-#ifndef ROAR_WITHOUT_VIO_CMD
- struct roar_vio_cmd_state * state;
-
- if ( calls == NULL || dst == NULL )
-  return -1;
-
- if ( reader == NULL && writer == NULL )
-  return -1;
-
- if ( (state = roar_mm_malloc(sizeof(struct roar_vio_cmd_state))) == NULL )
-  return -1;
-
- ROAR_DBG("roar_vio_open_cmd(*): pre reqs are OK");
-
- // clear all
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
- memset(state, 0, sizeof(struct roar_vio_cmd_state));
-
- // init reader and writer:
- state->reader.pid = -1;
- state->reader.in  = -1;
- state->reader.out = -1;
-
- if ( reader != NULL )
-  state->reader.cmd = roar_mm_strdup(reader);
-
- state->writer.pid = -1;
- state->writer.in  = -1;
- state->writer.out = -1;
-
- if ( writer != NULL )
-  state->writer.cmd = roar_mm_strdup(writer);
-
- // init state
- state->next    = dst;
- state->options = options;
- state->state   = ROAR_VIO_CMD_STATE_OPEN;
-
- // init calls
- calls->close    = roar_vio_cmd_close;
- calls->read     = roar_vio_cmd_read;
- calls->write    = roar_vio_cmd_write;
- calls->sync     = roar_vio_cmd_sync;
- calls->ctl      = roar_vio_cmd_ctl;
- calls->inst     = (void*) state;
-
- ROAR_DBG("roar_vio_open_cmd(*): var setup OK");
-
- if ( !(options & ROAR_VIO_CMD_OPTS_ON_DEMAND) ) {
-  if ( reader != NULL )
-   if ( roar_vio_cmd_fork(&(state->reader)) == -1 )
-    return roar_vio_cmd_close(calls);
-
-  if ( writer != NULL )
-   if ( roar_vio_cmd_fork(&(state->writer)) == -1 )
-    return roar_vio_cmd_close(calls);
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-#ifndef ROAR_WITHOUT_VIO_CMD
-int roar_vio_cmd_close(struct roar_vio_calls * vio) {
- struct roar_vio_cmd_state * state = (struct roar_vio_cmd_state *)vio->inst;
-
- state->state = ROAR_VIO_CMD_STATE_CLOSING;
-
- if ( state->writer.opened ) {
-  if ( state->writer.out != -1 ) {
-   close(state->writer.out);
-   state->writer.out = -1;
-  }
- }
-
- roar_vio_cmd_sync(vio);
-
- if ( state->reader.opened )
-  roar_vio_cmd_wait(&(state->reader));
-
- if ( state->writer.opened )
-  roar_vio_cmd_wait(&(state->writer));
-
- if ( state->reader.cmd != NULL )
-  roar_mm_free(state->reader.cmd);
-
- if ( state->writer.cmd != NULL )
-  roar_mm_free(state->writer.cmd);
-
- roar_vio_close(state->next);
-
-// state->state = ROAR_VIO_CMD_STATE_CLOSED;
- roar_mm_free(state);
-
- return 0;
-}
-
-int roar_vio_cmd_fork(struct roar_vio_cmd_child * child) {
- int in[2], out[2];
- char * bin_sh;
-
- if ( child == NULL )
-  return -1;
-
- if ( child->opened )
-  return 0;
-
- if ( child->cmd == NULL )
-  return -1;
-
- // open some pipes...
- if ( pipe(in) != 0 )
-  return -1;
-
- if ( pipe(out) != 0 ) {
-  close(in[0]);
-  close(in[1]);
-  return -1;
- }
-
- child->pid = roar_fork(NULL);
-
- switch (child->pid) {
-  case -1:
-    close(in[0]);
-    close(in[1]);
-    close(out[0]);
-    close(out[1]);
-    return -1;
-   break;
-  case 0:
-    roar_watchdog_stop();
-
-    close(in[0]);
-    close(out[1]);
-    close(ROAR_STDIN);
-    close(ROAR_STDOUT);
-
-    if ( dup2(out[0], ROAR_STDIN) == -1 )
-     ROAR_U_EXIT(1);
-
-    if ( dup2(in[1], ROAR_STDOUT) == -1 )
-     ROAR_U_EXIT(1);
-
-    bin_sh = roar_libroar_get_path("bin-sh", 0, NULL, NULL);
-    if ( bin_sh == NULL )
-     ROAR_U_EXIT(1);
-
-    execlp(bin_sh, bin_sh, "-c", child->cmd, (_LIBROAR_GOOD_CAST char*)NULL);
-
-    roar_mm_free(bin_sh);
-
-    ROAR_U_EXIT(1);
-   break;
- }
-
- close(in[1]);
- close(out[0]);
-
- child->opened = 1;
- child->in     = in[0];
- child->out    = out[1];
-
- return 0;
-}
-
-int roar_vio_cmd_wait(struct roar_vio_cmd_child * child) {
- int status;
-
- if ( child == NULL )
-  return -1;
-
- if ( !child->opened )
-  return 0;
-
- if ( child->out != -1 )
-  close(child->out);
-
- if ( child->in  != -1 )
-  close(child->in);
-
- waitpid(child->pid, &status, 0);
-
- return 0;
-}
-
-
-
-int roar_vio_open_2popen(struct roar_vio_calls * calls, char * command, int options) {
-#ifndef ROAR_WITHOUT_VIO_CMD
- struct roar_vio_2popen_state * state;
-
- if ( calls == NULL || command == NULL || options < 0 )
-  return -1;
-
- if ( (state = roar_mm_malloc(sizeof(struct roar_vio_2popen_state))) == NULL )
-  return -1;
-
- ROAR_DBG("roar_vio_open_2popen(*): pre reqs are OK");
-
- // clear all
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
- memset(state, 0, sizeof(struct roar_vio_2popen_state));
-
- // init reader and writer:
- state->child.pid = -1;
- state->child.in  = -1;
- state->child.out = -1;
-
- state->child.cmd = roar_mm_strdup(command);
-
- // init state
- state->options = options;
- state->state   = ROAR_VIO_CMD_STATE_OPEN;
-
- // init calls
- calls->close    = roar_vio_2popen_close;
-/*
- calls->read     = roar_vio_2popen_read;
- calls->write    = roar_vio_2popen_write;
- calls->sync     = roar_vio_2popen_sync;
- calls->ctl      = roar_vio_2popen_ctl;
-*/
- calls->inst     = (void*) state;
-
- ROAR_DBG("roar_vio_open_2popen(*): var setup OK");
-
- if ( !(options & ROAR_VIO_CMD_OPTS_ON_DEMAND) ) {
-  if ( roar_vio_cmd_fork(&(state->child)) == -1 )
-   return roar_vio_2popen_close(calls);
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-#ifndef ROAR_WITHOUT_VIO_CMD
-int roar_vio_2popen_close(struct roar_vio_calls * vio) {
- struct roar_vio_2popen_state * state = (struct roar_vio_2popen_state *)vio->inst;
-
- state->state = ROAR_VIO_CMD_STATE_CLOSING;
-
- if ( state->child.opened )
-  roar_vio_cmd_wait(&(state->child));
-
- if ( state->child.cmd != NULL )
-  roar_mm_free(state->child.cmd);
-
- roar_mm_free(state);
-
- return 0;
-}
-#endif
-
-
-// VIOs:
-
-ssize_t roar_vio_cmd_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_cmd_state * state = (struct roar_vio_cmd_state *)vio->inst;
- fd_set rfhs[1], wfhs[1];
- struct timeval tv;
- size_t done = 0;
- int max_fh;
- int ret;
- char    tbuf[ROAR_VIO_CMD_BUFSIZE];
- char  * tp   = NULL;
- ssize_t tlen = 0;
- int     nonblock = state->options & ROAR_VIO_CMD_OPTS_NONBLOCK;
- int     in, out;
-
- ROAR_DBG("roar_vio_cmd_read(*) = ?");
-
- if ( !state->reader.opened ) {
-  if ( buf == NULL && count == 0 ) /* sync: no need to do anything if no reader is forked :) */
-   return 0;
-
-  if ( !(state->options & ROAR_VIO_CMD_OPTS_ON_DEMAND) ) /* we are not on demand and no reader exists? -> err */
-   return -1;
-
-  if ( roar_vio_cmd_fork(&(state->reader)) == -1 )
-   return -1;
- }
-
- in  = state->reader.in;
- out = state->reader.out;
-
- while (done < count) {
-  if ( nonblock ) {
-   tv.tv_sec  =    0;
-   tv.tv_usec =    1;
-  } else {
-   tv.tv_sec  = 3600;
-   tv.tv_usec =    0;
-  }
-
-  FD_ZERO(rfhs);
-  FD_ZERO(wfhs);
-
-  FD_SET(in,  rfhs);
-
-  if ( out != -1 ) {
-   FD_SET(out, wfhs);
-  }
-
-#ifdef DEBUG
-  if ( FD_ISSET(in, rfhs) ) {
-   ROAR_DBG("roar_vio_cmd_read(*): reader set in fh group");
-  }
-#endif
-
-  max_fh = in > out ? in : out;
-  ROAR_DBG("roar_vio_cmd_read(*): max_fh=%i", max_fh);
-
-  if ( (ret = select(max_fh + 1, rfhs, wfhs, NULL, &tv)) == -1 ) {
-#ifdef EINTR
-   if ( errno == EINTR ) {
-    ROAR_DBG("roar_vio_cmd_read(*): Ooops. Something went wrong. (will try to continue)");
-    continue;
-   }
-#endif
-#ifdef ERESTARTNOHAND
-   if ( errno == ERESTARTNOHAND ) {
-    ROAR_WARN("roar_vio_cmd_read(*): We hit a kernel bug. Haha! (will try to continue)");
-    continue;
-   }
-#endif
-   return -1;
-  }
-
-  ROAR_DBG("roar_vio_cmd_read(*): select(*) = %i", ret);
-  ROAR_DBG("roar_vio_cmd_read(*): reader=%i, writer=%i", in, out);
-
-  if ( ret > 0 ) {
-   if ( FD_ISSET(in, rfhs) ) {
-    ROAR_DBG("roar_vio_cmd_read(*): event on reader");
-
-    if ( (ret = read(in, buf+done, count-done)) == -1 )
-     break;
-
-    if ( ret == 0 )
-     break;
-
-    done += ret;
-   }
-
-   if ( out != -1 && FD_ISSET(out, wfhs) ) {
-    ROAR_DBG("roar_vio_cmd_read(*): event on writer");
-
-    if ( !tlen ) {
-     tp   = tbuf;
-     tlen = 0;
-     if ( (tlen = roar_vio_read(state->next, tp, ROAR_VIO_CMD_BUFSIZE)) == -1 ) {
-      tlen = 0;
-      continue;
-     }
-    }
-
-    if ( tlen ) {
-     if ( (ret = write(out, tp, tlen)) > 0 ) {
-      tlen -= ret;
-      tp   += ret;
-     }
-    } else {
-     close(out);
-     state->reader.out = out = -1;
-    }
-   }
-  }
-
-  if ( nonblock )
-   break;
- }
-
- if ( tlen ) { /* we have some data to write to the child... */
-  // TODO: try to write it out...
-  return -1;
- }
-
- return done;
-}
-
-ssize_t roar_vio_cmd_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_cmd_state * state = (struct roar_vio_cmd_state *)vio->inst;
- fd_set rfhs[1], wfhs[1];
- struct timeval tv;
- size_t done = 0;
- int max_fh;
- int ret;
- char   tbuf[ROAR_VIO_CMD_BUFSIZE];
- int    nonblock = state->options & ROAR_VIO_CMD_OPTS_NONBLOCK;
- int    in, out;
-
- if ( !state->writer.opened ) {
-  if ( buf == NULL && count == 0 ) /* sync: no need to do anything if no writer is forked :) */
-   return 0;
-
-  if ( !(state->options & ROAR_VIO_CMD_OPTS_ON_DEMAND) ) /* we are not on demand and no writer exists? -> err */
-   return -1;
-
-  if ( roar_vio_cmd_fork(&(state->writer)) == -1 )
-   return -1;
- }
-
- in  = state->writer.in;
- out = state->writer.out;
-
- if ( buf == NULL ) { // we are requested to sync
-  if ( in != -1 ) {
-   ret = 1;
-   done = 0;
-   while (ret > 0) {
-    if ( state->state == ROAR_VIO_CMD_STATE_CLOSING ) {
-     tv.tv_sec  = 3600;
-     tv.tv_usec = 0;
-    } else {
-     tv.tv_sec  = 0;
-     tv.tv_usec = done ? 1 : 50000; // 50ms
-    }
-
-    done++;
-
-    FD_ZERO(rfhs);
-    FD_SET(in, rfhs);
-
-    if ( select(in+1, rfhs, NULL, NULL, &tv) < 1 )
-     break;
-
-    ret = read(in, tbuf, ROAR_VIO_CMD_BUFSIZE);
-
-    if ( roar_vio_write(state->next, tbuf, ret) != ret )
-     return -1;
-   }
-  }
-
-  return 0;
- }
-
- while (done < count) {
-  if ( nonblock ) {
-   tv.tv_sec  =    0;
-   tv.tv_usec =    1;
-  } else {
-   tv.tv_sec  = 3600;
-   tv.tv_usec =    0;
-  }
-
-  FD_ZERO(rfhs);
-  FD_ZERO(wfhs);
-
-  FD_SET(out, wfhs);
-
-  if ( in != -1 ) {
-   FD_SET(in,  rfhs);
-  }
-
-  max_fh = in > out ? in : out;
-
-  if ( (ret = select(max_fh + 1, rfhs, wfhs, NULL, &tv)) == -1 )
-   return -1;
-
-  if ( ret > 0 ) {
-   if ( FD_ISSET(out, wfhs) ) {
-
-    if ( (ret = write(out, buf+done, count-done)) == -1 )
-     break;
-
-    if ( ret == 0 )
-     break;
-
-    done += ret;
-   }
-   if ( in != -1 && FD_ISSET(in, rfhs) ) {
-    if ( (ret = read(in, tbuf, ROAR_VIO_CMD_BUFSIZE)) == -1 ) { /* error case: can not read on reader -> EOF */
-     close(in);
-     state->writer.in = in = -1;
-     break;
-    }
-
-    if ( roar_vio_write(state->next, tbuf, ret) != ret )
-     return -1;
-   }
-  }
-
-  if ( nonblock )
-   break;
- }
-
- return done;
-}
-
-int     roar_vio_cmd_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_cmd_state * state = (struct roar_vio_cmd_state *)vio->inst;
- int newblock = ROAR_SOCKET_BLOCK;
- int oldblock;
- int ret = 0;
-
- oldblock = state->options & ROAR_VIO_CMD_OPTS_NONBLOCK ? ROAR_SOCKET_NONBLOCK : ROAR_SOCKET_BLOCK;
-
- if ( roar_vio_cmd_ctl(vio, ROAR_VIO_CTL_NONBLOCK, &newblock) == -1 )
-  return -1;
-
- if ( roar_vio_cmd_write(vio, NULL, 0) == -1 )
-  ret = -1;
-
- if ( roar_vio_cmd_read(vio, NULL, 0) == -1 )
-  ret = -1;
-
- if ( roar_vio_cmd_ctl(vio, ROAR_VIO_CTL_NONBLOCK, &oldblock) == -1 )
-  return -1;
-
- return ret;
-}
-
-int     roar_vio_cmd_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_cmd_state * state = (struct roar_vio_cmd_state *)vio->inst;
- char buf[1];
-
- ROAR_DBG("roar_vio_cmd_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "cmd";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = state->next;
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-//    if ( !state->reader.opened ) {
-     //for (i = 0; i < 128; i++)
-      roar_vio_cmd_read(vio, buf, 0);
-//    }
-    if ( state->reader.opened ) {
-     ROAR_DBG("roar_vio_cmd_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_READ_FH(0x%.8x), data=%p) = 0 // fh=%i", vio, cmd, data, state->reader.in);
-     *(int*)data = state->reader.in;
-     return 0;
-    }
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-    return -1;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    state->options |= ROAR_VIO_CMD_OPTS_NONBLOCK;
-
-    if ( *(int*)data == ROAR_SOCKET_BLOCK )
-     state->options -= ROAR_VIO_CMD_OPTS_NONBLOCK;
-
-    _LIBROAR_IGNORE_RET(roar_vio_ctl(state->next, cmd, data)); // this should help, but may not necessarily.
-   break;
-  default:
-    return -1;
- }
-
- return 0;
-}
-#endif
-
-// MISC:
-int roar_vio_open_gzip(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int level) {
- roar_debug_warn_obsolete("roar_vio_open_gzip", "roar_vio_open_zlib", NULL);
-
-#ifdef ROAR_HAVE_LIBZ
- return roar_vio_open_zlib(calls, dst, level, 1);
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts, int options) {
-#if defined(ROAR_HAVE_BIN_GPG) && !defined(ROAR_WITHOUT_VIO_CMD)
- char command[1024];
- char para[1024] = {0};
- char * bin_gpg;
- int pwpipe[2];
- int ret;
-
-/*
-#define ROAR_VIO_PGP_OPTS_NONE      0x00
-#define ROAR_VIO_PGP_OPTS_ASCII     0x01
-#define ROAR_VIO_PGP_OPTS_SIGN      0x02
-#define ROAR_VIO_PGP_OPTS_TEXTMODE  0x04
-*/
-
- if ( options & ROAR_VIO_PGP_OPTS_ASCII )
-  strncat(para, "--armor ", 16);
-
- if ( options & ROAR_VIO_PGP_OPTS_SIGN )
-  strncat(para, "--sign ", 16);
-
- if ( options & ROAR_VIO_PGP_OPTS_TEXTMODE )
-  strncat(para, "--textmode ", 16);
-
- bin_gpg = roar_libroar_get_path("bin-gpg", 0, NULL, NULL);
- if ( bin_gpg == NULL )
-  return -1;
-
- if ( pw != NULL ) {
-  if ( pipe(pwpipe) == -1 ) {
-   roar_mm_free_noerror(bin_gpg);
-   return -1;
-  }
-
-  snprintf(command, sizeof(command), "%s --batch --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s %s", bin_gpg, pwpipe[0], para, opts);
-
-  write(pwpipe[1], pw, strlen(pw));
-
-  close(pwpipe[1]);
- } else {
-  snprintf(command, sizeof(command), "%s --no-verbose --quiet %s %s", bin_gpg, para, opts);
- }
-
- roar_mm_free(bin_gpg);
-
- if ( wronly ) {
-  ret = roar_vio_open_cmd(calls, dst, NULL, command, 0);
- } else {
-  ret = roar_vio_open_cmd(calls, dst, command, NULL, 0);
- }
-
- if ( pw != NULL )
-  close(pwpipe[0]);
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-int roar_vio_open_pgp_decrypt(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw) {
- return roar_vio_open_gpg(calls, dst, pw, 0, "-d", ROAR_VIO_PGP_OPTS_NONE);
-}
-
-int roar_vio_open_pgp_store(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int options) {
- return roar_vio_open_gpg(calls, dst, NULL, 1, "--store", options);
-}
-
-int roar_vio_open_pgp_encrypt_sym(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options) {
- return roar_vio_open_gpg(calls, dst, pw, 1, "--symmetric", options);
-}
-int roar_vio_open_pgp_encrypt_pub(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options, char * recipient) {
- char buf[1024];
-
- snprintf(buf, sizeof(buf), "-e -r %s", recipient);
- return roar_vio_open_gpg(calls, dst, pw, 1, buf, options);
-}
-
-//ll
Index: libroar/vio_dstr.c
===================================================================
--- libroar/vio_dstr.c	(revision 6052)
+++ 	(revision )
@@ -1,1144 +1,0 @@
-//vio_dstr.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifndef ROAR_WITHOUT_VIO_DSTR
-static struct _roar_vio_dstr_type {
- const int    id;
- const char * name;
- int (* setdef) (struct roar_vio_dstr_chain * cur,   struct roar_vio_dstr_chain * next);
- int (* openvio)(struct roar_vio_calls      * calls, struct roar_vio_calls      * dst, struct roar_vio_dstr_chain * cur, struct roar_vio_dstr_chain * next);
- int    pdeftype[16];
-} _roar_vio_dstr_objs[] = {
-/*
-grep '^#define ROAR_VIO_DSTR_OBJT_' vio_dstr.h | cut -d' ' -f2 | while read objt; do name=`cut -d_ -f5,6,7,8,9,10 <<<$objt | tr A-Z a-z`; echo -e " {$objt,\t \"$name\","; echo "      {ROAR_VIO_DEF_TYPE_EOL}},"; done;
-*/
- {ROAR_VIO_DSTR_OBJT_FILE,       "file",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_FH,         "fh",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_FD,         "fd",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SOCKETFH,   "socketfh",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_PASS,       "pass",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_RE,         "re",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_JUMBO,      "jumbo", /* TODO */
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_EXEC,       "exec",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-/* special devices */
- {ROAR_VIO_DSTR_OBJT_NULL,       "null",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_ZERO,       "zero",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_FULL,       "full",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_SOCKET,     "socket",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_UNIX,       "unix",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_DECNET,     "decnet",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_TCP,        "tcp",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_UDP,        "udp",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_TCP6,       "tcp6",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_UDP6,       "udp6",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_SOCKS,      "socks",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SOCKS4,     "socks4",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SOCKS4A,    "socks4a",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SOCKS4D,    "socks4d",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SOCKS5,     "socks5",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SSH,        "ssh",
-      roar_vio_proxy_setdef, roar_vio_proxy_openvio,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_HTTP09,     "http09",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_HTTP10,     "http10",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_HTTP11,     "http11",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_HTTP,       "http",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_GOPHER,     "gopher",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_GOPHER_PLUS,"gopher+",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_ICY,        "icy",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_RTP2,       "rtp2",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_RTP,        "rtp",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_GZIP,       "gzip",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_ZLIB,       "zlib",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_BZIP2,      "bzip2",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_PGP,        "pgp",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_PGP_ENC,    "pgp_enc",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_PGP_STORE,  "pgp_store",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SSL1,       "ssl1",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SSL2,       "ssl2",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SSL3,       "ssl3",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_TLS,        "tls",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SSLTLS,     "ssltls",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-/* Random numbers */
- {ROAR_VIO_DSTR_OBJT_NRANDOM,    "nrandom",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_URANDOM,    "urandom",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_SRANDOM,    "srandom",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_TRANSCODE,  "transcode", /* TODO  */
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_RAUM,       "raum",      /* TODO */
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_OGG,        "ogg",       /* TODO */
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_TAR,        "tar",       /* TODO */
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
-
- {ROAR_VIO_DSTR_OBJT_MAGIC,      "magic",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_TANTALOS,   "tantalos",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_EOL}},
-
- {ROAR_VIO_DSTR_OBJT_INTERNAL, "INTERNAL",
-      NULL, NULL,
-      {ROAR_VIO_DEF_TYPE_FILE, ROAR_VIO_DEF_TYPE_SOCKET, ROAR_VIO_DEF_TYPE_FH, ROAR_VIO_DEF_TYPE_SOCKETFH,
-       ROAR_VIO_DEF_TYPE_EOL}},
- {ROAR_VIO_DSTR_OBJT_EOL, NULL, NULL, NULL, {ROAR_VIO_DEF_TYPE_EOL}}
-};
-
-int     roar_vio_dstr_get_type(const char * str) {
- int i;
-
- for (i = 0; _roar_vio_dstr_objs[i].id != ROAR_VIO_DSTR_OBJT_EOL; i++) {
-  if ( strcasecmp(_roar_vio_dstr_objs[i].name, str) == 0 )
-   return _roar_vio_dstr_objs[i].id;
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-struct _roar_vio_dstr_type * roar_vio_dstr_get_by_type (int type) {
- int i;
-
- for (i = 0; _roar_vio_dstr_objs[i].id != ROAR_VIO_DSTR_OBJT_EOL; i++) {
-  if ( _roar_vio_dstr_objs[i].id == type )
-   return &(_roar_vio_dstr_objs[i]);
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-const char *  roar_vio_dstr_get_name(const int type) {
- struct _roar_vio_dstr_type * ret;
-
- if ( (ret = roar_vio_dstr_get_by_type(type)) != NULL )
-  return ret->name;
-
- if ( type == ROAR_VIO_DSTR_OBJT_EOL )
-  return "<<EOL>>";
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int     roar_vio_dstr_register_type(int   type,
-                                    char *name,
-                                    int (*setdef) (struct roar_vio_dstr_chain * cur,
-                                                   struct roar_vio_dstr_chain * next),
-                                    int (*openvio)(struct roar_vio_calls      * calls,
-                                                   struct roar_vio_calls      * dst,
-                                                   struct roar_vio_dstr_chain * cur,
-                                                   struct roar_vio_dstr_chain * next)) {
- struct _roar_vio_dstr_type * ret;
-
- if ( (ret = roar_vio_dstr_get_by_type(type)) == NULL ) /* we can currently not register new types */
-  return -1;
-
-
- // check if things are allready set, we do not want to allow overwrite here.
- if ( setdef != NULL && ret->setdef != NULL )
-  return -1;
-
- if ( openvio != NULL && ret->openvio != NULL )
-  return -1;
-
- if ( setdef != NULL )
-  ret->setdef = setdef;
-
- if ( openvio != NULL )
-  ret->openvio = openvio;
-
- return 0;
-}
-
-static void _roar_vio_dstr_init_otherlibs (void) {
- roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroardsp",   NULL);
- roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroareio",   NULL);
- roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarlight", NULL);
- roar_dl_ra_init(ROAR_DL_HANDLE_DEFAULT, "libroarmidi",  NULL);
-}
-
-#endif
-
-int     roar_vio_dstr_init_defaults (struct roar_vio_defaults * def, int type, int o_flags, mode_t o_mode) {
- if ( def == NULL )
-  return -1;
-
- memset(def, 0, sizeof(struct roar_vio_defaults));
-
- def->type    = type;
- def->o_flags = o_flags;
- def->o_mode  = o_mode;
-
- return 0;
-}
-
-int     roar_vio_dstr_init_defaults_c (struct roar_vio_defaults * def, int type, struct roar_vio_defaults * odef, int o_flags) {
- if ( o_flags < 1 )
-  o_flags = O_RDONLY;
-
- if ( odef == NULL ) {
-  return roar_vio_dstr_init_defaults(def, type, o_flags, 0644);
- } else {
-  return roar_vio_dstr_init_defaults(def, type, odef->o_flags, odef->o_mode);
- }
-}
-
-#ifndef ROAR_WITHOUT_VIO_DSTR
-#ifdef ROAR_HAVE_IO_POSIX
-static int _open_file(struct roar_vio_calls * calls, const char * filename, int flags, mode_t mode) {
- int fh;
-
- if ( calls == NULL || filename == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
-#ifdef ROAR_TARGET_WIN32
- flags |= O_BINARY;
-#endif
-
- ROAR_DBG("_open_file(calls=%p, filename='%s', flags=0x%x, mode=%i) = ?", calls, filename, flags, (int)mode);
- roar_err_clear_all();
- if ( (fh = open(filename, flags, mode)) == -1 ) {
-  roar_err_update();
-  return -1;
- }
-
- if ( roar_vio_open_fh(calls, fh) == -1 ) {
-  close(fh);
-  roar_err_to_errno();
-  return -1;
- }
-
- roar_err_update();
- return 0;
-}
-#endif
-
-int     roar_vio_open_default (struct roar_vio_calls * calls, struct roar_vio_defaults * def, char * opts) {
- ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s') = ?", calls, def, opts);
-
- if ( calls == NULL || def == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- switch (def->type) {
-  case ROAR_VIO_DEF_TYPE_NONE:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s'): def->type=%i, dummy open", calls, def, opts, (int)def->type);
-   break;
-#ifdef ROAR_HAVE_IO_POSIX
-  case ROAR_VIO_DEF_TYPE_FILE:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s'): def->type=%i, file open", calls, def, opts, (int)def->type);
-    if ( _open_file(calls, def->d.file, def->o_flags, def->o_mode) == -1 ) {
-     ROAR_DBG("roar_vio_open_default(*): Can not open file: %i", roar_error);
-     return -1;
-    }
-   break;
-#endif
-  case ROAR_VIO_DEF_TYPE_SOCKET:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s'): def->type=%i, socket open", calls, def, opts, (int)def->type);
-     if ( roar_vio_open_def_socket(calls, def, opts) == -1 )
-      return -1;
-   break;
-  case ROAR_VIO_DEF_TYPE_FH:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s'): def->type=%i, fh open", calls, def, opts, (int)def->type);
-    if ( roar_vio_open_fh(calls, def->d.fh) == -1 )
-     return -1;
-   break;
-  case ROAR_VIO_DEF_TYPE_SOCKETFH:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s'): def->type=%i, socket fh open", calls, def, opts, (int)def->type);
-    if ( roar_vio_open_fh_socket(calls, def->d.fh) == -1 )
-     return -1;
-   break;
-  default:
-    ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s') = -1 // error=NOTSUP", calls, def, opts);
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
- }
-
- return 0;
-}
-#endif
-
-int     roar_vio_open_dstr_simple(struct roar_vio_calls * calls, const char * dstr, int o_flags) {
- struct roar_vio_defaults def;
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, o_flags, 0644) == -1 )
-  return -1;
-
- if ( roar_vio_open_dstr_vio(calls, dstr, &def, 1, NULL) == -1 )
-  return -1;
-
- return 0;
-}
-
-struct roar_vio_calls * roar_vio_open_dstr_simple_new(const char * dstr, int o_flags) {
- struct roar_vio_calls * ret = roar_mm_malloc(sizeof(struct roar_vio_calls));
- int err;
-
- if ( ret == NULL )
-  return NULL;
-
- if ( roar_vio_open_dstr_simple(ret, dstr, o_flags) == -1 ) {
-  err = roar_error;
-  roar_mm_free(ret);
-  roar_error = err;
-  return NULL;
- }
-
- ret->flags |= ROAR_VIO_FLAGS_FREESELF;
-
- return ret;
-}
-
-int     roar_vio_open_dstr    (struct roar_vio_calls * calls, const char * dstr, struct roar_vio_defaults * def, int dnum) {
- return roar_vio_open_dstr_vio(calls, dstr, def, dnum, NULL);
-}
-
-#define _ret(x) do { roar_mm_free_noerror(dstr_copy); roar_err_to_errno(); return (x); } while (0)
-
-int     roar_vio_open_dstr_vio(struct roar_vio_calls * calls,
-                               const char * dstr, struct roar_vio_defaults * def, int dnum,
-                               struct roar_vio_calls * vio) {
-#ifndef ROAR_WITHOUT_VIO_DSTR
- struct roar_vio_dstr_chain chain[ROAR_VIO_DSTR_MAX_OBJ_PER_CHAIN];
- char * dstr_copy;
- char * next;
- char * this;
- char * name;
- char * opts;
- char * dst;
- char * c;
- int    inopts;
- int    type;
- int    cc = 1; // current chain element
-
- if ( calls == NULL || dstr == NULL )
-  return -1;
-
- if ( dnum != 0 && def == NULL )
-  return -1;
-
- if ( (dstr_copy = roar_mm_strdup(dstr)) == NULL )
-  return -1;
-
- memset(chain, 0, sizeof(chain));
-
- chain[0].type = ROAR_VIO_DSTR_OBJT_INTERNAL;
-
- next = dstr_copy;
-
- while (next != NULL) {
-  if ( (cc+1) == ROAR_VIO_DSTR_MAX_OBJ_PER_CHAIN ) {
-   _ret(-1);
-  }
-
-  this = next;
-  next = strstr(next, "##");
-
-  if (next != NULL) {
-   *next = 0;
-   next += 2;
-  }
-
-  // we have the current token in 'this'.
-
-  opts   = NULL;
-  dst    = NULL;
-
-  if ( strstr(this, ":") != NULL ) {
-   name   = this;
-   inopts = 0;
-   for (c = this; *c != 0; c++) {
-    if ( *c == '[' ) {
-     *c     = 0;
-     opts   = c + 1;
-     inopts = 1;
-    } else if ( *c == ']' &&  inopts ) {
-     *c     = 0;
-     inopts = 0;
-    } else if ( *c == ':' && !inopts ) {
-     *c     = 0;
-     dst    = *(c+1) == 0 ? NULL : c + 1;
-     break;
-    }
-   }
-  } else {
-   // we need to guess that this is here...
-   // currently we guess this is a file in all cases
-   name = "file";
-   dst  = this;
-  }
-
-  ROAR_DBG("roar_vio_open_dstr_vio(*): name='%s', opts='%s', dst='%s'", name, opts, dst);
-
-  if ( (type = roar_vio_dstr_get_type(name)) == -1 ) {
-   _ret(-1);
-  }
-
-  ROAR_DBG("roar_vio_open_dstr_vio(*): type=0x%.4x(%s)", type, roar_vio_dstr_get_name(type));
-
-  chain[cc].type     = type;
-  chain[cc].opts     = opts;
-  chain[cc].dst      = dst;
-  chain[cc].def      = NULL;
-  chain[cc].vio      = NULL;
-  chain[cc].need_vio = -1;
-  cc++;
-
- }
-
- chain[cc].type = ROAR_VIO_DSTR_OBJT_EOL;
-
- ROAR_DBG("roar_vio_open_dstr_vio(*): chain=%p", chain);
-
- if ( roar_vio_dstr_parse_opts(chain) == -1 ) {
-  _ret(-1);
- }
-
- if ( roar_vio_dstr_set_defaults(chain, cc, def, dnum) == -1 ) {
-  _ret(-1);
- }
-
- if ( roar_vio_dstr_build_chain(chain, calls, vio) == -1 ) {
-  _ret(-1);
- }
-
- _ret(0);
-#else
- return -1;
-#endif
-}
-
-#undef _ret
-
-#ifndef ROAR_WITHOUT_VIO_DSTR
-int     roar_vio_dstr_parse_opts(struct roar_vio_dstr_chain * chain) {
- if ( chain == NULL )
-  return -1;
-
- // TODO: we should add some code here later...
-
- return 0;
-}
-
-int     roar_vio_dstr_set_defaults(struct roar_vio_dstr_chain * chain, int len, struct roar_vio_defaults * def, int dnum) {
- struct _roar_vio_dstr_type * type;
- struct roar_vio_dstr_chain * c, * next;
- int i;
- int tmp[8];
-
- if ( chain == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( def == NULL && dnum != 0 )
-  return -1;
-
- if ( dnum > 1 ) /* currently not supported */
-  return -1;
-
- if ( dnum == 0 )
-  def = NULL;
-
- chain[len].def = def;
-
- for (i = len; i >= 0; i--) {
-  c    = &chain[i];
-
-  if ( i > 0 ) {
-   next = &chain[i-1];
-  } else {
-   next = NULL;
-
-   if ( c->type != ROAR_VIO_DSTR_OBJT_INTERNAL )
-    return -1;
-  }
-
-  memset(tmp, 0, sizeof(tmp));
-
-  ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s)", i, c->type & 0xFFFF, roar_vio_dstr_get_name(c->type));
-  ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): c->def=%p, c->def->type=%i", i, c->type & 0xFFFF,
-                   roar_vio_dstr_get_name(c->type), c->def, c->def == NULL ? -1 : c->def->type);
-
-  c->need_vio = 1;
-
-  switch (c->type) {
-   case ROAR_VIO_DSTR_OBJT_INTERNAL:
-     c->need_vio = 0;
-    break;
-   case ROAR_VIO_DSTR_OBJT_EOL:
-     tmp[0] = 1;
-   case ROAR_VIO_DSTR_OBJT_PASS:
-   case ROAR_VIO_DSTR_OBJT_RE:
-   case ROAR_VIO_DSTR_OBJT_RTP2: // we currently only forward the defs
-   case ROAR_VIO_DSTR_OBJT_GZIP:
-   case ROAR_VIO_DSTR_OBJT_ZLIB:
-   case ROAR_VIO_DSTR_OBJT_BZIP2:
-   case ROAR_VIO_DSTR_OBJT_PGP:
-   case ROAR_VIO_DSTR_OBJT_PGP_ENC:
-   case ROAR_VIO_DSTR_OBJT_PGP_STORE:
-   case ROAR_VIO_DSTR_OBJT_SSL1:
-   case ROAR_VIO_DSTR_OBJT_SSL2:
-   case ROAR_VIO_DSTR_OBJT_SSL3:
-   case ROAR_VIO_DSTR_OBJT_TLS:
-   case ROAR_VIO_DSTR_OBJT_MAGIC:
-     if ( tmp[0] )
-      c->need_vio = 0;
-
-     next->def = c->def;
-    break;
-   case ROAR_VIO_DSTR_OBJT_NULL:
-   case ROAR_VIO_DSTR_OBJT_ZERO:
-   case ROAR_VIO_DSTR_OBJT_FULL:
-   case ROAR_VIO_DSTR_OBJT_NRANDOM:
-   case ROAR_VIO_DSTR_OBJT_TANTALOS:
-     next->def = &(next->store_def);
-     roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_NONE, NULL, -1);
-    break;
-   case ROAR_VIO_DSTR_OBJT_FILE:
-     if ( c->dst == NULL ) /* should we allow multible cascaed file: objects? */
-      return -1;
-
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-     roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_FILE, c->def, -1);
-
-     if ( c->dst[0] == '/' && c->dst[1] == '/' ) {
-      next->def->d.file = c->dst + 1;
-     } else {
-      next->def->d.file = c->dst;
-     }
-    break;
-   case ROAR_VIO_DSTR_OBJT_FH:
-     tmp[0] = 1;
-   case ROAR_VIO_DSTR_OBJT_SOCKETFH:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( c->def != NULL ) {
-      tmp[2] = c->def->o_flags;
-      tmp[3] = c->def->o_mode;
-     } else {
-      tmp[2] = O_RDONLY;
-      tmp[3] = 0644;
-     }
-
-     if ( !strcasecmp(c->dst, "stdin") ) {
-      tmp[1] = ROAR_STDIN;
-      tmp[2] = O_RDONLY;
-     } else if ( !strcasecmp(c->dst, "stdout") ) {
-      tmp[1] = ROAR_STDOUT;
-      tmp[2] = O_WRONLY;
-     } else if ( !strcasecmp(c->dst, "stderr") ) {
-      tmp[1] = ROAR_STDERR;
-      tmp[2] = O_WRONLY;
-     } else {
-      if ( sscanf(c->dst, "%i", &tmp[1]) != 1 )
-       return -1;
-     }
-
-     roar_vio_dstr_init_defaults(next->def, tmp[0] ? ROAR_VIO_DEF_TYPE_FH : ROAR_VIO_DEF_TYPE_SOCKETFH, tmp[2], tmp[3]);
-     next->def->d.fh = tmp[1];
-    break;
-#ifdef ROAR_HAVE_UNIX
-   case ROAR_VIO_DSTR_OBJT_UNIX:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( c->dst == NULL ) { // we don't have a destination? -> slow way
-      if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-       return -1;
-
-      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_UNIX, SOCK_STREAM, c->def) == -1 )
-       return -1;
-     } else {                // we have a destination? -> fast way
-      if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-       return -1;
-
-      if ( roar_vio_socket_init_unix_def(next->def, c->dst) == -1 )
-       return -1;
-     }
-    break;
-#endif
-   case ROAR_VIO_DSTR_OBJT_SOCKET:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, -1, SOCK_STREAM, c->def) == -1 )
-      return -1;
-    break;
-#ifdef ROAR_HAVE_LIBDNET
-   case ROAR_VIO_DSTR_OBJT_DECNET:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_DECnet, SOCK_STREAM, c->def) == -1 )
-      return -1;
-    break;
-#endif
-#ifdef ROAR_HAVE_IPV4
-   case ROAR_VIO_DSTR_OBJT_TCP:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET, SOCK_STREAM, c->def) == -1 )
-      return -1;
-    break;
-   case ROAR_VIO_DSTR_OBJT_UDP:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET, SOCK_DGRAM, c->def) == -1 )
-      return -1;
-    break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-   case ROAR_VIO_DSTR_OBJT_TCP6:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET6, SOCK_STREAM, c->def) == -1 )
-      return -1;
-    break;
-   case ROAR_VIO_DSTR_OBJT_UDP6:
-     c->need_vio = 0;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
-      return -1;
-
-     if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET6, SOCK_DGRAM, c->def) == -1 )
-      return -1;
-    break;
-#endif
-   case ROAR_VIO_DSTR_OBJT_HTTP09:
-   case ROAR_VIO_DSTR_OBJT_HTTP10:
-   case ROAR_VIO_DSTR_OBJT_HTTP11:
-     c->need_vio = 1;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_proto_init_def(next->def, c->dst, ROAR_VIO_PROTO_P_HTTP, c->def) == -1 )
-      return -1;
-    break;
-   case ROAR_VIO_DSTR_OBJT_GOPHER:
-   case ROAR_VIO_DSTR_OBJT_GOPHER_PLUS:
-     c->need_vio = 1;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_proto_init_def(next->def, c->dst, ROAR_VIO_PROTO_P_GOPHER, c->def) == -1 )
-      return -1;
-    break;
-   case ROAR_VIO_DSTR_OBJT_ICY:
-     c->need_vio = 1;
-     next->def = &(next->store_def);
-
-     if ( roar_vio_proto_init_def(next->def, c->dst, ROAR_VIO_PROTO_P_ICY, c->def) == -1 )
-      return -1;
-    break;
-   default:
-     if ( (type = roar_vio_dstr_get_by_type(c->type)) == NULL ) {
-      return -1;
-     }
-
-     if ( type->setdef == NULL )
-      _roar_vio_dstr_init_otherlibs();
-
-     if ( type->setdef == NULL ) {
-      return -1;
-     }
-
-     if ( type->setdef(c, next) == -1 ) {
-      return -1;
-     }
-  }
-
-  if ( next != NULL ) {
-   ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): next->def=%p, next->def->type=%i", i,
-                    c->type & 0xFFFF, roar_vio_dstr_get_name(c->type),
-                    next->def, next->def == NULL ? -1 : next->def->type);
-   if ( next->def != NULL ) {
-    ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): next->def->o_flags=%i", i,
-                     c->type & 0xFFFF, roar_vio_dstr_get_name(c->type),
-                     next->def->o_flags);
-   }
-  } else {
-   ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): next=NULL", i,
-                    c->type & 0xFFFF, roar_vio_dstr_get_name(c->type));
-  }
- }
-
- ROAR_DBG("roar_vio_dstr_set_defaults(*) = 0");
-
- return 0;
-}
-
-#define _ret(x) do { int _err = roar_error; roar_vio_close(calls); roar_error = _err; roar_err_to_errno(); ROAR_DBG("roar_vio_dstr_build_chain(*) = %i", (x)); return (x); } while(0)
-
-int     roar_vio_dstr_build_chain(struct roar_vio_dstr_chain * chain, struct roar_vio_calls * calls,
-                                  struct roar_vio_calls * vio) {
- struct _roar_vio_dstr_type * type;
- struct roar_vio_dstr_chain * c;
- struct roar_vio_defaults   * def;
- struct roar_vio_calls      * tc, * prev;
- int i;
-
- ROAR_DBG("roar_vio_dstr_build_chain(*) = ?");
-
- if ( chain == NULL || calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( roar_vio_open_stack2(calls, NULL) == -1 )
-  return -1;
-
- ROAR_DBG("roar_vio_dstr_build_chain(*): chain=%p", chain);
-
- if ( (def = chain->def) != NULL ) {
-  if ( (tc = roar_mm_malloc(sizeof(struct roar_vio_calls))) == NULL ) {
-   _ret(-1);
-  }
-
-  if ( roar_vio_clear_calls(tc) == -1 ) {
-   roar_mm_free(tc);
-   _ret(-1);
-  }
-
-  if ( roar_vio_stack_add(calls, tc) == -1 ) {
-   _ret(-1);
-  }
-
-  if ( chain->opts == NULL ) {
-   if ( chain[1].type != ROAR_VIO_DSTR_OBJT_EOL ) {
-    chain->opts = chain[1].opts;
-   }
-  }
-
-  if ( roar_vio_open_default(tc, def, chain->opts) == -1 ) {
-   _ret(-1);
-  }
-
-  prev = tc;
- } else {
-  prev = vio;
- }
-
- for (i = 0; (c = &(chain[i]))->type != ROAR_VIO_DSTR_OBJT_EOL; i++) {
-  ROAR_DBG("roar_vio_dstr_build_chain(*): i=%i, c->type=0x%.4x(%s): need_vio=%i, def(%p)->o_flags=%i", i,
-                   c->type & 0xFFFF, roar_vio_dstr_get_name(c->type), c->need_vio, c->def, c->def != NULL ? c->def->o_flags : -1);
-
-  if ( c->need_vio ) {
-   if ( (tc = roar_mm_malloc(sizeof(struct roar_vio_calls))) == NULL ) {
-    _ret(-1);
-   }
-
-   if ( roar_vio_clear_calls(tc) == -1 ) {
-    roar_mm_free(tc);
-    _ret(-1);
-   }
-
-   if ( roar_vio_stack_add(calls, tc) == -1 ) {
-    _ret(-1);
-   }
-
-
-   switch (c->type) {
-    case ROAR_VIO_DSTR_OBJT_PASS:
-      if ( roar_vio_open_pass(tc, prev) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_RE:
-      if ( roar_vio_open_re(tc, prev) == -1 ) {
-       _ret(-1);
-      }
-     break;
-#ifdef ROAR_HAVE_LIBZ
-    case ROAR_VIO_DSTR_OBJT_GZIP:
-      if ( roar_vio_open_zlib(tc, prev, -1, 1) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_ZLIB:
-      if ( roar_vio_open_zlib(tc, prev, -1, 0) == -1 ) {
-       _ret(-1);
-      }
-     break;
-#endif
-    case ROAR_VIO_DSTR_OBJT_BZIP2:
-    case ROAR_VIO_DSTR_OBJT_PGP:
-      if ( roar_vio_open_pgp_decrypt(tc, prev, NULL) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_HTTP09:
-    case ROAR_VIO_DSTR_OBJT_HTTP10:
-    case ROAR_VIO_DSTR_OBJT_HTTP11:
-      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_HTTP, c->def) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_GOPHER:
-    case ROAR_VIO_DSTR_OBJT_GOPHER_PLUS:
-      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_GOPHER, c->def) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_ICY:
-      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_ICY, c->def) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_RTP2:
-      if ( roar_vio_open_rtp(tc, prev, c->dst, c->def) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_PGP_ENC:
-    case ROAR_VIO_DSTR_OBJT_PGP_STORE:
-      if ( roar_vio_open_pgp_store(tc, prev, ROAR_VIO_PGP_OPTS_NONE) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_TANTALOS:
-      if ( roar_vio_open_tantalos(tc, prev, c->dst, c->def) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_NULL:
-    case ROAR_VIO_DSTR_OBJT_ZERO:
-    case ROAR_VIO_DSTR_OBJT_FULL:
-    case ROAR_VIO_DSTR_OBJT_NRANDOM:
-      if ( roar_vio_open_misc_by_name(tc, roar_vio_dstr_get_name(c->type)) == -1 ) {
-       _ret(-1);
-      }
-     break;
-    case ROAR_VIO_DSTR_OBJT_SSL1:
-    case ROAR_VIO_DSTR_OBJT_SSL2:
-    case ROAR_VIO_DSTR_OBJT_SSL3:
-    case ROAR_VIO_DSTR_OBJT_TLS:
-    case ROAR_VIO_DSTR_OBJT_MAGIC:
-      _ret(-1);
-     break;
-    default:
-      if ( (type = roar_vio_dstr_get_by_type(c->type)) == NULL ) {
-       _ret(-1);
-      }
-
-      if ( type->openvio == NULL )
-       _roar_vio_dstr_init_otherlibs();
-
-      if ( type->openvio == NULL ) {
-       _ret(-1);
-      }
-
-      if ( type->openvio(tc, prev, c, &(chain[i+1])) == -1 ) {
-       _ret(-1);
-      }
-   }
-
-   prev = tc;
-  } // else we can skip to the next :)
- }
-
- ROAR_DBG("roar_vio_dstr_build_chain(*) = 0");
- return 0;
-}
-
-#undef _ret
-
-static inline ssize_t __libroar_dir_part_len(char * p, size_t len) {
- ssize_t i, c;
-
- c = -1;
-
- for (i = 0; i < len; i++, p++)
-  if ( *p == '/' )
-   c = i;
-
- return c;
-}
-
-char *  roar_vio_dstr_cat(char * buffer, ssize_t bufferlen, const struct roar_vio_dstr_pathelement * elements, size_t elementslen) {
- size_t needed = 0;
- size_t rootelement = 0;
- ssize_t ret;
- char * p;
- size_t i;
-
- if ( buffer == NULL )
-  bufferlen = -1;
-
- if ( elementslen == 0 ) {
-  if ( bufferlen == -1 ) {
-   if ( (buffer = roar_mm_malloc(2)) == NULL )
-    return NULL;
-   bufferlen = 2;
-  }
-
-  if ( bufferlen >= 2 ) {
-   buffer[0] = '.';
-   buffer[1] = 0;
-   return buffer;
-  } else {
-   roar_err_set(ROAR_ERROR_NOSPC);
-   return NULL;
-  }
- }
-
- if ( elements == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- for (i = 0; i < elementslen; i++) {
-  if ( elements[i].dstr == NULL ) {
-   roar_err_set(ROAR_ERROR_FAULT);
-   return NULL;
-  }
-
-  if ( !(elements[i].flags & ROAR_VIO_DSTR_PEF_ALLOW_MULTI) && strstr(elements[i].dstr, "##") != NULL ) {
-   roar_err_set(ROAR_ERROR_INVAL);
-   return NULL;
-  }
-
-  if ( !(elements[i].flags & ROAR_VIO_DSTR_PEF_ALLOW_PARENT) && strstr(elements[i].dstr, "..") != NULL ) {
-   roar_err_set(ROAR_ERROR_INVAL);
-   return NULL;
-  }
-
-  if ( strstr(elements[i].dstr, "##") != NULL ) {
-   roar_err_set(ROAR_ERROR_NOTSUP);
-   return NULL;
-  }
-
-  if ( strstr(elements[i].dstr, ":") != NULL ) {
-   if ( !(elements[i].flags & ROAR_VIO_DSTR_PEF_ALLOW_ABSOLUTE) ) {
-    roar_err_set(ROAR_ERROR_INVAL);
-    return NULL;
-   }
-   rootelement = i;
-   needed = 0;
-  }
-
-  needed += roar_mm_strlen(elements[i].dstr);
- }
-
- elements += rootelement;
- elementslen -= rootelement;
-
- if ( elementslen == 1 ) {
-  if ( bufferlen == -1 ) {
-   bufferlen = needed+1;
-   if ( (buffer = roar_mm_malloc(bufferlen)) == NULL )
-    return NULL;
-  }
-
-  if ( bufferlen >= (elementslen + 1) ) {
-   memcpy(buffer, elements[0].dstr, needed+1);
-   return buffer;
-  } else {
-   roar_err_set(ROAR_ERROR_NOSPC);
-   return NULL;
-  }
- }
-
- needed += elementslen * 2; // for '.', '/' and '\0'.
-
- if ( bufferlen == -1 ) {
-  bufferlen = needed;
-  if ( (buffer = roar_mm_malloc(bufferlen)) == NULL )
-   return NULL;
- }
-
- if ( bufferlen < needed ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return NULL;
- }
-
- p = buffer;
- for (i = 0; i < elementslen; i++) {
-  ret = roar_mm_strlen(elements[i].dstr);
-  memcpy(p, elements[i].dstr, ret);
-  if ( i == (elementslen-1) || elements[i].flags & ROAR_VIO_DSTR_PEF_IS_DIR ) {
-   p += ret;
-  } else {
-   ret = __libroar_dir_part_len(p, ret);
-   if ( ret == -1 ) {
-    *p = '.';
-    p++;
-   } else {
-    p += ret;
-   }
-  }
-
-  *p = '/';
-  p++;
- }
-
- p--;
- *p = 0;
- return buffer;
-}
-#endif
-
-//ll
Index: libroar/vio_jumbo.c
===================================================================
--- libroar/vio_jumbo.c	(revision 6052)
+++ 	(revision )
@@ -1,165 +1,0 @@
-//vio_jumbo.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_jumbo    (struct roar_vio_calls * calls, struct roar_vio_calls * vio, size_t buffersize) {
- struct roar_vio_jumbo * self;
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_vio_jumbo))) == NULL ) {
-  return -1;
- }
-
- memset(self, 0, sizeof(struct roar_vio_jumbo));
-
- self->backend = vio;
-
- if ( roar_buffer_new(&(self->buffer), buffersize) == -1 ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
- calls->inst     = self;
- calls->close    = roar_vio_jumbo_close;
- calls->read     = roar_vio_jumbo_read;
- calls->write    = roar_vio_jumbo_write;
- calls->lseek    = roar_vio_jumbo_lseek;
- calls->sync     = roar_vio_jumbo_sync;
- calls->ctl      = roar_vio_jumbo_ctl;
-
- return 0;
-}
-
-int     roar_vio_jumbo_close   (struct roar_vio_calls * vio) {
- struct roar_vio_jumbo * self = vio->inst;
-
- if ( roar_vio_jumbo_sync(vio) == -1 )
-  return -1;
-
- roar_buffer_free(self->buffer);
- roar_mm_free(self);
-
- return 0;
-}
-
-ssize_t roar_vio_jumbo_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_jumbo * self = vio->inst;
-
- return roar_vio_read(self->backend, buf, count);
-}
-
-ssize_t roar_vio_jumbo_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_jumbo * self = vio->inst;
- size_t   buflen;
- void   * data;
-
- ROAR_DBG("roar_vio_jumbo_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long) count);
-
- if ( roar_buffer_get_len(self->buffer, &buflen) == -1 )
-  return -1;
-
- ROAR_DBG("roar_vio_jumbo_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long) count);
-
- if ( roar_buffer_get_data(self->buffer, &data) == -1 )
-  return -1;
-
- ROAR_DBG("roar_vio_jumbo_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long) count);
-
- if ( (self->pos + count) > buflen ) {
-  if ( roar_vio_jumbo_sync(vio) == -1 )
-   return -1;
-
-  // in case we write something that is longer than the buffer
-  if ( count > buflen ) {
-   return roar_vio_write(self->backend, data, count);
-  }
-
-  memcpy(data, buf, count);
-  self->pos = count;
- } else {
-  memcpy(data + self->pos, buf, count);
-  self->pos += count;
- }
-
- ROAR_DBG("roar_vio_jumbo_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long) count);
-
- return count;
-}
-
-roar_off_t   roar_vio_jumbo_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- struct roar_vio_jumbo * self = vio->inst;
-
- if ( roar_vio_jumbo_sync(vio) == -1 )
-  return (roar_off_t) -1;
-
- return roar_vio_lseek(self->backend, offset, whence);
-}
-
-int     roar_vio_jumbo_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_jumbo * self = vio->inst;
- void                  * data;
-
- if ( self->pos == 0 )
-  return 0;
-
- if ( roar_buffer_get_data(self->buffer, &data) == -1 )
-  return -1;
-
- // TODO: do this a bit more intelergent (RE?)
- if ( roar_vio_write(self->backend, data, self->pos) != (ssize_t)self->pos )
-  return -1;
-
- self->pos = 0;
-
- return 0;
-}
-
-int     roar_vio_jumbo_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_jumbo * self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_NONBLOCK:
-    return roar_vio_ctl(self->backend, cmd, data);
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-//ll
Index: libroar/vio_magic.c
===================================================================
--- libroar/vio_magic.c	(revision 6052)
+++ 	(revision )
@@ -1,121 +1,0 @@
-
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#if 0
-
-static int     roar_vio_magic_close   (struct roar_vio_calls * vio);
-
-static ssize_t roar_vio_magic_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_magic * self = (struct roar_vio_magic *)(vio->inst);
- struct roar_buffer    * inp;
- void * calls;
- size_t len;
-
- if (self == NULL)
-  return -1;
-
- if ( roar_stack_get_cur(&(self->vios), &calls) == -1 )
-  return -1;
-
- inp = self->inp;
-
- if ( roar_buffer_get_len(inp, &len) == -1 )
-  return -1;
-
- if ( len ) {
-  len = len > count ? count : len;
-  if ( roar_buffer_shift_out(&inp, buf, &len) == -1 )
-   return -1;
- }
-
- count -= len;
- buf += len;
-
- if ( count ) {
-  if ( (count = roar_vio_read((struct roar_vio_calls*) calls, buf, count)) == -1 )
-   return len;
-
-  return len+count;
- }
-
- return len;
-}
-
-static ssize_t roar_vio_magic_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_magic * self = (struct roar_vio_magic *)(vio->inst);
- void * calls;
-
- if (self == NULL)
-  return -1;
-
- if ( roar_stack_get_cur(&(self->vios), &calls) == -1 )
-  return -1;
-
- return roar_vio_write((struct roar_vio_calls*)calls, buf, count);
-}
-
-static roar_off_t   roar_vio_magic_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- struct roar_vio_magic * self = (struct roar_vio_magic *)(vio->inst);
- void * calls;
-
- if (self == NULL)
-  return -1;
-
- if ( roar_stack_get_cur(&(self->vios), &calls) == -1 )
-  return -1;
-
- return roar_vio_lseek((struct roar_vio_calls*)calls, offset, whence);
-}
-
-static int     roar_vio_magic_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_magic * self = (struct roar_vio_magic *)(vio->inst);
- void * calls;
-
- if (self == NULL)
-  return -1;
-
- if ( roar_stack_get_cur(&(self->vios), &calls) == -1 )
-  return -1;
-
- return roar_vio_sync((struct roar_vio_calls*)calls);
-}
-
-int     roar_vio_open_magic    (struct roar_vio_calls * calls, struct roar_vio_calls * dst, int * codec);
-
-#endif
-
-//ll
Index: libroar/vio_misc.c
===================================================================
--- libroar/vio_misc.c	(revision 6052)
+++ 	(revision )
@@ -1,198 +1,0 @@
-//vio_misc.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static ssize_t roar_vio_misc_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_misc * self = vio->inst;
-
- if ( self->read == NULL ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- return self->read(buf, count, vio, self);
-}
-
-static ssize_t roar_vio_misc_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_misc * self = vio->inst;
-
- if ( self->write == NULL ) {
-  roar_err_set(ROAR_ERROR_RO);
-  return -1;
- }
-
- return self->write(buf, count, vio, self);
-}
-
-static roar_off_t   roar_vio_misc_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- (void)vio, (void)offset, (void)whence;
- return 0;
-}
-
-static int     roar_vio_misc_sync    (struct roar_vio_calls * vio) {
- (void)vio;
- return 0;
-}
-
-static int     roar_vio_misc_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_misc * self;
-
- if ( vio == NULL || cmd == -1 )
-  return -1;
-
- self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    *(const char**)data = self->name;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NOSYNC:
-    vio->sync = NULL;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( self->support_nonblocking )
-     return 0;
-
-    if ( *(int*)data == ROAR_SOCKET_BLOCK )
-     return 0;
-
-    roar_err_set(ROAR_ERROR_NOSYS);
-    return -1;
-   break; 
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-static int     roar_vio_misc_close   (struct roar_vio_calls * vio) {
- (void)vio;
- return 0;
-}
-
-int     roar_vio_open_misc    (struct roar_vio_calls * calls, const struct roar_vio_misc * callbacks) {
- if ( calls == NULL || callbacks == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
- calls->read     = roar_vio_misc_read;
- calls->write    = roar_vio_misc_write;
- calls->lseek    = roar_vio_misc_lseek;
- calls->sync     = roar_vio_misc_sync;
- calls->ctl      = roar_vio_misc_ctl;
- calls->close    = roar_vio_misc_close;
- calls->inst     = (void*)callbacks;
-
- return 0;
-}
-
-static ssize_t roar_vio_misc_op_return_len (void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks) {
- (void)buf, (void)vio, (void)callbacks;
- return len;
-}
-
-static ssize_t roar_vio_misc_op_return_zero(void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks) {
- (void)buf, (void)len, (void)vio, (void)callbacks;
- return 0;
-}
-
-static ssize_t roar_vio_misc_op_zero(void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks) {
- (void)vio, (void)callbacks;
- memset(buf, 0, len);
- return len;
-}
-
-static ssize_t roar_vio_misc_op_full(void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks)
-{
- (void)buf, (void)len, (void)vio, (void)callbacks;
- roar_err_set(ROAR_ERROR_NOSPC);
- return -1;
-}
-
-static ssize_t roar_vio_misc_op_random_nonce(void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks) {
- (void)vio, (void)callbacks;
-
- if ( roar_random_gen_nonce(buf, len) == -1 )
-  return -1;
-
- return len;
-}
-
-static ssize_t roar_vio_misc_op_random_salt_nonce(void * buf, size_t len, struct roar_vio_calls * vio, struct roar_vio_misc * callbacks) {
- (void)vio, (void)callbacks;
-
- if ( roar_random_salt_nonce(buf, len) == -1 )
-  return -1;
-
- return len;
-}
-
-static const struct roar_vio_misc libroar_vio_miscs[] = {
- {.name = "null", .support_nonblocking = 1, .read = roar_vio_misc_op_return_zero, .write = roar_vio_misc_op_return_len},
- {.name = "full", .support_nonblocking = 1, .read = roar_vio_misc_op_return_zero, .write = roar_vio_misc_op_full},
- {.name = "zero", .support_nonblocking = 1, .read = roar_vio_misc_op_zero,        .write = roar_vio_misc_op_return_len},
- {.name = "nrandom", .support_nonblocking = 1,
-  .read = roar_vio_misc_op_random_nonce, .write = roar_vio_misc_op_random_salt_nonce}
-};
-
-int     roar_vio_open_misc_by_name(struct roar_vio_calls * calls, const char * name) {
- size_t i;
-
- if ( calls == NULL || name == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- for (i = 0; i < (sizeof(libroar_vio_miscs)/sizeof(*libroar_vio_miscs)); i++)
-  if ( !strcasecmp(name, libroar_vio_miscs[i].name) )
-   return roar_vio_open_misc(calls, &(libroar_vio_miscs[i]));
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-//ll
Index: libroar/vio_ops.c
===================================================================
--- libroar/vio_ops.c	(revision 6052)
+++ 	(revision )
@@ -1,120 +1,0 @@
-//vio_ops.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define ROAR_VIO_COPY_BUFSIZE 1024
-
-#define BUFMAX     65536
-
-#ifdef ROAR_HAVE_IO_POSIX
-#define _CAN_OPERATE
-#endif
-
-#ifdef _CAN_OPERATE
-static inline ssize_t _send_file_raw (int out, int in) {
- ssize_t r = 0;
-#ifdef ROAR_HAVE_LINUX_SENDFILE
- ssize_t ret;
-#endif
-#if defined(__linux__) && defined(ROAR_HAVE_IPV4)
- int cork_new = 1, cork_old;
- socklen_t cork_len = sizeof(int);
-
- if ( getsockopt(out, IPPROTO_TCP, TCP_CORK, &cork_old, &cork_len) == -1 ) {
-  cork_old = -1;
- } else {
-  setsockopt(out, IPPROTO_TCP, TCP_CORK, &cork_new, sizeof(int));
- }
-#endif
-
- roar_debug_warn_obsolete("roar_file_send_raw", "roar_vio_copy_data", NULL);
-
-#ifdef ROAR_HAVE_LINUX_SENDFILE
- while ((ret = sendfile(out, in, NULL, BUFMAX)) > 0)
-  r += ret;
-#endif
-
- // TODO: try mmap here!
-
-#if defined(__linux__) && defined(ROAR_HAVE_IPV4)
- if ( cork_old != -1 )
-  setsockopt(out, IPPROTO_TCP, TCP_CORK, &cork_old, cork_len);
-#endif
- return r;
-}
-#endif
-
-
-ssize_t roar_vio_copy_data   (struct roar_vio_calls * out, struct roar_vio_calls * in) {
- char    buf[ROAR_VIO_COPY_BUFSIZE];
- ssize_t len;
- ssize_t done = 0;
-#ifdef _CAN_OPERATE
- int in_fh, out_fh;
-#endif
-
- ROAR_DBG("roar_vio_copy_data(out=%p, in=%p) = ?", out, in);
-
- if ( out == NULL || in == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
-#ifdef _CAN_OPERATE
- if ( roar_vio_ctl(in, ROAR_VIO_CTL_GET_READ_FH, &in_fh) == 0 )
-  if ( roar_vio_ctl(out, ROAR_VIO_CTL_GET_WRITE_FH, &out_fh) == 0 )
-   _send_file_raw(out_fh, in_fh);
-#endif
-
- roar_err_clear_all();
-
- while ((len = roar_vio_read(in, buf, ROAR_VIO_COPY_BUFSIZE)) > 0) {
-  if ( roar_vio_write(out, buf, len) != len )
-   return -1;
-
-  done += len;
-  ROAR_DBG("roar_vio_copy_data(out=%p, in=%p): len=%li, done=%li", out, in, (long int)len, (long int)done);
- }
-
- ROAR_DBG("roar_vio_copy_data(out=%p, in=%p): len=%li, done=%li", out, in, (long int)len, (long int)done);
-
- roar_err_clear_all();
-
- ROAR_DBG("roar_vio_copy_data(out=%p, in=%p) = %li", out, in, (long int)done);
- return done;
-}
-
-//ll
Index: libroar/vio_pipe.c
===================================================================
--- libroar/vio_pipe.c	(revision 6052)
+++ 	(revision )
@@ -1,374 +1,0 @@
-//vio_pipe.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_vio_open_pipe (struct roar_vio_calls * s0, struct roar_vio_calls * s1, int type, int flags) {
-#ifndef ROAR_WITHOUT_VIO_PIPE
- struct roar_vio_pipe * self;
- int                    rw = flags & (O_RDONLY|O_WRONLY|O_RDWR);
-
- if ( s0 == NULL || s1 == NULL )
-  return -1;
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_vio_pipe))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct roar_vio_pipe));
-
- self->refcount = 2;
- self->flags    = flags;
-
- if ( type == ROAR_VIO_PIPE_TYPE_AUTO ) {
-#ifdef ROAR_TARGET_WIN32
-  type = ROAR_VIO_PIPE_TYPE_BUFFER;
-#else
-  type = ROAR_VIO_PIPE_TYPE_SOCKET;
-#endif
- }
-
- self->type     = type;
-
- switch (type) {
-  case ROAR_VIO_PIPE_TYPE_BUFFER:
-    // no buffers need to be set up here,
-    // we handle the NULL pointer in the reader and writer func
-    roar_mm_free(self);
-    return -1;
-   break;
-  case ROAR_VIO_PIPE_TYPE_PIPE:
-    self->b.p[0] = self->b.p[1] = self->b.p[2] = self->b.p[3] = -1;
-
-    if ( rw == O_RDWR || rw == O_RDONLY )
-     if ( pipe(self->b.p) == -1 ) {
-      roar_mm_free(self);
-      return -1;
-     }
-    if ( rw == O_RDWR || rw == O_WRONLY )
-     if ( pipe((self->b.p) + 2) == -1 ) {
-      close(self->b.p[0]);
-      close(self->b.p[1]);
-      roar_mm_free(self);
-      return -1;
-     }
-   break;
-#ifdef ROAR_HAVE_UNIX
-  case ROAR_VIO_PIPE_TYPE_SOCKET:
-    if ( socketpair(AF_UNIX, SOCK_STREAM, 0, self->b.p) == -1 ) {
-     roar_mm_free(self);
-     return -1;
-    }
-
-    if ( rw == O_RDONLY ) {
-     ROAR_SHUTDOWN(self->b.p[0], SHUT_WR);
-     ROAR_SHUTDOWN(self->b.p[1], SHUT_RD);
-    } else if ( rw == O_WRONLY ) {
-     ROAR_SHUTDOWN(self->b.p[0], SHUT_RD);
-     ROAR_SHUTDOWN(self->b.p[1], SHUT_WR);
-    }
-   break;
-#endif
-  default:
-    roar_mm_free(self);
-    return -1;
- }
-
- roar_vio_pipe_init(s0, self, flags);
- roar_vio_pipe_init(s1, self, flags);
-
- self->s0 = s0;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-#ifndef ROAR_WITHOUT_VIO_PIPE
-int roar_vio_pipe_init (struct roar_vio_calls * s,  struct roar_vio_pipe * self, int flags) {
- int nonblock = ROAR_SOCKET_NONBLOCK;
-
- if ( s == NULL || self == NULL )
-  return -1;
-
- memset(s, 0, sizeof(struct roar_vio_calls));
- s->flags    = ROAR_VIO_FLAGS_NONE;
- s->refc     = 1;
-
- s->close    = roar_vio_pipe_close;
- s->read     = roar_vio_pipe_read;
- s->write    = roar_vio_pipe_write;
- s->sync     = roar_vio_pipe_sync;
-
- s->inst = (void*) self;
-
- if ( flags & O_NONBLOCK ) {
-  roar_vio_pipe_ctl(s, ROAR_VIO_CTL_NONBLOCK, &nonblock);
- }
-
- return 0;
-}
-
-int     roar_vio_pipe_close   (struct roar_vio_calls * vio) {
- struct roar_vio_pipe * self;
- int                    idx;
-
- if ( vio == NULL )
-  return -1;
-
- if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )
-  return -1;
-
- self->refcount--;
-
- switch (self->type) {
-  case ROAR_VIO_PIPE_TYPE_BUFFER:
-    // this will be a bit more complex as we need to change the flags, too.
-   break;
-  case ROAR_VIO_PIPE_TYPE_PIPE:
-   switch (ROAR_VIO_PIPE_S(self, vio)) {
-    case 0:
-      close(self->b.p[0]);
-      close(self->b.p[3]);
-      self->b.p[0] = -1;
-      self->b.p[3] = -1;
-     break;
-    case 1:
-      close(self->b.p[1]);
-      close(self->b.p[2]);
-      self->b.p[1] = -1;
-      self->b.p[2] = -1;
-     break;
-   }
-   break;
-#ifdef ROAR_HAVE_UNIX
-  case ROAR_VIO_PIPE_TYPE_SOCKET:
-    close(self->b.p[idx = ROAR_VIO_PIPE_S(self, vio)]);
-    self->b.p[idx] = -1;
-   break;
-#endif
- }
-
- if ( ! self->refcount ) {
-  roar_mm_free(self);
- }
-
- vio->inst = NULL;
- return 0;
-}
-
-int     roar_vio_pipe_sync    (struct roar_vio_calls * vio) {
- // we may add fdatasync() calls here depending on the type
- // but in general they should not be needed on pipes.
- (void)vio;
- return 0;
-}
-
-int     roar_vio_pipe_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_pipe * self;
-
- if (vio == NULL || cmd == -1)
-  return -1;
-
- if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )
-  return -1;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "pipe";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-#ifdef ROAR_HAVE_UNIX
-    if ( self->type == ROAR_VIO_PIPE_TYPE_SOCKET ) {
-     *(int*)data = self->b.p[ROAR_VIO_PIPE_S(self,vio)];
-     return 0;
-    } else {
-     return -1;
-    }
-#else
-    return -1;
-#endif
-   break;
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-    switch (self->type) {
-#ifdef ROAR_HAVE_UNIX
-     case ROAR_VIO_PIPE_TYPE_SOCKET:
-       *(int*)data = self->b.p[ROAR_VIO_PIPE_S(self,vio)];
-       return 0;
-      break;
-#endif
-     case ROAR_VIO_PIPE_TYPE_PIPE:
-       *(int*)data = self->b.p[ROAR_VIO_PIPE_S(self,vio)*2];
-       return 0;
-      break;
-    }
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-    switch (self->type) {
-#ifdef ROAR_HAVE_UNIX
-     case ROAR_VIO_PIPE_TYPE_SOCKET:
-       *(int*)data = self->b.p[ROAR_VIO_PIPE_S(self,vio)];
-       return 0;
-      break;
-#endif
-     case ROAR_VIO_PIPE_TYPE_PIPE:
-       *(int*)data = self->b.p[(ROAR_VIO_PIPE_SR(self,vio)*2)+1];
-       return 0;
-      break;
-    }
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    switch (self->type) {
-     case ROAR_VIO_PIPE_TYPE_PIPE:
-       if ( roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)*2], *(int*)data) == -1 )
-        return -1;
-       return roar_socket_nonblock(self->b.p[(ROAR_VIO_PIPE_SR(self,vio)*2)+1], *(int*)data);
-      break;
-#ifdef ROAR_HAVE_UNIX
-     case ROAR_VIO_PIPE_TYPE_SOCKET:
-       return roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)], *(int*)data);
-      break;
-#endif
-    }
-   break;
- }
-
- return -1;
-}
-
-
-ssize_t roar_vio_pipe_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_pipe * self;
- int                    idx;
-
- if ( vio == NULL )
-  return -1;
-
- if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )
-  return -1;
-
- switch (self->type) {
-  case ROAR_VIO_PIPE_TYPE_BUFFER:
-    idx = ROAR_VIO_PIPE_S(self,vio);
-
-    if ( (idx == 0 ? O_WRONLY : O_RDONLY) == (self->flags & (O_RDONLY|O_WRONLY|O_RDWR)) ) {
-     raise(SIGPIPE);
-     return -1;
-    }
-
-    if ( self->b.b[idx] == NULL )
-     return 0;
-
-    if ( roar_buffer_shift_out(&(self->b.b[idx]), buf, &count) == -1 )
-     return -1;
-
-    return count;
-   break;
-  case ROAR_VIO_PIPE_TYPE_PIPE:
-    return read(self->b.p[ROAR_VIO_PIPE_S(self,vio)*2], buf, count);
-   break;
-#ifdef ROAR_HAVE_UNIX
-  case ROAR_VIO_PIPE_TYPE_SOCKET:
-    return read(self->b.p[ROAR_VIO_PIPE_S(self,vio)], buf, count);
-   break;
-#endif
- }
-
- return -1;
-}
-
-ssize_t roar_vio_pipe_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_pipe * self;
- struct roar_buffer   * next;
- void                 * data;
- int                    idx;
-
- if ( vio == NULL )
-  return -1;
-
- if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )
-  return -1;
-
- switch (self->type) {
-  case ROAR_VIO_PIPE_TYPE_BUFFER:
-    if ( self->refcount < 2 ) {
-     raise(SIGPIPE);
-     return -1;
-    }
-
-    idx = ROAR_VIO_PIPE_SR(self,vio);
-
-    if ( (idx == 0 ? O_WRONLY : O_RDONLY) == (self->flags & (O_RDONLY|O_WRONLY|O_RDWR)) ) {
-     raise(SIGPIPE);
-     return -1;
-    }
-
-    if ( roar_buffer_new_data(&next, count, &data) == -1 )
-     return -1;
-
-    memcpy(data, buf, count);
-
-    if ( self->b.b[idx] == NULL ) {
-     self->b.b[idx] = next;
-    } else {
-     if ( roar_buffer_moveinto(self->b.b[idx], &next) == -1 ) {
-      roar_buffer_free(next);
-      return -1;
-     }
-    }
-
-    return count;
-   break;
-  case ROAR_VIO_PIPE_TYPE_PIPE:
-    return write(self->b.p[(ROAR_VIO_PIPE_SR(self,vio)*2)+1], buf, count);
-   break;
-#ifdef ROAR_HAVE_UNIX
-  case ROAR_VIO_PIPE_TYPE_SOCKET:
-    return write(self->b.p[ROAR_VIO_PIPE_S(self,vio)], buf, count);
-   break;
-#endif
- }
-
- return -1;
-}
-#endif
-
-//ll
Index: libroar/vio_proto.c
===================================================================
--- libroar/vio_proto.c	(revision 6052)
+++ 	(revision )
@@ -1,694 +1,0 @@
-//vio_proto.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifndef ROAR_WITHOUT_VIO_PROTO
-#include <roaraudio/proto_gopher.h>
-#endif
-
-int roar_vio_proto_init_def  (struct roar_vio_defaults * def, char * dstr, int proto, struct roar_vio_defaults * odef) {
-#ifndef ROAR_WITHOUT_VIO_PROTO
- int                        port = 0;
- int                        ret;
- char                     * ed;
- char                     * tmp;
- int                        flags = ROAR_VIOF_READWRITE;
-
- if ( def == NULL )
-  return -1;
-
- switch (proto) {
-  case ROAR_VIO_PROTO_P_HTTP:    port =   80; break;
-  case ROAR_VIO_PROTO_P_GOPHER:  port =   70; break;
-  case ROAR_VIO_PROTO_P_ICY:     port = 8000; break;
-  default:
-    return -1;
- }
-
- if ( dstr == NULL )
-  dstr = "//";
-
- if ( odef->o_flags & ROAR_VIOF_NONBLOCK )
-  flags |= ROAR_VIOF_NONBLOCK;
-
- if ( roar_vio_dstr_init_defaults(def, ROAR_VIO_DEF_TYPE_SOCKET, flags, 0644) == -1 )
-  return -1;
-
- if ( roar_vio_socket_init_tcp4_def(def, "localhost", port) == -1 )
-  return -1;
-
- if ( !strncmp(dstr, "//", 2) )
-  dstr += 2;
-
- if ( (ed = strstr(dstr, "/")) != NULL )
-  *ed = 0;
-
- if ( (tmp = strstr(dstr, "@")) != NULL )
-  dstr = tmp + 1;
-
- ROAR_DBG("roar_vio_proto_init_def(*): def->o_flags=%i", def->o_flags);
-
- ret = roar_vio_socket_init_dstr_def(def, dstr, -1, SOCK_STREAM, def);
-
- ROAR_DBG("roar_vio_proto_init_def(*): def->o_flags=%i", def->o_flags);
-
- if ( ed != NULL )
-  *ed = '/';
-
- ROAR_DBG("roar_vio_proto_init_def(*): dstr='%s'", dstr);
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-int roar_vio_open_proto      (struct roar_vio_calls * calls, struct roar_vio_calls * dst,
-                              const char * dstr, int proto, struct roar_vio_defaults * odef) {
-#ifndef ROAR_WITHOUT_VIO_PROTO
- struct roar_userpass userpass = {.subtype = -1, .user = NULL, .pass = NULL};
- struct roar_vio_proto * self;
- const char * host;
- char * tmp;
- int    ret;
-
- ROAR_DBG("roar_vio_open_proto(calls=%p, dst=%p, dstr='%s', proto=%i, odef=%p) = ?", calls, dst, dstr, proto, odef);
-
- if ( calls == NULL || dst == NULL || odef == NULL )
-  return -1;
-
- ROAR_DBG("roar_vio_open_proto(*): odef->o_flags=%i", odef->o_flags);
- ROAR_DBG("roar_vio_open_proto(*) = ?");
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_vio_proto))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct roar_vio_proto));
-
- self->next      = dst;
-
- calls->inst     = self;
-
- calls->read     = roar_vio_proto_read;
- calls->write    = roar_vio_proto_write;
- calls->sync     = roar_vio_proto_sync;
- calls->ctl      = roar_vio_proto_ctl;
- calls->close    = roar_vio_proto_close;
-
- ROAR_DBG("roar_vio_open_proto(*) = ?");
-
- if ( dstr != NULL ) {
-  dstr += 2;
-  host  = dstr;
-
-  if ( (tmp = strstr(dstr, "/")) == NULL )
-   return -1;
-
-  *tmp++ = 0;
-  dstr   = tmp;
-
-  if ( (tmp = strstr(dstr, "#")) != NULL )
-   *tmp = 0;
- } else {
-  ROAR_DBG("roar_vio_open_proto(*): no dstr!, odef->type=%i", odef->type);
-  if ( odef->type == ROAR_VIO_DEF_TYPE_FILE ) {
-   dstr = odef->d.file;
-   host = "localhost";
-
-   for (; *dstr == '/'; dstr++);
-
-  } else if ( odef->type == ROAR_VIO_DEF_TYPE_SOCKET ) {
-   dstr = ""; // index document
-   host = odef->d.socket.host;
-  } else {
-   return -1;
-  }
- }
-
- if ( (tmp = strstr(host, "@")) != NULL ) {
-  userpass.user = (char*)host;
-  *tmp = 0;
-  host = tmp + 1;
-  if ( (tmp = strstr(userpass.user, ":")) != NULL ) {
-   *tmp = 0;
-   userpass.pass = tmp + 1;
-  }
- }
-
- ROAR_DBG("roar_vio_open_proto(*) = ?");
- ROAR_DBG("roar_vio_open_proto(*): proto=%i, host='%s', file='%s', userpass={.user='%s', .pass='%s'}", proto, host, dstr, userpass.user, userpass.pass);
-
- self->proto = proto;
-
- if ( odef->o_flags & ROAR_VIOF_NONBLOCK ) {
-  if ( roar_vio_nonblock(calls, ROAR_SOCKET_BLOCK) == -1 ) {
-   return -1;
-  }
- }
- switch (proto) {
-  case ROAR_VIO_PROTO_P_HTTP:
-  case ROAR_VIO_PROTO_P_ICY:
-    ret = roar_vio_open_proto_http(calls, dst, host, dstr, userpass.user != NULL ? &userpass : NULL);
-   break;
-  case ROAR_VIO_PROTO_P_GOPHER:
-    ret = roar_vio_open_proto_gopher(calls, dst, host, dstr);
-   break;
-  default:
-    ROAR_DBG("roar_vio_open_proto(*) = -1 // no matching protocol");
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    ret = -1;
-   break;
- }
- if ( odef->o_flags & ROAR_VIOF_NONBLOCK ) {
-  if ( roar_vio_nonblock(calls, ROAR_SOCKET_NONBLOCK) == -1 ) {
-   return -1;
-  }
- }
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-#ifndef ROAR_WITHOUT_VIO_PROTO
-ssize_t roar_vio_proto_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_proto * self = vio->inst;
- ssize_t ret;
- ssize_t have = 0;
- size_t  len;
-
- ROAR_DBG("roar_vio_proto_read(*): have=%lli, count=%lli", (long long int)have, (long long int)count);
-
- if ( self->reader.buffer != NULL ) {
-  len = count;
-  if ( roar_buffer_shift_out(&(self->reader.buffer), buf, &len) == -1 ) {
-   // This is very bad.
-   return -1;
-  }
-
-  if ( len ) {
-   have   = len;
-   buf   += len;
-   count -= len;
-  }
- }
-
- ROAR_DBG("roar_vio_proto_read(*): have=%lli, count=%lli", (long long int)have, (long long int)count);
-
- if ( count == 0 )
-  return have;
-
- ROAR_DBG("roar_vio_proto_read(*): have=%lli, count=%lli", (long long int)have, (long long int)count);
-
- if ( (ret = roar_vio_read(self->next, buf, count)) == -1 )
-  return ret;
-
- return have + ret;
-}
-
-ssize_t roar_vio_proto_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_proto * self = vio->inst;
-
- return roar_vio_write(self->next, buf, count);
-}
-
-int     roar_vio_proto_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_proto * self = vio->inst;
-
- return roar_vio_sync(self->next);
-}
-
-int     roar_vio_proto_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_proto * self;
-
- if (vio == NULL || cmd == -1)
-  return -1;
-
- self = vio->inst;
-
- ROAR_DBG("roar_vio_proto_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    switch (self->proto) {
-     case ROAR_VIO_PROTO_P_HTTP:
-       *(char**)data = "http";
-      break;
-     case ROAR_VIO_PROTO_P_GOPHER:
-       *(char**)data = "gopher";
-      break;
-     case ROAR_VIO_PROTO_P_ICY:
-       *(char**)data = "icy";
-      break;
-     default:
-       *(char**)data = "proto";
-      break;
-    }
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = self->next;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NEXT:
-    self->next = *(struct roar_vio_calls **)data;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_MIMETYPE:
-    if ( data == NULL )
-     return -1;
-
-    if ( self->content_type == NULL )
-     return -1;
-
-    *(char**)data = self->content_type;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-    if ( self->reader.buffer == NULL && self->writer.buffer == NULL )
-     return roar_vio_ctl(self->next, cmd, data);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-    if ( self->reader.buffer == NULL )
-     return roar_vio_ctl(self->next, cmd, data);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-    if ( self->writer.buffer == NULL )
-     return roar_vio_ctl(self->next, cmd, data);
-    return -1;
-   break;
- }
-
- return roar_vio_ctl(self->next, cmd, data);
-}
-
-int     roar_vio_proto_close   (struct roar_vio_calls * vio) {
- struct roar_vio_proto * self = vio->inst;
-
- if ( roar_vio_close(self->next) == -1 )
-  return -1;
-
- if ( self->content_type != NULL )
-  roar_mm_free(self->content_type);
-
- roar_mm_free(self);
-
- return 0;
-}
-
-static int _parse_header(struct roar_keyval * kv, char ** buf, int * aligned, char * endofheader) {
- char * p = *buf;
- char   c = 0;
-
- if ( !(*aligned) ) {
-  for (; *p != 0 && *p != '\r' && *p != '\n'; p++);
-  p++;
-  if ( *p == '\n' )
-   p++;
- }
-
- if ( p >= endofheader )
-  return -1;
-
-/*
- if ( *p == '\r' || *p == '\n' )
-  return 0;
- */
-
- kv->key = p;
-
- for (; *p != 0 && *p != '\r' && *p != '\n' && *p != ':'; p++);
-
- if ( *p == 0 )
-  return -1;
-
- if ( p >= endofheader )
-  return -1;
-
- c = *p;
- *p = 0;
-
- if ( c == '\r' && *(p+1) == '\n' )
-  p++;
-
- p++;
-
- if ( c == '\r' || c == '\n' ) {
-  if ( *(kv->key) == '\r' || *(kv->key) == '\n' )
-   return 0;
-//  printf("Key-only\n");
-  kv->value = kv->key;
-  kv->key   = NULL;
-  *buf = p;
-  return 1;
- }
-
- for (; *p == ' '; p++);
-
- if ( *p == 0 )
-  return -1;
-
- kv->value = p;
-
- for (; *p != 0 && *p != '\r' && *p != '\n'; p++);
-
- if ( *p == 0 )
-  return -1;
-
- if ( p >= endofheader )
-  return -1;
-
- c = *p;
- *p = 0;
-
- if ( c == '\r' && *(p+1) == '\n' )
-  p++;
-
- p++;
-
- *buf = p;
-
- if ( c == '\r' || c == '\n' ) {
-//  printf("aligned\n");
-  *aligned = 1;
-  p++;
- } else {
-//  printf("non-aligned(c=0x%x)\n", (int)c);
-  *aligned = 0;
- }
-
- if ( *(kv->key) != 0 )
-  return 1;
-
- return 0;
-}
-
-static void _handle_header (struct roar_vio_proto * self, struct roar_keyval * kv) {
- ROAR_DBG("_handle_header(*): Header: key='%s', value='%s'", kv->key, kv->value);
-
- if ( kv->key == NULL || kv->value == NULL )
-  return;
-
- if ( !strcasecmp(kv->key, "Content-Type") ) {
-  if ( self->content_type != NULL )
-   roar_mm_free(self->content_type);
-
-  self->content_type = roar_mm_strdup(kv->value);
- }
-}
-
-static inline char * _up2http_auth (struct roar_userpass * up) {
- char * inbuf, * outbuf;
- size_t inlen, outlen;
- ssize_t ret;
- //Authorization: Basic dXNlcjpwdw==
-
- if ( up == NULL )
-  return NULL;
-
- if ( up->subtype != -1 )
-  return NULL;
-
- if ( up->user == NULL || up->pass == NULL )
-  return NULL;
-
- inlen = roar_mm_strlen(up->user) + roar_mm_strlen(up->pass) + 2;
- inbuf = roar_mm_malloc(inlen);
- if ( inbuf == NULL )
-  return NULL;
-
- inbuf[0] = 0;
- roar_mm_strlcat(inbuf, up->user, inlen);
- roar_mm_strlcat(inbuf, ":", inlen);
- roar_mm_strlcat(inbuf, up->pass, inlen);
-
- outlen = ((inlen * 3) / 2) + 3 /* padding... */ + 6 /* 'Basic ' */;
- outbuf = roar_mm_malloc(outlen);
- if ( outbuf == NULL ) {
-  roar_mm_free(inbuf);
-  return NULL;
- }
-
- strncpy(outbuf, "Basic ", 7); 
-
- ROAR_DBG("_up2http_auth(up=%p{.subtype=%i, .user='%s', .pass='%s'): inbuf='%s', outbuf='%s'", up, up->subtype, up->user, up->pass, inbuf, outbuf);
- ret = roar_base64_encode(NULL, outbuf + 6, outlen - 6, inbuf, inlen - 1, NULL, 1);
- ROAR_DBG("_up2http_auth(up=%p{.subtype=%i, .user='%s', .pass='%s'): inbuf='%s', outbuf='%s'", up, up->subtype, up->user, up->pass, inbuf, outbuf);
-
- roar_mm_free(inbuf);
-
- if ( ret == -1 ) {
-  roar_mm_free(outbuf);
-  return NULL;
- }
-
- return outbuf;
-}
-
-int roar_vio_open_proto_http   (struct roar_vio_calls * calls, struct roar_vio_calls * dst, const char * host, const char * file, struct roar_userpass * up) {
- struct roar_keyval kv;
- struct roar_vio_proto * self;
- struct roar_buffer * bufbuf;
- void * vpbuf;
- char * authbuf;
- char * buf;
- char * endofheader = NULL;
- char * p;
- char b0[80], b1[80];
- int  status;
- int  len;
- int  oeflen = 4;
- int  aligned = 1;
- int  error;
-
- ROAR_DBG("roar_vio_open_proto_http(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file);
-
- if ( calls == NULL || dst == NULL || host == NULL || file == NULL )
-  return -1;
-
- self         = calls->inst;
- calls->write = NULL; // Disable write as we do not support this
-
- if ( roar_buffer_new_data(&bufbuf, 1024, &vpbuf) == -1 )
-  return -1;
-
- buf = vpbuf;
-
- ROAR_DBG("roar_vio_open_proto_http(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file);
-
- if ( roar_vio_printf(dst, "GET /%s HTTP/1.1\r\n", file) == -1 )
-  return -1;
-
- roar_vio_printf(dst, "Host: %s\r\n", host);
- roar_vio_printf(dst, "User-Agent: roar_vio_open_proto_http() $Revision$\r\n");
- roar_vio_printf(dst, "Connection: close\r\n");
- if ( up != NULL ) {
-  if ( (authbuf = _up2http_auth(up)) != NULL ) {
-   roar_vio_printf(dst, "Authorization: %s\r\n", authbuf);
-   roar_mm_free(authbuf);
-  }
- }
- roar_vio_printf(dst, "\r\n");
-
- ROAR_DBG("roar_vio_open_proto_http(*) = ?");
-
- roar_vio_sync(dst);
-
- ROAR_DBG("roar_vio_open_proto_http(*) = ?");
-
- if ( (len = roar_vio_read(dst, buf, 1023)) < 1 ) {
-  ROAR_DBG("roar_vio_open_proto_http(*) = -1");
-  roar_buffer_free(bufbuf);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_open_proto_http(*): got %i bytes from server.", len);
-
- buf[len] = 0;
-
- ROAR_DBG("roar_vio_open_proto_http(*) = ?");
-
- if ( sscanf(buf, "%79s %i %79s\n", b0, &status, b1) != 3 ) {
-  ROAR_DBG("roar_vio_open_proto_http(*) = -1");
-  roar_buffer_free(bufbuf);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_open_proto_http(*): b0='%s'", b0);
-
- ROAR_DBG("roar_vio_open_proto_http(*) = ?");
-
- if ( status != 200 ) {
-  ROAR_DBG("roar_vio_open_proto_http(*) = -1 // status=%i", status);
-  roar_buffer_free(bufbuf);
-  if ( roar_err_convert(&error, ROAR_ERROR_TYPE_ROARAUDIO, status, ROAR_ERROR_TYPE_HTTP) != ROAR_ERROR_NONE ) {
-   roar_err_set(ROAR_ERROR_UNKNOWN);
-  } else {
-   roar_err_set(error);
-  }
-  return -1;
- }
-
- ROAR_DBG("roar_vio_open_proto_http(*): status=%i", status);
-// ROAR_WARN("roar_vio_open_proto_http(*): buf='%s'", buf);
-
- endofheader = strstr(buf, "\r\n\r\n");
- if ( endofheader == NULL ) {
-  endofheader = strstr(buf, "\n\n");
-  oeflen = 2;
- }
-
- ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader);
-
- p = buf;
- while ( _parse_header(&kv, &p, &aligned, endofheader) > 0 )
-  if ( aligned )
-   _handle_header(self, &kv);
-
- while ( endofheader == NULL ) {
-  if ( (len = roar_vio_read(dst, buf, 1023)) < 1 )
-   return -1;
-
-  buf[len] = 0;
-  endofheader = strstr(buf, "\r\n\r\n");
-  if ( endofheader == NULL ) {
-   endofheader = strstr(buf, "\n\n");
-   oeflen = 2;
-  }
-
-/* Doesn't work good.
-  while ( _parse_header(&kv, &p, &aligned, endofheader) > 0 )
-   if ( aligned )
-    _handle_header(self, &kv);
-*/
-
-  p = buf;
-  while ( _parse_header(&kv, &p, &aligned, endofheader) > 0 )
-   if ( aligned )
-    _handle_header(self, &kv);
-
-  ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader);
- }
-
- ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader);
- ROAR_DBG("roar_vio_open_proto_http(*): buf=%p\n", buf);
-
- if ( (endofheader - buf) == (len - oeflen) ) {
-  roar_buffer_free(bufbuf);
-  bufbuf = NULL;
- }
-
- if ( bufbuf != NULL ) {
-  if ( roar_buffer_set_offset(bufbuf, endofheader - buf + oeflen) == -1 ||
-       roar_buffer_set_len(bufbuf,    len - (endofheader - buf + oeflen) - 0 /* ??? */) == -1 ) {
-   // TODO: FIXME: handle this in a better way.
-   ROAR_ERR("roar_vio_open_proto_http(*): Can not set data area of buffer %p, VERY BAD.", bufbuf);
-  }
- }
- self->reader.buffer = bufbuf;
-
-/*
- if ( !strcmp((buf+len)-4, "\r\n\r\n") )
-  return 0;
-
- while (*buf != '\r' && *buf != '\n') {
-  if ( (len = roar_vio_read(dst, buf, 1023)) < 1 )
-   return -1;
- }
-*/
-
- return 0;
-}
-
-int roar_vio_open_proto_gopher (struct roar_vio_calls * calls, struct roar_vio_calls * dst, const char * host, const char * file) {
- struct roar_vio_proto * self;
- char type;
- const char * mime = NULL;
-
- if ( calls == NULL || dst == NULL || host == NULL || file == NULL )
-  return -1;
-
- self         = calls->inst;
- calls->write = NULL; // Disable write as we do not support this
-
- ROAR_DBG("roar_vio_open_proto_gopher(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file);
-
- type = file[0];
-
- file++;
-
- ROAR_DBG("roar_vio_open_proto_gopher(*): type='%c'", type);
-
- switch (type) {
-  case ROAR_GOPHER_TYPE_FILE:
-    mime = "text/plain";
-   break;
-  case ROAR_GOPHER_TYPE_DIR:
-    mime = "inode/directory";
-   break;
-  case ROAR_GOPHER_TYPE_BIN:
-    mime = "application/octet-stream";
-   break;
-  case ROAR_GOPHER_TYPE_GIF:
-    mime = "image/gif";
-   break;
-  case ROAR_GOPHER_TYPE_HTML:
-    mime = "text/html";
-   break;
- }
-
- if ( mime != NULL ) {
-  self->content_type = roar_mm_strdup(mime);
- }
-
- roar_vio_printf(dst, "%s\r\n", file);
-
- roar_vio_sync(dst); // for encryption/compression layers
-
- return 0;
-}
-#endif
-
-//ll
Index: libroar/vio_proxy.c
===================================================================
--- libroar/vio_proxy.c	(revision 6052)
+++ 	(revision )
@@ -1,230 +1,0 @@
-//vio_proxy.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int roar_vio_proxy_init_def(struct roar_vio_defaults * def,
-                            char * dstr, enum roar_vio_proxy_type type,
-                            struct roar_vio_defaults * odef) {
- int hint = -1;
-
- (void)type; // TODO: generate hints from type.
-
- ROAR_DBG("roar_vio_proxy_init_def(def=%p, dstr='%s', type=%i, odef=%p) = ?", def, dstr, (int)type, odef);
-
- if ( roar_vio_dstr_init_defaults(def, ROAR_VIO_DEF_TYPE_SOCKET, O_RDWR, 0644) == -1 )
-  return -1;
-
- if ( roar_vio_socket_init_dstr_def(def, dstr, hint, odef == NULL ? SOCK_STREAM : odef->d.socket.type, odef) == -1 ) {
-  ROAR_DBG("roar_vio_proxy_init_def(def=%p, dstr='%s', type=%i, odef=%p) = -1", def, dstr, (int)type, odef);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_proxy_init_def(def=%p, dstr='%s', type=%i, odef=%p) = 0", def, dstr, (int)type, odef);
- return 0;
-}
-
-static int roar_vio_proxy_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if ( cmd == ROAR_VIO_CTL_GET_NAME ) {
-  *(char **)data = "proxy";
-  return 0;
- }
-
- return roar_vio_pass_ctl(vio, cmd, data);
-}
-
-static int init_socks4(struct roar_vio_calls * dst, enum roar_vio_proxy_type type, struct roar_vio_defaults * odef) {
- char buf[9] = {
-  0x04,       // [0] Version
-  0x01,       // [1] mode=connect (listen is 0x02)
-  0, 0, 0, 0, // [2..5] host IP
-  0,          // [6] Port MSB
-  0,          // [7] Port LSB
-  0x00        // [8] EOS (\0) of username
- };
- enum roar_vio_proxy_type needed_type = ROAR_VIO_PROXY_INVALID;
-
- ROAR_DBG("init_socks4(dst=%p, type=%i, odef=%p{.d.socket={.domain=%i, .type=%i, .host='%s'}}) = ?", dst, (int)type, odef, odef->d.socket.domain, odef->d.socket.type, odef->d.socket.host);
-
- switch (odef->d.socket.domain) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET: needed_type = ROAR_VIO_PROXY_SOCKS4; break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-    if ( odef->d.socket.sa.dn.sdn_objnum == 0 ) {
-     needed_type = ROAR_VIO_PROXY_SOCKS4d;
-    } else {
-     needed_type = ROAR_VIO_PROXY_SOCKS4;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:
-#endif
-#ifdef ROAR_HAVE_IPX
-  case AF_IPX:
-#endif
-#ifdef ROAR_HAVE_UNIX
-  case AF_UNIX:
-#endif
-  default:
-    roar_err_set(ROAR_ERROR_AFNOTSUP);
-    return -1;
-   break;
- }
-
- if ( needed_type == ROAR_VIO_PROXY_SOCKS4 && type != needed_type )
-  needed_type = type;
-
- if ( needed_type != type ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- switch (odef->d.socket.domain) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:
-    if ( roar_vio_socket_init_inet4host_def(odef) == -1 )
-     return -1;
-    buf[2] = ((char*)&(odef->d.socket.sa.in.sin_port))[0];
-    buf[3] = ((char*)&(odef->d.socket.sa.in.sin_port))[1];
-    buf[4] = ((char*)&(odef->d.socket.sa.in.sin_addr.s_addr))[0];
-    buf[5] = ((char*)&(odef->d.socket.sa.in.sin_addr.s_addr))[1];
-    buf[6] = ((char*)&(odef->d.socket.sa.in.sin_addr.s_addr))[2];
-    buf[7] = ((char*)&(odef->d.socket.sa.in.sin_addr.s_addr))[3];
-    ROAR_DBG("init_socks4(dst=%p, type=%i, odef=%p{.d.socket={.domain=%i, .type=%i, .host='%s'}}): buf[]={%i, %i, %i, %i, %i, %i, %i, %i, %i}",
-             dst, (int)type, odef, odef->d.socket.domain, odef->d.socket.type, odef->d.socket.host,
-             buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]);
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-    if ( type == ROAR_VIO_PROXY_SOCKS4 ) {
-     buf[2] = 0;
-     buf[3] = odef->d.socket.sa.dn.sdn_objnum;
-     buf[4] = 0;
-     buf[5] = 2;
-     buf[6] = odef->d.socket.sa.dn.sdn_nodeaddr[0];
-     buf[7] = odef->d.socket.sa.dn.sdn_nodeaddr[1];
-    } else {
-     roar_err_set(ROAR_ERROR_NOTSUP);
-     return -1;
-    }
-   break;
-#endif
- }
-
- if ( roar_vio_write(dst, buf, sizeof(buf)) != (ssize_t)sizeof(buf) )
-  return -1;
-
- if ( roar_vio_read(dst, buf, 8) != (ssize_t)8 )
-  return -1;
-
- if ( buf[1] != 0x5a ) {
-  roar_err_set(ROAR_ERROR_UNKNOWN);
-  return -1;
- }
-
- return 0;
-}
-
-int roar_vio_open_proxy    (struct roar_vio_calls * calls, struct roar_vio_calls * dst,
-                            enum roar_vio_proxy_type type, struct roar_vio_defaults * odef) {
- int init_only = -1;
- int (*init)(struct roar_vio_calls * dst, enum roar_vio_proxy_type type, struct roar_vio_defaults * odef) = NULL;
-
- ROAR_DBG("roar_vio_open_proxy(calls=%p, dst=%p, type=%i, odef=%p{.type=%i}) = ?", calls, dst, (int)type, odef, (int)odef->type);
-
- if ( odef->type != ROAR_VIO_DEF_TYPE_SOCKET ) {
-  roar_err_set(ROAR_ERROR_NOTSOCK);
-  return -1;
- }
-
- switch (type) {
-  case ROAR_VIO_PROXY_NONE: init_only = 1; init = NULL; break;
-  case ROAR_VIO_PROXY_SOCKS:
-  case ROAR_VIO_PROXY_SOCKS4:
-  case ROAR_VIO_PROXY_SOCKS4a:
-  case ROAR_VIO_PROXY_SOCKS4d:
-    init_only = 1;
-    init = init_socks4;
-   break;
-#ifndef DEBUG
-  default:
-   break;
-#endif
- }
-
- if ( init_only == 1 ) {
-  if ( init != NULL )
-   if ( init(dst, type, odef) == -1 )
-    return -1;
-  if ( roar_vio_open_pass(calls, dst) == -1 )
-   return -1;
-
-  calls->ctl = roar_vio_proxy_ctl;
-
-  return 0;
- } else {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-}
-
-// DSTR interface:
-static enum roar_vio_proxy_type _dstrtype2proxytype(struct roar_vio_dstr_chain * chainelement) {
- switch (chainelement->type) {
-  case ROAR_VIO_DSTR_OBJT_SOCKS:   return ROAR_VIO_PROXY_SOCKS;   break;
-  case ROAR_VIO_DSTR_OBJT_SOCKS4:  return ROAR_VIO_PROXY_SOCKS4;  break;
-  case ROAR_VIO_DSTR_OBJT_SOCKS4A: return ROAR_VIO_PROXY_SOCKS4a; break;
-  case ROAR_VIO_DSTR_OBJT_SOCKS4D: return ROAR_VIO_PROXY_SOCKS4d; break;
-  case ROAR_VIO_DSTR_OBJT_SOCKS5:  return ROAR_VIO_PROXY_SOCKS5;  break;
-  default:
-    return ROAR_VIO_PROXY_INVALID;
-   break;
- }
-}
-
-int roar_vio_proxy_setdef(struct roar_vio_dstr_chain * cur,   struct roar_vio_dstr_chain * next) {
- next->def = &(next->store_def);
- return roar_vio_proxy_init_def(next->def, cur->dst, _dstrtype2proxytype(cur), cur->def);
-}
-
-int roar_vio_proxy_openvio(struct roar_vio_calls * calls, struct roar_vio_calls * dst, struct roar_vio_dstr_chain * cur, struct roar_vio_dstr_chain * next) {
- return roar_vio_open_proxy(calls, dst, _dstrtype2proxytype(cur), cur->def);
-}
-
-//ll
Index: libroar/vio_rtp.c
===================================================================
--- libroar/vio_rtp.c	(revision 6052)
+++ 	(revision )
@@ -1,412 +1,0 @@
-//vio_rtp.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static const struct {
- int pt;
- struct roar_audio_info info;
-} _g_rtp_pt[] = {
- {ROAR_RTP_PT_A_PCMU,      {.codec = ROAR_CODEC_MULAW,    .bits =  8, .rate =  8000, .channels = 1}},
- {ROAR_RTP_PT_A_PCMA,      {.codec = ROAR_CODEC_ALAW,     .bits =  8, .rate =  8000, .channels = 1}},
- {ROAR_RTP_PT_A_L16_441_2, {.codec = ROAR_CODEC_PCM_S_BE, .bits = 16, .rate = 44100, .channels = 2}},
- {ROAR_RTP_PT_A_L16_441_1, {.codec = ROAR_CODEC_PCM_S_BE, .bits = 16, .rate = 44100, .channels = 1}},
- {-1, {-1, -1, -1, -1}}
-};
-
-static int _info2pt (struct roar_audio_info * info) {
- int i;
-
- ROAR_DBG("_info2pt(info=%p{.codec=%s(%i), .bits=%i, .rate=%i, .channels=%i}) = ?", info, roar_codec2str(info->codec), info->codec, info->bits, info->rate, info->channels);
-
- for (i = 0; _g_rtp_pt[i].pt != -1; i++) {
-  if ( info->codec    == _g_rtp_pt[i].info.codec    &&
-       info->bits     == _g_rtp_pt[i].info.bits     &&
-       info->rate     == _g_rtp_pt[i].info.rate     &&
-       info->channels == _g_rtp_pt[i].info.channels ) {
-   return _g_rtp_pt[i].pt;
-  }
- }
-
- ROAR_DBG("_info2pt(info=%p{.codec=%s(%i), .bits=%i, .rate=%i, .channels=%i}) = -1", info, roar_codec2str(info->codec), info->codec, info->bits, info->rate, info->channels);
- return -1;
-}
-
-#if 0
-static const struct roar_audio_info * _pt2info (int pt) {
- int i;
-
- for (i = 0; _g_rtp_pt[i].pt != -1; i++) {
-  if ( _g_rtp_pt[i].pt == pt ) {
-   return &(_g_rtp_pt[i].info);
-  }
- }
-
- return NULL;
-}
-#endif
-
-int roar_vio_open_rtp        (struct roar_vio_calls * calls, struct roar_vio_calls * dst,
-                              char * dstr, struct roar_vio_defaults * odef) {
- struct roar_rtp_inst * self = NULL;
-
- ROAR_DBG("roar_vio_open_rtp(calls=%p, dst=%p, dstr='%s', odef=%p) = ?", calls, dst, dstr, odef);
-
- if ( calls == NULL || dst == NULL )
-  return -1;
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_rtp_inst))) == NULL )
-  return -1;
-
- ROAR_DBG("roar_vio_open_rtp(calls=%p, dst=%p, dstr='%s', odef=%p) = ?", calls, dst, dstr, odef);
-
- memset(self, 0, sizeof(struct roar_rtp_inst));
-
- self->vio                 = dst;
- self->bpf                 = 0;
- self->mtu                 = 768;
-
- memset(&(self->info), 0, sizeof(struct roar_audio_info));
-
- self->header.version      = 2;
- self->header.payload_type = ROAR_RTP_PT_UNKNOWN;
-
- // TODO: init with random values:
- //       Sequence Number 
- //       ts
- //       SSRC
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- calls->inst               = self;
- calls->read               = roar_vio_rtp_read;
- calls->write              = roar_vio_rtp_write;
- calls->sync               = roar_vio_rtp_sync;
- calls->ctl                = roar_vio_rtp_ctl;
- calls->close              = roar_vio_rtp_close;
-
- ROAR_DBG("roar_vio_open_rtp(calls=%p, dst=%p, dstr='%s', odef=%p) = 0", calls, dst, dstr, odef);
-
- return 0;
-}
-
-ssize_t roar_vio_rtp_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_rtp_inst * self = vio->inst;
- size_t len_need = self->mtu * 4 + sizeof(struct roar_rtp_header); // we hope to never get pkgs with size > 4*mtu
- size_t len_have;
- ssize_t have = 0;
- ssize_t ret;
- union {
-  void     * vp;
-  char     * cp;
-  uint16_t * u16;
-  uint32_t * u32;
- } data;
- size_t  dataoffset;
- int     i;
-
- ROAR_DBG("roar_vio_rtp_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- if ( self->rx_decoded != NULL ) {
-  // handle this case and set to NULL if the buffer is empty
-  // set have;
-  // increment buf, decrement count
- }
-
- if ( count == 0 )
-  return have;
-
- if ( self->io == NULL ) {
-  if ( roar_buffer_new(&(self->io), len_need) == -1 )
-   return have ? have : -1;
-
-  len_have = len_need;
- } else {
-  if ( roar_buffer_get_len(self->io, &len_have) == -1 )
-   return have ? have : -1;
-
-  if ( len_have < len_need ) {
-   if ( roar_buffer_set_len(self->io, len_need) == -1 ) {
-    if ( roar_buffer_free(self->io) == -1 )
-     return have ? have : -1;
-
-    self->io = NULL;
-    if ( have != 0 ) {
-     return have;
-    } else {
-     return roar_vio_rtp_read(vio, buf, count); // restart our self from the beginning with no buffer
-    }
-   }
-  }
- }
-
- if ( roar_buffer_get_data(self->io, &(data.vp)) == -1 )
-  return have ? have : -1;
-
- if ( (ret = roar_vio_read(self->vio, data.vp, len_need)) == -1 )
-  return have ? have : -1;
-
- if ( (data.cp[0] & 0x02) == 0x02 ) /* version check */
-  return have ? have : -1;
-
- self->header.csrc_count   = (data.cp[0] & 0xF0) >> 4;
- self->header.payload_type = (data.cp[1] & 0xFE) >> 1;
-
- // TODO: check old seqnum < new seqnum
- self->header.seq_num      = ROAR_NET2HOST16(data.u16[1]);
-
- // TODO: check timestamp:
- self->header.ts           = ROAR_NET2HOST32(data.u32[1]);
-
- self->header.ssrc         = ROAR_NET2HOST32(data.u32[2]);
-
- for (i = 0; i < self->header.csrc_count; i++) {
-  self->header.csrc[i]     = ROAR_NET2HOST16(data.u32[3+i]);
- }
-
- dataoffset   = 3*4 + self->header.csrc_count*4;
-
- ret     -= dataoffset;
- data.vp += dataoffset;
-
- if ( ret <= (ssize_t)count ) {
-  memcpy(buf, data.vp, ret);
-  ROAR_DBG("roar_vio_rtp_read(vio=%p, buf=%p, count=?) = %llu", vio, buf, (long long unsigned)(have+ret));
-  return have + ret;
- } else {
- }
-
- ROAR_DBG("roar_vio_rtp_read(vio=%p, buf=%p, count=?) = -1", vio, buf);
- return -1;
-}
-
-ssize_t roar_vio_rtp_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_rtp_inst * self = vio->inst;
- size_t len_need = count + sizeof(struct roar_rtp_header); // this is a bit more than we need
-                                                           // we ignore this at the moment
- size_t len_have;
- union {
-  void     * vp;
-  char     * cp;
-  uint16_t * u16;
-  uint32_t * u32;
- } data;
- size_t  dataoffset;
- ssize_t ret;
- int     i;
-
- ROAR_DBG("roar_vio_rtp_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- if ( self->mtu < (sizeof(struct roar_rtp_header) + self->bpf) )
-  return -1;
-
- if ( len_need > self->mtu ) {
-  len_have = 0;
-  ret      = 0;
-
-  while (count) {
-   len_need = self->mtu - sizeof(struct roar_rtp_header);
-
-   if ( count < len_need )
-    len_need = count;
-
-   if ( (ret = roar_vio_rtp_write(vio, buf, len_need)) == -1 )
-    break;
-
-   len_have += ret;
-   buf      += ret;
-   count    -= ret;
-  }
-
-  return len_have ? (ssize_t)len_have : ret;
- }
-
- if ( self->io == NULL ) {
-  if ( roar_buffer_new(&(self->io), len_need) == -1 )
-   return -1;
-
-  len_have = len_need;
- } else {
-  if ( roar_buffer_get_len(self->io, &len_have) == -1 )
-   return -1;
-
-  if ( len_have < len_need ) {
-   if ( roar_buffer_set_len(self->io, len_need) == -1 ) {
-    if ( roar_buffer_free(self->io) == -1 )
-     return -1;
-
-    self->io = NULL;
-    return roar_vio_rtp_write(vio, buf, count); // restart ower self from the beginning with no buffer
-   }
-  }
- }
-
- ROAR_DBG("roar_vio_rtp_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- if ( roar_buffer_get_data(self->io, &(data.vp)) == -1 )
-  return -1;
-
- memset(data.vp, 0, len_need);
-
- self->header.seq_num++;
-
- data.cp[0]   = 2;
- data.cp[0]  |= self->header.csrc_count   << 4;
- data.cp[1]  |= self->header.payload_type << 1;
-
- data.u16[1]  = ROAR_HOST2NET16(self->header.seq_num);
-
- data.u32[1]  = ROAR_HOST2NET32(self->header.ts);
- data.u32[2]  = ROAR_HOST2NET32(self->header.ssrc);
-
- for (i = 0; i < self->header.csrc_count; i++) {
-  data.u32[3+i] = ROAR_HOST2NET32(self->header.csrc[i]);
- }
-
- dataoffset   = 3*4 + self->header.csrc_count*4;
-
- memcpy(data.vp + dataoffset, buf, count);
-
- ROAR_DBG("roar_vio_rtp_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- if ( (ret = roar_vio_write(self->vio, data.vp, count+dataoffset)) == -1 )
-  return -1;
-
- len_have = ret - dataoffset;
-
- self->header.ts += len_have / self->bpf;
-
- return len_have;
-}
-
-int     roar_vio_rtp_sync    (struct roar_vio_calls * vio) {
- struct roar_rtp_inst * self = vio->inst;
-
- ROAR_DBG("roar_vio_rtp_sync(vio=%p) = ?", vio);
-
- return roar_vio_sync(self->vio);
-}
-
-int     roar_vio_rtp_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_rtp_inst * self = vio->inst;
- struct roar_stream          * s    = NULL;
- struct roar_stream_server   * ss   = NULL;
- struct roar_audio_info      * info = NULL;
-
- ROAR_DBG("roar_vio_rtp_ctl(vio=%p, cmd=%i, data=%p) = ?", vio, cmd, data);
-
- if (vio == NULL || cmd == -1)
-  return -1;
-
- ROAR_DBG("roar_vio_rtp_ctl(vio=%p, cmd=%i, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "rtp";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    s = ROAR_STREAM(ss = data);
-    info = &(s->info);
-   break;
-  case ROAR_VIO_CTL_SET_STREAM:
-    s = ROAR_STREAM(data);
-    info = &(s->info);
-   break;
-  case ROAR_VIO_CTL_SET_AUINFO:
-    info = data;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = self->vio;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NEXT:
-    self->vio = *(struct roar_vio_calls **)data;
-    return 0;
-   break;
- }
-
- ROAR_DBG("roar_vio_rtp_ctl(vio=%p, cmd=%i, data=%p) = ?", vio, cmd, data);
-
- if ( info != NULL ) {
-  switch (info->codec) {
-   case ROAR_CODEC_PCM_S_LE:
-   case ROAR_CODEC_PCM_S_PDP:
-     info->codec = ROAR_CODEC_PCM_S_BE;
-    break;
-   case ROAR_CODEC_PCM_U_LE:
-   case ROAR_CODEC_PCM_U_PDP:
-     info->codec = ROAR_CODEC_PCM_U_BE;
-    break;
-  }
-
-  memcpy(&(self->info), info, sizeof(struct roar_audio_info));
-
-  self->header.payload_type = _info2pt(info);
-
-  self->bpf                 = info->channels * info->bits / 8;
-
-  _LIBROAR_IGNORE_RET(roar_vio_ctl(self->vio, cmd, data));
-  return 0;
- }
-
- return roar_vio_ctl(self->vio, cmd, data);
-}
-
-int     roar_vio_rtp_close   (struct roar_vio_calls * vio) {
- struct roar_rtp_inst * self = vio->inst;
- int ret;
-
- ROAR_DBG("roar_vio_rtp_close(vio=%p) = ?", vio);
-
- ret = roar_vio_close(self->vio);
-
- if ( self->io != NULL )
-  if ( roar_buffer_free(self->io) == -1 )
-   ret = -1;
-
- roar_mm_free(self);
-
- ROAR_DBG("roar_vio_rtp_close(vio=%p) = %i", vio, ret);
-
- return ret;
-}
-
-//ll
Index: libroar/vio_select.c
===================================================================
--- libroar/vio_select.c	(revision 6052)
+++ 	(revision )
@@ -1,211 +1,0 @@
-//vio_select.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-ssize_t roar_vio_select(struct roar_vio_select * vios, size_t len, struct roar_vio_selecttv * rtv, struct roar_vio_selectctl * ctl) {
-#ifdef ROAR_HAVE_SELECT
- struct timeval tv;
- fd_set rfds, wfds, efds;
-#endif
- size_t i;
-#ifdef ROAR_HAVE_SELECT
- int max_fh = -1;
-#endif
- int ret;
-#ifdef DEBUG
- char * name;
-#endif
-
- ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = ?", vios, (long long unsigned int)len, rtv, ctl);
-
- if ( len == 0 ) {
-  ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = 0", vios, (long long unsigned int)len, rtv, ctl);
-  return 0;
- }
-
- if ( vios == NULL ) {
-  ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = -1", vios, (long long unsigned int)len, rtv, ctl);
-  return -1;
- }
-
- // pepaer internal structs:
- for (i = 0; i < len; i++) {
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_NO_RETEST )
-   continue;
-
-  ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): vios[i=%i].fh=%i", vios, (long long unsigned int)len, rtv, ctl, i, vios[i].fh);
-  if ( vios[i].fh == -1 ) {
-#ifdef DEBUG
-   name = NULL;
-   if ( roar_vio_ctl(vios[i].vio, ROAR_VIO_CTL_GET_NAME, &name) != 0 )
-    name = NULL;
-   ROAR_DBG("roar_vio_select(*): vios[%i]'s name is: '%s'", i, name);
-#endif
-
-   vios[i].internal.action = ROAR_VIO_SELECT_ACTION_NONE;
-
-   if ( vios[i].eventsq & ROAR_VIO_SELECT_READ ) {
-    if ( roar_vio_ctl(vios[i].vio, ROAR_VIO_CTL_GET_SELECT_READ_FH, &(vios[i].internal.fh[0])) == -1 ) {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_VIOS;
-     vios[i].internal.fh[0]   = -1;
-    } else {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_SELECT;
-    }
-   }
-
-   if ( vios[i].eventsq & ROAR_VIO_SELECT_WRITE ) {
-    if ( roar_vio_ctl(vios[i].vio, ROAR_VIO_CTL_GET_SELECT_WRITE_FH, &(vios[i].internal.fh[1])) == -1 ) {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_VIOS;
-     vios[i].internal.fh[1]   = -1;
-    } else {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_SELECT;
-    }
-   }
-
-   if ( vios[i].eventsq & ROAR_VIO_SELECT_EXCEPT ) {
-    if ( roar_vio_ctl(vios[i].vio, ROAR_VIO_CTL_GET_SELECT_FH, &(vios[i].internal.fh[2])) == -1 ) {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_VIOS;
-     vios[i].internal.fh[2]   = -1;
-    } else {
-     vios[i].internal.action |= ROAR_VIO_SELECT_ACTION_SELECT;
-    }
-   }
-   ROAR_DBG("roar_vio_select(*): vios[%i].internal.fh[] = {%i, %i, %i}", i, vios[i].internal.fh[0], vios[i].internal.fh[1], vios[i].internal.fh[2]);
-  } else {
-   vios[i].internal.action = ROAR_VIO_SELECT_ACTION_SELECT;
-   vios[i].internal.fh[0]  = vios[i].fh;
-   vios[i].internal.fh[1]  = vios[i].fh;
-   vios[i].internal.fh[2]  = vios[i].fh;
-  }
- }
-
- // check:
- for (i = 0; i < len; i++) {
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_NO_RETEST )
-   continue;
-
-  if ( !( vios[i].internal.action == 0 || vios[i].internal.action == ROAR_VIO_SELECT_ACTION_SELECT ) ) {
-   // we currently do not support non-select selects.
-   // TODO: Fix this.
-   ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = -1", vios, (long long unsigned int)len, rtv, ctl);
-   return -1;
-  }
- }
-
-#ifdef ROAR_HAVE_SELECT
- // prepaer fdsets:
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- FD_ZERO(&efds);
-
- for (i = 0; i < len; i++) {
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_NO_RETEST )
-   continue;
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_READ ) {
-   ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): vios[i=%i] is READ, fh=%i", vios, (long long unsigned int)len, rtv, ctl, i, vios[i].internal.fh[0]);
-   FD_SET(vios[i].internal.fh[0], &rfds);
-   if ( vios[i].internal.fh[0] > max_fh )
-    max_fh = vios[i].internal.fh[0];
-  }
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_WRITE ) {
-   ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): vios[i=%i] is WRITE, fh=%i", vios, (long long unsigned int)len, rtv, ctl, i, vios[i].internal.fh[1]);
-   FD_SET(vios[i].internal.fh[1], &wfds);
-   if ( vios[i].internal.fh[1] > max_fh )
-    max_fh = vios[i].internal.fh[1];
-  }
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_EXCEPT ) {
-   ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): vios[i=%i] is EXCEPT, fh=%i", vios, (long long unsigned int)len, rtv, ctl, i, vios[i].internal.fh[2]);
-   FD_SET(vios[i].internal.fh[2], &efds);
-   if ( vios[i].internal.fh[2] > max_fh )
-    max_fh = vios[i].internal.fh[2];
-  }
- }
-
- // the the select:
-  if ( rtv == NULL ) {
-   tv.tv_sec  = 1024;
-   tv.tv_usec = 0;
-  } else {
-   tv.tv_sec  = rtv->sec;
-   tv.tv_usec = rtv->nsec / 1000;
-   if ( tv.tv_sec == 0 && tv.tv_usec == 0 )
-    tv.tv_usec = 1;
-  }
-
-
- ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): Doing select() with max_fh=%i", vios, (long long unsigned int)len, rtv, ctl, max_fh);
- ret = select(max_fh + 1, &rfds, &wfds, &efds, &tv);
- ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p): select() returned %i", vios, (long long unsigned int)len, rtv, ctl, ret);
-
- // ret == -1 -> Error
- // ret ==  0 -> No data
- if ( ret < 1 ) {
-  ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = %lli", vios, (long long unsigned int)len, rtv, ctl, (long long int)ret);
-  return ret;
- }
-
- // set eventsa:
- for (i = 0; i < len; i++) {
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_NO_RETEST )
-   continue;
-
-  vios[i].eventsa = ROAR_VIO_SELECT_NONE;
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_READ )
-   if ( FD_ISSET(vios[i].internal.fh[0], &rfds) )
-    vios[i].eventsa |= ROAR_VIO_SELECT_READ;
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_WRITE )
-   if ( FD_ISSET(vios[i].internal.fh[1], &wfds) )
-    vios[i].eventsa |= ROAR_VIO_SELECT_WRITE;
-
-  if ( vios[i].eventsq & ROAR_VIO_SELECT_EXCEPT )
-   if ( FD_ISSET(vios[i].internal.fh[2], &efds) )
-    vios[i].eventsa |= ROAR_VIO_SELECT_EXCEPT;
- }
-
-#else
- ret = -1;
-#endif
-
- ROAR_DBG("roar_vio_select(vios=%p, len=%llu, rtv=%p, ctl=%p) = %lli", vios, (long long unsigned int)len, rtv, ctl, (long long int)ret);
- return ret;
-}
-
-//ll
Index: libroar/vio_socket.c
===================================================================
--- libroar/vio_socket.c	(revision 6080)
+++ 	(revision )
@@ -1,694 +1,0 @@
-//vio_socket.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_BSDSOCKETS
-#define _CAN_OPERATE
-#endif
-
-int     roar_vio_open_def_socket          (struct roar_vio_calls * calls, struct roar_vio_defaults * def, char * opts) {
-#ifdef _CAN_OPERATE
- int       fh  = -1;
- socklen_t len =  0;
- int       listening  = 0;
- int       one_client = 0;
- int       client;
- int       connection_less = 0;
-
- if ( calls == NULL || def == NULL )
-  return -1;
-
- if ( opts != NULL ) {
-  if ( strstr(opts, "listen=listener") != NULL ) {
-   listening  = 1;
-   one_client = 0;
-  } else if ( strstr(opts, "listen=single") != NULL || strstr(opts, "listen") != NULL ) {
-   listening  = 1;
-   one_client = 1;
-  }
- }
-
- if ( def->type != ROAR_VIO_DEF_TYPE_SOCKET )
-  return -1;
-
- switch (def->d.socket.domain) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:
-    len = sizeof(struct sockaddr_in);
-
-    if ( roar_vio_socket_init_inet4host_def(def) == -1 )
-     return -1;
-
-    switch (def->d.socket.type) {
-     case SOCK_STREAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_TCP);
-      break;
-     case SOCK_DGRAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_UDP);
-       connection_less = 1;
-      break;
-     default:
-       return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  case AF_UNIX:
-    len = sizeof(struct sockaddr_un);
-
-    switch (def->d.socket.type) {
-     case SOCK_STREAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_UNIX);
-      break;
-     case SOCK_DGRAM:
-       connection_less = 1;
-       return -1;
-      break;
-     default:
-       return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-    len = sizeof(struct sockaddr_dn);
-
-    if ( roar_vio_socket_init_decnetnode_def(def) == -1 )
-     return -1;
-
-    switch (def->d.socket.type) {
-     case SOCK_STREAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_DECNET);
-      break;
-     default:
-       return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:
-    len = sizeof(struct sockaddr_in6);
-
-    switch (def->d.socket.type) {
-     case SOCK_STREAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_TCP6);
-      break;
-     case SOCK_DGRAM:
-       fh = roar_socket_new(ROAR_SOCKET_TYPE_UDP6);
-       connection_less = 1;
-      break;
-     default:
-       return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_IPX
-  case AF_IPX:
-    len = sizeof(struct sockaddr_ipx);
-
-    return -1;
-   break;
-#endif
-  default:
-    return -1;
- }
-
- if ( fh == -1 )
-  return -1;
-
- if ( listening ) {
-  if ( bind(fh, &(def->d.socket.sa.sa), len) == -1 ) {
-   close(fh);
-   return -1;
-  }
-
-  if ( !connection_less ) {
-   if ( listen(fh, one_client ? 1 : 16) == -1 ) {
-    close(fh);
-    return -1;
-   }
-
-   if ( one_client ) {
-    client = accept(fh, NULL, NULL);
-    close(fh);
-
-    if ( client == -1 ) {
-     return -1;
-    }
-
-    fh = client;
-   }
-  }
- } else {
-  if ( def->o_flags & ROAR_VIOF_NONBLOCK ) {
-   if ( roar_socket_nonblock(fh, ROAR_SOCKET_NONBLOCK) == -1 ) {
-    close(fh);
-    return -1;
-   }
-  }
-
-  if ( connect(fh, &(def->d.socket.sa.sa), len) == -1 ) {
-#ifdef EINPROGRESS
-   if ( errno != EINPROGRESS ) {
-#endif
-    roar_err_from_errno();
-    close(fh);
-    return -1;
-#ifdef EINPROGRESS
-   }
-#endif
-  }
- }
-
- if ( roar_vio_open_fh_socket(calls, fh) == -1 ) {
-  close(fh);
-  return -1;
- }
-
- // there is no problem if the shutdown()s fail.
- // some socket domains don't support unidirectional connections
- // this just free()s some kernel buffers :)
- switch (def->o_flags & (O_RDONLY|O_WRONLY|O_RDWR)) {
-  case O_RDONLY:
-    ROAR_SHUTDOWN(fh, SHUT_WR);
-   break;
-  case O_WRONLY:
-    ROAR_SHUTDOWN(fh, SHUT_RD);
-   break;
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     roar_vio_socket_init_socket_def   (struct roar_vio_defaults * def, int domain, int type) {
-#ifdef _CAN_OPERATE
- if ( def == NULL || domain == -1 || type == -1 )
-  return -1;
-
- // we do not memset(def, 0, sizeof(...)) here
- // because this is allready done in roar_vio_dstr_init_defaults()
- // if we would be would override o_flags/o_mode and maybe others
-
- memset(&(def->d.socket.sa), 0, sizeof(def->d.socket.sa));
-
- def->type                     = ROAR_VIO_DEF_TYPE_SOCKET;
- def->d.socket.domain          = domain;
- def->d.socket.type            = type;
- def->d.socket.sa.sa.sa_family = domain;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     roar_vio_socket_init_dstr_def     (struct roar_vio_defaults * def, char * dstr, int hint, int type,
-                                           struct roar_vio_defaults * odef) {
-#ifdef _CAN_OPERATE
- char * host;
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
- int    port;
-#endif
-#if defined(ROAR_HAVE_IPV4)
- int ret;
-#endif
-
- if ( def == NULL )
-  return -1;
-
- if ( dstr == NULL && odef == NULL )
-  return -1;
-
- if ( dstr == NULL )
-  dstr = "";
-
- ROAR_DBG("roar_vio_socket_init_dstr_def(def=%p, dstr='%s', hint=%i, type=%i, odef=%p) = ?", def, dstr, hint, type, odef);
-
- if ( hint == -1 ) {
-  if ( 0 ) { // this is needed to keep the syntx ok, compiler will throw it away
-#ifdef ROAR_HAVE_IPV6
-  } else if ( strstr(dstr, "[") != NULL ) { // [ip]:service
-   hint = AF_INET6;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  } else if ( strstr(dstr, "::") != NULL ) { // node::object
-   hint = AF_DECnet;
-#endif
-#ifdef ROAR_HAVE_IPX
-  } else if ( strstr(dstr, "(") != NULL ) { // net:mac(service)
-   hint = AF_IPX;
-#endif
-#ifdef ROAR_HAVE_UNIX
-  } else if ( strstr(dstr, "/") != NULL ) { // /path/to/sock
-   hint = AF_UNIX;
-#endif
-#ifdef ROAR_HAVE_IPV4
-  } else if ( strstr(dstr, ":") != NULL ) { // host:port
-   hint = AF_INET;
-#endif
-  }
- }
-
- if ( hint == -1 && odef != NULL ) { // if we still don't know what this is we try
-                                     // to use the parent objects request
-  ROAR_DBG("roar_vio_socket_init_dstr_def(*): hint=-1 && odef!=NULL");
-  if ( odef->type == ROAR_VIO_DEF_TYPE_SOCKET ) {
-   ROAR_DBG("roar_vio_socket_init_dstr_def(*): hint=-1 && odef!=NULL, using hint from odef");
-   hint = odef->d.socket.domain;
-  }
- }
-
- if ( hint == -1 ) /* we really have no glue what this is... */
-  return -1;
-
-#ifdef ROAR_HAVE_UNIX
- if ( hint == AF_UNIX ) {
-  if ( *dstr != 0 && strcmp(dstr, "//") != 0 ) {
-   return roar_vio_socket_init_unix_def(def, dstr);
-  } else {
-   if ( roar_vio_socket_conv_def(odef, AF_UNIX) == -1 )
-    return -1;
-
-   return roar_vio_socket_init_unix_def(def, odef->d.socket.sa.un.sun_path);
-  }
- }
-#endif
-
- ROAR_DBG("roar_vio_socket_init_dstr_def(*) = ?");
-
- if ( *dstr == 0 ) {
-  if ( roar_vio_socket_conv_def(odef, hint) == -1 )
-   return -1;
-
-  if ( odef->d.socket.type != type )
-   return -1;
-
-  if ( def != odef )
-   memcpy(def, odef, sizeof(struct roar_vio_defaults));
-
-  return 0;
- }
-
- for (; *dstr == '/'; dstr++);
-
- ROAR_DBG("roar_vio_socket_init_dstr_def(*) = ?");
-
- switch (hint) {
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:
-    host = dstr;
-    for (; *dstr != 0 && *dstr != ':'; dstr++);
-
-    if ( *dstr == ':' ) { // we have a port :)
-     *dstr++ = 0;
-     if ( (port = roar_vio_socket_get_port(dstr, AF_INET, type)) == -1 )
-      return -1;
-
-     ret = roar_vio_socket_init_inet4_def(def, host, port, type);
-
-     *(dstr-1) = ':';
-
-     return ret;
-    } else {
-     if ( roar_vio_socket_conv_def(odef, AF_INET) == -1 )
-      return -1;
-
-     return roar_vio_socket_init_inet4_def(def, host, ROAR_NET2HOST16(odef->d.socket.sa.in.sin_port), type);
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-    ROAR_DBG("roar_vio_socket_init_dstr_def(*) = ?");
-    host = dstr;
-
-    if ( type != SOCK_STREAM )
-     return -1;
-
-    if ( (dstr = strstr(dstr, "::")) == NULL ) {
-     if ( roar_vio_socket_conv_def(odef, AF_DECnet) == -1 )
-      return -1;
-
-     return -1;
-//     return roar_vio_socket_init_decnet_def(def, host, -1, dstr);
-    } else {
-     *dstr  = 0;
-      dstr += 2;
-     return roar_vio_socket_init_decnet_def(def, host, -1, dstr);
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:
-    return -1;
-   break;
-#endif
-#ifdef ROAR_HAVE_IPX
-  case AF_IPX:
-    return -1;
-   break;
-#endif
-  default:
-    return -1;
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-#ifdef _CAN_OPERATE
-int     roar_vio_socket_conv_def          (struct roar_vio_defaults * def, int domain) {
- if ( def == NULL || domain == -1 )
-  return -1;
-
-#ifdef ROAR_HAVE_UNIX
- if ( domain == AF_UNIX ) {
-  if ( def->type == ROAR_VIO_DEF_TYPE_SOCKET ) {
-   if ( def->d.socket.domain == AF_UNIX )
-    return 0;
-
-   return -1;
-  } else {
-   if ( def->type == ROAR_VIO_DEF_TYPE_FILE )
-    return roar_vio_socket_init_unix_def(def, def->d.file);
-
-   return -1;
-  }
- }
-#endif
-
- if ( def->type != ROAR_VIO_DEF_TYPE_SOCKET )
-  return -1;
-
- if ( def->d.socket.domain == domain )
-  return 0;
-
- // we sould add support to convert IPv4 <-> IPv6 here
-
- return -1;
-}
-
-int     roar_vio_socket_get_port          (char * service, int domain, int type) {
-#ifdef ROAR_HAVE_GETSERVBYNAME
- struct servent * serv  = NULL;
- char           * proto = NULL;
-#endif
- int              port;
- char           * ts;
-
- if ( service == NULL || domain == -1 || type == -1 ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (ts = strstr(service, "/")) != NULL )
-  *ts = 0;
-
- if ( sscanf(service, "%i", &port) == 1 )
-  return port;
-
- if ( ts != NULL )
-  *ts = '/';
-
- switch (domain) {
-#ifdef ROAR_HAVE_IPV6
-  case AF_INET6:
-#endif
-#ifdef ROAR_HAVE_IPV4
-  case AF_INET:
-#endif
-#if defined(ROAR_HAVE_IPV6) || defined(ROAR_HAVE_IPV4)
-    switch (type) {
-     case SOCK_STREAM:
-#ifdef ROAR_HAVE_GETSERVBYNAME
-       proto = "tcp";
-#endif
-      break;
-     case SOCK_DGRAM:
-#ifdef ROAR_HAVE_GETSERVBYNAME
-       proto = "udp";
-#endif
-      break;
-     default:
-      return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case AF_DECnet:
-#ifdef ROAR_HAVE_GETOBJECTBYNAME
-    return getobjectbyname(service);
-#else
-    if ( !strcmp(service, "roar") )
-     return 0;
-
-    roar_err_set(ROAR_ERROR_NOENT);
-    return -1;
-#endif
-   break;
-#endif
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
- }
-
-#ifdef ROAR_HAVE_GETSERVBYNAME
- if ( ts != NULL )
-  *ts = 0;
-
- if ( (serv = getservbyname(service, proto)) == NULL ) {
-  roar_err_from_errno();
-  ROAR_DBG("roar_vio_socket_get_port(*): Unknown service: %s/%s: %s", service, proto, strerror(errno));
-
-  if ( ts != NULL )
-   *ts = '/';
-
-  return -1;
- }
-
- if ( ts != NULL )
-  *ts = '/';
-
- return ROAR_NET2HOST16(serv->s_port);
-#endif
-
-
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-}
-#endif
-
-// AF_UNIX:
-int     roar_vio_socket_init_unix_def     (struct roar_vio_defaults * def, const char * path) {
-#if defined(ROAR_HAVE_UNIX) && defined(_CAN_OPERATE)
- if ( def == NULL || path == NULL )
-  return -1;
-
- if ( roar_vio_socket_init_socket_def(def, AF_UNIX, SOCK_STREAM) == -1 )
-  return -1;
-
- strncpy(def->d.socket.sa.un.sun_path, path, sizeof(def->d.socket.sa.un.sun_path) - 1);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-// AF_DECnet:
-int     roar_vio_socket_init_decnetnode_def(struct roar_vio_defaults * def) {
-#if defined(ROAR_HAVE_LIBDNET) && defined(_CAN_OPERATE)
- char               * node;
- char               * ed;
- struct nodeent     * ne;
-
- if ( def == NULL )
-  return -1;
-
- if ( def->d.socket.host == NULL )
-  return -1;
-
- if ( (node = roar_mm_strdup(def->d.socket.host)) == NULL )
-  return -1;
-
- if ( (ed = strstr(node, "/")) != NULL )
-  *ed = 0;
-
- ne = getnodebyname(node);
-
- roar_mm_free(ed);
-
- if ( ne == NULL ) {
-  ROAR_ERR("roar_vio_socket_init_decnetnode_def(*): Can\'t resolve node name '%s'", node);
-  return -1;
- }
-
- memcpy(&(def->d.socket.sa.dn.sdn_add.a_addr), ne->n_addr, 2);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     roar_vio_socket_init_decnet_def   (struct roar_vio_defaults * def, const char * node, int object, char * objname) {
-#if defined(ROAR_HAVE_LIBDNET) && defined(_CAN_OPERATE)
- struct sockaddr_dn * dn;
-
- if ( def == NULL )
-  return -1;
-
- if ( object < 1 && objname == NULL )
-  return -1;
-
- if ( object == -1 )
-  object = roar_vio_socket_get_port(objname, AF_DECnet, SOCK_STREAM);
-
- if ( object == -1 ) {
-  if ( objname == NULL ) {
-   return -1;
-  } else {
-   object = 0;
-  }
- }
-
- if ( roar_vio_socket_init_socket_def(def, AF_DECnet, SOCK_STREAM) == -1 )
-  return -1;
-
- def->d.socket.host = node;
- dn                 = &(def->d.socket.sa.dn);
- dn->sdn_flags      = 0;
- dn->sdn_objnum     = object;
- dn->sdn_nodeaddrl  = 2;
-
- if ( objname == NULL ) {
-  dn->sdn_objnamel   = 0;
- } else {
-  dn->sdn_objnamel   = strlen(objname);
-  if ( dn->sdn_objnamel > DN_MAXOBJL )
-   dn->sdn_objnamel  = DN_MAXOBJL;
-
-  memcpy(&(dn->sdn_objname), objname, dn->sdn_objnamel);
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-
-// AF_INET:
-int     roar_vio_socket_init_inet4host_def(struct roar_vio_defaults * def) {
-#if defined(ROAR_HAVE_IPV4) && defined(_CAN_OPERATE)
- struct hostent     * he;
- char               * ed, * pd;
-
- if ( def == NULL )
-  return -1;
-
- if ( def->d.socket.host == NULL )
-  return -1;
-
- if ( (ed = strstr(def->d.socket.host, "/")) != NULL )
-  *ed = 0;
-
- if ( (pd = strstr(def->d.socket.host, ":")) != NULL )
-  *pd = 0;
-
- if ( (he = gethostbyname(def->d.socket.host)) == NULL ) {
-  ROAR_ERR("roar_vio_socket_init_inet4host_def(*): Can\'t resolve host name '%s'",
-                    def->d.socket.host);
-  if ( ed != NULL ) *ed = '/';
-  return -1;
- }
-
- if ( pd != NULL ) *pd = ':';
-
- if ( ed != NULL ) *ed = '/';
-
- memcpy((struct in_addr *)&def->d.socket.sa.in.sin_addr, he->h_addr, sizeof(struct in_addr));
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     roar_vio_socket_init_inet4_def    (struct roar_vio_defaults * def, const char * host, int port, int type) {
-#if defined(ROAR_HAVE_IPV4) && defined(_CAN_OPERATE)
- if ( roar_vio_socket_init_socket_def(def, AF_INET, type) == -1 )
-  return -1;
-
- def->d.socket.host             = host;
-
- def->d.socket.sa.in.sin_port   = ROAR_HOST2NET16(port);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     roar_vio_socket_init_tcp4_def     (struct roar_vio_defaults * def, const char * host, int port) {
- return roar_vio_socket_init_inet4_def(def, host, port, SOCK_STREAM);
-}
-
-int     roar_vio_socket_init_udp4_def     (struct roar_vio_defaults * def, const char * host, int port) {
- return roar_vio_socket_init_inet4_def(def, host, port, SOCK_DGRAM);
-}
-
-
-// AF_INET6:
-int     roar_vio_socket_init_inet6host_def(struct roar_vio_defaults * def);
-int     roar_vio_socket_init_inet6_def    (struct roar_vio_defaults * def, const char * host, int port, int type) {
- return -1;
-}
-
-int     roar_vio_socket_init_tcp6_def     (struct roar_vio_defaults * def, const char * host, int port) {
- return roar_vio_socket_init_inet6_def(def, host, port, SOCK_STREAM);
-}
-
-int     roar_vio_socket_init_udp6_def     (struct roar_vio_defaults * def, const char * host, int port) {
- return roar_vio_socket_init_inet6_def(def, host, port, SOCK_DGRAM);
-}
-
-//ll
Index: libroar/vio_stack.c
===================================================================
--- libroar/vio_stack.c	(revision 6052)
+++ 	(revision )
@@ -1,200 +1,0 @@
-//vio_stack.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_stack    (struct roar_vio_calls * calls) {
- return roar_vio_open_stack2(calls, free);
-}
-
-int     roar_vio_open_stack2   (struct roar_vio_calls * calls, void (*func)(void*)) {
- struct roar_vio_stack * self;
-
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( func == NULL )
-  func = roar_mm_free_retvoid;
-
- if ( (self = roar_mm_malloc(sizeof(struct roar_vio_stack))) == NULL )
-  return -1;
-
- memset(self,  0, sizeof(struct roar_vio_stack));
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- self->free      = func;
-
- calls->inst     = self;
- calls->close    = roar_vio_stack_close;
- calls->ctl      = roar_vio_stack_ctl;
- calls->read     = roar_vio_stack_read;
- calls->write    = roar_vio_stack_write;
- calls->lseek    = roar_vio_stack_lseek;
- calls->sync     = roar_vio_stack_sync;
-
- return 0;
-}
-
-int     roar_vio_stack_add     (struct roar_vio_calls * calls, struct roar_vio_calls * vio) {
- struct roar_vio_stack * self;
-
- if ( calls == NULL || vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (self = calls->inst) == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( self->next == ROAR_VIO_STACK_MAX )
-  return -1;
-
- self->cur = self->calls[self->next++] = vio;
-
- return 0;
-}
-
-int     roar_vio_stack_close   (struct roar_vio_calls * vio) {
- struct roar_vio_stack * self;
- int i;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( (self = vio->inst) == NULL )
-  return -1;
-
- if ( self->cur != NULL ) {
-  if ( roar_vio_close(self->cur) == -1 )
-   return -1;
-
-  for (i = 0; i < self->next; i++)
-   self->free(self->calls[i]);
- }
-
- roar_mm_free(self);
-
- return 0;
-}
-
-int     roar_vio_stack_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if (vio == NULL || cmd == -1)
-  return -1;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "stack";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_SELECT:
-    return roar_vio_ctl(((struct roar_vio_stack*)(vio->inst))->cur, cmd, data);
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = ((struct roar_vio_stack*)(vio->inst))->cur;
-    return 0;
-   break;
- }
-
- return roar_vio_ctl(((struct roar_vio_stack*)(vio->inst))->cur, cmd, data);
-}
-
-
-ssize_t roar_vio_stack_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- if ( vio == NULL )
-  return -1;
-
- if ( vio->inst == NULL )
-  return -1;
-
- if ( ((struct roar_vio_stack*)(vio->inst))->cur == NULL )
-  return -1;
-
- return roar_vio_read(((struct roar_vio_stack*)(vio->inst))->cur, buf, count);
-}
-
-ssize_t roar_vio_stack_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- if ( vio == NULL )
-  return -1;
-
- if ( vio->inst == NULL )
-  return -1;
-
- if ( ((struct roar_vio_stack*)(vio->inst))->cur == NULL )
-  return -1;
-
- return roar_vio_write(((struct roar_vio_stack*)(vio->inst))->cur, buf, count);
-}
-
-roar_off_t   roar_vio_stack_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- if ( vio == NULL )
-  return -1;
-
- if ( vio->inst == NULL )
-  return -1;
-
- if ( ((struct roar_vio_stack*)(vio->inst))->cur == NULL )
-  return -1;
-
- return roar_vio_lseek(((struct roar_vio_stack*)(vio->inst))->cur, offset, whence);
-}
-
-int     roar_vio_stack_sync    (struct roar_vio_calls * vio) {
- if ( vio == NULL )
-  return -1;
-
- if ( vio->inst == NULL )
-  return -1;
-
- if ( ((struct roar_vio_stack*)(vio->inst))->cur == NULL )
-  return -1;
-
- return roar_vio_sync(((struct roar_vio_stack*)(vio->inst))->cur);
-}
-
-//ll
Index: libroar/vio_stdio.c
===================================================================
--- libroar/vio_stdio.c	(revision 6052)
+++ 	(revision )
@@ -1,187 +1,0 @@
-//vio_stdio.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_open_stdio    (struct roar_vio_calls * calls, FILE * dst) {
-#ifndef ROAR_WITHOUT_VIO_STDIO
- if ( calls == NULL || dst == NULL )
-  return -1;
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags    = ROAR_VIO_FLAGS_NONE;
- calls->refc     = 1;
-
- calls->read  = roar_vio_stdio_read;
- calls->write = roar_vio_stdio_write;
- calls->lseek = roar_vio_stdio_lseek;
- calls->sync  = roar_vio_stdio_sync;
- calls->close = roar_vio_stdio_close;
-
- calls->inst  = dst;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-FILE *  roar_vio_to_stdio      (struct roar_vio_calls * calls, int flags) {
-#ifdef ROAR_HAVE_FOPENCOOKIE
- cookie_io_functions_t foc_funcs;
-#endif
-
- // (void)flags is the the individual sections because later added APIs
- // may require those flags.
-
- if ( calls == NULL )
-  return NULL;
-
-#if defined(ROAR_HAVE_FOPENCOOKIE)
- (void)flags;
-
- memset(&foc_funcs, 0, sizeof(cookie_io_functions_t));
-
- foc_funcs.close = roar_vio_to_stdio_close;
- foc_funcs.read  = roar_vio_to_stdio_read;
- foc_funcs.write = roar_vio_to_stdio_write;
-
- return fopencookie((void*) calls, "rw", foc_funcs);
-#elif defined(ROAR_HAVE_FUNOPEN)
- (void)flags;
-
- return funopen((void*) calls, roar_vio_to_stdio_read,  roar_vio_to_stdio_write,
-                               roar_vio_to_stdio_lseek, roar_vio_to_stdio_close);
-#else
- return NULL;
-#endif
-}
-
-#if defined(ROAR_HAVE_FOPENCOOKIE) || defined(ROAR_HAVE_FUNOPEN)
-int roar_vio_to_stdio_close (void *__cookie) {
- return roar_vio_close((struct roar_vio_calls *) __cookie);
-}
-
-#if defined(ROAR_HAVE_FOPENCOOKIE)
-ssize_t roar_vio_to_stdio_read (void *__cookie, char *__buf, size_t __nbytes) {
-#elif defined(ROAR_HAVE_FUNOPEN)
-int roar_vio_to_stdio_read(void *__cookie, char *__buf, int __nbytes) {
-#endif
- return roar_vio_read((struct roar_vio_calls *) __cookie, __buf, __nbytes);
-}
-
-#if defined(ROAR_HAVE_FOPENCOOKIE)
-ssize_t roar_vio_to_stdio_write (void *__cookie, __const char *__buf, size_t __n) {
-#elif defined(ROAR_HAVE_FUNOPEN)
-int roar_vio_to_stdio_write(void *__cookie, const char *__buf, int __n) {
-#endif
- ROAR_DBG("roar_vio_to_stdio_write(*) = ?");
- return roar_vio_write((struct roar_vio_calls *) __cookie, (char *) __buf, __n);
-}
-
-#if defined(ROAR_HAVE_FOPENCOOKIE)
-int roar_vio_to_stdio_lseek (void *__cookie, _IO_off64_t *__pos, int __w);
-#elif defined(ROAR_HAVE_FUNOPEN)
-fpos_t roar_vio_to_stdio_lseek(void *__cookie, fpos_t __pos, int __w) {
- return roar_vio_lseek((struct roar_vio_calls *) __cookie, __pos, __w);
-}
-#endif
-#endif
-
-// VIOs:
-
-// stdio:
-#ifndef ROAR_WITHOUT_VIO_STDIO
-ssize_t roar_vio_stdio_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- return fread(buf, 1, count, (FILE*)(vio->inst));
-}
-
-ssize_t roar_vio_stdio_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- return fwrite(buf, 1, count, (FILE*)(vio->inst));
-}
-
-roar_off_t   roar_vio_stdio_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
-// ftell() is broken on win. It sometimes returnes the binary offset and sometimes
-// the text mode offset (why? why are both diffrent?).
-#if defined(ROAR_HAVE_FSEEK) && defined(ROAR_HAVE_FTELL) && !defined(ROAR_TARGET_WIN32)
- if ( fseek((FILE*)(vio->inst), offset, whence) == -1 )
-  return -1;
-
- return ftell((FILE*)(vio->inst));
-#else
- return (roar_off_t)-1;
-#endif
-}
-
-int     roar_vio_stdio_sync    (struct roar_vio_calls * vio) {
- return fflush((FILE*)(vio->inst));
-}
-
-int     roar_vio_stdio_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
-
- if ( vio == NULL || cmd == -1 )
-  return -1;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "stdio";
-    return 0;
-   break;
-#ifdef ROAR_HAVE_FILENO
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-   *(int*)data = fileno((FILE*)(vio->inst));
-    return 0;
-   break;
-#endif
- }
-
- return -1;
-}
-
-int     roar_vio_stdio_close   (struct roar_vio_calls * vio) {
- return fclose((FILE*)(vio->inst));
-}
-
-#endif
-
-//ll
Index: libroar/vio_stdvios.c
===================================================================
--- libroar/vio_stdvios.c	(revision 6052)
+++ 	(revision )
@@ -1,93 +1,0 @@
-//vio_stdvios.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-static struct roar_vio_calls _libroar_vio_stdvios[3] = {
- { .inst     = (void*)(ROAR_INSTINT)(ROAR_STDIN  + 1),
-   .flags    = 0x00000000,
-   .refc     = 1,
-   .read     = roar_vio_basic_read,
-   .write    = roar_vio_basic_write,
-   .lseek    = roar_vio_basic_lseek,
-   .sync     = roar_vio_basic_sync,
-   .ctl      = roar_vio_basic_ctl,
-   .close    = roar_vio_basic_close
- },
- { .inst     = (void*)(ROAR_INSTINT)(ROAR_STDOUT + 1),
-   .flags    = 0x00000000,
-   .refc     = 1,
-   .read     = roar_vio_basic_read,
-   .write    = roar_vio_basic_write,
-   .lseek    = roar_vio_basic_lseek,
-   .sync     = roar_vio_basic_sync,
-   .ctl      = roar_vio_basic_ctl,
-   .close    = roar_vio_basic_close
- },
- { .inst     = (void*)(ROAR_INSTINT)(ROAR_STDERR + 1),
-   .flags    = 0x00000000,
-   .refc     = 1,
-   .read     = roar_vio_basic_read,
-   .write    = roar_vio_basic_write,
-   .lseek    = roar_vio_basic_lseek,
-   .sync     = roar_vio_basic_sync,
-   .ctl      = roar_vio_basic_ctl,
-   .close    = roar_vio_basic_close
- }
-};
-
-#ifndef ROAR_TARGET_WIN32
-struct roar_vio_calls * roar_stdin  = &(_libroar_vio_stdvios[0]);
-struct roar_vio_calls * roar_stdout = &(_libroar_vio_stdvios[1]);
-struct roar_vio_calls * roar_stderr = &(_libroar_vio_stdvios[2]);
-#else
-struct roar_vio_calls ** libroar_stdvio_win32workaround(int fh) {
- static struct roar_vio_calls * vios[3] = {
-  &(_libroar_vio_stdvios[0]),
-  &(_libroar_vio_stdvios[1]),
-  &(_libroar_vio_stdvios[2])
- };
-
- if ( fh >= 0 && fh <= 2) {
-  return &(vios[fh]);
- } else {
-  roar_strap(ROAR_TRAP_GROUP_LIBROAR, "libroar_stdvio_win32workaround.bad-fh");
-  roar_err_set(ROAR_ERROR_BADFH); // just in case somebody uses a debugger.
-  return NULL;
- }
-}
-#endif
-
-//ll
Index: libroar/vio_stream.c
===================================================================
--- libroar/vio_stream.c	(revision 6067)
+++ 	(revision )
@@ -1,466 +1,0 @@
-//vio_stream.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_TARGET_WIN32
-static inline int inet_aton(const char *s, struct in_addr *a) {
- int b0, b1, b2, b3;
-
- if (sscanf(s, "%d.%d.%d.%d", &b0, &b1, &b2, &b3) < 4)
-  return 0;
-
- a->s_addr = inet_addr(s);
-
- return a->s_addr != INADDR_NONE;
-}
-#endif
-
-static ssize_t _vio_stream_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- return roar_vio_read(roar_get_connection_vio2(vio->inst), buf, count);
-}
-
-static ssize_t _vio_stream_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- return roar_vio_write(roar_get_connection_vio2(vio->inst), buf, count);
-}
-
-static roar_off_t   _vio_stream_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- return roar_vio_lseek(roar_get_connection_vio2(vio->inst), offset, whence);
-}
-static int     _vio_stream_sync    (struct roar_vio_calls * vio) {
- return roar_vio_sync(roar_get_connection_vio2(vio->inst));
-}
-static int     _vio_stream_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if (vio == NULL) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if (cmd == -1) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    *(char**)data = "stream";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = roar_get_connection_vio2(vio->inst);
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NEXT:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    return roar_vio_ctl(roar_get_connection_vio2(vio->inst), ROAR_VIO_CTL_NONBLOCK, data);
-   break;
- }
-
- return roar_vio_ctl(roar_get_connection_vio2(vio->inst), cmd, data);
-}
-
-static int     _vio_stream_close   (struct roar_vio_calls * vio) {
- roar_vio_close(roar_get_connection_vio2(vio->inst));
- roar_mm_free(vio->inst);
-
- return 0;
-}
-
-int     roar_vio_simple_stream (struct roar_vio_calls * calls,
-                                uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec,
-                                const char * server, int dir, const char * name, int mixer) {
- struct roar_connection * con = NULL;
- struct roar_stream       stream;
- int err;
-
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( roar_stream_new(&stream, rate, channels, bits, codec) == -1 )
-  return -1;
-
- con = roar_mm_malloc(sizeof(struct roar_connection));
- if ( con == NULL )
-  return -1;
-
- memset(con, 0, sizeof(struct roar_connection));
-
- if ( roar_simple_connect(con, server, name) == -1 ) {
-  roar_mm_free_noerror(con);
-  return -1;
- }
-
- if ( roar_stream_connect(con, &stream, dir, mixer) == -1 ) {
-  err = roar_error;
-  roar_disconnect(con);
-  roar_mm_free(con);
-  roar_error = err;
-  return -1;
- }
-
- if ( roar_stream_exec(con, &stream) == -1 ) {
-  err = roar_error;
-  roar_disconnect(con);
-  roar_mm_free(con);
-  roar_error = err;
-  return -1;
- }
-
- roar_vio_clear_calls(calls);
-
- calls->inst       = con;
- calls->read       = _vio_stream_read;
- calls->write      = _vio_stream_write;
- calls->lseek      = _vio_stream_lseek;
- calls->sync       = _vio_stream_sync;
- calls->ctl        = _vio_stream_ctl;
- calls->close      = _vio_stream_close;
-
- if ( dir == ROAR_DIR_PLAY ) {
-  roar_vio_shutdown(calls, SHUT_RD);
- } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) {
-  roar_vio_shutdown(calls, SHUT_WR);
- }
-
- return 0;
-}
-
-static inline int _roar_simple_new_stream_obj_try_select (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer, struct roar_sockname * sockname, int * fh, int * can_go_on) {
-#ifdef ROAR_HAVE_SELECT
- int confh;
- fd_set fds;
- struct timeval timeout = {10, 0};
- struct roar_message    mes;
- int listen;
- int    port = 0;
- char file[80] = "";
- char socketaddr[80];
- ssize_t socketaddr_len = -1;
-#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_LIBDNET)
- int    opt  = 1;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
- static int count = 0;
- struct dn_naddr      *binaddr;
-#endif
-#ifdef ROAR_HAVE_IPV4
- struct sockaddr_in   socket_addr;
- socklen_t            len            = sizeof(struct sockaddr_in);
-#else
- struct sockaddr      socket_addr;
- socklen_t            len            = sizeof(struct sockaddr);
-#endif
-
- memset(&mes, 0, sizeof(mes));
- memset(&socket_addr, 0, sizeof(socket_addr));
-
- *can_go_on = 0;
-
- switch (sockname->type) {
-#ifdef ROAR_HAVE_LIBDNET
-  case ROAR_SOCKET_TYPE_DECNET:
-    if ( roar_socket_get_local_nodename() != NULL && (binaddr = getnodeadd()) != NULL ) {
-     snprintf(socketaddr+3, sizeof(socketaddr)-3, "roar$TMP%04x%02x", getpid(), count++);
-     snprintf(file, sizeof(file), "%s::%s", roar_socket_get_local_nodename(), socketaddr+3);
-     memcpy(socketaddr, binaddr->a_addr, 2);
-     socketaddr[2] = 0; // object 0.
-     socketaddr_len = 3 + roar_mm_strlen(socketaddr+3);
-    } else {
-     return -1;
-    }
-   break;
-#endif
-#ifdef ROAR_HAVE_IPV4
-  case ROAR_SOCKET_TYPE_TCP:
-    strncpy(file, sockname->addr, sizeof(file) - 1);
-    roar_err_set(ROAR_ERROR_NONE);
-    if ( inet_aton(sockname->addr, &socket_addr.sin_addr) == 0 ) {
-     roar_err_update();
-     return -1;
-    }
-    memcpy(socketaddr, &socket_addr.sin_addr.s_addr, 4);
-    socketaddr_len = 6;
-   break;
-#endif
-  default:
-    roar_err_set(ROAR_ERROR_AFNOTSUP);
-    return -1;
-   break;
- }
-
- roar_libroar_nowarn();
- if ( (listen = roar_socket_listen(sockname->type, file, port)) == -1 ) {
-  roar_libroar_warn();
-  return -1;
- }
- roar_libroar_warn();
-
- switch (sockname->type) {
-#ifdef ROAR_HAVE_IPV4
-  case ROAR_SOCKET_TYPE_TCP:
-    setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(int));
-
-    len = sizeof(struct sockaddr_in);
-    if ( getsockname(listen, (struct sockaddr *)&socket_addr, &len) == -1 ) {
-     return -1;
-    }
-    ((uint16_t*)socketaddr)[3] = socket_addr.sin_port;
-    port = ROAR_NET2HOST16(socket_addr.sin_port);
-    ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port);
-   break;
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-  case ROAR_SOCKET_TYPE_DECNET:
-    setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
-   break;
-#endif
- }
-
- if ( roar_stream_connect_to_advanced(con, s, 0, 1, 0, sockname->type, socketaddr_len, socketaddr, ROAR_PROTO_NONE, -1, NULL, 0, NULL) == -1 ) {
-  close(listen);
-  *can_go_on = 1;
-  return -1;
- } else {
-
-  FD_ZERO(&fds);
-  FD_SET(listen, &fds);
-
-  confh = roar_get_connection_fh(con);
-
-  if ( confh != -1 ) {
-   FD_SET(confh, &fds);
-  }
-
-  if ( select((confh > listen ? confh : listen) + 1, &fds, NULL, NULL, &timeout) < 1 ) {
-   close(listen);
-
-   // we don't need to check the content as we know it failed...
-   if ( roar_recv_message(con, &mes, NULL) == -1 )
-    return -1;
-
-   if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 )
-    return -1;
-
-   *can_go_on = 1;
-   return -1;
-  }
-
-  if ( FD_ISSET(listen, &fds) ) {
-   if ( (*fh = accept(listen, NULL, NULL)) != -1 ) {
-    /* TODO: FIXME: XXX: errr, do we need any error handling here? */
-   }
-
-   if ( roar_recv_message(con, &mes, NULL) == -1 ) {
-    if ( *fh != -1 )
-     close(*fh);
-    *fh = -1;
-   } else if ( mes.cmd != ROAR_CMD_OK ) {
-    if ( *fh != -1 )
-     close(*fh);
-    *fh = -1;
-   }
-  } else {
-   // we don't need to check the content as we know it failed...
-   if ( roar_recv_message(con, &mes, NULL) == -1 ) {
-    close(listen);
-    return -1;
-   }
-
-   if ( mes.cmd != ROAR_CMD_OK ) {
-    close(listen);
-    if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 )
-     return -1;
-
-    *can_go_on = 1;
-    return -1;
-   } else { // seems like we have a positive reply. So we retry the listen socket:
-    FD_ZERO(&fds);
-    FD_SET(listen, &fds);
-    timeout.tv_sec = 0;
-    timeout.tv_usec = 128000L;
-    *fh = -1;
-    if ( select(listen + 1, &fds, NULL, NULL, &timeout) > 0 ) {
-     if ( (*fh = accept(listen, NULL, NULL)) == -1 ) {
-      close(listen);
-      if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 )
-       return -1;
-
-      *can_go_on = 1;
-      return -1;
-     }
-    }
-   }
-  }
-  close(listen);
-  return 0;
- }
-
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-#endif
-}
-
-static int _roar_simple_new_stream_obj (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer) {
- struct roar_libroar_config * config = roar_libroar_get_config();
- int fh = -1;
-#ifdef ROAR_HAVE_UNIX
- int socks[2]; // for socketpair()
-#endif
- struct roar_sockname sockname;
- int can_go_on = 0;
-
- ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer);
-
- if ( config != NULL ) {
-  if ( config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_USE_EXECED ) {
-   return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer);
-  }
- }
-
- ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer);
-
- roar_libroar_nowarn();
- if ( roar_vio_ctl(roar_get_connection_vio2(con), ROAR_VIO_CTL_GET_SOCKNAME, &sockname) == -1 ) {
-  roar_libroar_warn();
-#ifdef ROAR_OS_OPENBSD
-  sockname.type = ROAR_SOCKET_TYPE_UNIX;
-#else
-  ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = -1", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer);
-
-  return -1;
-#endif
- }
- roar_libroar_warn();
-
- ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer);
-
- if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) {
-  return -1;
- }
-
- if ( roar_stream_connect(con, s, dir, mixer) == -1 ) {
-  return -1;
- }
-
- if ( sockname.type != ROAR_SOCKET_TYPE_UNIX ) {
-  do {
-   if ( _roar_simple_new_stream_obj_try_select(con, s,
-                                               rate, channels, bits, codec, dir, mixer,
-                                               &sockname, &fh, &can_go_on) != -1 )
-    break;
-   if ( !can_go_on )
-    return -1;
-
-   return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer);
-  } while (0);
- } else { // this is sockname.type == ROAR_SOCKET_TYPE_UNIX
-#ifdef ROAR_HAVE_UNIX
-  if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) {
-   roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors
-                                          // as we return -1 in both whys
-   return -1;
-  }
-
-  if ( roar_stream_passfh(con, s, socks[0]) == -1 ) {
-   roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors
-                                          // as we return -1 anyway.
-   close(socks[0]);
-   close(socks[1]);
-
-   return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer);
-  }
-
-  close(socks[0]);
-  fh = socks[1];
-#else
-  roar_kick(con, ROAR_OT_STREAM, s->id);
-  return -1;
-#endif
- }
-
- if ( fh != -1 ) {
-  if ( dir == ROAR_DIR_PLAY ) {
-   (void)ROAR_SHUTDOWN(fh, SHUT_RD);
-  } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) {
-   (void)ROAR_SHUTDOWN(fh, SHUT_WR);
-  }
- }
-
- s->fh = fh;
-
- ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = %i", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer, fh);
- return fh;
-}
-
-int     roar_vio_simple_new_stream_obj (struct roar_vio_calls * calls,
-                                        struct roar_connection * con,
-                                        struct roar_stream * s,
-                                        uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec,
-                                        int dir, int mixer) {
- struct roar_stream stream;
- int fh;
-
- ROAR_DBG("roar_vio_simple_new_stream_obj(*) = ?");
-
- if ( calls == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( s == NULL )
-  s = &stream;
-
- if ( (fh = _roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, dir, mixer)) == -1 ) {
-  ROAR_DBG("roar_vio_simple_new_stream_obj(*) = -1");
-  return -1;
- }
-
- ROAR_DBG("roar_vio_simple_new_stream_obj(*): fh=%i", fh);
-
- return roar_vio_open_fh_socket(calls, fh);
-}
-
-//ll
Index: libroar/vio_string.c
===================================================================
--- libroar/vio_string.c	(revision 6052)
+++ 	(revision )
@@ -1,147 +1,0 @@
-//vio_string.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-int     roar_vio_putc    (struct roar_vio_calls * vio, char c) {
- return roar_vio_write(vio, &c, 1);
-}
-
-int     roar_vio_getc    (struct roar_vio_calls * vio) {
- unsigned char c;
-
- if ( roar_vio_read(vio, &c, 1) != 1 )
-  return EOF;
-
- return c;
-}
-
-int     roar_vio_printf(struct roar_vio_calls * vio, const char *format, ...) {
- va_list ap;
- int ret;
- char buf[8192];
-
- va_start(ap, format);
- ret = vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
-
- return roar_vio_write(vio, buf, ret);
-}
-
-char *  roar_vio_fgets   (struct roar_vio_calls * vio, char * s, size_t size) {
- size_t  have = 0;
- size_t  need = size;
- ssize_t ret;
- char    cur;
- char    buf[1024];
- roar_off_t   offs;
- char  * eol;
-
- if ( size == 0 )
-  return s;
-
- if ( vio == NULL || s == NULL )
-  return NULL;
-
- // space for the \0
- size -= 1;
-
- if ( (offs = roar_vio_lseek(vio, 0, SEEK_CUR)) == (roar_off_t)-1 ) {
-  // need to use the one byte at a time methode
-  while ( have < size ) {
-   if ( roar_vio_read(vio, &cur, 1) != 1 )
-    break;
-
-   s[have] = cur;
-     have++;
-
-   if ( cur == '\n' )
-    break;
-  }
- } else {
-  // can use the optimized version
-  eol = NULL;
-
-  memset(s, '+', size);
-
-  while ( have < size && eol == NULL ) {
-   ret = roar_vio_read(vio, buf, need > 1023 ? 1023 : need);
-
-   if ( ret == -1 || ret == 0 )
-    break;
-
-   ROAR_DBG("roar_vio_fgets(*): have=%u", (unsigned int) have);
-
-   buf[1023] = 0;
-   if ( (eol = strstr(buf, "\n")) == NULL ) {
-    memcpy(s, buf, ret);
-    s    += ret;
-    have += ret;
-    need -= ret;
-   } else {
-    offs = eol - buf - ret + 1;
-    if ( roar_vio_lseek(vio, offs, SEEK_CUR) == -1 )
-     return NULL;
-
-    ROAR_DBG("roar_vio_fgets(*): have=%u", (unsigned int) have);
-    ROAR_DBG("roar_vio_fgets(*): eol - buf=%lli", (long long) (eol - buf));
-
-    ret = (size_t)(eol - buf);
-    ret++;
-    ROAR_DBG("roar_vio_fgets(*): ret=%lli", (long long) ret);
-
-    memcpy(s, buf, ret);
-    have += ret;
-
-    ROAR_DBG("roar_vio_fgets(*): have=%u", (unsigned int) have);
-
-    break;
-   }
-   ROAR_DBG("roar_vio_fgets(*): have=%u", (unsigned int) have);
-  }
-
- }
-
- ROAR_DBG("roar_vio_fgets(*): have=%u", (unsigned int) have);
-
- if ( !have )
-  return NULL;
-
- s[have] = 0;
-
- return s;
-}
-
-//ll
Index: libroar/vio_tantalos.c
===================================================================
--- libroar/vio_tantalos.c	(revision 6052)
+++ 	(revision )
@@ -1,108 +1,0 @@
-//vio_tantalos.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define _LEN 1024
-
-#ifdef ROAR_HAVE_LIBSLP
-static struct roar_slp_cookie * roar_vio_open_get_cookie (int reinit) {
- static struct roar_slp_cookie   cookie;
- static int inited = 0;
-
- if ( !inited ) {
-  if ( roar_slp_cookie_init(&cookie, NULL) == -1 )
-   return NULL;
-  inited++;
- }
-
- return &cookie;
-}
-#endif
-
-int     roar_vio_open_tantalos    (struct roar_vio_calls * calls, struct roar_vio_calls * dst,
-                                   char * key, struct roar_vio_defaults * odef) {
-#ifdef ROAR_HAVE_LIBSLP
- struct roar_slp_cookie * cookie;
- char url[_LEN];
- int i;
- int need_search = 0;
- time_t now = time(NULL);
-
- (void)dst;
-
- if ( (cookie = roar_vio_open_get_cookie(0)) == NULL )
-  return -1;
-
- if ( cookie->matchcount == 0 ) {
-  need_search++;
- } else {
-  for (i = 0; i < cookie->matchcount; i++) {
-   if ( cookie->match[i].tod < now ) {
-    need_search++;
-   }
-  }
- }
-
- if ( need_search ) {
-  if ( (cookie = roar_vio_open_get_cookie(1)) == NULL )
-   return -1;
-  if ( roar_slp_search(cookie, ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP) == -1 )
-   return -1;
- }
-
- // work on key:
- for (; *key == '/'; key++);
-
- for (i = 0; i < cookie->matchcount; i++) {
-  strncpy(url, cookie->match[i].url + ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP_LEN - 4, _LEN);
-  roar_mm_strscat(url, "?key=");
-  roar_mm_strscat(url, key);
-
-  ROAR_DBG("roar_vio_open_tantalos(*): url='%s'", url);
-
-  if ( roar_vio_open_dstr_vio(calls, url, odef, 1, NULL) == 0 )
-   return 0;
-
-  memset(calls, 0, sizeof(struct roar_vio_calls));
- }
-
- return -1;
-#else
- return -1;
-#endif
-}
-
-//ll
Index: libroar/vio_winsock.c
===================================================================
--- libroar/vio_winsock.c	(revision 6052)
+++ 	(revision )
@@ -1,166 +1,0 @@
-//vio_winsock.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_TARGET_WIN32
-
-static int _get_fh(struct roar_vio_calls * vio) {
- int fh;
-
- if ( roar_vio_basic_ctl(vio, ROAR_VIO_CTL_GET_FH, &fh) == -1 )
-  return -1;
-
- return fh;
-}
-
-ssize_t roar_vio_winsock_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- ssize_t ret;
-
- roar_err_clear_all();
- ret = recv(_get_fh(vio), buf, count, 0);
- roar_err_update();
-
- return ret;
-}
-
-ssize_t roar_vio_winsock_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- ssize_t ret;
-
- roar_err_clear_all();
- ret = send(_get_fh(vio), buf, count, 0);
- roar_err_update();
-
- return ret;
-}
-
-int     roar_vio_winsock_sync    (struct roar_vio_calls * vio) {
- return 0;
-}
-
-int     roar_vio_winsock_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- int tmp;
- int s_r = 0, s_w = 0;
-
- if ( vio == NULL || cmd == -1 )
-  return -1;
-
- ROAR_DBG("roar_vio_winsock_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL ) {
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    }
-
-    *(char**)data = "winsock";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-    ROAR_DBG("roar_vio_winsock_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_SELECT_*FH(0x%.8x), data=%p) = 0 // fh=%i", vio, cmd, data, _get_fh(vio));
-    *(int*)data = _get_fh(vio);
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SET_NOSYNC:
-    vio->sync = NULL;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_ACCEPT:
-    roar_err_clear_all();
-    tmp = accept(_get_fh(vio), NULL, 0);
-    roar_err_update();
-    if ( tmp == -1 )
-     return -1;
-
-    // most proably a socket.
-    if ( roar_vio_open_fh_socket(data, tmp) == -1 ) {
-     closesocket(tmp);
-     return -1;
-    }
-
-    return 0;
-   break;
-  case ROAR_VIO_CTL_SHUTDOWN:
-    tmp = *(int*)data;
-
-    if ( tmp & ROAR_VIO_SHUTDOWN_READ ) {
-     s_r = 1;
-     tmp -= ROAR_VIO_SHUTDOWN_READ;
-    }
-
-    if ( tmp & ROAR_VIO_SHUTDOWN_WRITE ) {
-     s_w = 1;
-     tmp -= ROAR_VIO_SHUTDOWN_WRITE;
-    }
-
-    if ( tmp != 0 ) { /* we currently only support R and W shutdowns */
-     roar_err_set(ROAR_ERROR_NOSYS);
-     return -1;
-    }
-
-    if ( s_r && s_w ) {
-     tmp = SHUT_RDWR;
-    } else if ( s_r ) {
-     tmp = SHUT_RD;
-    } else if ( s_w ) {
-     tmp = SHUT_WR;
-    } else {
-     return 0; // nothing to do.
-    }
-
-    return shutdown(_get_fh(vio), tmp);
-   break;
-  case ROAR_VIO_CTL_GET_SOCKNAME:
-  case ROAR_VIO_CTL_GET_PEERNAME:
-    return roar_vio_basic_ctl(vio, cmd, data);
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-int     roar_vio_winsock_close   (struct roar_vio_calls * vio) {
-
- closesocket(_get_fh(vio));
-
- return 0;
-}
-#endif
-
-//ll
Index: libroar/vio_zlib.c
===================================================================
--- libroar/vio_zlib.c	(revision 6052)
+++ 	(revision )
@@ -1,555 +1,0 @@
-//vio_gzip.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#ifdef ROAR_HAVE_LIBZ
-
-#include <zlib.h>
-
-struct roar_vio_gzip {
- struct roar_vio_calls * next;
- struct roar_buffer * outbuf, * inbuf;
- int compressor_error, decompressor_error;
- int compressor_flush;
- int compressor_used;
- z_stream compressor, decompressor;
- gz_header gz_compressorheader, gz_decompressorheader;
-};
-
-static void * _zalloc(voidpf opaque, uInt items, uInt size) {
- (void)opaque;
- return roar_mm_calloc(items, size);
-}
-
-static void _zfree(voidpf opaque, voidpf address) {
- (void)opaque;
- roar_mm_free(address);
-}
-
-static void _set_error (int error) {
- int raerror = ROAR_ERROR_UNKNOWN;
-
- switch (error) {
-  case Z_OK:            raerror = ROAR_ERROR_NONE;       break;
-  case Z_STREAM_END:    raerror = ROAR_ERROR_NODATA;     break;
-  case Z_NEED_DICT:     raerror = ROAR_ERROR_INVAL;      break;
-  case Z_ERRNO:         roar_err_from_errno();           break;
-  case Z_STREAM_ERROR:  raerror = ROAR_ERROR_INVAL;      break;
-  case Z_DATA_ERROR:    raerror = ROAR_ERROR_BADCKSUM;   break;
-  case Z_MEM_ERROR:     raerror = ROAR_ERROR_NOMEM;      break;
-  case Z_BUF_ERROR:     raerror = ROAR_ERROR_FAULT;      break;
-  case Z_VERSION_ERROR: raerror = ROAR_ERROR_BADVERSION; break;
- }
-
- ROAR_DBG("_set_error(error=%i): raerror=%s", error, roar_error2str(raerror));
- roar_err_set(raerror);
-}
-
-static int _init(struct roar_vio_gzip * self, struct roar_vio_calls * dst, int level, int gzip) {
- int ret;
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = ?", self, dst, level, gzip);
-
- if ( self == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = ?", self, dst, level, gzip);
-
- if ( level == -1 ) {
-  level = Z_DEFAULT_COMPRESSION;
- }
-
- memset(self, 0, sizeof(struct roar_vio_gzip));
-
- self->next   = dst;
-
- self->outbuf = NULL;
- self->inbuf  = NULL;
-
- self->compressor_error    = ROAR_ERROR_NONE;
- self->decompressor_error  = ROAR_ERROR_NONE;
-
- self->compressor_flush    = Z_SYNC_FLUSH;
- self->compressor_used     = 0;
-
- self->compressor.zalloc   = _zalloc;
- self->compressor.zfree    = _zfree;
- self->compressor.opaque   = NULL;
- self->compressor.next_in  = NULL;
- self->compressor.next_out = NULL;
-
- self->decompressor.zalloc   = _zalloc;
- self->decompressor.zfree    = _zfree;
- self->decompressor.opaque   = NULL;
- self->decompressor.next_in  = NULL;
- self->decompressor.next_out = NULL;
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = ?", self, dst, level, gzip);
-
- // for the magic numbers: see the zlib.h header file. There are no const for them.
- if ( (ret = deflateInit2(&(self->compressor), level, Z_DEFLATED, 15 + (gzip ? 16 : 0), 8, Z_DEFAULT_STRATEGY)) != Z_OK ) {
-  _set_error(ret);
-  return -1;
- }
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = ?", self, dst, level, gzip);
-
- if ( (ret = inflateInit2(&(self->decompressor), 15+32)) != Z_OK ) {
-  deflateEnd(&(self->compressor));
-  _set_error(ret);
-  return -1;
- }
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = ?", self, dst, level, gzip);
-
- // gzheader is descriped in RFC1952.
- memset(&(self->gz_compressorheader), 0, sizeof(self->gz_compressorheader));
- self->gz_compressorheader.os   = 255; // os='unknown'
- self->gz_compressorheader.hcrc = 0;   // for compatibility
-
- memset(&(self->gz_decompressorheader), 0, sizeof(self->gz_decompressorheader));
- self->gz_decompressorheader.os   = 255; // os='unknown'
- self->gz_decompressorheader.hcrc = 0;   // for compatibility
-
- if ( gzip ) {
-  if ( (ret = deflateSetHeader(&(self->compressor), &(self->gz_compressorheader))) != Z_OK ) {
-   deflateEnd(&(self->compressor));
-   inflateEnd(&(self->decompressor));
-   _set_error(ret);
-   return -1;
-  }
- }
-
- ROAR_DBG("_init(self=%p, dst=%p, level=%i, gzip=%i) = 0", self, dst, level, gzip);
-
- return 0;
-}
-
-static ssize_t roar_vio_zlib_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_gzip * self = vio->inst;
- struct roar_buffer * leftbuf;
- void * leftbufdata;
- size_t buflen;
- ssize_t len;
- size_t have = 0;
- int ret;
- unsigned char inbuf[1024];
-
- ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- if ( self->decompressor_error != ROAR_ERROR_NONE ) {
-  roar_err_set(self->decompressor_error);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- while ( self->inbuf != NULL ) {
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): self->inbuf=%p", vio, buf, (long long unsigned)count, self->inbuf);
-  if ( roar_buffer_get_data(self->inbuf, &leftbufdata) == -1 )
-   return -1;
-  if ( roar_buffer_get_len(self->inbuf, &buflen) == -1 )
-   return -1;
-
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
-  self->decompressor.next_out  = buf;
-  self->decompressor.avail_out = count;
-
-  self->decompressor.next_in  = leftbufdata;
-  self->decompressor.avail_in = buflen;
-
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): in: %llu Bytes, out: count Bytes.", vio, buf, (long long unsigned)count, (long long unsigned int)buflen);
-
-  ret = inflate(&(self->decompressor), Z_NO_FLUSH);
-
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): inflate() returned %i", vio, buf, (long long unsigned)count, ret);
-
-  len    = count - self->decompressor.avail_out;
-
-  if ( ret == Z_STREAM_END ) {
-   count = len;
-   ret = Z_OK;
-  }
-
-  if ( ret != Z_OK ) {
-   if ( len == 0 ) {
-    _set_error(ret);
-    return -1;
-   } else {
-    have += len;
-    return have;
-   }
-  }
-
-  buf   += len;
-  have  += len;
-  count -= len;
-
-  if ( len == (ssize_t)buflen ) {
-   ret = roar_buffer_next(&(self->inbuf));
-  } else {
-   ret = roar_buffer_set_offset(self->inbuf, len);
-  }
-
-  if ( ret == -1 ) {
-   roar_err_set((self->decompressor_error = ROAR_ERROR_LOSTSYNC));
-   return -1;
-  }
-
-  if ( count == 0 )
-   return have;
- }
-
- ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- self->decompressor.next_out  = buf;
- self->decompressor.avail_out = count;
-
- self->decompressor.next_in  = NULL;
- self->decompressor.avail_in = 0;
-
- while (self->decompressor.avail_out > 0) {
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): generating new output...", vio, buf, (long long unsigned)count);
-
-  if ( self->decompressor.avail_in == 0 ) {
-   ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): reading more data", vio, buf, (long long unsigned)count);
-
-   len = roar_vio_read(self->next, inbuf, sizeof(inbuf));
-   if ( len == -1 ) {
-    have += count - self->decompressor.avail_out;
-    if ( have == 0 ) {
-     // error is still set (by roar_vio_read()).
-     return -1;
-    } else {
-     return 0;
-    }
-   } else if ( len == 0 ) {
-    break;
-   }
-
-   ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): len=%llu", vio, buf, (long long unsigned)count, (long long unsigned)len);
-
-   self->decompressor.next_in  = inbuf;
-   self->decompressor.avail_in = len;
-  }
-
-  ret = inflate(&(self->decompressor), Z_NO_FLUSH);
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu): inflate() returned %i", vio, buf, (long long unsigned)count, ret);
-
-  if ( ret == Z_STREAM_END )
-   ret = Z_OK;
-
-  if ( ret != Z_OK ) {
-   if ( (count - self->decompressor.avail_out) == 0 ) {
-    _set_error(ret);
-    return -1;
-   } else {
-    break;
-   }
-  }
-
-  ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
- }
-
- if ( self->decompressor.avail_in != 0 ) {
-  if ( roar_buffer_new_data(&leftbuf, self->decompressor.avail_in, &leftbufdata) == -1 ) {
-   roar_err_set((self->decompressor_error = ROAR_ERROR_LOSTSYNC));
-   return -1;
-  }
-
-  memcpy(leftbufdata, self->decompressor.next_in, self->decompressor.avail_in);
-
-  if ( self->inbuf == NULL ) {
-   self->inbuf = leftbuf;
-  } else {
-   if ( roar_buffer_moveinto(self->inbuf, &leftbuf) == -1 ) {
-    roar_buffer_free(leftbuf);
-    roar_err_set((self->decompressor_error = ROAR_ERROR_LOSTSYNC));
-    return -1;
-   }
-  }
- }
-
- have += count - self->decompressor.avail_out;
-
- ROAR_DBG("roar_vio_zlib_read(vio=%p, buf=%p, count=%llu) = %llu", vio, buf, (long long unsigned)count, (long long unsigned)have);
-
- return have;
-}
-
-static ssize_t roar_vio_zlib_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_vio_gzip * self = vio->inst;
- struct roar_buffer * leftbuf;
- void * leftbufdata;
- size_t outlen;
- size_t buflen;
- char outbuf[1024];
- ssize_t len;
- int ret;
-
- ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- self->compressor_used = 1;
-
- if ( self->compressor_error != ROAR_ERROR_NONE ) {
-  roar_err_set(self->compressor_error);
-  return -1;
- }
-
- ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- while (self->outbuf != NULL) {
-  if ( roar_buffer_get_data(self->outbuf, &leftbufdata) == -1 )
-   return -1;
-  if ( roar_buffer_get_len(self->outbuf, &buflen) == -1 )
-   return -1;
-
-  len = roar_vio_write(self->next, leftbufdata, buflen);
-  if ( len == -1 ) {
-   return -1;
-  } else if ( len == (ssize_t)buflen ) {
-   if ( roar_buffer_next(&(self->outbuf)) == -1 ) {
-    roar_err_set((self->compressor_error = ROAR_ERROR_LOSTSYNC));
-    return -1;
-   }
-
-   
-  } else {
-   if ( roar_buffer_set_offset(self->outbuf, len) == -1 ) {
-    roar_err_set((self->compressor_error = ROAR_ERROR_LOSTSYNC));
-    return -1;
-   }
-
-   return 0;
-  }
- }
-
- ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
- self->compressor.next_in  = buf;
- self->compressor.avail_in = count;
-
- while (self->compressor.avail_in || count == 0) {
-  self->compressor.next_out  = (unsigned char *)outbuf;
-  self->compressor.avail_out = sizeof(outbuf);
-  outlen = self->compressor.total_out;
-
-  ret = deflate(&(self->compressor), count == 0 ? self->compressor_flush : Z_NO_FLUSH);
-
-  outlen = self->compressor.total_out - outlen;
-
-  ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu): deflate() returned %i", vio, buf, (long long unsigned)count, ret);
- ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu): outlen=%llu", vio, buf, (long long unsigned)count, (long long unsigned int)outlen);
-
-  if ( count != 0 && ret != Z_OK ) {
-   len = count - self->compressor.avail_in;
-   if ( len != 0 ) {
-    return len;
-   } else {
-    _set_error(ret);
-    return -1;
-   }
-  }
-
-  if ( outlen != 0 ) {
-   len = roar_vio_write(self->next, outbuf, outlen);
-
-   if ( len < (ssize_t)outlen ) {
-    if ( roar_buffer_new_data(&leftbuf, outlen - len, &leftbufdata) == -1 ) {
-     roar_err_set((self->compressor_error = ROAR_ERROR_LOSTSYNC));
-     return -1;
-    }
-
-    memcpy(leftbufdata, outbuf+len, outlen - len);
-
-    if ( self->outbuf == NULL ) {
-     self->outbuf = leftbuf;
-    } else {
-     if ( roar_buffer_moveinto(self->outbuf, &leftbuf) == -1 ) {
-      roar_buffer_free(leftbuf);
-      roar_err_set((self->compressor_error = ROAR_ERROR_LOSTSYNC));
-      return -1;
-     }
-    } 
-    break;
-   }
-  }
-
-  ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
-
-  if ( count == 0 && (
-         (self->compressor_flush == Z_FINISH && ret == Z_STREAM_END) ||
-         (self->compressor_flush != Z_FINISH && ret == Z_BUF_ERROR)   ) )
-   return 0;
-
-  ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned)count);
- }
-
- len = count - self->compressor.avail_in;
-
- ROAR_DBG("roar_vio_zlib_write(vio=%p, buf=%p, count=%llu) = %llu", vio, buf, (long long unsigned)count, (long long unsigned int)len);
-
- return len;
-}
-
-static roar_off_t   roar_vio_zlib_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- (void)vio, (void)offset, (void)whence;
- roar_err_set(ROAR_ERROR_NOSYS);
- return (roar_off_t)-1;
-}
-
-static int     roar_vio_zlib_sync    (struct roar_vio_calls * vio) {
- struct roar_vio_gzip * self = vio->inst;
-
- if ( self->compressor_used )
-  if ( self->compressor_error == ROAR_ERROR_NONE )
-   if ( roar_vio_zlib_write(vio, NULL, 0) == -1 )
-    return -1;
-
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static int     roar_vio_zlib_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_vio_gzip * self;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "zlib";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_NEXT:
-    *(struct roar_vio_calls **)data = self->next;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    return roar_vio_ctl(self->next, cmd, data);
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
- }
-}
-
-static int     roar_vio_zlib_close   (struct roar_vio_calls * vio) {
- struct roar_vio_gzip * self;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = vio->inst;
-
- self->compressor_flush = Z_FINISH;
-
- roar_vio_zlib_sync(vio);
-
- deflateEnd(&(self->compressor));
- inflateEnd(&(self->decompressor));
-
- if ( self->outbuf != NULL )
-  roar_buffer_free(self->outbuf);
- if ( self->inbuf != NULL )
-  roar_buffer_free(self->inbuf);
-
- roar_mm_free(self);
-
- return 0;
-}
-
-int roar_vio_open_zlib(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int level, int gzip) {
- struct roar_vio_gzip * self;
-
- ROAR_DBG("roar_vio_open_zlib(calls=%p, dst=%p, level=%i, gzip=%i) = ?", calls, dst, level, gzip);
-
- if ( calls == NULL || dst == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = roar_mm_malloc(sizeof(struct roar_vio_gzip));
-
- if ( _init(self, dst, level, gzip) == -1 ) {
-  roar_mm_free_noerror(self);
-  ROAR_DBG("roar_vio_open_zlib(calls=%p, dst=%p, level=%i, gzip=%i) = -1 // error=%s", calls, dst, level, gzip, roar_error2str(err));
-  return -1;
- }
-
- ROAR_DBG("roar_vio_open_zlib(calls=%p, dst=%p, level=%i, gzip=%i) = ?", calls, dst, level, gzip);
-
- memset(calls, 0, sizeof(struct roar_vio_calls));
- calls->flags      = ROAR_VIO_FLAGS_NONE;
- calls->refc       = 1;
-
- calls->inst       = self;
- calls->read       = roar_vio_zlib_read;
- calls->write      = roar_vio_zlib_write;
- calls->lseek      = roar_vio_zlib_lseek;
- calls->sync       = roar_vio_zlib_sync;
- calls->ctl        = roar_vio_zlib_ctl;
- calls->close      = roar_vio_zlib_close;
-
- ROAR_DBG("roar_vio_open_zlib(calls=%p, dst=%p, level=%i, gzip=%i) = 0", calls, dst, level, gzip);
-
- return 0;
-}
-
-#endif
-
-//ll
Index: libroar/vs.c
===================================================================
--- libroar/vs.c	(revision 6052)
+++ 	(revision )
@@ -1,1790 +1,0 @@
-//vs.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#if defined(ROAR_HAVE_GETSOCKOPT) && defined(ROAR_HAVE_SETSOCKOPT)
-#define _HAVE_SOCKOPT
-#endif
-
-#define LOCAL_CLOCK    ROAR_CLOCK_DEFAULT
-#define ASYNC_QLEN     4
-
-#define FLAG_NONE      0x0000
-#define FLAG_STREAM    0x0001
-#define FLAG_NONBLOCK  0x0002
-#define FLAG_BUFFERED  0x0004
-#define FLAG_CLOSEFILE 0x0008
-#define FLAG_FREE_VOL  0x0010
-#define FLAG_DEF_PAUSE 0x0020
-#define FLAG_VIO_RE    0x0040
-#define FLAG_DIR_IN    0x1000
-#define FLAG_DIR_OUT   0x2000
-
-#define _initerr()  roar_err_clear_all()
-#define _seterr(x)  do { if ( error != NULL ) *error = (x); roar_err_set((x)); ROAR_DBG("roar_vs_*(*): *error=%s(%i)", roar_vs_strerr((x)), (x)); } while(0)
-#define _seterrre() do { _seterr(roar_error); } while(0)
-#define _seterrse() do { roar_err_from_errno(); _seterr(roar_error); } while(0)
-#define _ckvss(ret) do { if ( vss == NULL ) { _seterr(ROAR_ERROR_FAULT); return (ret); } } while(0)
-#define _ckasync(ret) do { if ( _handle_async(vss, error) == -1 ) { return (ret); } } while(0)
-
-struct roar_vs {
- int flags;
- struct roar_connection con_store;
- struct roar_connection * con;
- struct roar_stream       stream;
- struct roar_vio_calls    vio;
- struct roar_vio_calls    vio_re;
- struct roar_vio_calls  * vio_ptr;
- struct roar_audio_info   info;
- size_t                   readc, writec;
- int                      mixerid;
- int                      first_primid;
- struct roar_buffer     * readbuffer, * writebuffer;
- struct roar_vio_calls    file_store;
- struct roar_vio_calls  * file;
- struct roar_buffer     * readring, * writering;
-#ifdef _HAVE_SOCKOPT
- struct {
-  float target;
-  float window;
-  float minlag;
-  float p;
- } latc;
-#endif
- struct {
-  ssize_t last_pos;
-  ssize_t last_offset;
-  struct roar_time last_time;
- } latmes;
- struct {
-  int    level;
-  size_t lock;
-  size_t qlen;
-  int qcmd[ASYNC_QLEN];
-  int qsubcmd[ASYNC_QLEN];
-  int read_latency;
-  int last_backend;
- } async;
-};
-
-static int _roar_vs_find_first_prim(roar_vs_t * vss);
-
-static int _send_async_req(roar_vs_t * vss, int cmd, int subcmd, int stream, int * error) {
- struct roar_message mes;
- uint16_t * data = (uint16_t *) mes.data;
-
- if ( !vss->async.level ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( vss->async.lock ) {
-  _seterr(ROAR_ERROR_BUSY);
-  return -1;
- }
-
- if ( vss->async.qlen == ASYNC_QLEN ) {
-  _seterr(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- memset(&mes, 0, sizeof(mes));
-
- mes.cmd    = cmd;
- mes.stream = stream;
- mes.pos    = 0;
-
- if ( cmd == ROAR_CMD_GET_STREAM_PARA && subcmd == ROAR_STREAM_PARA_INFO ) {
-  mes.datalen = 4;
-  data[0] = ROAR_HOST2NET16(0); // Version and reserved
-  data[1] = ROAR_HOST2NET16(ROAR_STREAM_PARA_INFO); // stream
- } else if ( cmd == ROAR_CMD_GET_STREAM ) {
-  mes.datalen = 1;
-  mes.data[0] = mes.stream;
- } else {
-  _seterr(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- if ( roar_send_message(vss->con, &mes, NULL) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- vss->async.qcmd[vss->async.qlen] = cmd;
- vss->async.qsubcmd[vss->async.qlen] = subcmd;
- vss->async.qlen++;
-
- vss->async.read_latency = 0;
-
- return 0;
-}
-
-static int _handle_async_req(roar_vs_t * vss, int * error) {
- struct roar_message mes;
- char * data = NULL;
- uint16_t * ud16 = (uint16_t *) mes.data;
- ssize_t offset;
- int cmd, subcmd;
- size_t i;
-
- if ( roar_recv_message(vss->con, &mes, &data) == -1 ) {
-  _seterrre();
- }
-
- cmd    = vss->async.qcmd[0];
- subcmd = vss->async.qsubcmd[0];
- vss->async.qlen--;
-
- for (i = 1; i < ASYNC_QLEN; i++) {
-  vss->async.qcmd[i-1]    = vss->async.qcmd[i];
-  vss->async.qsubcmd[i-1] = vss->async.qsubcmd[i];
- }
-
- //printf("mes.cmd=%i, cmd=%i, subcmd=%i\n", (int)mes.cmd, cmd, subcmd);
-
- if ( mes.cmd == ROAR_CMD_OK ) {
-  switch (cmd) {
-   case ROAR_CMD_GET_STREAM_PARA:
-     if ( subcmd == ROAR_STREAM_PARA_INFO ) {
-      if ( mes.datalen >= 16 ) {
-       for (i = 0; i < mes.datalen/2; i++) {
-        ud16[i] = ROAR_HOST2NET16(ud16[i]);
-       }
-       if ( ud16[0] == 0 || ud16[1] == 1 ) {
-        offset  = ud16[7];
-        offset *= 1000;
-        offset *= vss->info.rate;
-        offset /= 1000000;
-        vss->latmes.last_offset = offset;
-       }
-      }
-     } else {
-      ROAR_WARN("_handle_async_req(vss=%p, error=%p): Got unexpected reply for command GET_STREAM_PARA, subcommand %i", vss, error, subcmd);
-     }
-    break;
-   case ROAR_CMD_GET_STREAM:
-     if ( roar_clock_gettime(&(vss->latmes.last_time), LOCAL_CLOCK) == -1 ) {
-      vss->latmes.last_pos = -1;
-     } else {
-      vss->latmes.last_pos = mes.pos;
-     }
-     //printf("vss->latmes.last_pos=%li, mes.pos=%li\n", (long int)vss->latmes.last_pos, (long int)mes.pos);
-    break;
-   default:
-     ROAR_WARN("_handle_async_req(vss=%p, error=%p): Got unexpected reply for command %i", vss, error, cmd);
-     _seterr(ROAR_ERROR_NOSYS);
-    break;
-  }
- }
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- return 0;
-}
-
-static inline int _handle_async(roar_vs_t * vss, int * error) {
- while (vss->async.qlen) {
-  if ( _handle_async_req(vss, error) == -1 ) {
-   return -1;
-  }
- }
-
- return 0;
-}
-
-static void _check_async(roar_vs_t * vss) {
- struct roar_vio_select vios;
- struct roar_vio_selecttv tv = {0, 0};
-
- if ( !vss->async.qlen )
-  return;
-
- ROAR_VIO_SELECT_SETVIO(&vios, roar_get_connection_vio2(vss->con), ROAR_VIO_SELECT_READ);
-
- if ( roar_vio_select(&vios, 1, &tv, NULL) < 1 )
-  return;
-
- if ( !(vios.eventsa & ROAR_VIO_SELECT_READ) )
-  return;
-
- _handle_async_req(vss, NULL);
-}
-
-const char * roar_vs_strerr(int error) {
- const char * ret = roar_error2str(error);
-
- if ( ret == NULL )
-  return "(unknown)";
-
- return ret;
-}
-
-static roar_vs_t * roar_vs_init(int * error) {
- roar_vs_t * vss = roar_mm_malloc(sizeof(roar_vs_t));
-
- if ( vss == NULL ) {
-  _seterrse();
-  return NULL;
- }
-
- memset(vss, 0, sizeof(roar_vs_t));
-
- vss->vio_ptr = &(vss->vio);
-
- vss->mixerid      = -1;
- vss->first_primid = -1;
-
-#ifdef _HAVE_SOCKOPT
- vss->latc.target = -2.; // must be less than latc.minlag!
- vss->latc.window = -1.;
- vss->latc.minlag = -1.;
- vss->latc.p      =  0.005;
-#endif
-
- vss->latmes.last_pos = -1;
-
- vss->async.last_backend = ROAR_VS_BACKEND_NONE;
-
- return vss;
-}
-
-roar_vs_t * roar_vs_new_from_con(struct roar_connection * con, int * error) {
- roar_vs_t * vss = roar_vs_init(error);
-
- if ( vss == NULL )
-  return NULL;
-
- vss->con = con;
-
- return vss;
-}
-
-roar_vs_t * roar_vs_new(const char * server, const char * name, int * error) {
- roar_vs_t * vss = roar_vs_init(error);
- int ret;
-
- if ( vss == NULL )
-  return NULL;
-
- vss->con = &(vss->con_store);
-
- _initerr();
-
- ret = roar_simple_connect(vss->con, server, name);
-
- if ( ret == -1 ) {
-  roar_vs_close(vss, ROAR_VS_TRUE, NULL);
-  _seterrre();
-  return NULL;
- }
-
- return vss;
-}
-
-int roar_vs_stream(roar_vs_t * vss, const struct roar_audio_info * info, int dir, int * error) {
- struct roar_stream_info sinfo;
- int ret;
-
- _ckvss(-1);
-
- if ( vss->flags & FLAG_STREAM ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( dir == ROAR_DIR_FILTER )
-  vss->flags |= FLAG_DEF_PAUSE;
-
- _initerr();
-
- if ( info != &(vss->info) )
-  memcpy(&(vss->info), info, sizeof(struct roar_audio_info));
-
- ret = roar_vio_simple_new_stream_obj(&(vss->vio), vss->con, &(vss->stream),
-                                      info->rate, info->channels, info->bits, info->codec,
-                                      dir, vss->mixerid
-                                     );
-
- if ( roar_vio_open_re(&(vss->vio_re), &(vss->vio)) != -1 ) {
-  vss->flags |= FLAG_VIO_RE;
-  vss->vio_ptr = &(vss->vio_re);
- }
-
- if ( ret == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( vss->mixerid != -1 ) {
-  if ( roar_stream_get_info(vss->con, &(vss->stream), &sinfo) != -1 ) {
-   vss->mixerid = sinfo.mixer;
-  }
- }
-
- if ( vss->mixerid != -1 )
-  _roar_vs_find_first_prim(vss);
-
- vss->flags |= FLAG_STREAM;
-
- switch (dir) {
-  case ROAR_DIR_PLAY: vss->flags |= FLAG_DIR_OUT; break;
- }
-
- return 0;
-}
-
-roar_vs_t * roar_vs_new_simple(const char * server, const char * name, int rate, int channels, int codec, int bits, int dir, int * error) {
- roar_vs_t * vss = roar_vs_new(server, name, error);
- int ret;
-
- if (vss == NULL)
-  return NULL;
-
- memset(&(vss->info), 0, sizeof(vss->info));
-
- vss->info.rate     = rate;
- vss->info.channels = channels;
- vss->info.codec    = codec;
- vss->info.bits     = bits;
-
- ret = roar_vs_stream(vss, &(vss->info), dir, error);
-
- if (ret == -1) {
-  roar_vs_close(vss, ROAR_VS_TRUE, NULL);
-  return NULL;
- }
-
- return vss;
-}
-
-int roar_vs_file(roar_vs_t * vss, struct roar_vio_calls * vio, int closefile, int * error) {
- _ckvss(-1);
-
- if ( vio == NULL || (closefile != ROAR_VS_TRUE && closefile != ROAR_VS_FALSE)) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( vss->file != NULL ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- vss->file = vio;
- if ( closefile == ROAR_VS_TRUE )
-  vss->flags |= FLAG_CLOSEFILE;
-
- return 0;
-}
-
-int roar_vs_file_simple(roar_vs_t * vss, const char * filename, int * error) {
- struct roar_vio_defaults def;
- struct roar_vio_calls * file;
- char buf[64];
- ssize_t ret;
- int dir = O_RDONLY;
- int codec = -1;
- const char * content_type;
-
- _ckvss(-1);
-
- if ( vss->file != NULL ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( vss->flags & FLAG_STREAM ) {
-  switch (vss->flags & (FLAG_DIR_IN|FLAG_DIR_OUT)) {
-   case FLAG_DIR_IN:  dir = O_WRONLY; break;
-   case FLAG_DIR_OUT: dir = O_RDONLY; break;
-   case FLAG_DIR_IN|FLAG_DIR_OUT: dir = O_RDWR; break;
-   default:
-     _seterr(ROAR_ERROR_INVAL);
-     return -1;
-  }
- }
-
- file = &(vss->file_store);
-
- _initerr();
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, dir, 0644) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( roar_vio_open_dstr(file, filename, &def, 1) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  if ( roar_vio_ctl(file, ROAR_VIO_CTL_GET_MIMETYPE, &content_type) != -1 ) {
-   codec = roar_mime2codec(content_type);
-  }
-
-  if ( codec == -1 ) {
-   ret = roar_vio_read(file, buf, sizeof(buf));
-
-   codec = roar_file_codecdetect(buf, ret);
-
-   if ( codec == -1 ) {
-    roar_vio_close(file);
-    _seterr(ROAR_ERROR_INVAL); // Other value?
-    return -1;
-   }
-
-   if ( roar_vio_lseek(file, 0, SEEK_SET) != 0 ) {
-    roar_vio_close(file);
-   _seterrre();
-    return -1;
-   }
-  }
-
-  memset(&(vss->info), 0, sizeof(vss->info));
-
-  vss->info.rate     = ROAR_RATE_DEFAULT;
-  vss->info.channels = ROAR_CHANNELS_DEFAULT;
-  vss->info.codec    = codec;
-  vss->info.bits     = ROAR_BITS_DEFAULT;
-
-  ret = roar_vs_stream(vss, &(vss->info), ROAR_DIR_PLAY, error);
-
-  if ( ret == -1 ) {
-   roar_vio_close(file);
-   return -1;
-  }
- }
-
- if ( roar_vs_file(vss, file, ROAR_VS_TRUE, error) == -1 ) {
-  roar_vio_close(file);
-  return -1;
- }
-
- return 0;
-}
-
-roar_vs_t * roar_vs_new_from_file(const char * server, const char * name, const char * filename, int * error) {
- roar_vs_t * vss = roar_vs_new(server, name, error);
-
- if ( vss == NULL )
-  return NULL;
-
- if ( roar_vs_file_simple(vss, filename, error) != 0 ) {
-  roar_vs_close(vss, ROAR_VS_TRUE, NULL);
-  return NULL;
- }
-
- return vss;
-}
-
-int roar_vs_buffer(roar_vs_t * vss, size_t buffer, int * error) {
- _ckvss(-1);
-
- if ( vss->flags & FLAG_BUFFERED )
-  return -1;
-
- if ( roar_buffer_ring_new(&(vss->readring), buffer, 0) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( roar_buffer_ring_new(&(vss->writering), buffer, 0) == -1 ) {
-  _seterrre();
-  roar_buffer_free(vss->readring);
-  vss->readring = NULL;
-  return -1;
- }
-
- vss->flags |= FLAG_BUFFERED;
-
- return 0;
-}
-
-int roar_vs_close(roar_vs_t * vss, int killit, int * error) {
- if ( killit != ROAR_VS_TRUE && killit != ROAR_VS_FALSE ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _ckvss(-1);
- _ckasync(-1);
-
- if ( vss->readbuffer != NULL )
-  roar_buffer_free(vss->readbuffer);
- if ( vss->writebuffer != NULL )
-  roar_buffer_free(vss->writebuffer);
-
- if ( vss->readring != NULL )
-  roar_buffer_free(vss->readring);
- if ( vss->writering != NULL )
-  roar_buffer_free(vss->writering);
-
- if ( vss->file != NULL && vss->flags & FLAG_CLOSEFILE )
-  roar_vio_close(vss->file);
-
- if ( vss->flags & FLAG_STREAM ) {
-  if ( killit == ROAR_VS_TRUE ) {
-   roar_kick(vss->con, ROAR_OT_STREAM, roar_stream_get_id(&(vss->stream)));
-  }
-
-  roar_vio_close(vss->vio_ptr);
- }
-
- if ( vss->con == &(vss->con_store) ) {
-  roar_disconnect(vss->con);
- }
-
- roar_mm_free(vss);
- return 0;
-}
-
-static ssize_t roar_vs_write_direct(roar_vs_t * vss, const void * buf, size_t len, int * error) {
- ssize_t ret = roar_vio_write(vss->vio_ptr, (void*)buf, len);
-
- if ( ret == -1 ) {
-#ifdef EAGAIN
-  if ( roar_error == ROAR_ERROR_AGAIN )
-   return 0;
-#endif
-
-  _seterrre();
- } else {
-  if ( !(vss->flags & FLAG_BUFFERED) ) {
-   //printf("A: vss->writec=%zu, ret=%zi\n", vss->writec, ret);
-   vss->writec += ret;
-  }
- }
-
- //printf("B: vss->writec=%zu, ret=%zi\n", vss->writec, ret);
- return ret;
-}
-
-ssize_t roar_vs_write(roar_vs_t * vss, const void * buf, size_t len, int * error) {
- ssize_t ret;
- size_t writelen;
-
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- if ( vss->flags & FLAG_BUFFERED ) {
-  writelen = len;
-
-  if ( roar_buffer_ring_write(vss->writering, (void*)buf, &writelen) == -1 ) {
-   _seterrre();
-   return -1;
-  }
-
-  ret = writelen;
-  vss->writec += ret;
- } else {
-  ret = roar_vs_write_direct(vss, buf, len, error);
- }
-
- return ret;
-}
-
-ssize_t roar_vs_read (roar_vs_t * vss,       void * buf, size_t len, int * error) {
- ssize_t ret;
-
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- ret = roar_vio_read(vss->vio_ptr, buf, len);
-
- if ( ret == -1 ) {
-  _seterrre();
- } else {
-  vss->readc += ret;
- }
-
- return ret;
-}
-
-int     roar_vs_sync (roar_vs_t * vss, int wait, int * error) {
- struct roar_event waits, triggered;
-
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( wait != ROAR_VS_NOWAIT && wait != ROAR_VS_WAIT ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- if ( roar_vio_sync(vss->vio_ptr) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( wait == ROAR_VS_WAIT ) {
-  _ckasync(-1);
-
-  memset(&waits, 0, sizeof(waits));
-  waits.event       = ROAR_OE_STREAM_XRUN;
-  waits.emitter     = -1;
-  waits.target      = roar_stream_get_id(&(vss->stream));
-  waits.target_type = ROAR_OT_STREAM;
-
-  if ( roar_wait(vss->con, &triggered, &waits, 1) == -1 ) {
-   _seterrre();
-   return -1;
-  }
- }
-
- return 0;
-}
-
-int     roar_vs_blocking (roar_vs_t * vss, int val, int * error) {
- int old = -1;
-
- _ckvss(-1);
-
-  if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- old = vss->flags & FLAG_NONBLOCK ? ROAR_VS_FALSE : ROAR_VS_TRUE;
-
- _initerr();
-
- switch (val) {
-  case ROAR_VS_TRUE:
-    if ( roar_vio_nonblock(vss->vio_ptr, ROAR_SOCKET_BLOCK) == -1 ) {
-     _seterrre();
-     return -1;
-    }
-    vss->flags |= FLAG_NONBLOCK;
-    vss->flags -= FLAG_NONBLOCK;
-    return old;
-   break;
-  case ROAR_VS_FALSE:
-    if ( roar_vio_nonblock(vss->vio_ptr, ROAR_SOCKET_NONBLOCK) == -1 ) {
-     _seterrre();
-     return -1;
-    }
-    vss->flags |= FLAG_NONBLOCK;
-    return old;
-   break;
-  case ROAR_VS_TOGGLE:
-    if ( old == ROAR_VS_TRUE ) {
-     return roar_vs_blocking(vss, ROAR_VS_FALSE, error);
-    } else {
-     return roar_vs_blocking(vss, ROAR_VS_TRUE, error);
-    }
-   break;
-  case ROAR_VS_ASK:
-    return old;
-   break;
- }
-
- _seterr(ROAR_ERROR_INVAL);
- return -1;
-}
-
-static int _roar_vs_find_first_prim(roar_vs_t * vss) {
- struct roar_stream stream;
- struct roar_stream_info info;
- int id[ROAR_STREAMS_MAX];
- int num;
- int i;
- int * error = NULL; // needed for _ckasync() macro
-
- _ckasync(-1);
-
- if ( vss->first_primid != -1 )
-  return vss->first_primid;
-
- if ( vss->mixerid == -1 )
-  return -1;
-
- if ( (num = roar_list_streams(vss->con, id, ROAR_STREAMS_MAX)) == -1 ) {
-  return -1;
- }
-
- for (i = 0; i < num; i++) {
-  if ( roar_get_stream(vss->con, &stream, id[i]) == -1 )
-   continue;
-
-  if ( stream.dir != ROAR_DIR_OUTPUT )
-   continue;
-
-  if ( roar_stream_get_info(vss->con, &stream, &info) == -1 )
-   continue;
-
-  if ( info.mixer == vss->mixerid ) {
-   vss->first_primid = id[i];
-   return id[i];
-  }
- }
-
- return -1;
-}
-
-ssize_t roar_vs_position(roar_vs_t * vss, int backend, int * error) {
- struct roar_stream stream;
- struct roar_stream      out_stream;
- struct roar_stream_info out_info;
- size_t offset = 0;
-
- _ckvss(-1);
- _ckasync(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- if ( roar_get_stream(vss->con, &stream, roar_stream_get_id(&(vss->stream))) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( backend == ROAR_VS_BACKEND_DEFAULT ) {
-  backend = ROAR_VS_BACKEND_FIRST;
- }
-
- switch (backend) {
-  case ROAR_VS_BACKEND_NONE:
-//    return stream.pos;
-    // do nothing.
-   break;
-  case ROAR_VS_BACKEND_FIRST:
-    if ( vss->first_primid == -1 ) {
-     _seterr(ROAR_ERROR_UNKNOWN);
-     return -1;
-    }
-
-    backend = vss->first_primid;
-   break;
-  default:
-    if ( backend < 0 ) {
-     _seterr(ROAR_ERROR_INVAL);
-     return -1;
-    }
-   break;
- }
-
- vss->async.last_backend = backend;
-
- if ( backend >= 0 ) {
-  roar_stream_new_by_id(&out_stream, backend);
-
-  if ( roar_stream_get_info(vss->con, &out_stream, &out_info) == -1 ) {
-   _seterrre();
-   return -1;
-  }
-
-  offset  = out_info.delay * vss->info.rate;
-  offset /= 1000000;
- }
-
- if ( roar_clock_gettime(&(vss->latmes.last_time), LOCAL_CLOCK) == -1 ) {
-  vss->latmes.last_pos = -1;
- } else {
-  vss->latmes.last_pos    = stream.pos;
-  vss->latmes.last_offset = offset;
- }
-
- return stream.pos + offset;
-}
-
-#ifdef _HAVE_SOCKOPT
-static void roar_vs_latency_managed(roar_vs_t * vss, roar_mus_t lat) {
- struct roar_vio_sysio_sockopt sockopt;
- float tmp = ((float)lat/1000.0) - vss->latc.target;
- int val;
-
- tmp *= vss->latc.p;
-
- sockopt.level   = SOL_SOCKET;
- sockopt.optname = SO_SNDBUF;
- sockopt.optval  = &val;
- sockopt.optlen  = sizeof(val);
-
- if ( roar_vio_ctl(vss->vio_ptr, ROAR_VIO_CTL_GET_SYSIO_SOCKOPT, &sockopt) == -1 )
-  return;
-
- val /= 2;
-
- tmp = 1.0 - tmp;
-
- val = (float)val*tmp;
-
- sockopt.optlen  = sizeof(val);
-
- if ( roar_vio_ctl(vss->vio_ptr, ROAR_VIO_CTL_SET_SYSIO_SOCKOPT, &sockopt) == -1 )
-  return;
-}
-#endif
-
-roar_mus_t roar_vs_latency(roar_vs_t * vss, int backend, int wait, int * error) {
- ssize_t pos;
- ssize_t bps;  // byte per sample
- size_t  lioc; // local IO (byte) counter
- size_t  lpos; // local position
- signed long long int lag;
- struct roar_time rt;
-
- _initerr();
-
- _ckvss(0);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return 0;
- }
-
- _check_async(vss);
-
- if ( wait == ROAR_VS_WAIT ) {
-  _ckasync(0);
-
-  pos = roar_vs_position(vss, backend, error);
-  if (pos == -1) {
-   _seterrre();
-   return 0;
-  }
-
-  if ( vss->writec == 0 ) {
-   lioc = vss->readc;
-  } else {
-   //printf("writec=%zu\n", vss->writec);
-   lioc = vss->writec;
-  }
-
-  bps = roar_info2samplesize(&(vss->info));
-
-  if ( bps == -1 ) {
-   _seterrre();
-   return 0;
-  }
-
-  lpos = (lioc*8) / bps;
-
-  lag = (signed long long int)lpos - (signed long long int)pos;
-  lag /= vss->info.channels;
-
-  // we now have the lag in frames
-  // return value are mus
-  // so we need to multiply with 1s/mus and
-  // multiply by 1/rate
-
-  lag *= 1000000; // 1s/mus
-  lag /= vss->info.rate;
-
-#ifdef _HAVE_SOCKOPT
-  if (vss->latc.target > vss->latc.minlag) {
-   roar_vs_latency_managed(vss, lag);
-  }
-#endif
-
-  vss->async.read_latency = 1;
-
-  if ( lag == 0 ) {
-   _seterr(ROAR_ERROR_NONE);
-  }
-
-  return lag;
- } else if ( wait == ROAR_VS_NOWAIT ) {
-  vss->async.read_latency = 1;
-
-  if ( vss->latmes.last_pos == -1 ) {
-   _seterr(ROAR_ERROR_NODATA);
-   return 0;
-  }
-
-  if ( vss->writec == 0 ) {
-   lioc = vss->readc;
-  } else {
-   //printf("writec=%zu\n", vss->writec);
-   lioc = vss->writec;
-  }
-
-  bps = roar_info2samplesize(&(vss->info));
-
-  if ( bps == -1 ) {
-   _seterrre();
-   return 0;
-  }
-
-  lpos = (lioc*8) / bps;
-
-  //printf("pos=%zi, lpos=%zi, bps=%zi, diff[lpos-pos]=%zi\n", pos, lpos, bps, (lpos - pos));
-
-  lag = (signed long long int)lpos - (signed long long int)(vss->latmes.last_pos + vss->latmes.last_offset);
-  lag /= vss->info.channels;
-
-  // we now have the lag in frames
-  // return value are mus
-  // so we need to multiply with 1s/mus and
-  // multiply by 1/rate
-
-  lag *= 1000000; // 1s/mus
-  lag /= vss->info.rate;
-
-  _initerr();
-  if ( roar_clock_gettime(&rt, LOCAL_CLOCK) == -1 ) {
-   _seterrre();
-   return 0;
-  }
-
-//  printf("%lli, %lli\n", (rt.t_sec  - vss->latmes.last_time.t_sec ), (rt.t_ssec/2 - vss->latmes.last_time.t_ssec/2)/ 18446744073710LL);
-//  printf("%lli, %llu\n", rt.t_sec, rt.t_ssec);
-  lag -= (rt.t_sec  - vss->latmes.last_time.t_sec ) * 1000000LL;
-  lag -= ((int64_t)(rt.t_ssec/2) - (int64_t)(vss->latmes.last_time.t_ssec/2)) / 9223372036855LL;
-
-  if ( lag == 0 ) {
-   _seterr(ROAR_ERROR_NONE);
-  }
-
-  return lag;
- } else if ( wait == ROAR_VS_ASYNC ) {
-  if ( _send_async_req(vss, ROAR_CMD_GET_STREAM, -1, roar_stream_get_id(&(vss->stream)), error) == -1 )
-   return 0;
-  switch (backend) {
-   case ROAR_VS_BACKEND_NONE:
-    break;
-   case ROAR_VS_BACKEND_FIRST:
-     if ( vss->first_primid == -1 ) {
-      _seterr(ROAR_ERROR_UNKNOWN);
-      return 0;
-     }
-
-     backend = vss->first_primid;
-    break;
-   default:
-     if ( backend < 0 ) {
-      _seterr(ROAR_ERROR_INVAL);
-      return -1;
-     }
-    break;
-  }
-
-  vss->async.last_backend = backend;
-
-  if ( backend >= 0 )
-   if ( _send_async_req(vss, ROAR_CMD_GET_STREAM_PARA, ROAR_STREAM_PARA_INFO, backend, error) == -1 )
-    return 0;
-  _seterr(ROAR_ERROR_NODATA);
-  return 0;
- }
-
- _seterr(ROAR_ERROR_INVAL);
- return 0;
-}
-
-static int roar_vs_flag(roar_vs_t * vss, int flag, int val, int * error) {
- struct roar_stream_info info;
- int old = -1;
-
- _ckvss(-1);
- _ckasync(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( val != ROAR_VS_ASK )
-  old = roar_vs_flag(vss, flag, ROAR_VS_ASK, error);
-
- _initerr();
-
- switch (val) {
-  case ROAR_VS_TRUE:
-  case ROAR_VS_FALSE:
-    if ( roar_stream_set_flags(vss->con, &(vss->stream), flag,
-                                val == ROAR_VS_TRUE ? ROAR_SET_FLAG : ROAR_RESET_FLAG) == -1 ) {
-     _seterrre();
-     return -1;
-    }
-    return old;
-   break;
-  case ROAR_VS_TOGGLE:
-    return roar_vs_flag(vss, flag, old == ROAR_VS_TRUE ? ROAR_VS_FALSE : ROAR_VS_TRUE, error);
-   break;
-  case ROAR_VS_ASK:
-    if ( roar_stream_get_info(vss->con, &(vss->stream), &info) == -1 ) {
-     _seterrre();
-     return -1;
-    }
-    return info.flags & flag ? ROAR_VS_TRUE : ROAR_VS_FALSE;
-   break;
- }
-
- _seterr(ROAR_ERROR_INVAL);
- return -1;
-}
-
-int     roar_vs_pause(roar_vs_t * vss, int val, int * error) {
- return roar_vs_flag(vss, ROAR_FLAG_PAUSE, val, error);
-}
-
-int     roar_vs_mute (roar_vs_t * vss, int val, int * error) {
- return roar_vs_flag(vss, ROAR_FLAG_MUTE, val, error);
-}
-
-static int roar_vs_volume (roar_vs_t * vss, float * c, size_t channels, int * error) {
- struct roar_mixer_settings mixer;
- size_t i;
- register float s, max_s = -100.0, scale = 65535.0;
- int oldchannels;
- int mode = ROAR_SET_VOL_ALL;
-
- _ckvss(-1);
- _ckasync(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( channels > ROAR_MAX_CHANNELS ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- if ( roar_get_vol(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, &oldchannels) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( vss->flags & FLAG_FREE_VOL ) {
-  for (i = 0; i < channels; i++) {
-   if ( c[i] > max_s ) {
-    max_s = c[i];
-   } else if ( c[i] < -0.01 ) {
-    _seterr(ROAR_ERROR_RANGE);
-    return -1;
-   }
-  }
-
-  if ( max_s > 1.00 ) {
-   scale = 65535.0 / max_s;
-  }
- }
-
- for (i = 0; i < channels; i++) {
-  if ( vss->flags & FLAG_FREE_VOL ) {
-   s = c[i] * scale;
-   if ( s < 0.0 )
-    s = 0.0;
-  } else {
-   s = c[i] * 65535.0;
-   if ( s > 66190.0 || s < -655.0 ) {
-    _seterr(ROAR_ERROR_RANGE);
-    return -1;
-   } else if ( s > 65535.0 ) {
-    s = 65535.0;
-   } else if ( s <     0.0 ) {
-    s = 0.0;
-   }
-  }
-  mixer.mixer[i] = s;
- }
-
- if ( vss->flags & FLAG_FREE_VOL ) {
-  mixer.scale = scale;
- } else {
-  mixer.scale = 65535;
- }
-
- if ( channels != (size_t)oldchannels )
-  mode = ROAR_SET_VOL_UNMAPPED;
-
- if ( roar_set_vol(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, channels, mode) == 0 )
-  return 0;
-
- if ( mode == ROAR_SET_VOL_ALL ) {
-  _seterrre();
-  return -1;
- }
-
- if ( roar_conv_volume(&mixer, &mixer, oldchannels, channels) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- channels = oldchannels;
- mode     = ROAR_SET_VOL_ALL;
-
- if ( roar_set_vol(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, channels, mode) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- return 0;
-}
-
-int     roar_vs_volume_mono   (roar_vs_t * vss, float c, int * error) {
- return roar_vs_volume(vss, &c, 1, error);
-}
-
-int     roar_vs_volume_stereo (roar_vs_t * vss, float l, float r, int * error) {
- float c[2] = {l, r};
- return roar_vs_volume(vss, c, 2, error);
-}
-
-int     roar_vs_volume_get    (roar_vs_t * vss, float * l, float * r, int * error) {
- struct roar_mixer_settings mixer;
- int channels;
-
- if ( vss == NULL || l == NULL || r == NULL ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _ckasync(-1);
-
- _initerr();
-
- if ( roar_get_vol(vss->con, roar_stream_get_id(&(vss->stream)), &mixer, &channels) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- if ( channels == 1 )
-  mixer.mixer[1] = mixer.mixer[0];
-
- *l = mixer.mixer[0] / (float)mixer.scale;
- *r = mixer.mixer[1] / (float)mixer.scale;
-
- return 0;
-}
-
-int     roar_vs_meta          (roar_vs_t * vss, struct roar_keyval * kv, size_t len, int * error) {
- struct roar_meta meta;
- size_t i;
- int type;
- int ret = 0;
-
- _ckvss(-1);
- _ckasync(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- meta.type   = ROAR_META_TYPE_NONE;
- meta.key[0] = 0;
- meta.value  = NULL;
-
- _initerr();
-
- if ( roar_stream_meta_set(vss->con, &(vss->stream), ROAR_META_MODE_CLEAR, &meta) == -1 ) {
-  _seterrre();
-  ret = -1;
- }
-
- for (i = 0; i < len; i++) {
-  type = roar_meta_inttype(kv[i].key);
-  meta.type  = type;
-  meta.value = kv[i].value;
-
-  if ( roar_stream_meta_set(vss->con, &(vss->stream), ROAR_META_MODE_ADD, &meta) == -1 ) {
-   _seterrre();
-   ret = -1;
-  }
- }
-
- meta.type   = ROAR_META_TYPE_NONE;
- meta.key[0] = 0;
- meta.value  = NULL;
- if ( roar_stream_meta_set(vss->con, &(vss->stream), ROAR_META_MODE_FINALIZE, &meta) == -1 ) {
-  _seterrre();
-  ret = -1;
- }
-
- return ret;
-}
-
-int     roar_vs_role          (roar_vs_t * vss, int role, int * error) {
- _ckvss(-1);
- _ckasync(-1);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- _initerr();
-
- if ( roar_stream_set_role(vss->con, &(vss->stream), role) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- return 0;
-}
-
-
-int     roar_vs_iterate       (roar_vs_t * vss, int wait, int * error) {
- struct roar_vio_select vios[3];
- struct roar_vio_selecttv rtv = {.sec = 0, .nsec = 1};
- size_t len = 0;
- size_t i;
- ssize_t ret;
- int can_read = 0, can_write = 0;
- int can_flush_stream = 0, can_flush_file = 0;
- int is_eof = 0;
- void * data;
- size_t tmp;
-
- // TODO: fix error handling below.
-
- ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p) = ?", vss, wait, error);
-
- _ckvss(-1);
-
- if ( wait != ROAR_VS_WAIT && wait != ROAR_VS_NOWAIT ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- ROAR_VIO_SELECT_SETVIO(&(vios[len]), vss->vio_ptr, ((vss->flags & FLAG_DIR_IN  ? ROAR_VIO_SELECT_READ  : 0) |
-                                                    (vss->flags & FLAG_DIR_OUT ? ROAR_VIO_SELECT_WRITE : 0)));
- vios[len].ud.vp = vss->vio_ptr;
- len++;
-
- ROAR_VIO_SELECT_SETVIO(&(vios[len]), roar_get_connection_vio2(vss->con), ROAR_VIO_SELECT_READ);
- vios[len].ud.vp = vss->con;
- len++;
-
-
-// TODO: FIXME: need to do two select()s so we can sleep more efficently and test for both directions.
-// for the moment we disable file direction and hope it will not block anyway...
-/*
- if ( vss->file != NULL ) {
-  ROAR_VIO_SELECT_SETVIO(&(vios[len]), vss->file, ((vss->flags & FLAG_DIR_IN  ? ROAR_VIO_SELECT_WRITE : 0) |
-                                                   (vss->flags & FLAG_DIR_OUT ? ROAR_VIO_SELECT_READ  : 0)));
-  vios[len].ud.vp = vss->file;
-  len++;
- }
-*/
-
- ret = roar_vio_select(vios, len, (wait == ROAR_VS_NOWAIT ? &rtv : NULL), NULL);
-
-// part 2 of above hack:
-// emulate read handle.
-  if ( vss->file != NULL ) {
-   vios[len].ud.vp   = vss->file;
-   vios[len].eventsa = ROAR_VIO_SELECT_WRITE|ROAR_VIO_SELECT_READ;
-   len++;
-  }
-
- // no error here nor EOF.
- if ( ret == 0 )
-  return 1;
-
- for (i = 0; i < len; i++) {
-  if ( !vios[i].eventsa )
-   continue;
-
-  if ( vios[i].ud.vp == vss->vio_ptr ) {
-   if ( vios[i].eventsa & ROAR_VIO_SELECT_READ )
-    can_read++;
-
-   if ( vios[i].eventsa & ROAR_VIO_SELECT_WRITE ) {
-    can_write++;
-    can_flush_stream = 1;
-   }
-  } else if ( vios[i].ud.vp == vss->con ) {
-   if ( vss->async.qlen ) {
-    _handle_async_req(vss, NULL);
-   } else {
-    roar_sync(vss->con);
-   }
-  } else if ( vss->file != NULL && vios[i].ud.vp == vss->file ) {
-   if ( vios[i].eventsa & ROAR_VIO_SELECT_READ )
-    can_write++;
-
-   if ( vios[i].eventsa & ROAR_VIO_SELECT_WRITE ) {
-    can_read++;
-    can_flush_file = 1;
-   }
-  }
- }
-
- if ( vss->flags & FLAG_BUFFERED ) {
-  if ( roar_buffer_ring_avail(vss->readring, NULL, &tmp) != -1 )
-   if ( tmp > 0 )
-    can_read++;
-
-// no check here to just let the read return zero and we do EOF handling.
-/*
-  if ( roar_buffer_ring_avail(vss->writering, &tmp, NULL) != -1 )
-   if ( tmp > 0 )
-*/
-    can_write++;
- }
-
- ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p): can_read=%i, can_write=%i", vss, wait, error, can_read, can_write);
-
- // TODO: FIXME: Need to correct error handling here!
-
- if ( can_flush_stream && vss->writebuffer != NULL ) {
-  if ( roar_buffer_get_data(vss->writebuffer, &data) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_len(vss->writebuffer, &len) == -1 )
-   return -1;
-
-  ret = roar_vs_write_direct(vss, data, len, error);
-
-  if ( ret == -1 ) {
-   return -1;
-  } else if ( ret == (ssize_t)len ) {
-   roar_buffer_free(vss->writebuffer);
-   vss->writebuffer = NULL;
-  } else {
-   if ( roar_buffer_set_offset(vss->writebuffer, ret) == -1 )
-    return -1;
-  }
- }
-
- if ( can_flush_file && vss->readbuffer != NULL ) {
-  if ( roar_buffer_get_data(vss->readbuffer, &data) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_len(vss->readbuffer, &len) == -1 )
-   return -1;
-
-  ret = roar_vio_write(vss->file, data, len);
-
-  if ( ret == -1 ) {
-   return -1;
-  } else if ( ret == (ssize_t)len ) {
-   roar_buffer_free(vss->readbuffer);
-   vss->readbuffer = NULL;
-  } else {
-   if ( roar_buffer_set_offset(vss->readbuffer, ret) == -1 )
-    return -1;
-  }
- }
-
-#define _READ_SIZE 1024
-
- if ( can_read == 2 && vss->readbuffer == NULL ) {
-  if ( roar_buffer_new_data(&(vss->readbuffer), (len = _READ_SIZE), &data) == -1 ) 
-   return -1;
-
-  ret = roar_vs_read(vss, data, len, error);
-
-  if ( ret == -1 ) {
-   roar_buffer_free(vss->readbuffer);
-   vss->readbuffer = NULL;
-   return -1;
-  } else if ( ret == 0 ) {
-   is_eof = 1;
-   roar_buffer_free(vss->readbuffer);
-   vss->readbuffer = NULL;
-  } else {
-   len = ret;
-   if ( roar_buffer_set_len(vss->readbuffer, len) == -1 )
-    return -1;
-
-   if ( vss->flags & FLAG_BUFFERED ) {
-    tmp = len;
-    if ( roar_buffer_ring_write(vss->readring, data, &tmp) == -1 ) {
-     ret = -1;
-    } else {
-     ret = tmp;
-    }
-   } else {
-    ret = roar_vio_write(vss->file, data, len);
-   }
-
-   if ( ret == -1 ) {
-    return -1;
-   } else if ( ret == (ssize_t)len ) {
-    roar_buffer_free(vss->readbuffer);
-    vss->readbuffer = NULL;
-   } else {
-    if ( roar_buffer_set_offset(vss->readbuffer, ret) == -1 )
-     return -1;
-   }
-  }
- }
-
- if ( can_write == 2 && vss->writebuffer == NULL ) {
-  if ( roar_buffer_new_data(&(vss->writebuffer), (len = _READ_SIZE), &data) == -1 )
-   return -1;
-
-  if ( vss->flags & FLAG_BUFFERED ) {
-   tmp = len;
-   if ( roar_buffer_ring_read(vss->writering, data, &tmp) == -1 ) {
-    ret = -1;
-   } else {
-    ret = tmp;
-   }
-  } else {
-   ret = roar_vio_read(vss->file, data, len);
-  }
-
-  ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p): ret=%lli", vss, wait, error, (long long int)ret);
-
-  if ( ret == -1 ) {
-   ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p) = ?", vss, wait, error);
-
-   roar_buffer_free(vss->writebuffer);
-   vss->writebuffer = NULL;
-   return -1;
-  } else if ( ret == 0 ) {
-   ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p) = ?", vss, wait, error);
-
-   is_eof = 1;
-   roar_buffer_free(vss->writebuffer);
-   vss->writebuffer = NULL;
-  } else {
-   ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p) = ?", vss, wait, error);
-
-   if ( (ssize_t)len != ret ) {
-    len = ret;
-    if ( roar_buffer_set_len(vss->writebuffer, len) == -1 )
-     return -1;
-   }
-
-   ROAR_DBG("roar_vs_iterate(vss=%p, wait=%i, error=%p) = ?", vss, wait, error);
-
-   ret = roar_vs_write_direct(vss, data, len, error);
-
-   if ( ret == -1 ) {
-    return -1;
-   } else if ( ret == (ssize_t)len ) {
-    roar_buffer_free(vss->writebuffer);
-    vss->writebuffer = NULL;
-   } else {
-    if ( roar_buffer_set_offset(vss->writebuffer, ret) == -1 )
-     return -1;
-   }
-  }
- }
-
- if ( vss->async.level == ROAR_VS_ASYNCLEVEL_AUTO && !vss->async.lock &&
-      vss->async.read_latency                     && !vss->async.qlen ) {
-  _LIBROAR_IGNORE_RET(roar_vs_latency(vss,
-                                      vss->async.last_backend < 0 ? ROAR_VS_BACKEND_NONE : vss->async.last_backend,
-                                      ROAR_VS_ASYNC, NULL));
- }
-
- return is_eof ? 0 : 2;
-}
-
-int     roar_vs_run           (roar_vs_t * vss, int * error) {
- int ret;
-
- _ckvss(-1);
-
- while ((ret = roar_vs_iterate(vss, ROAR_VS_WAIT, error)) > 0);
-
- ROAR_DBG("roar_vs_run(vss=%p, error=%p): ret=%i", vss, error, ret);
-
- if ( ret == 0 ) {
-  // flush buffers:
-  roar_vs_iterate(vss, ROAR_VS_WAIT, error);
- }
-
- if ( roar_vs_sync(vss, ROAR_VS_WAIT, error) == -1 )
-  return -1;
-
- return ret;
-}
-
-ssize_t roar_vs_get_avail_read(roar_vs_t * vss, int * error) {
- size_t len;
-
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_BUFFERED) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( roar_buffer_ring_avail(vss->readring, &len, NULL) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- return len;
-}
-
-ssize_t roar_vs_get_avail_write(roar_vs_t * vss, int * error) {
- size_t len;
-
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_BUFFERED) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( roar_buffer_ring_avail(vss->writering, NULL, &len) == -1 ) {
-  _seterrre();
-  return -1;
- }
-
- return len;
-}
-
-int     roar_vs_reset_buffer(roar_vs_t * vss, int writering, int readring, int * error) {
- _ckvss(-1);
-
- if ( !(vss->flags & FLAG_BUFFERED) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( writering != ROAR_VS_TRUE || writering != ROAR_VS_FALSE ||
-      readring  != ROAR_VS_TRUE || readring  != ROAR_VS_FALSE ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( writering ) {
-  if ( roar_buffer_ring_reset(vss->writering) == -1 ) {
-   _seterrre();
-   return -1;
-  }
- }
-
- if ( readring ) {
-  if ( roar_buffer_ring_reset(vss->readring) == -1 ) {
-   _seterrre();
-   return -1;
-  }
- }
-
- return 0;
-}
-
-int     roar_vs_ctl           (roar_vs_t * vss, roar_vs_ctlcmd cmd, void * argp, int * error) {
- _ckvss(-1);
-
- switch (cmd) {
-  case ROAR_VS_CMD_NOOP:
-   break;
-  case ROAR_VS_CMD_SET_MIXER:
-    vss->mixerid = *(int*)argp;
-   break;
-  case ROAR_VS_CMD_GET_MIXER:
-    *(int*)argp = vss->mixerid;
-   break;
-  case ROAR_VS_CMD_SET_FIRST_PRIM:
-    vss->first_primid = *(int*)argp;
-   break;
-  case ROAR_VS_CMD_GET_FIRST_PRIM:
-    *(int*)argp = vss->first_primid;
-   break;
-#ifdef _HAVE_SOCKOPT
-  case ROAR_VS_CMD_SET_LATC_P:
-    vss->latc.p = *(float*)argp;
-   break;
-  case ROAR_VS_CMD_GET_LATC_P:
-    *(float*)argp = vss->latc.p;
-   break;
-  case ROAR_VS_CMD_SET_LATC_TARGET:
-    vss->latc.target = *(float*)argp;
-   break;
-  case ROAR_VS_CMD_GET_LATC_TARGET:
-    *(float*)argp = vss->latc.target;
-   break;
-  case ROAR_VS_CMD_SET_LATC_WINDOW:
-    vss->latc.window = *(float*)argp;
-   break;
-  case ROAR_VS_CMD_GET_LATC_WINDOW:
-    *(float*)argp = vss->latc.window;
-   break;
-  case ROAR_VS_CMD_SET_LATC_MINLAG:
-    vss->latc.minlag = *(float*)argp;
-   break;
-  case ROAR_VS_CMD_GET_LATC_MINLAG:
-    *(float*)argp = vss->latc.minlag;
-   break;
-#endif
-  case ROAR_VS_CMD_SET_FREE_VOLUME:
-    switch (*(int*)argp) {
-     case ROAR_VS_TRUE:
-       vss->flags |= FLAG_FREE_VOL;
-      break;
-     case ROAR_VS_FALSE:
-       vss->flags |= FLAG_FREE_VOL;
-       vss->flags -= FLAG_FREE_VOL;
-      break;
-     case ROAR_VS_TOGGLE:
-       if ( vss->flags & FLAG_FREE_VOL ) {
-        vss->flags -= FLAG_FREE_VOL;
-       } else {
-        vss->flags |= FLAG_FREE_VOL;
-       }
-      break;
-     default:
-       _seterr(ROAR_ERROR_INVAL);
-       return -1;
-      break;
-    }
-   break;
-  case ROAR_VS_CMD_GET_FREE_VOLUME:
-    *(int*)argp = vss->flags & FLAG_FREE_VOL ? ROAR_VS_TRUE : ROAR_VS_FALSE;
-   break;
-  case ROAR_VS_CMD_SET_DEFAULT_PAUSED:
-    switch (*(int*)argp) {
-     case ROAR_VS_TRUE:
-       vss->flags |= FLAG_DEF_PAUSE;
-      break;
-     case ROAR_VS_FALSE:
-       vss->flags |= FLAG_DEF_PAUSE;
-       vss->flags -= FLAG_DEF_PAUSE;
-      break;
-     case ROAR_VS_TOGGLE:
-       if ( vss->flags & FLAG_DEF_PAUSE ) {
-        vss->flags -= FLAG_DEF_PAUSE;
-       } else {
-        vss->flags |= FLAG_DEF_PAUSE;
-       }
-      break;
-     default:
-       _seterr(ROAR_ERROR_INVAL);
-       return -1;
-      break;
-    }
-   break;
-  case ROAR_VS_CMD_GET_DEFAULT_PAUSED:
-    *(int*)argp = vss->flags & FLAG_DEF_PAUSE ? ROAR_VS_TRUE : ROAR_VS_FALSE;
-   break;
-  case ROAR_VS_CMD_SET_ASYNC:
-    vss->async.level = *(int*)argp;
-   break;
-  case ROAR_VS_CMD_GET_ASYNC:
-    *(int*)argp = vss->async.level;
-   break;
-  case ROAR_VS_CMD_LOCK_ASYNC:
-    _ckasync(-1);
-    if ( argp == NULL ) {
-     vss->async.lock++;
-    } else {
-     vss->async.lock -= *(int*)argp;
-    }
-   break;
-  case ROAR_VS_CMD_UNLOCK_ASYNC:
-    if ( argp == NULL ) {
-     if ( !vss->async.lock ) {
-      _seterr(ROAR_ERROR_LOSTSYNC);
-      return -1;
-     } else {
-      vss->async.lock--;
-     }
-    } else {
-     if ( vss->async.lock < (size_t)*(int*)argp ) {
-      _seterr(ROAR_ERROR_LOSTSYNC);
-      return -1;
-     } else {
-      vss->async.lock -= *(int*)argp;
-     }
-    }
-   break;
-// use ifndef here so warnings of unhandled enum values will be shown in DEBUG mode.
-#ifndef DEBUG
-  default:
-    _seterr(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
-#endif
- }
-
- return 0;
-}
-
-struct roar_connection * roar_vs_connection_obj(roar_vs_t * vss, int * error) {
- _ckvss(NULL);
-
- return vss->con;
-}
-
-struct roar_stream     * roar_vs_stream_obj    (roar_vs_t * vss, int * error) {
- _ckvss(NULL);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return NULL;
- }
-
- return &(vss->stream);
-}
-
-struct roar_vio_calls  * roar_vs_vio_obj       (roar_vs_t * vss, int * error) {
- _ckvss(NULL);
-
- if ( !(vss->flags & FLAG_STREAM) ) {
-  _seterr(ROAR_ERROR_INVAL);
-  return NULL;
- }
-
- return vss->vio_ptr;
-}
-
-//ll
Index: libroar/watchdog.c
===================================================================
--- libroar/watchdog.c	(revision 6052)
+++ 	(revision )
@@ -1,225 +1,0 @@
-//watchdog.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2015
- *
- *  This file is part of libroar a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  libroar is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this lib
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
-
-#include "libroar.h"
-
-#define _CONF_DEFAULT ROAR_WATCHDOG_CONF_STOPPABLE|ROAR_WATCHDOG_CONF_CLOCK_INTERNAL;
-static int _config = _CONF_DEFAULT;
-static int _triggered = 0;
-static int _running = 0;
-static int_least32_t _timeout = 10000; // 10 sec.
-static int (*_callback)(enum roar_watchdog_event event) = NULL;
-static pid_t _starter_pid = 0;
-
-#ifdef ROAR_HAVE_ALARM
-static void _on_sig_alarm (int signum) {
- (void)signum;
- signal(SIGALRM,  _on_sig_alarm);
- alarm(_timeout/1000);
- roar_watchdog_tick();
-}
-#endif
-
-static int __event_handler(enum roar_watchdog_event event) {
- int ret;
-
- if ( event == ROAR_WATCHDOG_DOUBLETIMEOUT ) {
-  ROAR_ERR("Watchdog event: DoubleTimeOut. Bad. Terminating program.");
-  // panic...
-  roar_panic(ROAR_FATAL_ERROR_WATCHDOG, NULL);
- } else if ( event == ROAR_WATCHDOG_TIMEOUT ) {
-  ROAR_ERR("Watchdog event: TimeOut. Cleaning Up.");
- }
-
- if ( _callback != NULL ) {
-  if ( (_config & ROAR_WATCHDOG_CONF_EVENTS_ALSO_MINOR) ||
-       event == ROAR_WATCHDOG_TIMEOUT                   ||
-       event == ROAR_WATCHDOG_START                     ||
-       event == ROAR_WATCHDOG_STOP ) {
-   ret = _callback(event);
-   if ( ret == -1 && event == ROAR_WATCHDOG_TIMEOUT )
-    __event_handler(ROAR_WATCHDOG_DOUBLETIMEOUT);
-  }
- }
-
- if ( event == ROAR_WATCHDOG_TIMEOUT ) {
-  ROAR_ERR("Watchdog event: TimeOut. Terminating program.");
-  roar_panic(ROAR_FATAL_ERROR_WATCHDOG, NULL);
- }
-
- return 0;
-}
-
-// start the watchdog.
-// timeout is in ms.
-int roar_watchdog_start(int config, int_least32_t timeout, int (*callback)(enum roar_watchdog_event event)) {
- int ret = -1;
-
- if ( config == ROAR_WATCHDOG_CONF_DEFAULTS ) {
-  config = _CONF_DEFAULT;
- } else if ( config == ROAR_WATCHDOG_CONF_RESTART ) {
-  config = _config;
-  if ( timeout == -1 )
-   timeout = _timeout;
-  if ( callback == NULL )
-   callback = _callback;
- }
-
- if ( timeout < 1 ) {
-  roar_err_set(ROAR_ERROR_CAUSALITY);
-  return -1;
- }
-
- if ( _running ) {
-  if ( _config & ROAR_WATCHDOG_CONF_STOPPABLE ) {
-   if ( roar_watchdog_stop() == -1 )
-    return -1;
-  } else {
-   roar_err_set(ROAR_ERROR_BUSY);
-   return -1;
-  }
- }
-
- if ( !(config & ROAR_WATCHDOG_CONF_CLOCK_EXTERNAL) ) {
-#ifdef ROAR_HAVE_ALARM
-  if ( config & ROAR_WATCHDOG_CONF_CLOCK_ROUND_UP ) {
-   if ( timeout % 1000 )
-    timeout += 1000;
-  }
-
-  timeout /= 1000;
-  if ( timeout == 0 )
-   timeout = 1;
-
-  timeout *= 1000;
-#else
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
-#endif
- }
-
- _config   = config;
- _timeout  = timeout;
- _callback = callback;
-
- if ( config & ROAR_WATCHDOG_CONF_CLOCK_EXTERNAL ) {
-  ret = __event_handler(ROAR_WATCHDOG_START);
-#ifdef ROAR_HAVE_ALARM
- } else {
-  signal(SIGALRM,  _on_sig_alarm);
-  alarm(_timeout/1000);
-  ret = 0;
-#endif
- }
-
- if ( ret == -1 )
-  return -1;
-
- _running = 1;
- _starter_pid = getpid();
- return 0;
-}
-
-// Get timeout for watchdog.
-// This may be diffrent from the requested time.
-int_least32_t roar_watchdog_gettime(void) {
- if ( !_running ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
- return _timeout;
-}
-
-// stop it, if stopping is enabled.
-int roar_watchdog_stop(void) {
- int ret;
-
- if ( !_running )
-  return 0;
-
- // test if we are allowed to stop the watchdog.
- // In addition always allow to stop it in childs.
- if ( !(_config & ROAR_WATCHDOG_CONF_STOPPABLE) && _starter_pid == getpid() ) {
-  ROAR_WARN("roar_watchdog_stop(void): Software tries to stop watchdog but is not allowed to.");
-  roar_err_set(ROAR_ERROR_PERM);
-  return -1;
- }
-
-
-#ifdef ROAR_HAVE_ALARM
- if ( !(_config & ROAR_WATCHDOG_CONF_CLOCK_EXTERNAL) ) {
-  alarm(0);
-  _running = 0;
- }
-#endif
-
- ret = __event_handler(ROAR_WATCHDOG_STOP);
- if ( ret != -1 )
-  _running = 0;
-
- return ret;
-}
-
-// Trigger the watchdog to show that we are still alive.
-int roar_watchdog_trigger(void) {
- if ( !_running )
-  return 0;
-
- _triggered = 1;
- return __event_handler(ROAR_WATCHDOG_TRIGGER);
-}
-
-// Trigger the watchdog clock. This is only used if configured to run with external clock source.
-int roar_watchdog_tick(void) {
- int ret = 0;
-
- ROAR_DBG("roar_watchdog_tick(void) = ?");
-
- if ( !_running )
-  return 0;
-
- if ( _triggered == 0 ) {
-  _triggered = -1;
-  ret = __event_handler(ROAR_WATCHDOG_TIMEOUT);
- } else if ( _triggered == -1 ) {
-  ret = __event_handler(ROAR_WATCHDOG_DOUBLETIMEOUT);
- } else {
-  _triggered = 0;
- }
-
- return ret;
-}
-
-//ll
