2 * Copyright (C) 2006-2007 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 */
16 DEFINE_RECEIVER_ARRAY;
17 static void *parse_receiver_args(int receiver_num, char *options)
19 struct receiver *r = &receivers[receiver_num];
25 // PARA_DEBUG_LOG("%s, options: %s\n", r->name,
26 // options? options : "(none)");
28 PARA_DEBUG_LOG("options: %s\n", options);
29 argc = split_args(options, &argv, " \t");
30 for (i = argc - 1; i >= 0; i--)
31 argv[i + 1] = argv[i];
32 argv[0] = para_strdup(r->name);
34 PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
37 argv = para_malloc(2 * sizeof(char*));
41 conf = r->parse_config(argc, argv);
48 * check if given string is a valid command line for any receiver
50 * \param \ra string of the form receiver_name:options
51 * \param receiver_num contains the number of the receiver upon success
53 * This function checks whether \a ra starts with the name of a supported
54 * paraslash receiver, optinally followed by a colon and any options for that
55 * receiver. If a valid receiver name was found and further are present, the
56 * remaining part of \a ra is passed to that receiver's config parser.
58 * \return On success, a pointer to the gengetopt args info struct is returned
59 * and \a receiver_num contains the number of the receiver. Otherwise this function
62 void *check_receiver_arg(char *ra, int *receiver_num)
66 PARA_DEBUG_LOG("checking %s\n", ra);
67 for (j = 0; receivers[j].name; j++) {
68 const char *name = receivers[j].name;
69 size_t len = strlen(name);
73 if (strncmp(name, ra, len))
78 if (c && !receivers[j].parse_config)
81 return parse_receiver_args(j, c? ra + len + 1: NULL);
83 PARA_ERROR_LOG("%s", "receiver not found\n");