1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #ifndef EDITORCONFIG_H
25 #define EDITORCONFIG_H
26
27 #include <stdlib.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 typedef struct EditorConfig EditorConfig;
34
35 typedef struct ECSection ECSection;
36 typedef struct ECKeyValue ECKeyValue;
37
38 enum ECIndentStyle {
EC_INDENT_STYLE_UNSET =
0,
EC_TAB,
EC_SPACE };
39 enum ECEndOfLine {
EC_EOL_UNSET =
0,
EC_LF,
EC_CR,
EC_CRLF };
40 enum ECBOM {
EC_BOM_UNSET =
0,
EC_BOM };
41
42 struct EditorConfig {
43 int found;
44 enum ECIndentStyle indent_style;
45 int indent_size;
46 int tab_width;
47 enum ECEndOfLine end_of_line;
48 char *charset;
49 enum ECBOM bom;
50
51
52 };
53
54 struct ECSection {
55 char *name;
56
57 ECKeyValue *values;
58
59 ECSection *next;
60 };
61
62 struct ECKeyValue {
63 char *name;
64 char *value;
65 ECKeyValue *next;
66 };
67
68 typedef struct {
69 char *parent;
70
71 char *content;
72 size_t length;
73
74 ECSection *preamble;
75 ECSection *sections;
76 } ECFile;
77
78 EditorConfig EditorConfigGet(
const char *path,
const char *name);
79
80 ECFile* ECLoadContent(
const char *path);
81 int ECParse(ECFile *ec);
82
83 int ECGetConfig(ECFile *ecf,
const char *filepath, EditorConfig *config);
84
85 void ECDestroy(ECFile *ecf);
86
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif
93
94