-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathend.c
More file actions
31 lines (27 loc) · 866 Bytes
/
end.c
File metadata and controls
31 lines (27 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*******************************************************************************
* File: end.c
* Created: 2024-03-23
*
* Authors:
* Tyler Matijevich
*
* License:
* This file end.c is part of the IecString project
* released under the MIT license agreement.
******************************************************************************/
#include "main.h"
/* Does source end with suffix */
uint8_t IecStringEndsWith(char *source, char *suffix)
{
/* Guard null pointers */
if (!source || !suffix)
return false;
/* Check lengths */
size_t source_length = strlen(source);
size_t suffix_length = strlen(suffix);
if (suffix_length > source_length)
return false;
/* Compare characters of strings */
return strncmp(source + source_length - suffix_length,
suffix, suffix_length) == 0;
}