59630dfcc5f5f6fc5cfa973fd25c4476366b6b92
2 * Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file recv_common.c common functions of para_recv and para_audiod */
15 #include "buffer_tree.h"
20 * Call the init function of each paraslash receiver.
27 receivers
[i
].init(&receivers
[i
]);
30 static void *parse_receiver_args(int receiver_num
, char *options
)
32 struct receiver
*r
= &receivers
[receiver_num
];
38 argc
= create_shifted_argv(options
, " \t", &argv
);
43 argv
= para_malloc(2 * sizeof(char*));
46 argv
[0] = make_message("%s_recv", r
->name
);
47 conf
= r
->parse_config(argc
, argv
);
53 * Check if the given string is a valid receiver specifier.
55 * \param \ra string of the form receiver_name:options
56 * \param receiver_num contains the number of the receiver upon success
58 * This function checks whether \a ra starts with the name of a receiver,
59 * optionally followed by options for that receiver. If a valid receiver name
60 * was found the remaining part of \a ra is passed to the receiver's config
63 * \return On success, a pointer to the receiver-specific gengetopt args info
64 * struct is returned and \a receiver_num contains the number of the receiver.
65 * On errors, the function returns \p NULL.
67 void *check_receiver_arg(char *ra
, int *receiver_num
)
71 PARA_DEBUG_LOG("checking %s\n", ra
);
72 for (j
= 0; receivers
[j
].name
; j
++) {
73 const char *name
= receivers
[j
].name
;
74 size_t len
= strlen(name
);
78 if (strncmp(name
, ra
, len
))
83 if (c
&& !receivers
[j
].parse_config
)
86 return parse_receiver_args(j
, c
? ra
+ len
+ 1: NULL
);
88 PARA_ERROR_LOG("receiver not found\n");
93 * Print out the help texts to all receivers.
95 * \param flags Passed to \ref ggo_print_help().
97 void print_receiver_helps(unsigned flags
)
101 printf_or_die("\nAvailable receivers: ");
103 printf_or_die("%s%s", i
? " " : "", receivers
[i
].name
);
105 FOR_EACH_RECEIVER(i
) {
106 struct receiver
*r
= receivers
+ i
;
107 if (!r
->help
.short_help
)
109 printf_or_die("\n%s: %s", r
->name
,
111 ggo_print_help(&r
->help
, flags
);
116 * Simple pre-select hook, used by all receivers.
118 * \param s Scheduler info.
119 * \param rn The receiver node.
121 * This requests a minimal delay from the scheduler if the status of the buffer
122 * tree node indicates an error/eof condition. No file descriptors are added to
123 * the fd sets of \a s.
125 * \return The status of the btr node of the receiver node, i.e. the return
126 * value of the underlying call to \ref btr_node_status().
128 int generic_recv_pre_select(struct sched
*s
, struct receiver_node
*rn
)
130 int ret
= btr_node_status(rn
->btrn
, 0, BTR_NT_ROOT
);