and provide a non-empty log-function.
fade_objs = fade.cmdline.o fade.o exec.o close_on_fork.o string.o fd.o
krell_objs = krell.o string.o
slider_objs = slider.o string.o
-audioc_objs = audioc.cmdline.o audioc.o string.o net.o fd.o
*.o: para.h config.h gcc-compat.h
para_audiod: @audiod_objs@
$(CC) -o $@ @audiod_objs@ @audiod_ldflags@
-para_audioc: $(audioc_objs)
- $(CC) -o $@ $(audioc_objs)
+para_audioc: @audioc_objs@
+ $(CC) -o $@ @audioc_objs@
para_dbadm: $(dbadm_objs)
$(CC) -o $@ $(dbadm_objs) -lncurses -lmenu
just like para_recv and para_filter.
- random/playlist selector: improved info strings
- new audiod commands: tasks, kill
- - para_client uses the error subsystem
+ - para_client/para_audioc use the error subsystem
------------------------------------------
#include "net.h"
#include "string.h"
#include "fd.h"
+#include "error.h"
+
+INIT_AUDIOC_ERRLISTS;
struct gengetopt_args_info conf;
char *tmpfifo;
-enum {E_SYNTAX, E_READ, E_WRITE, E_SOCKET, E_INIT_SOCK_ADDR, E_CONNECT, E_CREDENTIALS, E_SELECT, E_OVERRUN};
-void para_log(__a_unused int ll, __a_unused const char* fmt,...) /* no logging */
+/*
+ * client log function
+ */
+void para_log(int ll, const char* fmt,...)
{
+ va_list argp;
+
+ /* ignore log message if loglevel is not high enough */
+ if (ll < conf.loglevel_arg)
+ return;
+ va_start(argp, fmt);
+ vfprintf(stderr, fmt, argp);
+ va_end(argp);
}
/* audioc does not use encryption */
int main(int argc, char *argv[])
{
struct sockaddr_un unix_addr;
- int ret = -E_SYNTAX, fd, loaded = 0;
+ int ret = -E_AUDIOC_SYNTAX, fd, loaded = 0;
char *cf, *socket_name, *randname = para_tmpname(), *tmpsocket_name = NULL,
*buf = NULL, *hn = para_hostname(), *args, *home = para_homedir();
tmpsocket_name = make_message("%s/.paraslash/audioc_sock.%s.%s",
home, hn, randname);
- ret = -E_SOCKET;
- fd = create_pf_socket(tmpsocket_name, &unix_addr, S_IRUSR | S_IWUSR);
+ ret = create_pf_socket(tmpsocket_name, &unix_addr, S_IRUSR | S_IWUSR);
unlink(tmpsocket_name);
- if (fd < 0)
+ if (ret < 0)
goto out;
+ fd = ret;
ret = -E_INIT_SOCK_ADDR;
if (init_unix_addr(&unix_addr, socket_name) < 0)
goto out;
- ret = - E_CONNECT;
+ ret = - E_AUDIOC_CONNECT;
if (connect(fd, (struct sockaddr *)&unix_addr, UNIX_PATH_MAX) < 0)
goto out;
+ fprintf(stderr, "loaded: %d\n", loaded);
ret = -E_CREDENTIALS;
if (send_cred_buffer(fd, args) < 0)
goto out;
para_fd_set(STDOUT_FILENO, &wfd, &max_fileno);
check_write = 1;
}
- ret = -E_OVERRUN;
+ ret = -E_AUDIOC_OVERRUN;
if (max_fileno < 0)
goto out;
ret = para_select(max_fileno + 1, &rfd, &wfd, NULL);
- if (ret < 0) {
- ret = -E_SELECT;
+ if (ret < 0)
goto out;
- }
if (loaded < conf.bufsize_arg && FD_ISSET(fd, &rfd)) {
len = recv_bin_buffer(fd, buf + loaded,
conf.bufsize_arg - loaded);
if (len <= 0) {
- ret = len < 0? -E_READ : 0;
+ ret = len < 0? -E_AUDIOC_READ : 0;
goto out;
}
loaded += len;
if (check_write && FD_ISSET(STDOUT_FILENO, &wfd)) {
ret = write(STDOUT_FILENO, buf, loaded);
if (ret < 0) {
- ret = -E_WRITE;
+ ret = -E_AUDIOC_WRITE;
goto out;
}
loaded -= ret;
out:
if (!ret && loaded && buf)
ret = write(STDOUT_FILENO, buf, loaded);
- return ret < 0? -ret : EXIT_SUCCESS;
+ if (ret < 0)
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+ return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
}
filter_errlist_objs="filter_chain wav compress filter string stdin stdout sched fd"
filter_ldflags=""
+audioc_cmdline_objs="audioc.cmdline"
+audioc_errlist_objs="audioc string net fd"
+
audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
http_recv.cmdline dccp_recv.cmdline file_write.cmdline"
audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
server_objs="$server_cmdline_objs $server_errlist_objs"
write_objs="$write_cmdline_objs $write_errlist_objs"
client_objs="$client_cmdline_objs $client_errlist_objs"
+audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
AC_SUBST(recv_objs, add_dot_o($recv_objs))
AC_SUBST(recv_ldflags, $recv_ldflags)
AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
objlist_to_errlist($client_errlist_objs), errors used by para_client)
+AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
+AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
+ objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
+
enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
enum of supported writers)
/** \cond list of all subsystems that support the shiny error facility */
enum para_subsystem {
- SS_CLIENT,
- SS_SCHED,
SS_GUI,
SS_TIME,
SS_WAV,
SS_RECV,
SS_NET,
SS_ORTP_RECV,
+ SS_CLIENT,
+ SS_AUDIOC,
+ SS_SCHED,
SS_AUDIOD,
SS_AUDIOD_COMMAND,
SS_EXEC,
extern const char **para_errlist[];
/** \endcond */
+#define AUDIOC_ERRORS \
+ PARA_ERROR(AUDIOC_SYNTAX, "audioc syntax error"), \
+ PARA_ERROR(AUDIOC_READ, "audioc read error"), \
+ PARA_ERROR(AUDIOC_WRITE, "audioc write error"), \
+ PARA_ERROR(INIT_SOCK_ADDR, "can not init socket"), \
+ PARA_ERROR(AUDIOC_CONNECT, "audioc connect error"), \
+ PARA_ERROR(CREDENTIALS, "failed to send unix socket credentials"), \
+ PARA_ERROR(AUDIOC_OVERRUN, "audioc buffer overrun"), \
+
+
#define CLIENT_ERRORS \
PARA_ERROR(CLIENT_SYNTAX, "syntax error"), \
PARA_ERROR(INVALID_CHALLENGE, "did not receive valid challenge"), \
SS_ENUM(FILE_WRITER);
SS_ENUM(RINGBUFFER);
SS_ENUM(CLIENT);
+SS_ENUM(AUDIOC);
/** \endcond */
#undef PARA_ERROR
/* rest of the world only sees the error text */