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

Function l_getStructStrFromFile

deps/leptonica/src/stringcode.c:523–552  ·  view source on GitHub ↗

! * \brief l_getStructStrFromFile() * * \param[in] filename * \param[in] field (L_STR_TYPE, L_STR_NAME, L_STR_READER, L_STR_MEMREADER) * \param[out] pstr struct string for this file * \return 0 if found, 1 on error. * * * Notes: * (1) For example, if %field == L_STR_NAME, and the file is a serialized * pixa, this will return "Pixa", the name of the struc

Source from the content-addressed store, hash-verified

521 * (2) Caller must free the returned string.
522 */
523l_int32
524l_getStructStrFromFile(const char *filename,
525 l_int32 field,
526 char **pstr)
527{
528l_int32 index;
529
530 PROCNAME("l_getStructStrFromFile");
531
532 if (!pstr)
533 return ERROR_INT("&str not defined", procName, 1);
534 *pstr = NULL;
535 if (!filename)
536 return ERROR_INT("filename not defined", procName, 1);
537 if (field != L_STR_TYPE && field != L_STR_NAME &&
538 field != L_STR_READER && field != L_STR_MEMREADER)
539 return ERROR_INT("invalid field", procName, 1);
540
541 if (l_getIndexFromFile(filename, &index))
542 return ERROR_INT("index not retrieved", procName, 1);
543 if (field == L_STR_TYPE)
544 *pstr = stringNew(l_assoc[index].type);
545 else if (field == L_STR_NAME)
546 *pstr = stringNew(l_assoc[index].structname);
547 else if (field == L_STR_READER)
548 *pstr = stringNew(l_assoc[index].reader);
549 else /* field == L_STR_MEMREADER */
550 *pstr = stringNew(l_assoc[index].memreader);
551 return 0;
552}
553
554
555/*---------------------------------------------------------------------*/

Callers 1

pixaReadBothFunction · 0.85

Calls 2

l_getIndexFromFileFunction · 0.85
stringNewFunction · 0.85

Tested by

no test coverage detected