Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: add support for GAME section #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down