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

Function arrayFindSequence

deps/leptonica/src/utils2.c:1032–1069  ·  view source on GitHub ↗

! * \brief arrayFindSequence() * * \param[in] data byte array * \param[in] datalen length of data, in bytes * \param[in] sequence subarray of bytes to find in data * \param[in] seqlen length of sequence, in bytes * \param[out] poffset offset from beginning of * data where the sequence begins * \param[out] pfound 1 if sequence is found; 0 otherwise

Source from the content-addressed store, hash-verified

1030 * </pre>
1031 */
1032l_int32
1033arrayFindSequence(const l_uint8 *data,
1034 size_t datalen,
1035 const l_uint8 *sequence,
1036 size_t seqlen,
1037 l_int32 *poffset,
1038 l_int32 *pfound)
1039{
1040l_int32 i, j, found, lastpos;
1041
1042 PROCNAME("arrayFindSequence");
1043
1044 if (poffset) *poffset = 0;
1045 if (pfound) *pfound = FALSE;
1046 if (!data || !sequence)
1047 return ERROR_INT("data & sequence not both defined", procName, 1);
1048 if (!poffset || !pfound)
1049 return ERROR_INT("&offset and &found not defined", procName, 1);
1050
1051 lastpos = datalen - seqlen + 1;
1052 found = FALSE;
1053 for (i = 0; i < lastpos; i++) {
1054 for (j = 0; j < seqlen; j++) {
1055 if (data[i + j] != sequence[j])
1056 break;
1057 if (j == seqlen - 1)
1058 found = TRUE;
1059 }
1060 if (found == TRUE)
1061 break;
1062 }
1063
1064 if (found == TRUE) {
1065 *poffset = i;
1066 *pfound = TRUE;
1067 }
1068 return 0;
1069}
1070
1071
1072/*--------------------------------------------------------------------*

Callers 7

readHeaderMemJp2kFunction · 0.85
fgetJp2kResolutionFunction · 0.85
parseTrailerPdfFunction · 0.85
substituteObjectNumbersFunction · 0.85
sarraySelectBySubstringFunction · 0.85
sarrayParseRangeFunction · 0.85
arrayFindEachSequenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected