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 DEFINE_RECEIVER_ARRAY;
21 * Call the init function of each paraslash receiver.
28 receivers[i].init(&receivers[i]);
31 static void *parse_receiver_args(int receiver_num, char *options)
33 struct receiver *r = &receivers[receiver_num];
39 PARA_DEBUG_LOG("%s, options: %s\n", r->name,
40 options? options : "(none)");
42 PARA_DEBUG_LOG("options: %s\n", options);
43 argc = create_argv(options, " \t", &argv);
46 for (i = argc - 1; i >= 0; i--)
47 argv[i + 1] = argv[i];
52 argv = para_malloc(2 * sizeof(char*));
56 conf = r->parse_config(argc, argv);
57 for (i = 1; i < argc; i++)
64 * check if given string is a valid command line for any receiver
66 * \param \ra string of the form receiver_name:options
67 * \param receiver_num contains the number of the receiver upon success
69 * This function checks whether \a ra starts with the name of a supported
70 * paraslash receiver, optinally followed by a colon and any options for that
71 * receiver. If a valid receiver name was found and further are present, the
72 * remaining part of \a ra is passed to that receiver's config parser.
74 * \return On success, a pointer to the gengetopt args info struct is returned
75 * and \a receiver_num contains the number of the receiver. Otherwise this function
78 void *check_receiver_arg(char *ra, int *receiver_num)
82 PARA_DEBUG_LOG("checking %s\n", ra);
83 for (j = 0; receivers[j].name; j++) {
84 const char *name = receivers[j].name;
85 size_t len = strlen(name);
89 if (strncmp(name, ra, len))
94 if (c && !receivers[j].parse_config)
97 return parse_receiver_args(j, c? ra + len + 1: NULL);
99 PARA_ERROR_LOG("receiver not found\n");
104 * Print out the help texts to all receivers.
106 * \param detailed Whether the detailed help should be printed.
108 void print_receiver_helps(int detailed)
112 printf_or_die("\nAvailable receivers: \n\t");
114 printf_or_die("%s%s", i? " " : "", receivers[i].name);
115 printf_or_die("\n\n");
116 FOR_EACH_RECEIVER(i) {
117 struct receiver *r = receivers + i;
118 if (!r->help.short_help)
120 printf_or_die("Options for %s:\n", r->name);
121 ggo_print_help(&r->help, detailed);