mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 23:10:06 +01:00
Add startswith() helper
Simple helper that use strncmp() to test whether a given string starts with a given suffix. While it doesn't reduce code-size by much, it is a lot more readable than the strncmp() usage. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
639a5a9b56
commit
5183bf3763
1 changed files with 8 additions and 0 deletions
|
|
@ -24,8 +24,16 @@
|
|||
#define _UTIL_H_
|
||||
|
||||
#include <config.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "libevdev-int.h"
|
||||
|
||||
static inline bool
|
||||
startswith(const char *str, size_t len, const char *prefix, size_t plen)
|
||||
{
|
||||
return len >= plen && !strncmp(str, prefix, plen);
|
||||
}
|
||||
|
||||
static inline int
|
||||
bit_is_set(const unsigned long *array, int bit)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue