From af1171de59bfa506df1fb7e2097b97a2eb65fee1 Mon Sep 17 00:00:00 2001 From: Jon Feldman Date: Mon, 9 Oct 2017 13:51:48 -0400 Subject: [PATCH 1/2] parser: add support for GAME section --- src/parser.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/parser.c b/src/parser.c index 65a732d..638de51 100644 --- a/src/parser.c +++ b/src/parser.c @@ -16,6 +16,7 @@ static const char *TOKEN_ALL_SECTION = "ALL"; static const char *TOKEN_KERNEL_SECTION = "KERNEL"; +static const char *TOKEN_GAME_SECTION = "GAME"; #ifdef NO_STRING #include @@ -42,6 +43,18 @@ static int strcmp(const char * s1, const char * s2) return (*s1 - *s2); } +static int strncmp(const char * s1, const char * s2, size_t count) +{ + while ((*s1) && (*s1 == *s2) && count != 0) + { + ++s1; + ++s2; + --count; + } + if (count == 0) return 0; + return (*s1 - *s2); +} + #endif // NO_STRING static inline int is_continuation_byte(char b) @@ -243,6 +256,11 @@ void taihen_config_parse(const char *input, const char *section, taihen_config_h { record_entries = 1; } + else if (strcmp(ctx.line_pos, TOKEN_GAME_SECTION) == 0 && strcmp(section, TOKEN_KERNEL_SECTION) != 0 && + strlen(section) == 9 && strncmp(section, "PCS", 3) == 0 && section[3] >= 'A' && section[3] <= 'H') + { + record_entries = 1; + } else if (strcmp(section, ctx.line_pos) == 0) { record_entries = 1; From 090d741a2e69330508a4364de9bbb5b6555b4178 Mon Sep 17 00:00:00 2001 From: Jon Feldman Date: Mon, 9 Oct 2017 14:04:06 -0400 Subject: [PATCH 2/2] readme: update documentation for changes to parser --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c83852..117b9d8 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,9 @@ A section of the same name may appear in the file multiple times. This functiona A section can optionally have the halt point token ```!``` following the section token ```*``` in the configuration file. This token instructs the parser to stop further parsing of the file if the section name is within context. See the examples below for a visual worked case on this feature. ### Reserved names -There are currently two reserved names for sections: +There are currently three reserved names for sections: - ```ALL``` - A catch all user-mode section that will load the modules it contains for every user-mode process. + - ```GAME``` - A user-mode section that will load the modules it contains for every user-mode process with a titleID prefix used for a game such as PCSE, PCSB, and so on. - ```KERNEL``` - A section that loads resident kernel modules on the start of taiHEN. Using the halt point ```!``` on these sections results in undefined behaviour.