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
146
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/***************************************************************************
* multicast_configuration.cc
*
* Wed Oct 12 10:12:11 CEST 2005
* Copyright 2005 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
/*
* This file is part of MIaV.
*
* MIaV is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MIaV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
/*
#include "config.h"
#include "multicast_configuration.h"
#include "info.h"
MulticastConfiguration::MulticastConfiguration(char *file)
: MiavConfig(file)
{
mcastconf_t conf;
// Create the default values.
global_conf.addr = "224.0.0.1";
global_conf.port = 1234;
global_conf.enabled = false;
global_conf.with_audio = false;
bool global = true;
_cfg *cfg = configs;
// Build the client list
while(cfg) {
if(strcmp(cfg->name->c_str(), "client") == 0) {
if(!global) confs.push_back(conf);
// Reset the configuration to the defaults
conf.client = *(cfg->stringval);
conf.addr = global_conf.addr;
conf.port = global_conf.port;
conf.enabled = global_conf.enabled;
conf.with_audio = global_conf.with_audio;
global = false;
}
if(strcmp(cfg->name->c_str(), "address") == 0) {
if(global) global_conf.addr = *(cfg->stringval);
else conf.addr = *(cfg->stringval);
}
if(strcmp(cfg->name->c_str(), "port") == 0) {
if(global) global_conf.port = cfg->intval;
else conf.port = cfg->intval;
}
if(strcmp(cfg->name->c_str(), "enabled") == 0) {
if(global) global_conf.enabled = cfg->boolval;
else conf.enabled = cfg->boolval;
}
if(strcmp(cfg->name->c_str(), "with_audio") == 0) {
if(global) global_conf.with_audio = cfg->boolval;
else conf.with_audio = cfg->boolval;
}
cfg = cfg->next;
}
if(!global) confs.push_back(conf);
// Show the configuration in the log file .
MIaV::info->info("Global - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
global_conf.enabled?"Yes\0":"No\0",
global_conf.addr.c_str(),
global_conf.port,
global_conf.with_audio?"Yes\0":"No\0");
for(unsigned int cnt = 0; cnt < confs.size(); cnt++) {
MIaV::info->info("Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
confs[cnt].client.c_str(),
confs[cnt].enabled?"Yes\0":"No\0",
confs[cnt].addr.c_str(),
confs[cnt].port,
confs[cnt].with_audio?"Yes\0":"No\0");
}
MIaV::info->info("Chosing:");
}
MulticastConfiguration::~MulticastConfiguration()
{
}
mcastconf_t &MulticastConfiguration::getConf(char *client)
{
for(unsigned int cnt = 0; cnt < confs.size(); cnt++) {
if(strcmp(confs[cnt].client.c_str(), client) == 0)
return confs[cnt];
}
return global_conf;
}
*/
#ifdef __TEST_MULTICAST_CONFIGURATION
#include "info_simple.h"
int main(int argc, char *argv[]) {
if(argc < 2) {
fprintf(stderr, "usage:\n\t%s [filename]\n", argv[0]);
return 1;
}
InfoSimple info;
MulticastConfiguration conf(&info, argv[1]);
mcastconf_t mcconf = conf.getConf("192.168.0.11");
info.warn("Client: %s - Enabled: %s - Addr: %s - Port: %d",
mcconf.client.c_str(),
mcconf.enabled?"Yes\0":"No\0",
mcconf.addr.c_str(),
mcconf.port);
mcconf = conf.getConf("192.168.0.0");
info.warn("Client: %s - Enabled: %s - Addr: %s - Port: %d",
mcconf.client.c_str(),
mcconf.enabled?"Yes\0":"No\0",
mcconf.addr.c_str(),
mcconf.port);
}
#endif/* __TEST_MULTICAST_CONFIGURATION*/
|