source: roaraudio/libroaryiff/connection.c @ 730:b43149bb9cb3

Last change on this file since 730:b43149bb9cb3 was 688:60db5a500947, checked in by phi, 16 years ago

added copyright statements

File size: 2.1 KB
Line 
1//connection.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - August 2008
5 *
6 *  This file is part of libroaryiff a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  libroaryiff is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include <libroaryiff.h>
26
27YConnection *YOpenConnection (const char *start_arg, const char *con_arg) {
28 YConnection * ycon = malloc(sizeof(YConnection));
29 struct roar_connection con;
30 char * server = (char *)con_arg;
31 char * name   = "libroaryiff client";
32
33 memset(ycon, 0, sizeof(YConnection));
34
35 // there is no symbolic value for default con_arg
36 // in the heder files. So we use a hard coded value from the docs
37
38 if ( strcmp(server, "127.0.0.1:9433") == 0 ||
39      strcmp(server, "127.0.0.1")      == 0 ||   // \\                                         //
40      strcmp(server, "localhost")      == 0 ||   //   => Don't know if this is valid for libY  //
41      strcmp(server, "localhost:9433") == 0 ) {  // //   but we support it.                    //
42
43  server = NULL; // try default locations
44 }
45
46 if (roar_simple_connect(&con, server, name) == -1) {
47  // Handle start_arg here!
48  free(ycon);
49  return NULL;
50 }
51
52 ycon->fd = con.fh;
53
54 return ycon;
55}
56
57void YCloseConnection (YConnection *connection, Boolean no_shutdown) {
58 if ( !connection )
59  return;
60
61 roar_simple_close(connection->fd);  // roard will clean up all other sockets if the close the main one.
62
63
64 free(connection);
65}
66
67//ll
Note: See TracBrowser for help on using the repository browser.