Rev | Line | |
---|
[338] | 1 | //connection.c: |
---|
| 2 | |
---|
| 3 | #include <libroaryiff.h> |
---|
| 4 | |
---|
[339] | 5 | YConnection *YOpenConnection (const char *start_arg, const char *con_arg) { |
---|
[342] | 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 |
---|
[339] | 15 | |
---|
[342] | 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 | } |
---|
[339] | 23 | |
---|
[342] | 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; |
---|
[339] | 33 | } |
---|
| 34 | |
---|
| 35 | void YCloseConnection (YConnection *connection, Boolean no_shutdown) { |
---|
| 36 | if ( !connection ) |
---|
| 37 | return; |
---|
| 38 | |
---|
[342] | 39 | roar_simple_close(connection->fd); // roard will clean up all other sockets if the close the main one. |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | free(connection); |
---|
[339] | 43 | } |
---|
| 44 | |
---|
[338] | 45 | //ll |
---|
Note: See
TracBrowser
for help on using the repository browser.