dte test coverage


Directory: ./
File: src/filetype.h
Date: 2025-02-14 16:55:22
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

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(const StringView *name) PURE NONNULL_ARGS;
26
27 2333 static inline bool is_valid_filetype_name(const char *name)
28 {
29 2333 const StringView sv = strview_from_cstring(name);
30 2333 return is_valid_filetype_name_sv(&sv);
31 }
32
33 bool is_ft(const PointerArray *filetypes, const char *name);
34 const char *find_ft(const PointerArray *filetypes, const char *filename, StringView line);
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