source: roaraudio/libroaryiff/connection.c @ 787:a69f7ee33a38

Last change on this file since 787:a69f7ee33a38 was 787:a69f7ee33a38, checked in by phi, 16 years ago

check for the server to not be NULL before use strcmp()

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 ( server != NULL ) {
39  if ( strcmp(server, "127.0.0.1:9433") == 0 ||
40       strcmp(server, "127.0.0.1")      == 0 ||   // \\                                         //
41       strcmp(server, "localhost")      == 0 ||   //   => Don't know if this is valid for libY  //
42       strcmp(server, "localhost:9433") == 0 ) {  // //   but we support it.                    //
43
44   server = NULL; // try default locations
45  }
46 }
47
48 if (roar_simple_connect(&con, server, name) == -1) {
49  // Handle start_arg here!
50  free(ycon);
51  return NULL;
52 }
53
54 ycon->fd = con.fh;
55
56 return ycon;
57}
58
59void YCloseConnection (YConnection *connection, Boolean no_shutdown) {
60 if ( !connection )
61  return;
62
63 roar_simple_close(connection->fd);  // roard will clean up all other sockets if the close the main one.
64
65
66 free(connection);
67}
68
69//ll
Note: See TracBrowser for help on using the repository browser.