CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
littlefs_searching.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include "littlefs/lfs.h"
#include "littlefs/littlefs_searching.h"
#include "littlefs/littlefs_helper.h"
Include dependency graph for littlefs_searching.c:

Functions

int32_t LFS_search_count_occurrences (const char *filename, const uint8_t *needle, size_t needle_len)
 Count the number of occurrences of a string/byte pattern in an LFS file.
int32_t LFS_search_find_nth_occurrence (const char *filename, const uint8_t *needle, size_t needle_len, uint16_t n, lfs_soff_t *out_offset)
 Find the byte offset of the nth occurrence of a string/byte pattern in an LFS file.

Function Documentation

◆ LFS_search_count_occurrences()

int32_t LFS_search_count_occurrences ( const char * filename,
const uint8_t * needle,
size_t needle_len )

Count the number of occurrences of a string/byte pattern in an LFS file.

Parameters
filenameFile name/path of the "haystack" file to open and search within.
needlePattern to search for.
needle_lenLength of pattern to search for.
Returns
The number of matches. 0 if no matches. Negative LFS error code on error.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_search_find_nth_occurrence()

int32_t LFS_search_find_nth_occurrence ( const char * filename,
const uint8_t * needle,
size_t needle_len,
uint16_t n,
lfs_soff_t * out_offset )

Find the byte offset of the nth occurrence of a string/byte pattern in an LFS file.

Parameters
lfsFilesystem.
filenameFile name/path of the "haystack" file to open and search within.
needlePattern to search for.
needle_lenLength of pattern to search for.
nNth occurrence to find.
out_offsetPointer to store the byte offset of the found occurrence.
Returns
0 on success, or a negative LFS error code, or a positive error code indicating a problem in function. Returns 1 if invalid arguments. Returns 3 if needle not found.
Here is the call graph for this function:
Here is the caller graph for this function: