MCPcopy Create free account
hub / github.com/creatale/node-dv / readProfileFromFile

Function readProfileFromFile

deps/tesseract/opencl/openclwrapper.cpp:318–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316 unsigned int serializedScoreSize);
317
318static ds_status readProfileFromFile(ds_profile *profile,
319 ds_score_deserializer deserializer,
320 const char *file) {
321 ds_status status = DS_SUCCESS;
322 char *contentStart = NULL;
323 const char *contentEnd = NULL;
324 size_t contentSize;
325
326 if (profile == NULL) return DS_INVALID_PROFILE;
327
328 status = readProFile(file, &contentStart, &contentSize);
329 if (status == DS_SUCCESS) {
330 const char *currentPosition;
331 const char *dataStart;
332 const char *dataEnd;
333
334 contentEnd = contentStart + contentSize;
335 currentPosition = contentStart;
336
337 // parse the version string
338 dataStart = findString(currentPosition, contentEnd, DS_TAG_VERSION);
339 if (dataStart == NULL) {
340 status = DS_PROFILE_FILE_ERROR;
341 goto cleanup;
342 }
343 dataStart += strlen(DS_TAG_VERSION);
344
345 dataEnd = findString(dataStart, contentEnd, DS_TAG_VERSION_END);
346 if (dataEnd == NULL) {
347 status = DS_PROFILE_FILE_ERROR;
348 goto cleanup;
349 }
350
351 size_t versionStringLength = strlen(profile->version);
352 if (versionStringLength + dataStart != dataEnd ||
353 strncmp(profile->version, dataStart, versionStringLength) != 0) {
354 // version mismatch
355 status = DS_PROFILE_FILE_ERROR;
356 goto cleanup;
357 }
358 currentPosition = dataEnd + strlen(DS_TAG_VERSION_END);
359
360 // parse the device information
361 while (1) {
362 unsigned int i;
363
364 const char *deviceTypeStart;
365 const char *deviceTypeEnd;
366 ds_device_type deviceType;
367
368 const char *deviceNameStart;
369 const char *deviceNameEnd;
370
371 const char *deviceScoreStart;
372 const char *deviceScoreEnd;
373
374 const char *deviceDriverStart;
375 const char *deviceDriverEnd;

Callers 1

openclwrapper.cppFile · 0.85

Calls 2

readProFileFunction · 0.85
findStringFunction · 0.85

Tested by

no test coverage detected