2 * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file recv_common.c common functions of para_recv and para_audiod */
18 #include "buffer_tree.h"
20 DEFINE_RECEIVER_ARRAY
;
23 * Call the init function of each paraslash receiver.
30 receivers
[i
].init(&receivers
[i
]);
33 static void *parse_receiver_args(int receiver_num
, char *options
)
35 struct receiver
*r
= &receivers
[receiver_num
];
41 PARA_DEBUG_LOG("%s, options: %s\n", r
->name
,
42 options
? options
: "(none)");
44 PARA_DEBUG_LOG("options: %s\n", options
);
45 argc
= create_argv(options
, " \t", &argv
);
48 for (i
= argc
- 1; i
>= 0; i
--)
49 argv
[i
+ 1] = argv
[i
];
54 argv
= para_malloc(2 * sizeof(char*));
58 conf
= r
->parse_config(argc
, argv
);
59 for (i
= 1; i
< argc
; i
++)
66 * check if given string is a valid command line for any receiver
68 * \param \ra string of the form receiver_name:options
69 * \param receiver_num contains the number of the receiver upon success
71 * This function checks whether \a ra starts with the name of a supported
72 * paraslash receiver, optinally followed by a colon and any options for that
73 * receiver. If a valid receiver name was found and further are present, the
74 * remaining part of \a ra is passed to that receiver's config parser.
76 * \return On success, a pointer to the gengetopt args info struct is returned
77 * and \a receiver_num contains the number of the receiver. Otherwise this function
80 void *check_receiver_arg(char *ra
, int *receiver_num
)
84 PARA_DEBUG_LOG("checking %s\n", ra
);
85 for (j
= 0; receivers
[j
].name
; j
++) {
86 const char *name
= receivers
[j
].name
;
87 size_t len
= strlen(name
);
91 if (strncmp(name
, ra
, len
))
96 if (c
&& !receivers
[j
].parse_config
)
99 return parse_receiver_args(j
, c
? ra
+ len
+ 1: NULL
);
101 PARA_ERROR_LOG("receiver not found\n");
106 * Print out the help texts to all receivers.
108 * \param detailed Whether the detailed help should be printed.
110 void print_receiver_helps(int detailed
)
114 printf_or_die("\nAvailable receivers: \n\t");
116 printf_or_die("%s%s", i
? " " : "", receivers
[i
].name
);
117 printf_or_die("\n\n");
118 FOR_EACH_RECEIVER(i
) {
119 struct receiver
*r
= receivers
+ i
;
120 if (!r
->help
.short_help
)
122 printf_or_die("Options for %s:\n", r
->name
);
123 ggo_print_help(&r
->help
, detailed
);
127 int generic_recv_pre_select(struct sched
*s
, struct task
*t
)
129 struct receiver_node
*rn
= container_of(t
, struct receiver_node
, task
);
130 int ret
= btr_node_status(rn
->btrn
, 0, BTR_NT_ROOT
);
134 s
->timeout
.tv_sec
= 0;
135 s
->timeout
.tv_usec
= 1;