source: roaraudio/libroaryiff/connection.c @ 5961:06e7fd9e4c25

Last change on this file since 5961:06e7fd9e4c25 was 5961:06e7fd9e4c25, checked in by phi, 10 years ago

Updates of copyright and license headers

File size: 3.0 KB
RevLine 
[338]1//connection.c:
2
[688]3/*
[5961]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014
[688]5 *
[4037]6 *  The code (may) include prototypes and comments (and maybe
7 *  other code fragements) from the yiff sound system.
8 *  According to the debian/copyright file upstream author is
9 *  Tara Milana <learfox@twu.net>. Also copyright is listed as:
10 *  Copyright (C)  1997-2003 WolfPack Entertainment
11 *
[688]12 *  This file is part of libroaryiff a part of RoarAudio,
13 *  a cross-platform sound system for both, home and professional use.
14 *  See README for details.
15 *
16 *  This file is free software; you can redistribute it and/or modify
17 *  it under the terms of the GNU General Public License version 3
18 *  as published by the Free Software Foundation.
19 *
20 *  libroaryiff is distributed in the hope that it will be useful,
21 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *  GNU General Public License for more details.
24 *
25 *  You should have received a copy of the GNU General Public License
26 *  along with this software; see the file COPYING.  If not, write to
[3517]27 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28 *  Boston, MA 02110-1301, USA.
[688]29 *
[4037]30 * NOTE: code fragments (like prototypes) taken from the yiff package
31 *       are 'GPLv2 or later' and are upgraded to GPLv3 by being used
32 *       within this document.
33 *
[688]34 */
35
[338]36#include <libroaryiff.h>
37
[339]38YConnection *YOpenConnection (const char *start_arg, const char *con_arg) {
[3832]39 YConnection * ycon = roar_mm_malloc(sizeof(YConnection));
[342]40 struct roar_connection con;
[5270]41 const char * server = (char *)con_arg;
42 const char * name   = "libroaryiff client";
[342]43
44 memset(ycon, 0, sizeof(YConnection));
45
46 // there is no symbolic value for default con_arg
47 // in the heder files. So we use a hard coded value from the docs
[339]48
[787]49 if ( server != NULL ) {
50  if ( strcmp(server, "127.0.0.1:9433") == 0 ||
51       strcmp(server, "127.0.0.1")      == 0 ||   // \\                                         //
52       strcmp(server, "localhost")      == 0 ||   //   => Don't know if this is valid for libY  //
53       strcmp(server, "localhost:9433") == 0 ) {  // //   but we support it.                    //
[342]54
[787]55   server = NULL; // try default locations
56  }
[342]57 }
[339]58
[342]59 if (roar_simple_connect(&con, server, name) == -1) {
60  // Handle start_arg here!
[3832]61  roar_mm_free(ycon);
[342]62  return NULL;
63 }
64
[1660]65 if ( (ycon->fd = roar_get_connection_fh(&con)) == -1 ) {
66  roar_disconnect(&con);
[3832]67  roar_mm_free(ycon);
[1660]68  return NULL;
69 }
[342]70
71 return ycon;
[339]72}
73
74void YCloseConnection (YConnection *connection, Boolean no_shutdown) {
[5247]75 struct roar_vio_calls vio;
76
[5270]77 // in case we started the server by using +fork we can not keep it running
78 // as it will terminate anyway. If there are any other clients (I guess
79 // this is what this option is about) it will keep running.
80 (void)no_shutdown;
81
[3832]82 if ( connection == NULL )
[339]83  return;
84
[5247]85 // roard will clean up all other sockets if the close the main one.
[342]86
[5247]87 if ( roar_vio_open_fh_socket(&vio, connection->fd) != -1 ) {
88  roar_vio_close(&vio);
89 }
[342]90
[3832]91 roar_mm_free(connection);
[339]92}
93
[338]94//ll
Note: See TracBrowser for help on using the repository browser.