Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdlib.h>
00018 #include <string.h>
00019
00020 #include "xmmsc/xmmsc_util.h"
00021 #include "xmmsc/xmmsc_ipc_transport.h"
00022 #include "socket_unix.h"
00023 #include "socket_tcp.h"
00024 #include "url.h"
00025
00026 void
00027 xmms_ipc_transport_destroy (xmms_ipc_transport_t *ipct)
00028 {
00029 x_return_if_fail (ipct);
00030
00031 ipct->destroy_func (ipct);
00032
00033 free (ipct);
00034 }
00035
00036 int
00037 xmms_ipc_transport_read (xmms_ipc_transport_t *ipct, char *buffer, int len)
00038 {
00039 return ipct->read_func (ipct, buffer, len);
00040 }
00041
00042 int
00043 xmms_ipc_transport_write (xmms_ipc_transport_t *ipct, char *buffer, int len)
00044 {
00045 return ipct->write_func (ipct, buffer, len);
00046 }
00047
00048 xmms_socket_t
00049 xmms_ipc_transport_fd_get (xmms_ipc_transport_t *ipct)
00050 {
00051 x_return_val_if_fail (ipct, -1);
00052 return ipct->fd;
00053 }
00054
00055 xmms_ipc_transport_t *
00056 xmms_ipc_server_accept (xmms_ipc_transport_t *ipct)
00057 {
00058 x_return_val_if_fail (ipct, NULL);
00059
00060 if (!ipct->accept_func)
00061 return NULL;
00062
00063 return ipct->accept_func (ipct);
00064 }
00065
00066 char *
00067 xmms_ipc_hostname (const char *path)
00068 {
00069 xmms_url_t *url;
00070 char* ret = NULL;
00071
00072 url = parse_url (path);
00073 if (!strcasecmp (url->protocol, "tcp")) {
00074 if (strlen (url->host)) {
00075 ret = strdup (url->host);
00076 }
00077 }
00078 free_url (url);
00079
00080 return ret;
00081 }
00082