summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--3rdparty/libconfig/extra/gen/scanner.l4
-rw-r--r--3rdparty/libconfig/grammar.c2
-rw-r--r--3rdparty/libconfig/libconfig.c7
-rw-r--r--3rdparty/libconfig/scanner.c248
-rw-r--r--3rdparty/libconfig/scanner.h2
-rw-r--r--src/common/conf.h4
-rw-r--r--src/map/quest.c2
-rw-r--r--src/test/Makefile.in34
-rw-r--r--src/test/libconfig/test.conf1
-rw-r--r--src/test/test_libconfig.c842
-rw-r--r--src/test/test_spinlock.c2
11 files changed, 1010 insertions, 138 deletions
diff --git a/3rdparty/libconfig/extra/gen/scanner.l b/3rdparty/libconfig/extra/gen/scanner.l
index bf527e596..7c71f047e 100644
--- a/3rdparty/libconfig/extra/gen/scanner.l
+++ b/3rdparty/libconfig/extra/gen/scanner.l
@@ -97,7 +97,7 @@ static int fromihex(const char *s) {
true [Tt][Rr][Uu][Ee]
false [Ff][Aa][Ll][Ss][Ee]
-name [A-Za-z\*][-A-Za-z0-9_\*']*
+name [A-Za-z0-9\*][-A-Za-z0-9_\*'.]*
integer [-+]?[0-9]+
integer64 [-+]?[0-9]+L(L)?
hex 0[Xx][0-9A-Fa-f]+
@@ -181,12 +181,12 @@ include_open ^[ \t]*@include[ \t]+\"
\} { return(TOK_GROUP_END); }
{true} { yylval->ival = 1; return(TOK_BOOLEAN); }
{false} { yylval->ival = 0; return(TOK_BOOLEAN); }
-{name} { yylval->sval = yytext; return(TOK_NAME); }
{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
{hex} { yylval->ival = fromihex(yytext); return(TOK_HEX); }
{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
+{name} { yylval->sval = yytext; return(TOK_NAME); }
\[ { return(TOK_ARRAY_START); }
\] { return(TOK_ARRAY_END); }
\( { return(TOK_LIST_START); }
diff --git a/3rdparty/libconfig/grammar.c b/3rdparty/libconfig/grammar.c
index 55216535b..26444f816 100644
--- a/3rdparty/libconfig/grammar.c
+++ b/3rdparty/libconfig/grammar.c
@@ -1261,7 +1261,7 @@ YYSTYPE yylval;
`yyss': related to states.
`yyvs': related to semantic values.
- Refer to the stacks through separate pointers, to allow yy overflow
+ Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
diff --git a/3rdparty/libconfig/libconfig.c b/3rdparty/libconfig/libconfig.c
index 358c415f5..8f2b3fb42 100644
--- a/3rdparty/libconfig/libconfig.c
+++ b/3rdparty/libconfig/libconfig.c
@@ -40,7 +40,7 @@
#include <string.h>
#include <ctype.h>
-#define PATH_TOKENS ":./"
+#define PATH_TOKENS ":/"
#define CHUNK_SIZE 16
#define FLOAT_PRECISION 10
@@ -537,12 +537,13 @@ static int __config_validate_name(const char *name)
if(*p == '\0')
return(CONFIG_FALSE);
- if(! isalpha((int)*p) && (*p != '*'))
+ if(! isalpha((int)*p) && !isdigit((int)*p) && (*p != '*')) {
return(CONFIG_FALSE);
+ }
for(++p; *p; ++p)
{
- if(! (isalpha((int)*p) || isdigit((int)*p) || strchr("*_-'", (int)*p)))
+ if(! (isalpha((int)*p) || isdigit((int)*p) || strchr("*_-'.", (int)*p)))
return(CONFIG_FALSE);
}
diff --git a/3rdparty/libconfig/scanner.c b/3rdparty/libconfig/scanner.c
index 44a7d69dd..96c01fc5f 100644
--- a/3rdparty/libconfig/scanner.c
+++ b/3rdparty/libconfig/scanner.c
@@ -13,7 +13,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 37
+#define YY_FLEX_SUBMINOR_VERSION 39
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -198,6 +198,13 @@ typedef size_t yy_size_t;
if ( yytext[yyl] == '\n' )\
--yylineno;\
}while(0)
+ #define YY_LINENO_REWIND_TO(dst) \
+ do {\
+ const char *p;\
+ for ( p = yy_cp-1; p >= (dst); --p)\
+ if ( *p == '\n' )\
+ --yylineno;\
+ }while(0)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@@ -374,21 +381,22 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[112] =
+static yyconst flex_int16_t yy_accept[123] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 46, 44, 25, 24, 24, 5, 44, 40, 41, 32,
- 44, 27, 33, 44, 34, 34, 26, 42, 44, 32,
- 32, 38, 39, 28, 29, 25, 44, 3, 4, 3,
+ 46, 44, 25, 24, 24, 5, 44, 40, 41, 37,
+ 44, 27, 32, 44, 33, 33, 26, 42, 44, 37,
+ 37, 38, 39, 28, 29, 25, 44, 3, 4, 3,
6, 15, 14, 20, 23, 45, 17, 45, 25, 0,
- 43, 32, 33, 34, 33, 0, 1, 0, 33, 0,
- 35, 0, 16, 32, 32, 25, 0, 0, 2, 6,
- 12, 0, 11, 10, 7, 8, 9, 20, 22, 21,
- 17, 0, 18, 0, 33, 33, 0, 0, 33, 35,
- 36, 32, 32, 0, 0, 0, 33, 37, 32, 30,
-
- 0, 13, 37, 31, 0, 0, 0, 0, 0, 19,
- 0
+ 43, 37, 32, 33, 32, 0, 1, 0, 32, 33,
+ 37, 34, 37, 16, 37, 37, 25, 0, 0, 2,
+ 6, 12, 0, 11, 10, 7, 8, 9, 20, 22,
+ 21, 17, 0, 18, 32, 0, 34, 0, 32, 32,
+ 37, 0, 37, 32, 34, 35, 37, 37, 0, 0,
+
+ 32, 0, 32, 34, 0, 37, 32, 36, 37, 30,
+ 0, 13, 32, 36, 31, 0, 0, 0, 0, 0,
+ 19, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -426,49 +434,51 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[51] =
{ 0,
1, 1, 1, 1, 1, 2, 1, 3, 1, 1,
- 3, 1, 1, 3, 1, 1, 4, 4, 1, 1,
+ 3, 1, 1, 3, 3, 1, 4, 4, 1, 1,
1, 1, 1, 1, 4, 4, 4, 4, 3, 3,
3, 3, 3, 3, 3, 1, 2, 1, 4, 4,
4, 4, 3, 3, 3, 3, 3, 3, 1, 1
} ;
-static yyconst flex_int16_t yy_base[124] =
+static yyconst flex_int16_t yy_base[134] =
{ 0,
- 0, 49, 49, 50, 48, 49, 50, 51, 214, 213,
- 218, 221, 215, 221, 221, 221, 213, 221, 221, 0,
- 47, 221, 41, 55, 62, 66, 221, 221, 209, 189,
- 32, 221, 221, 221, 221, 67, 170, 221, 221, 196,
- 0, 221, 64, 0, 221, 61, 205, 187, 207, 205,
- 221, 0, 77, 97, 99, 111, 221, 204, 103, 119,
- 170, 0, 221, 46, 71, 98, 153, 126, 221, 0,
- 221, 0, 221, 221, 221, 221, 221, 0, 221, 221,
- 164, 146, 221, 57, 117, 124, 131, 129, 135, 221,
- 138, 135, 123, 127, 0, 137, 139, 132, 131, 0,
-
- 117, 221, 221, 0, 112, 99, 91, 111, 157, 221,
- 221, 172, 176, 180, 184, 188, 190, 194, 198, 202,
- 104, 98, 68
+ 0, 49, 49, 50, 48, 49, 50, 51, 244, 243,
+ 248, 251, 245, 251, 251, 251, 243, 251, 251, 0,
+ 47, 251, 41, 55, 62, 210, 251, 251, 238, 218,
+ 32, 251, 251, 251, 251, 67, 199, 251, 251, 225,
+ 0, 251, 64, 0, 251, 61, 234, 216, 236, 234,
+ 251, 0, 66, 87, 95, 106, 251, 233, 98, 200,
+ 115, 204, 123, 251, 46, 47, 70, 190, 187, 251,
+ 0, 251, 0, 251, 251, 251, 251, 251, 0, 251,
+ 251, 219, 198, 251, 117, 142, 166, 57, 113, 120,
+ 154, 125, 128, 135, 0, 165, 162, 128, 154, 0,
+
+ 156, 163, 161, 251, 167, 169, 171, 152, 149, 0,
+ 126, 251, 174, 0, 0, 119, 117, 85, 119, 94,
+ 251, 251, 197, 201, 205, 209, 213, 215, 219, 223,
+ 227, 115, 104
} ;
-static yyconst flex_int16_t yy_def[124] =
+static yyconst flex_int16_t yy_def[134] =
{ 0,
- 111, 1, 112, 112, 113, 113, 114, 114, 115, 115,
- 111, 111, 111, 111, 111, 111, 116, 111, 111, 117,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 117,
- 117, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 118, 111, 111, 119, 111, 111, 120, 120, 111, 116,
- 111, 117, 111, 111, 111, 111, 111, 116, 111, 111,
- 111, 121, 111, 117, 117, 111, 111, 111, 111, 118,
- 111, 122, 111, 111, 111, 111, 111, 119, 111, 111,
- 120, 120, 111, 111, 111, 111, 111, 111, 111, 111,
- 121, 117, 117, 111, 123, 111, 111, 111, 117, 117,
-
- 111, 111, 111, 117, 111, 111, 111, 111, 111, 111,
- 0, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111
+ 122, 1, 123, 123, 124, 124, 125, 125, 126, 126,
+ 122, 122, 122, 122, 122, 122, 127, 122, 122, 128,
+ 122, 122, 122, 122, 128, 25, 122, 122, 122, 128,
+ 128, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 129, 122, 122, 130, 122, 122, 131, 131, 122, 127,
+ 122, 128, 122, 122, 122, 122, 122, 127, 128, 25,
+ 128, 128, 128, 122, 128, 128, 122, 122, 122, 122,
+ 129, 122, 132, 122, 122, 122, 122, 122, 130, 122,
+ 122, 131, 131, 122, 122, 122, 122, 122, 122, 128,
+ 128, 122, 128, 128, 128, 63, 128, 128, 122, 133,
+
+ 122, 122, 122, 122, 122, 128, 128, 128, 128, 128,
+ 122, 122, 122, 128, 128, 122, 122, 122, 122, 122,
+ 122, 0, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122
} ;
-static yyconst flex_int16_t yy_nxt[272] =
+static yyconst flex_int16_t yy_nxt[302] =
{ 0,
12, 13, 14, 15, 15, 16, 17, 12, 18, 19,
20, 21, 22, 21, 23, 24, 25, 26, 27, 28,
@@ -476,33 +486,37 @@ static yyconst flex_int16_t yy_nxt[272] =
20, 20, 31, 20, 20, 32, 12, 33, 20, 20,
20, 30, 20, 20, 20, 20, 31, 20, 34, 35,
36, 39, 39, 42, 42, 45, 45, 55, 55, 40,
- 40, 53, 65, 54, 54, 57, 79, 56, 66, 71,
- 58, 102, 37, 85, 85, 92, 59, 65, 54, 54,
- 59, 56, 54, 54, 43, 43, 46, 46, 60, 92,
- 67, 61, 60, 55, 55, 61, 62, 80, 72, 66,
-
- 73, 95, 60, 56, 93, 74, 60, 91, 75, 76,
- 77, 59, 109, 54, 54, 55, 55, 56, 93, 86,
- 86, 67, 84, 60, 84, 56, 61, 85, 85, 87,
- 88, 108, 88, 85, 85, 89, 89, 60, 107, 56,
- 86, 86, 96, 87, 96, 89, 89, 97, 97, 100,
- 87, 89, 89, 97, 97, 97, 97, 104, 109, 106,
- 105, 103, 110, 100, 87, 101, 99, 98, 111, 82,
- 94, 104, 38, 38, 38, 38, 41, 41, 41, 41,
- 44, 44, 44, 44, 47, 47, 47, 47, 50, 50,
- 50, 50, 52, 52, 70, 68, 70, 70, 78, 90,
-
- 78, 78, 81, 81, 81, 81, 51, 51, 49, 83,
- 82, 69, 68, 64, 63, 51, 49, 111, 48, 48,
- 11, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111
+ 40, 53, 66, 54, 54, 57, 80, 56, 67, 72,
+ 58, 67, 37, 89, 89, 97, 59, 66, 60, 60,
+ 98, 56, 55, 55, 43, 43, 46, 46, 61, 97,
+ 68, 62, 56, 68, 98, 120, 63, 81, 73, 121,
+
+ 74, 85, 61, 54, 54, 75, 56, 112, 76, 77,
+ 78, 55, 55, 86, 90, 90, 87, 88, 100, 88,
+ 120, 56, 89, 89, 91, 119, 92, 86, 93, 89,
+ 89, 94, 94, 101, 101, 56, 90, 90, 91, 96,
+ 96, 103, 103, 102, 94, 94, 91, 96, 96, 96,
+ 96, 94, 94, 92, 110, 92, 118, 102, 103, 103,
+ 91, 96, 96, 96, 96, 105, 117, 106, 110, 116,
+ 107, 107, 101, 101, 105, 115, 105, 103, 103, 113,
+ 113, 114, 102, 113, 113, 107, 107, 107, 107, 115,
+ 113, 113, 111, 109, 108, 104, 102, 38, 38, 38,
+
+ 38, 41, 41, 41, 41, 44, 44, 44, 44, 47,
+ 47, 47, 47, 50, 50, 50, 50, 52, 52, 71,
+ 122, 71, 71, 79, 83, 79, 79, 82, 82, 82,
+ 82, 99, 69, 95, 52, 51, 51, 49, 84, 83,
+ 70, 69, 65, 64, 52, 51, 49, 122, 48, 48,
+ 11, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+
+ 122
} ;
-static yyconst flex_int16_t yy_chk[272] =
+static yyconst flex_int16_t yy_chk[302] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -511,29 +525,33 @@ static yyconst flex_int16_t yy_chk[272] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 3, 4, 5, 6, 7, 8, 23, 23, 3,
4, 21, 31, 21, 21, 24, 46, 23, 36, 43,
- 24, 123, 2, 84, 84, 64, 25, 31, 25, 25,
- 26, 23, 26, 26, 5, 6, 7, 8, 25, 64,
- 36, 25, 26, 53, 53, 26, 25, 46, 43, 66,
-
- 43, 122, 25, 53, 65, 43, 26, 121, 43, 43,
- 43, 54, 108, 54, 54, 55, 55, 53, 65, 59,
- 59, 66, 56, 54, 56, 55, 54, 56, 56, 59,
- 60, 107, 60, 85, 85, 60, 60, 54, 106, 55,
- 86, 86, 87, 59, 87, 88, 88, 87, 87, 93,
- 86, 89, 89, 96, 96, 97, 97, 99, 109, 105,
- 101, 98, 109, 93, 86, 94, 92, 91, 82, 81,
- 68, 99, 112, 112, 112, 112, 113, 113, 113, 113,
- 114, 114, 114, 114, 115, 115, 115, 115, 116, 116,
- 116, 116, 117, 117, 118, 67, 118, 118, 119, 61,
-
- 119, 119, 120, 120, 120, 120, 58, 50, 49, 48,
- 47, 40, 37, 30, 29, 17, 13, 11, 10, 9,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111
+ 24, 67, 2, 88, 88, 65, 25, 31, 25, 25,
+ 66, 23, 53, 53, 5, 6, 7, 8, 25, 65,
+ 36, 25, 53, 67, 66, 120, 25, 46, 43, 120,
+
+ 43, 54, 25, 54, 54, 43, 53, 133, 43, 43,
+ 43, 55, 55, 54, 59, 59, 54, 56, 132, 56,
+ 119, 55, 56, 56, 59, 118, 61, 54, 61, 89,
+ 89, 61, 61, 85, 85, 55, 90, 90, 59, 63,
+ 63, 92, 92, 85, 93, 93, 90, 63, 63, 63,
+ 63, 94, 94, 86, 98, 86, 117, 85, 86, 86,
+ 90, 63, 63, 63, 63, 91, 116, 91, 98, 111,
+ 91, 91, 101, 101, 102, 109, 102, 103, 103, 102,
+ 102, 108, 101, 105, 105, 106, 106, 107, 107, 109,
+ 113, 113, 99, 97, 96, 87, 101, 123, 123, 123,
+
+ 123, 124, 124, 124, 124, 125, 125, 125, 125, 126,
+ 126, 126, 126, 127, 127, 127, 127, 128, 128, 129,
+ 83, 129, 129, 130, 82, 130, 130, 131, 131, 131,
+ 131, 69, 68, 62, 60, 58, 50, 49, 48, 47,
+ 40, 37, 30, 29, 26, 17, 13, 11, 10, 9,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+ 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
+
+ 122
} ;
/* Table of booleans, true if rule could match eol. */
@@ -633,7 +651,7 @@ static int fromihex(const char *s) {
}
-#line 637 "scanner.c"
+#line 655 "scanner.c"
#define INITIAL 0
#define COMMENT 1
@@ -865,11 +883,6 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 112 "scanner.l"
-
-
-#line 872 "scanner.c"
-
yylval = yylval_param;
if ( !yyg->yy_init )
@@ -898,6 +911,12 @@ YY_DECL
libconfig_yy_load_buffer_state(yyscanner );
}
+ {
+#line 112 "scanner.l"
+
+
+#line 919 "scanner.c"
+
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = yyg->yy_c_buf_p;
@@ -915,7 +934,7 @@ YY_DECL
yy_match:
do
{
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
@@ -924,13 +943,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 112 )
+ if ( yy_current_state >= 123 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_current_state != 111 );
+ while ( yy_current_state != 122 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@@ -941,7 +960,7 @@ yy_find_action:
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
{
- int yyl;
+ yy_size_t yyl;
for ( yyl = 0; yyl < yyleng; ++yyl )
if ( yytext[yyl] == '\n' )
@@ -1157,32 +1176,32 @@ YY_RULE_SETUP
case 32:
YY_RULE_SETUP
#line 184 "scanner.l"
-{ yylval->sval = yytext; return(TOK_NAME); }
+{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 185 "scanner.l"
-{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
+{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 186 "scanner.l"
-{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 187 "scanner.l"
-{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
+{ yylval->ival = fromihex(yytext); return(TOK_HEX); }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 188 "scanner.l"
-{ yylval->ival = fromihex(yytext); return(TOK_HEX); }
+{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 189 "scanner.l"
-{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
+{ yylval->sval = yytext; return(TOK_NAME); }
YY_BREAK
case 38:
YY_RULE_SETUP
@@ -1245,7 +1264,7 @@ YY_RULE_SETUP
#line 209 "scanner.l"
ECHO;
YY_BREAK
-#line 1249 "scanner.c"
+#line 1268 "scanner.c"
case YY_END_OF_BUFFER:
{
@@ -1375,6 +1394,7 @@ ECHO;
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
+ } /* end of user's declarations */
} /* end of libconfig_yylex */
/* yy_get_next_buffer - try to read in a new buffer
@@ -1542,7 +1562,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 112 )
+ if ( yy_current_state >= 123 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1571,11 +1591,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 112 )
+ if ( yy_current_state >= 123 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 111);
+ yy_is_jam = (yy_current_state == 122);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@@ -1997,7 +2017,7 @@ YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, yy_size_t _yy
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- int i;
+ yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
diff --git a/3rdparty/libconfig/scanner.h b/3rdparty/libconfig/scanner.h
index ac79ff5d1..f684433ec 100644
--- a/3rdparty/libconfig/scanner.h
+++ b/3rdparty/libconfig/scanner.h
@@ -17,7 +17,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 37
+#define YY_FLEX_SUBMINOR_VERSION 39
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
diff --git a/src/common/conf.h b/src/common/conf.h
index ac97a5427..0ef86adea 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -16,8 +16,8 @@ struct libconfig_interface {
int (*read) (config_t *config, FILE *stream);
void (*write) (const config_t *config, FILE *stream);
/* */
- void (*set_auto_convert) (config_t *config, int flag);
- int (*get_auto_convert) (const config_t *config);
+ void (*set_auto_convert) (config_t *config, int flag); // TODO: Replace with config_set_options
+ int (*get_auto_convert) (const config_t *config); // TODO: Replace with config_get_options
/* */
int (*read_string) (config_t *config, const char *str);
int (*read_file_src) (config_t *config, const char *filename);
diff --git a/src/map/quest.c b/src/map/quest.c
index fe4014ae5..4958644ee 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -507,7 +507,7 @@ int quest_read_db(void)
const char *filename = "quest_db.conf";
sprintf(filepath, "%s/%s", map->db_path, filename);
- if (libconfig->read_file(&quest_db_conf, filepath) || !(qdb = libconfig->setting_get_member(quest_db_conf.root, filename))) {
+ if (libconfig->read_file(&quest_db_conf, filepath) || !(qdb = libconfig->setting_get_member(quest_db_conf.root, "quest_db"))) {
ShowError("can't read %s\n", filepath);
return -1;
}
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
index 8f999fb37..4d8f55e1f 100644
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -24,10 +24,12 @@ MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-TEST_SPINLOCK_OBJ = obj/test_spinlock.o
-TEST_SPINLOCK_C = test_spinlock.c
-TEST_SPINLOCK_H =
-TEST_SPINLOCK_DEPENDS = $(TEST_SPINLOCK_OBJ) $(COMMON_D)/obj_sql/common_sql.a $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ $(SYSINFO_INC))
+TEST_C = test_libconfig.c test_spinlock.c
+TEST_OBJ = $(addprefix obj/, $(patsubst %c,%o,%(TEST_C)))
+TEST_H =
+TEST_DEPENDS = $(COMMON_D)/obj_sql/common_sql.a $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(SYSINFO_INC)
+
+TESTS_ALL = test_libconfig test_spinlock
@SET_MAKE@
@@ -35,9 +37,9 @@ CC = @CC@
export CC
#####################################################################
-.PHONY: all test_spinlock clean buildclean
+.PHONY: all $(TESTS_ALL) clean buildclean
-all: test_spinlock Makefile
+all: $(TESTS_ALL) Makefile
buildclean:
@echo " CLEAN test (build temp files)"
@@ -45,14 +47,14 @@ buildclean:
clean: buildclean
@echo " CLEAN test"
- @rm -rf ../../test_spinlock@EXEEXT@
+ @rm -rf ../../test_*@EXEEXT@
#####################################################################
Makefile: Makefile.in
@$(MAKE) -C ../.. src/test/Makefile
-$(SYSINFO_INC): $(TEST_SPINLOCK_C) $(TEST_SPINLOCK_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H)
+$(SYSINFO_INC): $(TEST_C) $(TEST_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H)
@echo " MAKE $@"
@$(MAKE) -C ../.. sysinfo
@@ -62,17 +64,21 @@ obj:
@echo " MKDIR obj"
@-mkdir obj
-#executables
+# executables
+
+$(TESTS_ALL): test_%: ../../test_%@EXEEXT@
+ @echo " TEST $@"
-test_spinlock: $(TEST_SPINLOCK_DEPENDS) Makefile
- @echo " LD $@"
- @$(CC) @LDFLAGS@ -o ../../test_spinlock@EXEEXT@ $(TEST_SPINLOCK_DEPENDS) @LIBS@ @MYSQL_LIBS@
+../../test_%@EXEEXT@: obj/test_%.o $(TEST_DEPENDS) Makefile
+ @echo " LD $(notdir $@)"
+ @$(CC) @STATIC@ @LDFLAGS@ -o $@ $< $(COMMON_D)/obj_sql/common_sql.a \
+ $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
# object files
-obj/%.o: %.c $(TEST_SPINLOCK_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj
+obj/%.o: %.c $(TEST_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(COMMON_D)/obj_all/common.a:
diff --git a/src/test/libconfig/test.conf b/src/test/libconfig/test.conf
new file mode 100644
index 000000000..bbdc2cd96
--- /dev/null
+++ b/src/test/libconfig/test.conf
@@ -0,0 +1 @@
+Test: true
diff --git a/src/test/test_libconfig.c b/src/test/test_libconfig.c
new file mode 100644
index 000000000..e0b5b3fca
--- /dev/null
+++ b/src/test/test_libconfig.c
@@ -0,0 +1,842 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Base author: Haru <haru@dotalux.com>
+#define HERCULES_CORE
+
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/core.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+
+#include <stdlib.h>
+
+#define TEST(name, function, ...) do { \
+ const char *message = NULL; \
+ ShowMessage("-------------------------------------------------------------------------------\n"); \
+ ShowNotice("Testing %s...\n", (name)); \
+ if ((message = (function)(##__VA_ARGS__)) != NULL) { \
+ ShowError("Failed. %s\n", message); \
+ ShowMessage("===============================================================================\n"); \
+ ShowFatalError("Failure. Aborting further tests.\n"); \
+ exit(EXIT_FAILURE); \
+ } \
+ ShowInfo("Test passed.\n"); \
+} while (false)
+
+static const char *test_libconfig_truefalse(void)
+{
+ if (CONFIG_TRUE != true) {
+ return "CONFIG_TRUE != true";
+ }
+ if (CONFIG_FALSE != false) {
+ return "CONFIG_FALSE != false";
+ }
+ return NULL;
+}
+
+static const char *test_libconfig_defaults(void)
+{
+ if (libconfig == NULL) {
+ return "Unable to find libconfig interface.";
+ }
+ if (libconfig->init == NULL) {
+ return "Unable to find libconfig methods";
+ }
+ if (libconfig->read_file_src == NULL) {
+ return "Unable to find libconfig core methods";
+ }
+ return NULL;
+}
+
+static const char *test_libconfig_init_destroy(void)
+{
+ config_t config;
+ libconfig->init(&config);
+ if (config.root == NULL || config.root != config_root_setting(&config)) {
+ return "Unable to create config.";
+ }
+ libconfig->destroy(&config);
+ if (config.root != NULL) {
+ return "Unable to destroy config.";
+ }
+ return NULL;
+}
+
+static const char *test_libconfig_read_file_src(void)
+{
+ config_t config;
+#define FILENAME "src/test/libconfig/test.conf"
+ if (libconfig->read_file_src(&config, FILENAME) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to read file '" FILENAME "'.";
+ }
+#undef FILENAME
+ if (config.root == NULL) {
+ libconfig->destroy(&config);
+ return "Invalid config.";
+ }
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_read(void)
+{
+ config_t config;
+#define FILENAME "src/test/libconfig/test.conf"
+ FILE *fp = fopen(FILENAME, "r");
+ if (!fp) {
+ return "File not found: '" FILENAME "'.";
+ }
+ if (libconfig->read(&config, fp) == CONFIG_FALSE) {
+ fclose(fp);
+ libconfig->destroy(&config);
+ return "Unable to read from file '" FILENAME "'.";
+ }
+#undef FILENAME
+ if (config.root == NULL) {
+ libconfig->destroy(&config);
+ return "Invalid config.";
+ }
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_read_file(void)
+{
+ config_t config;
+#define FILENAME "src/test/libconfig/test.conf"
+ if (libconfig->read_file(&config, FILENAME) != 0) {
+ return "Unable to read file '" FILENAME "'.";
+ }
+#undef FILENAME
+ if (config.root == NULL || !config_setting_is_root(config.root)) {
+ libconfig->destroy(&config);
+ return "Invalid config.";
+ }
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_write(void)
+{
+ //void (*write) (const config_t *config, FILE *stream);
+ return "TEST NOT IMPLEMENTED";
+}
+
+static const char *test_libconfig_write_file(void)
+{
+ //int (*write_file) (config_t *config, const char *filename);
+ return "TEST NOT IMPLEMENTED";
+}
+
+static const char *test_libconfig_read_string(void)
+{
+ config_t config;
+ if (libconfig->read_string(&config, "") == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to read from string.";
+ }
+ if (config.root == NULL) {
+ libconfig->destroy(&config);
+ return "Invalid config.";
+ }
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_syntax(void)
+{
+ config_t config;
+ const char *input = "/* Test File */\n"
+ "Setting_Int: 1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Float: 1.0;\n"
+ "Setting_Bool: true;\n"
+ "Setting_String: \"1\";\n"
+ "Setting_Array: [ ];\n"
+ "Setting_Group: { };\n"
+ "Setting_List: ( );\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to read from string.";
+ }
+ if (config.root == NULL) {
+ libconfig->destroy(&config);
+ return "Invalid config.";
+ }
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_set_include_dir(void)
+{
+ //void (*set_include_dir) (config_t *config, const char *include_dir);
+ return "TEST NOT IMPLEMENTED";
+}
+
+static const char *test_libconfig_lookup(void)
+{
+ config_t config;
+ config_setting_t *t = NULL;
+ int32 i32;
+ int64 i64;
+ double f;
+ const char *str;
+ const char *input = "/* Test File */\n"
+ "Setting_Int: 1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Float: 1.0;\n"
+ "Setting_Bool: true;\n"
+ "Setting_String: \"1\";\n"
+ "Setting_Array: [ ];\n"
+ "Setting_Group: { };\n"
+ "Setting_List: ( );\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Int")) == NULL) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup failed.";
+ }
+
+ if ((t = libconfig->lookup_from(config.root, "Setting_Int")) == NULL) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_from failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Int", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_int failed.";
+ }
+
+ if (libconfig->lookup_int64(&config, "Setting_Int64", &i64) == CONFIG_FALSE || i64 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_int64 failed.";
+ }
+
+ if (libconfig->lookup_float(&config, "Setting_Float", &f) == CONFIG_FALSE || f < 1.0 - 0.1 || f > 1.0 + 0.1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_float failed.";
+ }
+
+ if (libconfig->lookup_bool(&config, "Setting_Bool", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_bool failed.";
+ }
+
+ if (libconfig->lookup_string(&config, "Setting_String", &str) == CONFIG_FALSE || str == NULL || str[0] != '1' || str[1] != '\0') {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_string failed.";
+ }
+
+ libconfig->destroy(&config);
+
+ return NULL;
+}
+
+static const char *test_libconfig_setting_get(void)
+{
+ config_t config;
+ config_setting_t *t = NULL;
+ double f;
+ const char *str;
+ const char *input = "/* Test File */\n"
+ "Setting_Int: 1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Float: 1.0;\n"
+ "Setting_Bool: true;\n"
+ "Setting_String: \"1\";\n"
+ "Setting_Array: [ ];\n"
+ "Setting_Group: { };\n"
+ "Setting_List: ( );\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Int")) == NULL || libconfig->setting_get_int(t) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_int failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Int64")) == NULL || libconfig->setting_get_int64(t) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_int64 failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Float")) == NULL || (f = libconfig->setting_get_float(t)) < 1.0 - 0.1 || f > 1.0 + 0.1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_float failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Bool")) == NULL || libconfig->setting_get_bool(t) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_bool failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_String")) == NULL || (str = libconfig->setting_get_string(t)) == NULL || str[0] != '1' || str[1] != '\0') {
+ libconfig->destroy(&config);
+ return "libconfig->lookup_string failed.";
+ }
+
+ t = config_root_setting(&config);
+
+ if (libconfig->setting_get_int_elem(t, 0) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_int_elem failed.";
+ }
+
+ if (libconfig->setting_get_int64_elem(t, 1) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_int64_elem failed.";
+ }
+
+ if ((f = libconfig->setting_get_float_elem(t, 2)) < 1.0 - 0.1 || f > 1.0 + 0.1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_float_elem failed.";
+ }
+
+ if (libconfig->setting_get_bool_elem(t, 3) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_bool_elem failed.";
+ }
+
+ if ((str = libconfig->setting_get_string_elem(t, 4)) == NULL || str[0] != '1' || str[1] != '\0') {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_string_elem failed.";
+ }
+
+ if ((t = libconfig->setting_get_elem(config.root, 0)) == NULL || libconfig->setting_get_int(t) != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_elem failed.";
+ }
+
+ if ((t = libconfig->setting_get_member(config.root, "Setting_Int")) == NULL || libconfig->setting_get_int(t) != 1 || strcmp(config_setting_name(t), "Setting_Int") != 0) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_get_member failed.";
+ }
+
+ if ((t = libconfig->setting_get_elem(config.root, 0)) == NULL || strcmp(config_setting_name(t), "Setting_Int") != 0) {
+ libconfig->destroy(&config);
+ return "config_setting_name failed.";
+ }
+
+ if ((t = libconfig->setting_get_member(config.root, "Setting_Int")) == NULL || libconfig->setting_index(t) != 0) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_index failed.";
+ }
+
+ if (libconfig->setting_length(config.root) != 8) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_length failed.";
+ }
+
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_set(void)
+{
+ //int (*setting_set_int) (config_setting_t *setting ,int value);
+ //int (*setting_set_int64) (config_setting_t *setting, long long value);
+ //int (*setting_set_float) (config_setting_t *setting, double value);
+ //int (*setting_set_bool) (config_setting_t *setting, int value);
+ //int (*setting_set_string) (config_setting_t *setting, const char *value);
+ return "TEST NOT IMPLEMENTED";
+}
+
+static const char *test_libconfig_setting_lookup(void)
+{
+ config_t config;
+ int32 i32;
+ int64 i64;
+ double f;
+ const char *str;
+ const char *input = "/* Test File */\n"
+ "Setting_Int: 1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Float: 1.0;\n"
+ "Setting_Bool: true;\n"
+ "Setting_String: \"1\";\n"
+ "Setting_Array: [ ];\n"
+ "Setting_Group: { };\n"
+ "Setting_List: ( );\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->setting_lookup_int(config.root, "Setting_Int", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_lookup_int failed.";
+ }
+
+ if (libconfig->setting_lookup_int64(config.root, "Setting_Int64", &i64) == CONFIG_FALSE || i64 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_lookup_int64 failed.";
+ }
+
+ if (libconfig->setting_lookup_float(config.root, "Setting_Float", &f) == CONFIG_FALSE || f < 1.0 - 0.1 || f > 1.0 + 0.1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_lookup_float failed.";
+ }
+
+ if (libconfig->setting_lookup_bool(config.root, "Setting_Bool", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "libconfig->setting_lookup_bool failed.";
+ }
+
+ if (libconfig->setting_lookup_string(config.root, "Setting_String", &str) == CONFIG_FALSE || str == NULL || str[0] != '1' || str[1] != '\0') {
+ libconfig->destroy(&config);
+ return "libconfig->setting_lookup_string failed.";
+ }
+
+ libconfig->destroy(&config);
+
+ return NULL;
+}
+
+static const char *test_libconfig_setting_types(void)
+{
+ config_t config;
+ config_setting_t *t;
+ const char *input = "/* Test File */\n"
+ "Setting_Int: 1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Float: 1.0;\n"
+ "Setting_Bool: true;\n"
+ "Setting_String: \"1\";\n"
+ "Setting_Array: [ ];\n"
+ "Setting_Group: { };\n"
+ "Setting_List: ( );\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (config_setting_type(config.root) != CONFIG_TYPE_GROUP) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_GROUP failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Int")) == NULL || config_setting_type(t) != CONFIG_TYPE_INT
+ || config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || config_setting_is_aggregate(t) || !config_setting_is_scalar(t) || !config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_INT failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Int64")) == NULL || config_setting_type(t) != CONFIG_TYPE_INT64
+ || config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || config_setting_is_aggregate(t) || !config_setting_is_scalar(t) || !config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_INT64 failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Float")) == NULL || config_setting_type(t) != CONFIG_TYPE_FLOAT
+ || config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || config_setting_is_aggregate(t) || !config_setting_is_scalar(t) || !config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_FLOAT failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Bool")) == NULL || config_setting_type(t) != CONFIG_TYPE_BOOL
+ || config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || config_setting_is_aggregate(t) || !config_setting_is_scalar(t) || config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_BOOL failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_String")) == NULL || config_setting_type(t) != CONFIG_TYPE_STRING
+ || config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || config_setting_is_aggregate(t) || !config_setting_is_scalar(t) || config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_STRING failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Array")) == NULL || config_setting_type(t) != CONFIG_TYPE_ARRAY
+ || config_setting_is_group(t) || !config_setting_is_array(t) || config_setting_is_list(t)
+ || !config_setting_is_aggregate(t) || config_setting_is_scalar(t) || config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_ARRAY failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Group")) == NULL || config_setting_type(t) != CONFIG_TYPE_GROUP
+ || !config_setting_is_group(t) || config_setting_is_array(t) || config_setting_is_list(t)
+ || !config_setting_is_aggregate(t) || config_setting_is_scalar(t) || config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_GROUP failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_List")) == NULL || config_setting_type(t) != CONFIG_TYPE_LIST
+ || config_setting_is_group(t) || config_setting_is_array(t) || !config_setting_is_list(t)
+ || !config_setting_is_aggregate(t) || config_setting_is_scalar(t) || config_setting_is_number(t)
+ ) {
+ libconfig->destroy(&config);
+ return "CONFIG_TYPE_LIST failed.";
+ }
+
+ libconfig->destroy(&config);
+
+ return NULL;
+}
+
+static const char *test_libconfig_values(void)
+{
+ config_t config;
+ int32 i32;
+ int64 i64;
+ const char *input = "/* Test File */\n"
+ "Setting_Int1: 1;\n"
+ "Setting_IntHex: 0x10;\n"
+ "Setting_IntNegative: -1;\n"
+ "Setting_Int64: 1L;\n"
+ "Setting_Int64Hex: 0x10L;\n"
+ "Setting_Int64Negative: -1L;\n"
+ "Setting_IntSignedMax: 0x7fffffff;\n"
+ "/* End test file */\n";
+
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->setting_lookup_int(config.root, "Setting_Int1", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "(int) 1 failed.";
+ }
+
+ if (libconfig->setting_lookup_int(config.root, "Setting_IntHex", &i32) == CONFIG_FALSE || i32 != 0x10) {
+ libconfig->destroy(&config);
+ return "(int) 0x10 failed.";
+ }
+
+ if (libconfig->setting_lookup_int(config.root, "Setting_IntNegative", &i32) == CONFIG_FALSE || i32 != -1) {
+ libconfig->destroy(&config);
+ return "(int) -1 failed.";
+ }
+
+ if (libconfig->setting_lookup_int64(config.root, "Setting_Int64", &i64) == CONFIG_FALSE || i64 != 1) {
+ libconfig->destroy(&config);
+ return "(int64) 1 failed.";
+ }
+
+ if (libconfig->setting_lookup_int64(config.root, "Setting_Int64Hex", &i64) == CONFIG_FALSE || i64 != 0x10) {
+ libconfig->destroy(&config);
+ return "(int64) 0x10 failed.";
+ }
+
+ if (libconfig->setting_lookup_int64(config.root, "Setting_Int64Negative", &i64) == CONFIG_FALSE || i64 != -1) {
+ libconfig->destroy(&config);
+ return "(int64) -1 failed.";
+ }
+
+ if (libconfig->setting_lookup_int(config.root, "Setting_IntSignedMax", &i32) == CONFIG_FALSE || i32 != INT32_MAX) {
+ libconfig->destroy(&config);
+ return "(int) INT32_MAX failed.";
+ }
+
+ libconfig->destroy(&config);
+
+ return NULL;
+}
+
+static const char *test_libconfig_path_lookup(void)
+{
+ config_t config;
+ int32 i32;
+ const char *input = "/* Test File */\n"
+ "Setting_Array: [1, 2, 3];\n"
+ "Setting_Group: {\n"
+ " Group_Nested1: 4;\n"
+ " Group_Nested2: 5;\n"
+ " Group_Nested3: 6;\n"
+ " Group_Nested4: 7;\n"
+ "};\n"
+ "Setting_List: (\n"
+ " (\"List_Nested1\", 8),\n"
+ " (\"List_Nested2\", 9),\n"
+ " 10,\n"
+ ");\n"
+ "/* End test file */\n";
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Array/[0]", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "Setting_Array/[0] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Array:[0]", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "Setting_Array:[0] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Array/[1]", &i32) == CONFIG_FALSE || i32 != 2) {
+ ShowDebug("%d\n", i32);
+ libconfig->destroy(&config);
+ return "Setting_Array/[1] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Array/[2]", &i32) == CONFIG_FALSE || i32 != 3) {
+ libconfig->destroy(&config);
+ return "Setting_Array/[2] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Group/Group_Nested1", &i32) == CONFIG_FALSE || i32 != 4) {
+ libconfig->destroy(&config);
+ return "Setting_Group/Group_Nested1 failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Group/Group_Nested2", &i32) == CONFIG_FALSE || i32 != 5) {
+ libconfig->destroy(&config);
+ return "Setting_Group/Group_Nested2 failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Group/Group_Nested3", &i32) == CONFIG_FALSE || i32 != 6) {
+ libconfig->destroy(&config);
+ return "Setting_Group/Group_Nested3 failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Group/Group_Nested4", &i32) == CONFIG_FALSE || i32 != 7) {
+ libconfig->destroy(&config);
+ return "Setting_Group/Group_Nested4 failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_List/[0]/[1]", &i32) == CONFIG_FALSE || i32 != 8) {
+ libconfig->destroy(&config);
+ return "Setting_List/[0]/[1] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_List/[1]/[1]", &i32) == CONFIG_FALSE || i32 != 9) {
+ libconfig->destroy(&config);
+ return "Setting_List/[1]/[1] failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_List/[2]", &i32) == CONFIG_FALSE || i32 != 10) {
+ libconfig->destroy(&config);
+ return "Setting_List/[2] failed.";
+ }
+
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_setting_names(void)
+{
+ config_t config;
+ int32 i32;
+ const char *input = "/* Test File */\n"
+ "Setting'with'apostrophes: 1;\n"
+ "Setting.with.periods: 2;\n"
+ "Setting: {\n"
+ " with: {\n"
+ " periods: 3;\n"
+ " };\n"
+ " nested: {\n"
+ " in: {\n"
+ " groups: 4;\n"
+ " };\n"
+ " };\n"
+ "};\n"
+ "1st_setting_with_numbers: 5;\n"
+ "/* End test file */\n";
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting'with'apostrophes", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "Setting'with'apostrophes failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting.with.periods", &i32) == CONFIG_FALSE || i32 != 2) {
+ libconfig->destroy(&config);
+ return "Setting.with.periods failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting:with:periods", &i32) == CONFIG_FALSE || i32 != 3) {
+ libconfig->destroy(&config);
+ return "Setting:with:periods failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting:nested:in:groups", &i32) == CONFIG_FALSE || i32 != 4) {
+ libconfig->destroy(&config);
+ return "Setting:nested:in:groups failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting/nested/in/groups", &i32) == CONFIG_FALSE || i32 != 4) {
+ libconfig->destroy(&config);
+ return "Setting/nested/in/groups failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "1st_setting_with_numbers", &i32) == CONFIG_FALSE || i32 != 5) {
+ libconfig->destroy(&config);
+ return "1st_setting_with_numbers failed.";
+ }
+
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_duplicate_keys(void)
+{
+ config_t config;
+ int32 i32;
+ config_setting_t *t, *tt;
+ int i = 0;
+ const char *input = "/* Test File */\n"
+ "Setting_Group: {\n"
+ " Duplicate: 1;\n"
+ " Duplicate: 2;\n"
+ " Duplicate: 3;\n"
+ " Duplicate: 4;\n"
+ "};\n"
+ "/* End test file */\n";
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting_Group/Duplicate", &i32) == CONFIG_FALSE || i32 != 1) {
+ libconfig->destroy(&config);
+ return "Setting_Group/Duplicate failed.";
+ }
+
+ if ((t = libconfig->lookup(&config, "Setting_Group")) == NULL) {
+ libconfig->destroy(&config);
+ return "Setting_Group failed.";
+ }
+
+ if (libconfig->setting_length(t) != 4) {
+ libconfig->destroy(&config);
+ return "Wrong amount of duplicates.";
+ }
+
+ while ((tt = libconfig->setting_get_elem(t, i++)) != NULL) {
+ if (i != libconfig->setting_get_int(tt)) {
+ libconfig->destroy(&config);
+ return "Duplicate ordering error.";
+ }
+ }
+
+ if (i != 5) {
+ libconfig->destroy(&config);
+ return "Wrong amount of duplicates scanned.";
+ }
+
+
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+static const char *test_libconfig_special_string_syntax(void)
+{
+ config_t config;
+ const char *str;
+ const char *input = "/* Test File */\n"
+ "SpecialString: <\"This is an \"Item_Script\" Special String\n\tWith a line-break inside.\">;\n"
+ "/* End test file */\n";
+ if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
+ libconfig->destroy(&config);
+ return "Unable to parse configuration.";
+ }
+
+ if (libconfig->lookup_string(&config, "SpecialString", &str) == CONFIG_FALSE || str == NULL) {
+ libconfig->destroy(&config);
+ return "String lookup failed.";
+ }
+
+ if (strcmp("This is an \"Item_Script\" Special String\n\tWith a line-break inside.", str) != 0) {
+ libconfig->destroy(&config);
+ return "String mismatch.";
+ }
+
+ libconfig->destroy(&config);
+ return NULL;
+}
+
+int do_init(int argc, char **argv)
+{
+ ShowMessage("===============================================================================\n");
+ ShowStatus("Starting tests.\n");
+
+ TEST("CONFIG_TRUE and CONFIG_FALSE", test_libconfig_truefalse);
+ TEST("libconfig availability", test_libconfig_defaults);
+ TEST("libconfig->init and libconfig->destroy", test_libconfig_init_destroy);
+ TEST("libconfig->read_file_src", test_libconfig_read_file_src);
+ TEST("libconfig->read", test_libconfig_read);
+ TEST("libconfig->read_file", test_libconfig_read_file);
+ (void)test_libconfig_write; //TEST("libconfig->write", test_libconfig_write);
+ (void)test_libconfig_write_file; //TEST("libconfig->write_file", test_libconfig_write_file);
+ TEST("libconfig->read_string", test_libconfig_read_string);
+ TEST("libconfig syntax", test_libconfig_syntax);
+ (void)test_libconfig_set_include_dir; //TEST("libconfig->set_include_dir", test_libconfig_set_include_dir);
+ //int (*setting_set_format) (config_setting_t *setting, short format);
+ //short (*setting_get_format) (const config_setting_t *setting);
+ //config_setting_t * (*setting_set_int_elem) (config_setting_t *setting, int idx, int value);
+ //config_setting_t * (*setting_set_int64_elem) (config_setting_t *setting, int idx, long long value);
+ //config_setting_t * (*setting_set_float_elem) (config_setting_t *setting, int idx, double value);
+ //config_setting_t * (*setting_set_bool_elem) (config_setting_t *setting, int idx, int value);
+ //config_setting_t * (*setting_set_string_elem) (config_setting_t *setting, int idx, const char *value);
+ //config_setting_t * (*setting_add) (config_setting_t *parent, const char *name, int type);
+ //int (*setting_remove) (config_setting_t *parent, const char *name);
+ //int (*setting_remove_elem) (config_setting_t *parent, unsigned int idx);
+ //void (*setting_set_hook) (config_setting_t *setting, void *hook);
+ //void (*set_destructor) (config_t *config, void (*destructor)(void *));
+ TEST("libconfig->lookup_*", test_libconfig_lookup);
+ TEST("libconfig->setting_get_*", test_libconfig_setting_get);
+ (void)test_libconfig_set; //TEST("libconfig->setting_set_*", test_libconfig_setting_set);
+ TEST("libconfig->setting_lookup_*", test_libconfig_setting_lookup);
+ TEST("setting types", test_libconfig_setting_types);
+ //void (*setting_copy_simple) (config_setting_t *parent, const config_setting_t *src);
+ //void (*setting_copy_elem) (config_setting_t *parent, const config_setting_t *src);
+ //void (*setting_copy_aggregate) (config_setting_t *parent, const config_setting_t *src);
+ //int (*setting_copy) (config_setting_t *parent, const config_setting_t *src);
+ TEST("values", test_libconfig_values);
+ TEST("path lookup", test_libconfig_path_lookup);
+ TEST("setting key names", test_libconfig_setting_names);
+ TEST("duplicate keys", test_libconfig_duplicate_keys);
+ TEST("special string syntax", test_libconfig_special_string_syntax);
+
+ core->runflag = CORE_ST_STOP;
+ return EXIT_SUCCESS;
+}
+
+int do_final(void) {
+ ShowMessage("===============================================================================\n");
+ ShowStatus("All tests passed.\n");
+ return EXIT_SUCCESS;
+}
+
+void do_abort(void) { }
+
+void set_server_type(void)
+{
+ SERVER_TYPE = SERVER_TYPE_UNKNOWN;
+}
+
+void cmdline_args_init_local(void) { }
diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c
index a11f8643b..d4b2c48f9 100644
--- a/src/test/test_spinlock.c
+++ b/src/test/test_spinlock.c
@@ -103,3 +103,5 @@ int do_final(void) {
int parse_console(const char* command){
return 0;
}//end: parse_console
+
+void cmdline_args_init_local(void) { }