Skip to content

Commit dd6ce78

Browse files
committed
chore(fnmatch): added Doxygen
Signed-off-by: Spago123 <harun.spago.code@gmail.com>
1 parent 210e6cd commit dd6ce78

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

include/zephyr/posix/fnmatch.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,26 @@
5050
extern "C" {
5151
#endif
5252

53-
int fnmatch(const char *, const char *, int);
53+
/**
54+
* Function used to check if the given pattern is in the string, using the given flags
55+
*
56+
* @param pattern pattern that is matched against the string
57+
* @param string string that is checked for the pattern
58+
* @param flags used to signal special matching conditions
59+
* FNM_NOESCAPE 0x01 Disable backslash escaping.
60+
* FNM_PATHNAME 0x02 Slash must be matched by slash.
61+
* FNM_PERIOD 0x04 Period must be matched by period.
62+
* FNM_CASEFOLD 0x08 Pattern is matched case-insensitive
63+
* FNM_LEADING_DIR 0x10 Ignore /<tail> after Imatch.
64+
*
65+
*
66+
* @return int
67+
* @retval 0 pattern found in string
68+
* @retval FNM_NOMATCH pattern not found in string
69+
* @retval FNM_NORES recursion limit reached
70+
* @retval FNM_NOSYS function not implemented
71+
*/
72+
int fnmatch(const char *pattern, const char *string, int flags);
5473

5574
#ifdef __cplusplus
5675
}

lib/posix/options/fnmatch.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,44 @@ static inline int foldcase(int ch, int flags)
5858
return ch;
5959
}
6060

61+
/**
62+
* @brief Function to check for FNM_PERIOD condition
63+
*
64+
* @param string string whose first character is checked if it is a period
65+
* @param flags passed flags to check for FNM_PERIOD
66+
* @return int
67+
* @retval 1 if first character is period and FNM_PERIOD flag is set
68+
* @retval 0 otherwise
69+
*/
6170
static int check_fnm_period(const char* string, const int flags)
6271
{
6372
return *string == '.' && (flags & FNM_PERIOD);
6473
}
6574

75+
/**
76+
* @brief Function to check for FNM_PATHNAME condition
77+
*
78+
* @param letter letter to be checked if it is a '/'
79+
* @param flags flags passed to check for FNM_PATHNAME
80+
* @return int
81+
* @retval 1 if letter is '/' and FNM_PATHNAME flag is set
82+
* @retval 0 otherwise
83+
*/
6684
static int check_for_pathname(const char letter, const int flags)
6785
{
6886
return letter == '/' && (flags & FNM_PATHNAME);
6987
}
7088

7189
#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags))
7290

91+
/**
92+
* @brief Function to match POSIX character classes
93+
*
94+
* @param pattern start of the pattern, should point to the character after '['
95+
* @param test next character in the string to be tested against the class
96+
* @return true
97+
* @return false
98+
*/
7399
static bool match_posix_class(const char **pattern, int test) {
74100
const struct {
75101
const char *name;

0 commit comments

Comments
 (0)