--func-name $(subst _write.ggo,,$<)_cmdline_parser < $<
%.cmdline.h %.cmdline.c: %.ggo
- case $< in client.ggo) O="--unamed-opts=command --arg-struct-name=$(subst .ggo,,$<)_args_info";; \
+ case $< in client.ggo) O="--unamed-opts=command";; \
audioc.ggo) O="--unamed-opts=command";; \
esac; \
- gengetopt $$O --conf-parser --file-name=$(*F).cmdline --set-package="para_$(subst .cmdline,,$(*F))" --set-version="$V" < $<
+ gengetopt $$O \
+ --conf-parser \
+ --file-name=$(*F).cmdline \
+ --func-name $(*F)_cmdline_parser \
+ --arg-struct-name=$(*F)_args_info \
+ --set-package="para_$(subst .cmdline,,$(*F))" \
+ --set-version="$V" < $<
aacdec.o: aacdec.c
$(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
- Support for m4a files via the new aac filter/ and audio
format handler. (requires libfaad)
- new writer: osxplay (thanks to Gerd Becker)
- - writers are integrated into para_audiod
+ - writers are integrated in para_audiod
+ - para_client is integrated in para_audiod
- each writer of para_write has its own command line parser,
just like para_recv and para_filter.
- random/playlist selector: improved info strings
extern struct misc_meta_data *mmd;
extern struct audio_file_selector selectors[];
extern struct sender senders[];
-extern struct gengetopt_args_info conf;
static FILE *audio_file = NULL;
INIT_AUDIOC_ERRLISTS;
-struct gengetopt_args_info conf;
+struct audioc_args_info conf;
char *tmpfifo;
*buf = NULL, *hn = para_hostname(), *args, *home = para_homedir();
- if (cmdline_parser(argc, argv, &conf))
+ if (audioc_cmdline_parser(argc, argv, &conf))
goto out;
cf = configfile_exists();
if (cf) {
- if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) {
+ if (audioc_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) {
fprintf(stderr, "parse error in config file\n");
exit(EXIT_FAILURE);
}
#include "audiod.cmdline.h"
#include "list.h"
-#include "close_on_fork.h"
#include "sched.h"
#include "recv.h"
#include "filter.h"
#include "grab_client.cmdline.h"
#include "grab_client.h"
-
-#include "error.h"
+#include "client.cmdline.h"
+#include "client.h"
#include "audiod.h"
#include "net.h"
#include "daemon.h"
#include "fd.h"
#include "write.h"
#include "write_common.h"
+#include "error.h"
/** define the array of error lists needed by para_audiod */
INIT_AUDIOD_ERRLISTS;
int audiod_status = AUDIOD_ON;
-struct gengetopt_args_info conf;
+struct audiod_args_info conf;
static char *socket_name;
static FILE *logfile;
static struct audio_format_info afi[NUM_AUDIO_FORMATS];
PARA_INFO_LOG("signal pipe: fd %d\n", sig_task->fd);
para_install_sighandler(SIGINT);
para_install_sighandler(SIGTERM);
- para_install_sighandler(SIGCHLD);
para_install_sighandler(SIGHUP);
- para_install_sighandler(SIGPIPE);
-// signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
}
static void clear_slot(int slot_num)
{
int i;
- if (stat_task->fd < 0)
+ if (!stat_task->pcd)
return;
- PARA_NOTICE_LOG("%s", "closing status pipe\n");
- close(stat_task->fd);
- del_close_on_fork_list(stat_task->fd);
- stat_task->fd = -1;
-// kill_all_decoders();
+ client_close(stat_task->pcd);
+ stat_task->pcd = NULL;
for (i = 0; i < NUM_STAT_ITEMS; i++) {
free(stat_task->stat_item_values[i]);
stat_task->stat_item_values[i] = NULL;
int i;
struct timeval diff;
- if (!stat_task->af_status)
+ if (!stat_task->af_status || !stat_task->pcd)
return 0;
i = get_audio_format_num(stat_task->af_status);
if (i < 0)
static void handle_signal(int sig)
{
switch (sig) {
- case SIGCHLD:
- for (;;) {
- pid_t pid = para_reap_child();
- if (pid <= 0)
- return;
- PARA_CRIT_LOG("para_client died (pid %d)\n", pid);
- }
case SIGINT:
case SIGTERM:
case SIGHUP:
PARA_EMERG_LOG("%s", "can not listen on socket\n");
exit(EXIT_FAILURE); /* do not unlink socket */
}
- add_close_on_fork_list(fd);
mark_fd_nonblock(fd);
return fd;
}
-static int open_stat_pipe(void)
-{
- int ret, fd[3] = {-1, 1, 0};
- pid_t pid;
- ret = para_exec_cmdline_pid(&pid, BINDIR "/para_client stat", fd);
- if (ret >= 0) {
- ret = fd[1];
- PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
- add_close_on_fork_list(ret);
- mark_fd_nonblock(ret);
- } else
- clean_exit(EXIT_FAILURE, "failed to open status pipe");
- return ret;
-}
-
void signal_event_handler(struct task *t)
{
struct signal_task *st = t->private_data;
sprintf(ct->task.status, "command task");
}
+static void client_task_event_handler(__a_unused struct task *t)
+{
+ struct private_client_data *pcd = t->private_data;
+ if (t->ret == -E_HANDSHAKE_COMPLETE)
+ return;
+ unregister_task(t);
+ pcd->eof = 1;
+}
+
static void status_event_handler(__a_unused struct task *t)
{
struct timeval delay = {1, 0};
static void status_pre_select(struct sched *s, struct task *t)
{
struct status_task *st = t->private_data;
+ int argc = 2;
+ char *argv[] = {"audiod", "stat", NULL};
t->ret = 1;
- if (st->fd >= 0 && audiod_status == AUDIOD_OFF)
+ if (st->pcd && (audiod_status == AUDIOD_OFF || st->pcd->eof))
close_stat_pipe();
- if (st->fd < 0 && audiod_status != AUDIOD_OFF
+ if (!st->pcd && audiod_status != AUDIOD_OFF
&& tv_diff(now, &st->restart_barrier, NULL) > 0) {
- st->fd = open_stat_pipe();
- st->loaded = 0;
- st->buf[0] = '\0';
+ t->ret = client_parse_config(argc, argv, &st->pcd);
+ if (t->ret < 0)
+ return;
+ t->ret = client_open(st->pcd);
+ if (t->ret < 0)
+ return;
+ st->pcd->task.event_handler = client_task_event_handler;
+ s->timeout.tv_sec = 0;
+ s->timeout.tv_usec = 1;
}
- if (st->fd >= 0 && audiod_status != AUDIOD_OFF)
- para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
-static void status_post_select(struct sched *s, struct task *t)
+static void status_post_select(__a_unused struct sched *s, struct task *t)
{
struct status_task *st = t->private_data;
t->ret = 1;
- if (st->fd < 0 || !FD_ISSET(st->fd, &s->rfds))
- return;
- t->ret = read(st->fd, st->buf + st->loaded, STRINGSIZE - 1 - st->loaded);
- if (t->ret <= 0) {
- if (!t->ret)
- t->ret = -E_STATUS_EOF;
+ if (!st->pcd || !st->pcd->loaded
+ || st->pcd->status != CL_RECEIVING_SERVER_OUTPUT)
return;
- }
- st->buf[t->ret + st->loaded] = '\0';
- st->loaded = for_each_line(st->buf, t->ret + st->loaded,
+ st->pcd->loaded = for_each_line(st->pcd->buf, st->pcd->loaded,
&check_stat_line);
}
st->task.post_select = status_post_select;
st->task.event_handler = status_event_handler;
st->task.private_data = st;
- st->fd = -1;
st->sa_time_diff_sign = 1;
sprintf(st->task.status, "status task");
}
struct task audiod_task_struct, *audiod_task = &audiod_task_struct;
valid_fd_012();
- cmdline_parser(argc, argv, &conf);
+ audiod_cmdline_parser(argc, argv, &conf);
para_drop_privileges(conf.user_arg, conf.group_arg);
cf = configfile_exists();
if (cf) {
- if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) {
+ if (audiod_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) {
PARA_EMERG_LOG("%s", "parse error in config file\n");
exit(EXIT_FAILURE);
}
register_task(&cmd_task->task);
register_task(&stat_task->task);
register_task(audiod_task);
- s.default_timeout.tv_sec = 3;
+ s.default_timeout.tv_sec = 0;
s.default_timeout.tv_usec = 99 * 1000;
ret = sched(&s);
* \sa struct task, struct sched
*/
struct status_task {
- /** the output of the stat command is read from this fd */
- int fd;
- /** stat data is stored here */
- char buf[STRINGSIZE];
- /** number of bytes loaded in \a buf */
- unsigned loaded;
+ /** the associated task structure of audiod */
+ struct task task;
+ struct private_client_data *pcd;
/** the array of status items sent by para_server */
char *stat_item_values[NUM_STAT_ITEMS];
- /** the associated task structure */
- struct task task;
/** do not restart client command until this time */
struct timeval restart_barrier;
/** the offset value announced by para_server */
extern struct status_task *stat_task;
extern struct slot_info slot[MAX_STREAM_SLOTS];
-extern struct gengetopt_args_info conf;
+extern struct audiod_args_info conf;
extern int audiod_status;
extern const char *status_item_list[NUM_STAT_ITEMS];
#include "net.h"
#include "fd.h"
#include "string.h"
+#include "client.cmdline.h"
#include "client.h"
#include "error.h"
para_calloc(sizeof(struct private_client_data));
pcd->fd = -1;
- cmdline_parser(argc, argv, &pcd->conf);
+ client_cmdline_parser(argc, argv, &pcd->conf);
ret = - E_CLIENT_SYNTAX;
if (!pcd->conf.inputs_num)
goto out;
goto out;
}
if (!ret)
- cmdline_parser_configfile(pcd->config_file, &pcd->conf, 0, 0, 0);
+ client_cmdline_parser_configfile(pcd->config_file,
+ &pcd->conf, 0, 0, 0);
ret = 1;
*pcd_ptr = pcd;
PARA_INFO_LOG(
{
struct private_client_data *pcd = t->private_data;
- PARA_INFO_LOG("status %d\n", pcd->status);
t->ret = 1;
pcd->check_r = 0;
pcd->check_w = 0;
{
struct private_client_data *pcd = t->private_data;
- PARA_INFO_LOG("status %d\n", pcd->status);
+// PARA_INFO_LOG("status %d\n", pcd->status);
t->ret = 1;
if (pcd->fd < 0)
return;
if (t->ret < 0)
return;
bytes_received = t->ret;
- PARA_INFO_LOG("++++ server info ++++\n%s\n++++ end of server "
+ PARA_DEBUG_LOG("++++ server info ++++\n%s\n++++ end of server "
"info ++++\n", pcd->buf);
/* check if server has sent "Proceed" message */
t->ret = -E_CLIENT_AUTH;
free(tmp);
}
command = para_strcat(command, EOC_MSG "\n");
- PARA_INFO_LOG("--> %s\n", command);
+ PARA_DEBUG_LOG("--> %s\n", command);
t->ret = send_buffer(pcd->fd, command);
free(command);
if (t->ret > 0)
extern const char *status_item_list[NUM_STAT_ITEMS];
extern struct misc_meta_data *mmd;
-extern struct gengetopt_args_info conf;
extern struct audio_file_selector selectors[];
extern struct sender senders[];
extern char *user_list;
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
+ http_recv.cmdline dccp_recv.cmdline file_write.cmdline client.cmdline"
+audiod_errlist_objs="audiod signal string daemon stat net
time grab_client filter_chain wav compress http_recv dccp dccp_recv
- recv_common fd sched write_common file_writer audiod_command"
+ recv_common fd sched write_common file_writer audiod_command crypt
+ client_common"
audiod_ldflags=""
server_cmdline_objs="server.cmdline"
CHECK_SSL($enable_ssldir)
server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
+audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
########################################################################### ucred
#include "fd.h"
#include "close_on_fork.h"
#include "server.cmdline.h"
-extern struct gengetopt_args_info conf;
+
/** the list of connected clients **/
static struct list_head clients;
static int listen_fd = -1;
#include "string.h"
-struct gengetopt_args_info args_info;
+struct fade_args_info args_info;
void para_log(__a_unused int ll, const char *fmt,...)
{
{
int ret;
- if (cmdline_parser(argc, argv, &args_info))
+ if (fade_cmdline_parser(argc, argv, &args_info))
exit(EXIT_FAILURE);
ret = configfile_exists();
if (!ret && args_info.config_file_given) {
exit(EXIT_FAILURE);
}
if (ret)
- cmdline_parser_configfile(args_info.config_file_arg,
+ fade_cmdline_parser_configfile(args_info.config_file_arg,
&args_info, 0, 0, 0);
if ((ret = open_mixer()) < 0) {
PARA_EMERG_LOG("can not open mixer device %s.",
static struct stdout_task stdout_task_struct;
static struct stdout_task *sot = &stdout_task_struct;
-struct gengetopt_args_info conf;
+struct filter_args_info conf;
__printf_2_3 void para_log(int ll, const char* fmt,...)
{
struct stat statbuf;
int i;
- if (cmdline_parser(argc, argv, &conf))
+ if (filter_cmdline_parser(argc, argv, &conf))
return -E_FILTER_SYNTAX;
if (!cf) {
char *home = para_homedir();
free(home);
}
if (!stat(cf, &statbuf)) {
- if (cmdline_parser_configfile(cf, &conf, 0, 0, 0))
+ if (filter_cmdline_parser_configfile(cf, &conf, 0, 0, 0))
return -E_FILTER_SYNTAX;
}
if (!conf.list_filters_given)
*/
#include "para.h"
-#include "close_on_fork.h"
#include "grab_client.cmdline.h"
#include "list.h"
#include "sched.h"
if (gc->conf->one_shot_given || gc->error) {
PARA_INFO_LOG("closing fd %d (grab client %p)\n", gc->fd, gc);
- del_close_on_fork_list(gc->fd);
close(gc->fd);
gc_free(gc);
/* close on fork ?*/
static int command_pipe = -1;
static int audiod_pipe = -1;
-static struct gengetopt_args_info conf;
+static struct gui_args_info conf;
enum {GETCH_MODE, COMMAND_MODE, EXTERNAL_MODE};
return;
}
PARA_INFO_LOG("%s", "rereading command line options and config file");
- cmdline_parser(_argc, _argv, &conf);
- cmdline_parser_configfile(cf, &conf, 1, 1, 0);
+ gui_cmdline_parser(_argc, _argv, &conf);
+ gui_cmdline_parser_configfile(cf, &conf, 1, 1, 0);
PARA_NOTICE_LOG("%s", "configuration read");
if (check_key_map_args() < 0)
finish(EXIT_FAILURE);
_argc = argc;
_argv = argv;
- if (cmdline_parser(argc, argv, &conf)) {
+ if (gui_cmdline_parser(argc, argv, &conf)) {
fprintf(stderr, "parse error while reading command line\n");
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
if (cf)
- cmdline_parser_configfile(cf, &conf, 0, 0, 0);
+ gui_cmdline_parser_configfile(cf, &conf, 0, 0, 0);
if (check_key_map_args() < 0) {
fprintf(stderr, "invalid key map in config file\n");
exit(EXIT_FAILURE);
if (!FD_ISSET(phd->fd, &s->wfds))
goto out;
rq = make_request_msg();
- PARA_NOTICE_LOG("%s", "sending http request\n");
+ PARA_INFO_LOG("%s", "sending http request\n");
t->ret = send_va_buffer(phd->fd, "%s", rq);
free(rq);
if (t->ret > 0)
t->ret = recv_pattern(phd->fd, HTTP_OK_MSG, MAXLINE);
if (t->ret < 0)
goto out;
- PARA_NOTICE_LOG("%s", "received ok msg, streaming\n");
+ PARA_INFO_LOG("%s", "received ok msg, streaming\n");
t->ret = 1;
phd->status = HTTP_STREAMING;
goto out;
rn->buf = para_calloc(BUFSIZE);
rn->private_data = para_calloc(sizeof(struct private_http_recv_data));
phd = rn->private_data;
- PARA_NOTICE_LOG("phd = %p, rn = %p\n", phd, rn);
ret = get_host_info(conf->host_arg, &he);
if (!ret < 0)
goto err_out;
#define HTTP_ERR_MSG "HTTP/1.0 400 Bad Request\n"
/** \endcond */
-extern struct gengetopt_args_info conf;
-
/** the possible states of a client from the server's POV */
enum http_status {
HTTP_CONNECTED,
#include "net.h"
#include "string.h"
-extern struct gengetopt_args_info conf;
/** pointer to the shared memory area */
extern struct misc_meta_data *mmd;
#define TARGET_ADDR(oc) inet_ntoa((oc)->addr)
/** \endcond */
-extern struct gengetopt_args_info conf;
-
/** describes one entry in the list of targets for the ortp sender */
struct ortp_target {
/** address info */
#include "string.h"
static int com_random_info(int, int, char **);
-extern struct gengetopt_args_info conf;
extern struct misc_meta_data *mmd;
static unsigned int num_audio_files, audio_file_count;
#include "error.h"
#include "stdout.h"
-struct gengetopt_args_info conf;
+struct recv_args_info conf;
INIT_RECV_ERRLISTS;
{
int i;
- if (cmdline_parser(argc, argv, &conf))
+ if (recv_cmdline_parser(argc, argv, &conf))
return NULL;
if (conf.list_receivers_given) {
printf("available receivers: ");
static int height = 0;
extern const char *status_item_list[NUM_STAT_ITEMS];
-struct gengetopt_args_info args_info;
+struct sdl_gui_args_info args_info;
#define FRAME_WIDTH 10
#define FONT_HEIGHT 36
int i, ret, pipe;
SDLKey sym;
- cmdline_parser(argc, argv, &args_info);
+ sdl_gui_cmdline_parser(argc, argv, &args_info);
ret = configfile_exists();
// printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg);
exit(EXIT_FAILURE);
}
if (ret)
- cmdline_parser_configfile(args_info.config_file_arg,
+ sdl_gui_cmdline_parser_configfile(args_info.config_file_arg,
&args_info, 0, 0, 0);
signal(SIGCHLD, SIG_IGN);
width = args_info.width_arg;
* It also contains the options for all audio file selectors and all supported
* senders.
*/
-struct gengetopt_args_info conf;
+struct server_args_info conf;
char *user_list = NULL;
extern void dccp_send_init(struct sender *);
extern void http_send_init(struct sender *);
}
if (!ret) {
int tmp = conf.daemon_given;
- cmdline_parser_configfile(cf, &conf, override, 0, 0);
+ server_cmdline_parser_configfile(cf, &conf, override, 0, 0);
conf.daemon_given = tmp;
}
/* logfile */
init_random_seed();
/* parse command line options */
- cmdline_parser(argc, argv, &conf);
+ server_cmdline_parser(argc, argv, &conf);
para_drop_privileges(conf.user_arg, conf.group_arg);
/* parse config file, open log and set defaults */
parse_config(0);
struct sender_command_data sender_cmd_data;
};
+extern struct server_args_info conf;
int handle_connect(int fd, struct sockaddr_in *addr);
void mmd_unlock(void);
new_client = para_malloc(sizeof(struct stat_client));
new_client->fd = fd;
new_client->item_mask = mask;
- add_close_on_fork_list(fd);
list_add(&new_client->node, &client_list);
dump_stat_client_list();
num_clients++;
}
/* write error or fd not ready for writing */
close(fd);
- del_close_on_fork_list(fd);
num_clients--;
PARA_INFO_LOG("deleting client on fd %d\n", fd);
list_del(&sc->node);
struct task task;
};
-static struct gengetopt_args_info conf;
+static struct write_args_info conf;
struct stdin_task sit;
struct check_wav_task cwt;
struct initial_delay_task idt;
int ret = -E_WRITE_SYNTAX;
struct sched s;
- cmdline_parser(argc, argv, &conf);
+ write_cmdline_parser(argc, argv, &conf);
init_supported_writers();
wng = check_args();