Line | |
---|
1 | //connection.c: |
---|
2 | |
---|
3 | #include <libroaryiff.h> |
---|
4 | |
---|
5 | YConnection *YOpenConnection (const char *start_arg, const char *con_arg) { |
---|
6 | YConnection * ycon = malloc(sizeof(YConnection)); |
---|
7 | struct roar_connection con; |
---|
8 | char * server = (char *)con_arg; |
---|
9 | char * name = "libroaryiff client"; |
---|
10 | |
---|
11 | memset(ycon, 0, sizeof(YConnection)); |
---|
12 | |
---|
13 | // there is no symbolic value for default con_arg |
---|
14 | // in the heder files. So we use a hard coded value from the docs |
---|
15 | |
---|
16 | if ( strcmp(server, "127.0.0.1:9433") == 0 || |
---|
17 | strcmp(server, "127.0.0.1") == 0 || // \\ // |
---|
18 | strcmp(server, "localhost") == 0 || // => Don't know if this is valid for libY // |
---|
19 | strcmp(server, "localhost:9433") == 0 ) { // // but we support it. // |
---|
20 | |
---|
21 | server = NULL; // try default locations |
---|
22 | } |
---|
23 | |
---|
24 | if (roar_simple_connect(&con, server, name) == -1) { |
---|
25 | // Handle start_arg here! |
---|
26 | free(ycon); |
---|
27 | return NULL; |
---|
28 | } |
---|
29 | |
---|
30 | ycon->fd = con.fh; |
---|
31 | |
---|
32 | return ycon; |
---|
33 | } |
---|
34 | |
---|
35 | void YCloseConnection (YConnection *connection, Boolean no_shutdown) { |
---|
36 | if ( !connection ) |
---|
37 | return; |
---|
38 | |
---|
39 | roar_simple_close(connection->fd); // roard will clean up all other sockets if the close the main one. |
---|
40 | |
---|
41 | |
---|
42 | free(connection); |
---|
43 | } |
---|
44 | |
---|
45 | //ll |
---|
Note: See
TracBrowser
for help on using the repository browser.