gamemode: Add a helper to compare string tails

Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
Kai Krakow 2018-09-29 15:27:55 +02:00
parent c2344f4387
commit 373fe5a8af

View File

@ -74,6 +74,17 @@ POSSIBILITY OF SUCH DAMAGE.
#define safe_snprintf(b, s, ...) \
(snprintf(b, sizeof(b), s, __VA_ARGS__) < (ssize_t)sizeof(b) ? strndup(b, sizeof(b)) : NULL)
/**
* Helper function: Test, if haystack ends with needle.
*/
static inline const char *strtail(const char *haystack, const char *needle)
{
char *pos = strstr(haystack, needle);
if (pos && (strlen(pos) == strlen(needle)))
return pos;
return NULL;
}
/**
* The GameModeClient encapsulates the remote connection, providing a list
* form to contain the pid and credentials.