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 */
17 DEFINE_RECEIVER_ARRAY;
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 // PARA_DEBUG_LOG("%s, options: %s\n", r->name,
39 // options? options : "(none)");
41 PARA_DEBUG_LOG("options: %s\n", options);
42 argc = split_args(options, &argv, " \t");
43 for (i = argc - 1; i >= 0; i--)
44 argv[i + 1] = argv[i];
48 argv = para_malloc(2 * sizeof(char*));
51 argv[0] = make_message("%s_recv", r->name);
52 conf = r->parse_config(argc, argv);
59 * check if given string is a valid command line for any receiver
61 * \param \ra string of the form receiver_name:options
62 * \param receiver_num contains the number of the receiver upon success
64 * This function checks whether \a ra starts with the name of a supported
65 * paraslash receiver, optinally followed by a colon and any options for that
66 * receiver. If a valid receiver name was found and further are present, the
67 * remaining part of \a ra is passed to that receiver's config parser.
69 * \return On success, a pointer to the gengetopt args info struct is returned
70 * and \a receiver_num contains the number of the receiver. Otherwise this function
73 void *check_receiver_arg(char *ra, int *receiver_num)
77 PARA_DEBUG_LOG("checking %s\n", ra);
78 for (j = 0; receivers[j].name; j++) {
79 const char *name = receivers[j].name;
80 size_t len = strlen(name);
84 if (strncmp(name, ra, len))
89 if (c && !receivers[j].parse_config)
92 return parse_receiver_args(j, c? ra + len + 1: NULL);
94 PARA_ERROR_LOG("receiver not found\n");
99 * Print out the help texts to all receivers.
101 * \param detailed Whether the detailed help should be printed.
103 void print_receiver_helps(int detailed)
107 printf_or_die("\nAvailable receivers: \n\t");
109 printf_or_die("%s%s", i? " " : "", receivers[i].name);
110 printf_or_die("\n\n");
111 FOR_EACH_RECEIVER(i) {
112 struct receiver *r = receivers + i;
113 if (!r->help.short_help)
115 printf_or_die("Options for %s:\n", r->name);
116 ggo_print_help(&r->help, detailed);