Move all files to /inih.
diff --git a/cpp/INIReader.h b/INIReader.h
similarity index 100%
rename from cpp/INIReader.h
rename to INIReader.h
diff --git a/cpp/INIReaderTest.cpp b/INIReaderTest.cpp
similarity index 100%
rename from cpp/INIReaderTest.cpp
rename to INIReaderTest.cpp
diff --git a/examples/config.def b/examples/config.def
deleted file mode 100644
index 6113252..0000000
--- a/examples/config.def
+++ /dev/null
@@ -1,8 +0,0 @@
-// CFG(section, name, default)
-
-CFG(protocol, version, "0")
-
-CFG(user, name, "Fatty Lumpkin")
-CFG(user, email, "fatty@lumpkin.com")
-
-#undef CFG
diff --git a/examples/ini_buffer.c b/examples/ini_buffer.c
deleted file mode 100644
index 4b20465..0000000
--- a/examples/ini_buffer.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Example: parse an INI file using a custom ini_reader and a string buffer for I/O
-
-This example was provided by Grzegorz Sokół (https://github.com/greg-sokol)
-in pull request https://github.com/benhoyt/inih/pull/38
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../ini.h"
-
-typedef struct
-{
- int version;
- const char* name;
- const char* email;
-} configuration;
-
-typedef struct
-{
- const char* ptr;
- int bytes_left;
-} buffer_ctx;
-
-static char* ini_buffer_reader(char* str, int num, void* stream)
-{
- buffer_ctx* ctx = (buffer_ctx*)stream;
- int idx = 0;
- char newline = 0;
-
- if (ctx->bytes_left <= 0)
- return NULL;
-
- for (idx = 0; idx < num - 1; ++idx)
- {
- if (idx == ctx->bytes_left)
- break;
-
- if (ctx->ptr[idx] == '\n')
- newline = '\n';
- else if (ctx->ptr[idx] == '\r')
- newline = '\r';
-
- if (newline)
- break;
- }
-
- memcpy(str, ctx->ptr, idx);
- str[idx] = 0;
-
- ctx->ptr += idx + 1;
- ctx->bytes_left -= idx + 1;
-
- if (newline && ctx->bytes_left > 0 &&
- ((newline == '\r' && ctx->ptr[0] == '\n') ||
- (newline == '\n' && ctx->ptr[0] == '\r'))) {
- ctx->bytes_left--;
- ctx->ptr++;
- }
- return str;
-}
-
-static int handler(void* user, const char* section, const char* name,
- const char* value)
-{
- configuration* pconfig = (configuration*)user;
-
- #define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
- if (MATCH("protocol", "version")) {
- pconfig->version = atoi(value);
- } else if (MATCH("user", "name")) {
- pconfig->name = strdup(value);
- } else if (MATCH("user", "email")) {
- pconfig->email = strdup(value);
- } else {
- return 0; /* unknown section/name, error */
- }
- return 1;
-}
-
-int main(int argc, char* argv[])
-{
- configuration config;
- buffer_ctx ctx;
-
- ctx.ptr = "; Test ini buffer\n"
- "\n"
- "[protocol]\n"
- "version=42\n"
- "\n"
- "[user]\n"
- "name = Jane Smith\n"
- "email = jane@smith.com\n";
- ctx.bytes_left = strlen(ctx.ptr);
-
- if (ini_parse_stream((ini_reader)ini_buffer_reader, &ctx, handler, &config) < 0) {
- printf("Can't load buffer\n");
- return 1;
- }
- printf("Config loaded from buffer: version=%d, name=%s, email=%s\n",
- config.version, config.name, config.email);
- return 0;
-}
diff --git a/examples/ini_dump.c b/examples/ini_dump.c
deleted file mode 100644
index 87253ee..0000000
--- a/examples/ini_dump.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ini.h example that simply dumps an INI file without comments */
-
-#include <stdio.h>
-#include <string.h>
-#include "../ini.h"
-
-static int dumper(void* user, const char* section, const char* name,
- const char* value)
-{
- static char prev_section[50] = "";
-
- if (strcmp(section, prev_section)) {
- printf("%s[%s]\n", (prev_section[0] ? "\n" : ""), section);
- strncpy(prev_section, section, sizeof(prev_section));
- prev_section[sizeof(prev_section) - 1] = '\0';
- }
- printf("%s = %s\n", name, value);
- return 1;
-}
-
-int main(int argc, char* argv[])
-{
- int error;
-
- if (argc <= 1) {
- printf("Usage: ini_dump filename.ini\n");
- return 1;
- }
-
- error = ini_parse(argv[1], dumper, NULL);
- if (error < 0) {
- printf("Can't read '%s'!\n", argv[1]);
- return 2;
- }
- else if (error) {
- printf("Bad config file (first error on line %d)!\n", error);
- return 3;
- }
- return 0;
-}
diff --git a/examples/ini_example.c b/examples/ini_example.c
deleted file mode 100644
index 0973572..0000000
--- a/examples/ini_example.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Example: parse a simple configuration file */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../ini.h"
-
-typedef struct
-{
- int version;
- const char* name;
- const char* email;
-} configuration;
-
-static int handler(void* user, const char* section, const char* name,
- const char* value)
-{
- configuration* pconfig = (configuration*)user;
-
- #define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
- if (MATCH("protocol", "version")) {
- pconfig->version = atoi(value);
- } else if (MATCH("user", "name")) {
- pconfig->name = strdup(value);
- } else if (MATCH("user", "email")) {
- pconfig->email = strdup(value);
- } else {
- return 0; /* unknown section/name, error */
- }
- return 1;
-}
-
-int main(int argc, char* argv[])
-{
- configuration config;
-
- if (ini_parse("test.ini", handler, &config) < 0) {
- printf("Can't load 'test.ini'\n");
- return 1;
- }
- printf("Config loaded from 'test.ini': version=%d, name=%s, email=%s\n",
- config.version, config.name, config.email);
- return 0;
-}
diff --git a/examples/ini_xmacros.c b/examples/ini_xmacros.c
deleted file mode 100644
index a2cab43..0000000
--- a/examples/ini_xmacros.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Parse a configuration file into a struct using X-Macros */
-
-#include <stdio.h>
-#include <string.h>
-#include "../ini.h"
-
-/* define the config struct type */
-typedef struct {
- #define CFG(s, n, default) char *s##_##n;
- #include "config.def"
-} config;
-
-/* create one and fill in its default values */
-config Config = {
- #define CFG(s, n, default) default,
- #include "config.def"
-};
-
-/* process a line of the INI file, storing valid values into config struct */
-int handler(void *user, const char *section, const char *name,
- const char *value)
-{
- config *cfg = (config *)user;
-
- if (0) ;
- #define CFG(s, n, default) else if (strcmp(section, #s)==0 && \
- strcmp(name, #n)==0) cfg->s##_##n = strdup(value);
- #include "config.def"
-
- return 1;
-}
-
-/* print all the variables in the config, one per line */
-void dump_config(config *cfg)
-{
- #define CFG(s, n, default) printf("%s_%s = %s\n", #s, #n, cfg->s##_##n);
- #include "config.def"
-}
-
-int main(int argc, char* argv[])
-{
- if (ini_parse("test.ini", handler, &Config) < 0)
- printf("Can't load 'test.ini', using defaults\n");
- dump_config(&Config);
- return 0;
-}
diff --git a/examples/test.ini b/examples/test.ini
deleted file mode 100644
index 680c3b9..0000000
--- a/examples/test.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-; Test config file for ini_example.c and INIReaderTest.cpp
-
-[protocol] ; Protocol configuration
-version=6 ; IPv6
-
-[user]
-name = Bob Smith ; Spaces around '=' are stripped
-email = bob@smith.com ; And comments (like this) ignored
-active = true ; Test a boolean
-pi = 3.14159 ; Test a floating point number
diff --git a/cpp/makefile b/makefile
similarity index 100%
rename from cpp/makefile
rename to makefile
diff --git a/cpp/test.ini b/test.ini
similarity index 100%
rename from cpp/test.ini
rename to test.ini
diff --git a/tests/bad_comment.ini b/tests/bad_comment.ini
deleted file mode 100644
index d4bab4a..0000000
--- a/tests/bad_comment.ini
+++ /dev/null
@@ -1 +0,0 @@
-This is an error
diff --git a/tests/bad_multi.ini b/tests/bad_multi.ini
deleted file mode 100644
index 3ec342f..0000000
--- a/tests/bad_multi.ini
+++ /dev/null
@@ -1 +0,0 @@
- indented
diff --git a/tests/bad_section.ini b/tests/bad_section.ini
deleted file mode 100644
index 689a4e5..0000000
--- a/tests/bad_section.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[section1]
-name1=value1
-[section2
-[section3 ; comment ]
-name2=value2
diff --git a/tests/baseline_disallow_inline_comments.txt b/tests/baseline_disallow_inline_comments.txt
deleted file mode 100644
index 0e9c558..0000000
--- a/tests/baseline_disallow_inline_comments.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-no_file.ini: e=-1 user=0
-... [section1]
-... one=This is a test ; name=value comment;
-... two=1234;
-... [ section 2 ]
-... happy=4;
-... sad=;
-... [comment_test]
-... test1=1;2;3 ; only this will be a comment;
-... test2=2;3;4;this won't be a comment, needs whitespace before ';';
-... test;3=345 ; key should be "test;3";
-... test4=4#5#6 ; '#' only starts a comment at start of line;
-... [colon_tests]
-... Content-Type=text/html;
-... foo=bar;
-... adams=42;
-... funny1=with = equals;
-... funny2=with : colons;
-... funny3=two = equals;
-... funny4=two : colons;
-normal.ini: e=0 user=101
-... [section1]
-... name1=value1;
-... [section3 ; comment ]
-... name2=value2;
-bad_section.ini: e=3 user=102
-bad_comment.ini: e=1 user=102
-... [section]
-... a=b;
-... user=parse_error;
-... c=d;
-user_error.ini: e=3 user=104
-... [section1]
-... single1=abc;
-... multi=this is a;
-... multi=multi-line value;
-... single2=xyz;
-... [section2]
-... multi=a;
-... multi=b;
-... multi=c;
-... [section3]
-... single=ghi;
-... multi=the quick;
-... multi=brown fox;
-... name=bob smith ; comment line 1;
-multi_line.ini: e=0 user=105
-bad_multi.ini: e=1 user=105
-... [bom_section]
-... bom_name=bom_value;
-... key“=value“;
-bom.ini: e=0 user=107
diff --git a/tests/baseline_multi.txt b/tests/baseline_multi.txt
deleted file mode 100644
index dfc323b..0000000
--- a/tests/baseline_multi.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-no_file.ini: e=-1 user=0
-... [section1]
-... one=This is a test;
-... two=1234;
-... [ section 2 ]
-... happy=4;
-... sad=;
-... [comment_test]
-... test1=1;2;3;
-... test2=2;3;4;this won't be a comment, needs whitespace before ';';
-... test;3=345;
-... test4=4#5#6;
-... [colon_tests]
-... Content-Type=text/html;
-... foo=bar;
-... adams=42;
-... funny1=with = equals;
-... funny2=with : colons;
-... funny3=two = equals;
-... funny4=two : colons;
-normal.ini: e=0 user=101
-... [section1]
-... name1=value1;
-... name2=value2;
-bad_section.ini: e=3 user=102
-bad_comment.ini: e=1 user=102
-... [section]
-... a=b;
-... user=parse_error;
-... c=d;
-user_error.ini: e=3 user=104
-... [section1]
-... single1=abc;
-... multi=this is a;
-... multi=multi-line value;
-... single2=xyz;
-... [section2]
-... multi=a;
-... multi=b;
-... multi=c;
-... [section3]
-... single=ghi;
-... multi=the quick;
-... multi=brown fox;
-... name=bob smith;
-multi_line.ini: e=0 user=105
-bad_multi.ini: e=1 user=105
-... [bom_section]
-... bom_name=bom_value;
-... key“=value“;
-bom.ini: e=0 user=107
diff --git a/tests/baseline_single.txt b/tests/baseline_single.txt
deleted file mode 100644
index 3693085..0000000
--- a/tests/baseline_single.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-no_file.ini: e=-1 user=0
-... [section1]
-... one=This is a test;
-... two=1234;
-... [ section 2 ]
-... happy=4;
-... sad=;
-... [comment_test]
-... test1=1;2;3;
-... test2=2;3;4;this won't be a comment, needs whitespace before ';';
-... test;3=345;
-... test4=4#5#6;
-... [colon_tests]
-... Content-Type=text/html;
-... foo=bar;
-... adams=42;
-... funny1=with = equals;
-... funny2=with : colons;
-... funny3=two = equals;
-... funny4=two : colons;
-normal.ini: e=0 user=101
-... [section1]
-... name1=value1;
-... name2=value2;
-bad_section.ini: e=3 user=102
-bad_comment.ini: e=1 user=102
-... [section]
-... a=b;
-... user=parse_error;
-... c=d;
-user_error.ini: e=3 user=104
-... [section1]
-... single1=abc;
-... multi=this is a;
-... single2=xyz;
-... [section2]
-... multi=a;
-... [section3]
-... single=ghi;
-... multi=the quick;
-... name=bob smith;
-multi_line.ini: e=4 user=105
-bad_multi.ini: e=1 user=105
-... [bom_section]
-... bom_name=bom_value;
-... key“=value“;
-bom.ini: e=0 user=107
diff --git a/tests/baseline_stop_on_first_error.txt b/tests/baseline_stop_on_first_error.txt
deleted file mode 100644
index c5fdbcb..0000000
--- a/tests/baseline_stop_on_first_error.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-no_file.ini: e=-1 user=0
-... [section1]
-... one=This is a test;
-... two=1234;
-... [ section 2 ]
-... happy=4;
-... sad=;
-... [comment_test]
-... test1=1;2;3;
-... test2=2;3;4;this won't be a comment, needs whitespace before ';';
-... test;3=345;
-... test4=4#5#6;
-... [colon_tests]
-... Content-Type=text/html;
-... foo=bar;
-... adams=42;
-... funny1=with = equals;
-... funny2=with : colons;
-... funny3=two = equals;
-... funny4=two : colons;
-normal.ini: e=0 user=101
-... [section1]
-... name1=value1;
-bad_section.ini: e=3 user=102
-bad_comment.ini: e=1 user=102
-... [section]
-... a=b;
-... user=parse_error;
-user_error.ini: e=3 user=104
-... [section1]
-... single1=abc;
-... multi=this is a;
-... multi=multi-line value;
-... single2=xyz;
-... [section2]
-... multi=a;
-... multi=b;
-... multi=c;
-... [section3]
-... single=ghi;
-... multi=the quick;
-... multi=brown fox;
-... name=bob smith;
-multi_line.ini: e=0 user=105
-bad_multi.ini: e=1 user=105
-... [bom_section]
-... bom_name=bom_value;
-... key“=value“;
-bom.ini: e=0 user=107
diff --git a/tests/bom.ini b/tests/bom.ini
deleted file mode 100644
index 44c519f..0000000
--- a/tests/bom.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[bom_section]
-bom_name=bom_value
-key“ = value“
diff --git a/tests/multi_line.ini b/tests/multi_line.ini
deleted file mode 100644
index b00f086..0000000
--- a/tests/multi_line.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[section1]
-single1 = abc
-multi = this is a
- multi-line value
-single2 = xyz
-[section2]
-multi = a
- b
- c
-[section3]
-single: ghi
-multi: the quick
- brown fox
-name = bob smith ; comment line 1
- ; comment line 2
diff --git a/tests/normal.ini b/tests/normal.ini
deleted file mode 100644
index 222b477..0000000
--- a/tests/normal.ini
+++ /dev/null
@@ -1,29 +0,0 @@
-; This is an INI file
-[section1] ; section comment
-one=This is a test ; name=value comment
-two = 1234
-; x=y
-
-[ section 2 ]
-happy = 4
-sad =
-
-[empty]
-; do nothing
-
-[comment_test]
-test1 = 1;2;3 ; only this will be a comment
-test2 = 2;3;4;this won't be a comment, needs whitespace before ';'
-test;3 = 345 ; key should be "test;3"
-test4 = 4#5#6 ; '#' only starts a comment at start of line
-#test5 = 567 ; entire line commented
- # test6 = 678 ; entire line commented, except in MULTILINE mode
-
-[colon_tests]
-Content-Type: text/html
-foo:bar
-adams : 42
-funny1 : with = equals
-funny2 = with : colons
-funny3 = two = equals
-funny4 : two : colons
diff --git a/tests/unittest.bat b/tests/unittest.bat
deleted file mode 100644
index daca866..0000000
--- a/tests/unittest.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@call tcc ..\ini.c -I..\ -run unittest.c > baseline_multi.txt
-@call tcc ..\ini.c -I..\ -DINI_ALLOW_MULTILINE=0 -run unittest.c > baseline_single.txt
-@call tcc ..\ini.c -I..\ -DINI_ALLOW_INLINE_COMMENTS=0 -run unittest.c > baseline_disallow_inline_comments.txt
-@call tcc ..\ini.c -I..\ -DINI_STOP_ON_FIRST_ERROR=1 -run unittest.c > baseline_stop_on_first_error.txt
diff --git a/tests/unittest.c b/tests/unittest.c
deleted file mode 100644
index 97643ca..0000000
--- a/tests/unittest.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* inih -- unit tests
-
-This works simply by dumping a bunch of info to standard output, which is
-redirected to an output file (baseline_*.txt) and checked into the Subversion
-repository. This baseline file is the test output, so the idea is to check it
-once, and if it changes -- look at the diff and see which tests failed.
-
-Here's how I produced the two baseline files (with Tiny C Compiler):
-
-tcc -DINI_ALLOW_MULTILINE=1 ../ini.c -run unittest.c > baseline_multi.txt
-tcc -DINI_ALLOW_MULTILINE=0 ../ini.c -run unittest.c > baseline_single.txt
-
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../ini.h"
-
-int User;
-char Prev_section[50];
-
-int dumper(void* user, const char* section, const char* name,
- const char* value)
-{
- User = (int)user;
- if (strcmp(section, Prev_section)) {
- printf("... [%s]\n", section);
- strncpy(Prev_section, section, sizeof(Prev_section));
- Prev_section[sizeof(Prev_section) - 1] = '\0';
- }
- printf("... %s=%s;\n", name, value);
-
- return strcmp(name, "user")==0 && strcmp(value, "parse_error")==0 ? 0 : 1;
-}
-
-void parse(const char* fname) {
- static int u = 100;
- int e;
-
- *Prev_section = '\0';
- e = ini_parse(fname, dumper, (void*)u);
- printf("%s: e=%d user=%d\n", fname, e, User);
- u++;
-}
-
-int main(void)
-{
- parse("no_file.ini");
- parse("normal.ini");
- parse("bad_section.ini");
- parse("bad_comment.ini");
- parse("user_error.ini");
- parse("multi_line.ini");
- parse("bad_multi.ini");
- parse("bom.ini");
- return 0;
-}
diff --git a/tests/user_error.ini b/tests/user_error.ini
deleted file mode 100644
index 6596387..0000000
--- a/tests/user_error.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[section]
-a = b
-user = parse_error
-c = d