| 224 | } |
| 225 | |
| 226 | static ds_status profileDevices(ds_profile *profile, |
| 227 | const ds_evaluation_type type, |
| 228 | ds_perf_evaluator evaluator, |
| 229 | void *evaluatorData, unsigned int *numUpdates) { |
| 230 | ds_status status = DS_SUCCESS; |
| 231 | unsigned int i; |
| 232 | unsigned int updates = 0; |
| 233 | |
| 234 | if (profile == NULL) { |
| 235 | return DS_INVALID_PROFILE; |
| 236 | } |
| 237 | if (evaluator == NULL) { |
| 238 | return DS_INVALID_PERF_EVALUATOR; |
| 239 | } |
| 240 | |
| 241 | for (i = 0; i < profile->numDevices; i++) { |
| 242 | ds_status evaluatorStatus; |
| 243 | |
| 244 | switch (type) { |
| 245 | case DS_EVALUATE_NEW_ONLY: |
| 246 | if (profile->devices[i].score != NULL) break; |
| 247 | // else fall through |
| 248 | case DS_EVALUATE_ALL: |
| 249 | evaluatorStatus = evaluator(profile->devices + i, evaluatorData); |
| 250 | if (evaluatorStatus != DS_SUCCESS) { |
| 251 | status = evaluatorStatus; |
| 252 | return status; |
| 253 | } |
| 254 | updates++; |
| 255 | break; |
| 256 | default: |
| 257 | return DS_INVALID_PERF_EVALUATOR_TYPE; |
| 258 | break; |
| 259 | }; |
| 260 | } |
| 261 | if (numUpdates) *numUpdates = updates; |
| 262 | return status; |
| 263 | } |
| 264 | |
| 265 | static const char *findString(const char *contentStart, const char *contentEnd, |
| 266 | const char *string) { |