*/
int main(int argc, char *argv[])
{
- struct sockaddr_un unix_addr;
int ret = -E_AUDIOC_SYNTAX, fd;
- char *cf, *socket_name, *randname = para_tmpname(), *tmpsocket_name = NULL,
- *buf = NULL, *hn = para_hostname(), *args, *home = para_homedir();
+ char *cf, *buf = NULL, *args;
size_t bufsize, loaded = 0;
+ struct sockaddr_un unix_addr;
if (audioc_cmdline_parser(argc, argv, &conf))
goto out;
para_strdup("stat");
bufsize = conf.bufsize_arg;
buf = para_malloc(bufsize);
- if (conf.socket_given)
- socket_name = para_strdup(conf.socket_arg);
- else
- socket_name = make_message(
- "/var/paraslash/audiod_socket.%s", hn);
- if (conf.tmpdir_given)
- tmpsocket_name = make_message("%s/audioc.sock.%s.%s",
- conf.tmpdir_arg, hn, randname);
- else
- tmpsocket_name = make_message("%s/.paraslash/audioc_sock.%s.%s",
- home, hn, randname);
-
- ret = create_local_socket(tmpsocket_name, &unix_addr, S_IRUSR | S_IWUSR);
- unlink(tmpsocket_name);
- free(tmpsocket_name);
+ ret = get_stream_socket(PF_UNIX);
if (ret < 0)
goto out;
fd = ret;
- ret = -E_INIT_SOCK_ADDR;
- if (init_unix_addr(&unix_addr, socket_name) < 0)
+ if (conf.socket_given)
+ ret = init_unix_addr(&unix_addr, conf.socket_arg);
+ else {
+ char *hn = para_hostname(), *socket_name = make_message(
+ "/var/paraslash/audiod_socket.%s", hn);
+ free(hn);
+ ret = init_unix_addr(&unix_addr, socket_name);
+ free(socket_name);
+ }
+ if (ret < 0)
goto out;
ret = PARA_CONNECT(fd, &unix_addr);
if (ret < 0)