#ifndef EDITORCONFIG_H
#define EDITORCONFIG_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct EditorConfig EditorConfig;
typedef struct ECSection ECSection;
typedef struct ECKeyValue ECKeyValue;
enum ECIndentStyle { EC_INDENT_STYLE_UNSET = 0, EC_TAB, EC_SPACE };
enum ECEndOfLine { EC_EOL_UNSET = 0, EC_LF, EC_CR, EC_CRLF };
enum ECBOM { EC_BOM_UNSET = 0, EC_BOM };
struct EditorConfig {
int found;
enum ECIndentStyle indent_style;
int indent_size;
int tab_width;
enum ECEndOfLine end_of_line;
char *charset;
enum ECBOM bom;
};
struct ECSection {
char *name;
ECKeyValue *values;
ECSection *next;
};
struct ECKeyValue {
char *name;
char *value;
ECKeyValue *next;
};
typedef struct {
char *parent;
char *content;
size_t length;
ECSection *preamble;
ECSection *sections;
} ECFile;
EditorConfig EditorConfigGet(const char *path, const char *name);
ECFile* ECLoadContent(const char *path);
int ECParse(ECFile *ec);
int ECGetConfig(ECFile *ecf, const char *filepath, EditorConfig *config);
void ECDestroy(ECFile *ecf);
#ifdef __cplusplus
}
#endif
#endif