157 } |
157 } |
158 |
158 |
159 return list; |
159 return list; |
160 } |
160 } |
161 |
161 |
|
162 /*****************************************************************************/ |
|
163 |
|
164 bool operator<( |
|
165 const ec_ioctl_config_t &a, |
|
166 const ec_ioctl_config_t &b |
|
167 ) |
|
168 { |
|
169 return a.alias < b.alias |
|
170 || (a.alias == b.alias && a.position < b.position); |
|
171 } |
|
172 |
|
173 /*****************************************************************************/ |
|
174 |
|
175 Command::ConfigList Command::selectedConfigs(MasterDevice &m) |
|
176 { |
|
177 unsigned int i; |
|
178 int effAlias; |
|
179 ec_ioctl_master_t master; |
|
180 ec_ioctl_config_t config; |
|
181 ConfigList list; |
|
182 stringstream err; |
|
183 |
|
184 m.getMaster(&master); |
|
185 |
|
186 // Assume alias 0 if only position is given. |
|
187 if (alias == -1 && position != -1) { |
|
188 effAlias = 0; |
|
189 } else { |
|
190 effAlias = alias; |
|
191 } |
|
192 |
|
193 if (effAlias == -1) { // no alias given |
|
194 if (position == -1) { // no alias and position given |
|
195 // all items |
|
196 for (i = 0; i < master.config_count; i++) { |
|
197 m.getConfig(&config, i); |
|
198 list.push_back(config); |
|
199 } |
|
200 } |
|
201 } else { // alias given |
|
202 if (position == -1) { // alias, but no position given |
|
203 // take all items with a given alias |
|
204 for (i = 0; i < master.config_count; i++) { |
|
205 m.getConfig(&config, i); |
|
206 if (config.alias == effAlias) { |
|
207 list.push_back(config); |
|
208 } |
|
209 } |
|
210 } else { // alias and position given |
|
211 for (i = 0; i < master.config_count; i++) { |
|
212 m.getConfig(&config, i); |
|
213 if (config.alias == effAlias && config.position == position) { |
|
214 list.push_back(config); |
|
215 break; // there can be at most one matching |
|
216 } |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 list.sort(); |
|
222 return list; |
|
223 } |
|
224 |
162 /****************************************************************************/ |
225 /****************************************************************************/ |
163 |
226 |
164 string Command::alStateString(uint8_t state) |
227 string Command::alStateString(uint8_t state) |
165 { |
228 { |
166 switch (state) { |
229 switch (state) { |