@@ -88,8 +88,19 @@ contains_str(fds_filter_value_u *big, fds_filter_value_u *little, fds_filter_val
8888 result -> b = strnnstr (big -> str .chars , little -> str .chars , big -> str .len , little -> str .len ) != NULL ;
8989}
9090
91+ void
92+ startswith_str (fds_filter_value_u * big , fds_filter_value_u * little , fds_filter_value_u * result )
93+ {
94+ result -> b = (big -> str .len >= little -> str .len
95+ && memcmp (big -> str .chars , little -> str .chars , little -> str .len ) == 0 );
96+ }
9197
92-
98+ void
99+ endswith_str (fds_filter_value_u * big , fds_filter_value_u * little , fds_filter_value_u * result )
100+ {
101+ result -> b = (big -> str .len >= little -> str .len
102+ && memcmp (& big -> str .chars [big -> str .len - little -> str .len ], little -> str .chars , little -> str .len ) == 0 );
103+ }
93104
94105void
95106str_in_list (fds_filter_value_u * item , fds_filter_value_u * list , fds_filter_value_u * result )
@@ -136,6 +147,8 @@ const fds_filter_op_s str_operations[] = {
136147 FDS_FILTER_DEF_BINARY_OP (FDS_FDT_STR , "!=" , FDS_FDT_STR , ne_str , FDS_FDT_BOOL ),
137148
138149 FDS_FILTER_DEF_BINARY_OP (FDS_FDT_STR , "contains" , FDS_FDT_STR , contains_str , FDS_FDT_BOOL ),
150+ FDS_FILTER_DEF_BINARY_OP (FDS_FDT_STR , "startswith" , FDS_FDT_STR , startswith_str , FDS_FDT_BOOL ),
151+ FDS_FILTER_DEF_BINARY_OP (FDS_FDT_STR , "endswith" , FDS_FDT_STR , endswith_str , FDS_FDT_BOOL ),
139152
140153 FDS_FILTER_DEF_BINARY_OP (FDS_FDT_STR , "in" , FDS_FDT_LIST | FDS_FDT_STR , str_in_list , FDS_FDT_BOOL ),
141154
0 commit comments