lib/util/startswith.h
raw| 1 | /// @file |
| 2 | /// @ingroup cgraph_utils |
| 3 | #pragma once |
| 4 | |
| 5 | #include <assert.h> |
| 6 | #include <stdbool.h> |
| 7 | #include <stddef.h> |
| 8 | #include <string.h> |
| 9 | |
| 10 | /// does the string \p s begin with the string \p prefix? |
| 11 | static inline bool startswith(const char *s, const char *prefix) { |
| 12 | assert(s != NULL); |
| 13 | assert(prefix != NULL); |
| 14 | |
| 15 | return strncmp(s, prefix, strlen(prefix)) == 0; |
| 16 | } |