1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
* (c) BayCom GmbH, http://www.baycom.de, info@baycom.de
*
* See the COPYING file for copyright information and
* how to reach the author.
*
*/
#include "headers.h"
#define CI_RESET_WAIT 10
#ifdef __MINGW32__
#include <getopt.h>
#endif
cmdline_t cmd;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
static void print_help (int argc, char *argv[])
{
printf ("Usage:\n" \
" mcli --ifname <network interface>\n" \
" mcli --port <port> (default: -port 23000)\n" \
" mcli --dvb-s <num> --dvb-c <num> --dvb-t <num> --atsc <num> --dvb-s2 <num>\n" \
" limit number of device types (default: 8 of every type)\n" \
" mcli --diseqc-conf <filepath>\n" \
" mcli --rotor-conf <filepath>\n" \
" mcli --mld-reporter-disable\n" \
" mcli --sock-path <filepath>\n"\
" mcli --ca-enable <bitmask>\n"\
" mcli --ci-timeout <time>\n"\
" mcli --vdr-diseqc-bind <0|1>\n"\
" mcli --reel-cam-mode\n"\
"\n");
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
static void init_cmd_line_parameters ()
{
int i;
memset (&cmd, 0, sizeof (cmdline_t));
for (i=0; i<=FE_DVBS2; i++) {
cmd.tuner_type_limit[i] = 8;
}
cmd.port = 23000;
cmd.mld_start = 1;
cmd.ca_enable = 3;
cmd.vdrdiseqcmode = 1;
cmd.reelcammode = 0;
cmd.ci_timeout = CI_RESET_WAIT;
strcpy (cmd.cmd_sock_path, API_SOCK_NAMESPACE);
cmd.disec_conf_path[0]=0;
cmd.rotor_conf_path[0]=0;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void get_options (int argc, char *argv[])
{
int tuners = 0, i;
char c;
int ret;
//init parameters
init_cmd_line_parameters ();
while (1) {
//int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
{"port", 1, 0, 0}, //0
{"ifname", 1, 0, 0}, //1
{"help", 0, 0, 0}, //2
{"dvb-s", 1, 0, 0}, //3
{"dvb-c", 1, 0, 0}, //4
{"dvb-t", 1, 0, 0}, //5
{"atsc", 1, 0, 0}, //6
{"dvb-s2", 1, 0, 0}, //7
{"diseqc-conf", 1, 0, 0}, //8
{"mld-reporter-disable", 0, 0, 0}, //9
{"sock-path", 1, 0, 0}, //10
{"ca-enable", 1, 0, 0}, //11
{"ci-timeout", 1, 0, 0}, //12
{"vdr-diseqc-bind", 1, 0, 0}, //13
{"reel-cam-mode", 0, 0, 0}, //14
{"rotor-conf", 1, 0, 0}, //15
{NULL, 0, 0, 0}
};
ret = getopt_long_only (argc, argv, "", long_options, &option_index);
c=(char)ret;
if (ret == -1 || c == '?') {
break;
}
switch (option_index) {
case 0:
cmd.port = atoi (optarg);
break;
case 1:
strncpy (cmd.iface, optarg, IFNAMSIZ-1);
break;
case 2:
print_help (argc, argv);
exit (0);
break;
case 3:
case 4:
case 5:
case 6:
case 7:
i = atoi (optarg);
if (!tuners) {
memset (cmd.tuner_type_limit, 0, sizeof (cmd.tuner_type_limit));
}
cmd.tuner_type_limit[option_index - 3] = i;
tuners += i;
break;
case 8:
strncpy (cmd.disec_conf_path, optarg, _POSIX_PATH_MAX-1);
break;
case 9:
cmd.mld_start = 0;
break;
case 10:
strncpy (cmd.cmd_sock_path, optarg, _POSIX_PATH_MAX-1);
break;
case 11:
cmd.ca_enable=atoi(optarg);
break;
case 12:
cmd.ci_timeout=atoi(optarg);
break;
case 13:
cmd.vdrdiseqcmode=atoi(optarg);
break;
case 14:
cmd.reelcammode = 1;
break;
case 15:
strncpy (cmd.rotor_conf_path, optarg, _POSIX_PATH_MAX-1);
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
}
|