! * \brief arrayFindEachSequence() * * \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 * \return dna of offsets where the sequence is found, or NULL if * none are found or on error * * * Notes: * (1) The byte arrays %da
| 970 | * </pre> |
| 971 | */ |
| 972 | L_DNA * |
| 973 | arrayFindEachSequence(const l_uint8 *data, |
| 974 | size_t datalen, |
| 975 | const l_uint8 *sequence, |
| 976 | size_t seqlen) |
| 977 | { |
| 978 | l_int32 start, offset, realoffset, found; |
| 979 | L_DNA *da; |
| 980 | |
| 981 | PROCNAME("arrayFindEachSequence"); |
| 982 | |
| 983 | if (!data || !sequence) |
| 984 | return (L_DNA *)ERROR_PTR("data & sequence not both defined", |
| 985 | procName, NULL); |
| 986 | |
| 987 | da = l_dnaCreate(0); |
| 988 | start = 0; |
| 989 | while (1) { |
| 990 | arrayFindSequence(data + start, datalen - start, sequence, seqlen, |
| 991 | &offset, &found); |
| 992 | if (found == FALSE) |
| 993 | break; |
| 994 | |
| 995 | realoffset = start + offset; |
| 996 | l_dnaAddNumber(da, realoffset); |
| 997 | start = realoffset + seqlen; |
| 998 | if (start >= datalen) |
| 999 | break; |
| 1000 | } |
| 1001 | |
| 1002 | if (l_dnaGetCount(da) == 0) |
| 1003 | l_dnaDestroy(&da); |
| 1004 | return da; |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | /*! |
no test coverage detected