| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef FILETYPE_H | ||
| 2 | #define FILETYPE_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include "command/error.h" | ||
| 6 | #include "util/macros.h" | ||
| 7 | #include "util/ptr-array.h" | ||
| 8 | #include "util/string-view.h" | ||
| 9 | #include "util/string.h" | ||
| 10 | |||
| 11 | // Note: the order of these values changes the order of iteration | ||
| 12 | // in find_ft() | ||
| 13 | typedef enum { | ||
| 14 | FT_INTERPRETER, | ||
| 15 | FT_BASENAME, | ||
| 16 | FT_CONTENT, | ||
| 17 | FT_EXTENSION, | ||
| 18 | FT_FILENAME, | ||
| 19 | } FileDetectionType; | ||
| 20 | |||
| 21 | enum { | ||
| 22 | FILETYPE_NAME_MAX = 63, | ||
| 23 | }; | ||
| 24 | |||
| 25 | bool is_valid_filetype_name_sv(StringView name) PURE; | ||
| 26 | |||
| 27 | 3173 | static inline bool is_valid_filetype_name(const char *name) | |
| 28 | { | ||
| 29 | 3173 | return is_valid_filetype_name_sv(strview(name)); | |
| 30 | } | ||
| 31 | |||
| 32 | bool is_ft(const PointerArray *filetypes, const char *name); | ||
| 33 | const char *find_ft(const PointerArray *filetypes, const char *filename, StringView line); | ||
| 34 | const char *filetype_str_from_extension(const char *path) NONNULL_ARGS; | ||
| 35 | void collect_ft(const PointerArray *filetypes, PointerArray *a, const char *prefix); | ||
| 36 | String dump_filetypes(const PointerArray *filetypes); | ||
| 37 | void free_filetypes(PointerArray *filetypes); | ||
| 38 | |||
| 39 | WARN_UNUSED_RESULT NONNULL_ARG(1, 2, 3) | ||
| 40 | bool add_filetype ( | ||
| 41 | PointerArray *filetypes, | ||
| 42 | const char *name, | ||
| 43 | const char *str, | ||
| 44 | FileDetectionType type, | ||
| 45 | ErrorBuffer *ebuf | ||
| 46 | ); | ||
| 47 | |||
| 48 | #endif | ||
| 49 |