TOML Parsing and Code Refactor #15

Closed
FeTetra wants to merge 12 commits from config-parse into main
FeTetra commented 2025-09-01 03:28:01 +00:00 (Migrated from github.com)

This commit changes a decent amount of things, namely:

  1. Patchwork can now parse simple TOML files and has support for string, boolean, and integer values
  2. A lot of code has been moved into individual files of which lie in different directories to neaten up the project

And there are also some smaller changes:

  1. Patchwork is now versioned at build-time using config.mk
  2. The root of the project has been added as an include path for easier includes
  3. Some more error handling has been added surrounding reading the configuration
  4. A function to create a webMAN popup has been added for future use
  5. Memory allocation has been adjusted to use statically-sized buffers in most places
  6. Some things have been changed to fit more consistent C styling practices (more work to be done here)
This commit changes a decent amount of things, namely: 1. Patchwork can now parse simple TOML files and has support for string, boolean, and integer values 2. A lot of code has been moved into individual files of which lie in different directories to neaten up the project And there are also some smaller changes: 1. Patchwork is now versioned at build-time using `config.mk` 2. The root of the project has been added as an include path for easier includes 3. Some more error handling has been added surrounding reading the configuration 4. A function to create a webMAN popup has been added for future use 5. Memory allocation has been adjusted to use statically-sized buffers in most places 6. Some things have been changed to fit more consistent C styling practices (more work to be done here)
Zaprit (Migrated from github.com) reviewed 2025-09-01 03:28:01 +00:00
Zaprit (Migrated from github.com) reviewed 2025-09-01 03:28:01 +00:00
jvyden (Migrated from github.com) reviewed 2025-09-01 03:28:01 +00:00
Zaprit (Migrated from github.com) requested changes 2025-09-02 00:07:45 +00:00
Zaprit (Migrated from github.com) left a comment

Some nitpicks, looks good overall though

Some nitpicks, looks good overall though
@ -10,7 +14,7 @@ LD = $(PPU_DIR)/$(PPU_PREFIX)gcc
SCETOOL ?= ./scetool.exe
Zaprit (Migrated from github.com) commented 2025-09-01 23:44:32 +00:00

Realistically this should probably be a placeholder rather than your local ps3 ip

Realistically this should probably be a placeholder rather than your local ps3 ip
@ -1,83 +1,33 @@
#include <sys/prx.h>
#include <stdlib.h>
#include <sys/ppu_thread.h> // sys_ppu_thread_yield
#include <string.h>
Zaprit (Migrated from github.com) commented 2025-09-01 23:54:45 +00:00

you have done a stupid find and replace, and it has broken the emphasis. please fix.

you have done a stupid find and replace, and it has broken the emphasis. please fix.
@ -127,103 +77,123 @@ void patch_thread(uint64_t arg) {
}
Zaprit (Migrated from github.com) commented 2025-09-01 23:56:43 +00:00
    if (lobby_password[0]) {

this is C, not 0 is true

```suggestion if (lobby_password[0]) { ``` this is C, not 0 is true
Zaprit (Migrated from github.com) commented 2025-09-01 23:59:58 +00:00

this could probably also be statically allocated

    char msgBuf[sizeof(SUCCESS_MESSAGE_WITHOUT_PW)] = SUCCESS_MESSAGE_WITH_PW
    
    if (password_randomized == 0) {
        strcpy(msgBuf, SUCCESS_MESSAGE_WITH_PW);
    }
this could probably also be statically allocated ```suggestion char msgBuf[sizeof(SUCCESS_MESSAGE_WITHOUT_PW)] = SUCCESS_MESSAGE_WITH_PW if (password_randomized == 0) { strcpy(msgBuf, SUCCESS_MESSAGE_WITH_PW); } ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:00:33 +00:00

If going with the suggestion on line 123, this if statement will need to be removed.

If going with the suggestion on line 123, this if statement will need to be removed.
Zaprit (Migrated from github.com) commented 2025-09-02 00:01:55 +00:00

this is wonky looking

this is wonky looking
@ -163,3 +131,4 @@
else {
strcpy(msgBuf, SUCCESS_MESSAGE_WITHOUT_PW);
}
Zaprit (Migrated from github.com) commented 2025-09-02 00:02:30 +00:00

did you change the message for it to require a different offset, I genuinely can't tell at this point.

did you change the message for it to require a different offset, I genuinely can't tell at this point.
Zaprit (Migrated from github.com) commented 2025-09-02 00:02:50 +00:00
            if (digest[0]) {
```suggestion if (digest[0]) { ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:03:03 +00:00
            if (url[0]) {
```suggestion if (url[0]) { ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:03:16 +00:00
            if (url[0]) {
```suggestion if (url[0]) { ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:03:27 +00:00
            if (digest[0]) {
```suggestion if (digest[0]) { ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:03:38 +00:00
            if (url[0]) {
```suggestion if (url[0]) { ```
Zaprit (Migrated from github.com) commented 2025-09-02 00:03:50 +00:00
            if (digest[0]) {
```suggestion if (digest[0]) { ```
Zaprit commented 2025-09-02 00:08:08 +00:00 (Migrated from github.com)

@jvyden do you mind giving this a review when you get a chance please?

@jvyden do you mind giving this a review when you get a chance please?
FeTetra (Migrated from github.com) reviewed 2025-09-02 00:58:04 +00:00
@ -127,103 +77,123 @@ void patch_thread(uint64_t arg) {
}
FeTetra (Migrated from github.com) commented 2025-09-02 00:58:04 +00:00

Why is that? It should still work fine. I could set the value when I create the variable I suppose.

Why is that? It should still work fine. I could set the value when I create the variable I suppose.
FeTetra (Migrated from github.com) reviewed 2025-09-02 01:01:58 +00:00
FeTetra (Migrated from github.com) reviewed 2025-09-02 01:04:15 +00:00
FeTetra (Migrated from github.com) reviewed 2025-09-02 01:07:03 +00:00
@ -127,103 +77,123 @@ void patch_thread(uint64_t arg) {
}
FeTetra (Migrated from github.com) commented 2025-09-02 01:07:03 +00:00

I didn't like how else if () looked with it in front of the } so I just did it this way everywhere lol.

I didn't like how `else if ()` looked with it in front of the `}` so I just did it this way everywhere lol.
FeTetra (Migrated from github.com) reviewed 2025-09-02 01:45:11 +00:00
@ -163,3 +131,4 @@
else {
strcpy(msgBuf, SUCCESS_MESSAGE_WITHOUT_PW);
}
FeTetra (Migrated from github.com) commented 2025-09-02 01:45:11 +00:00

Yes, it is now just a string which doesn't include any of the webMAN request stuff (like "%0A" string in place of newline character). This gets passed to the function which turns strings into webMAN popup requests.

Yes, it is now just a string which doesn't include any of the webMAN request stuff (like `"%0A"` string in place of newline character). This gets passed to the function which turns strings into webMAN popup requests.
FeTetra (Migrated from github.com) reviewed 2025-09-02 02:18:56 +00:00
@ -10,7 +14,7 @@ LD = $(PPU_DIR)/$(PPU_PREFIX)gcc
SCETOOL ?= ./scetool.exe
FeTetra (Migrated from github.com) commented 2025-09-02 02:18:56 +00:00

I'll just fix this at the end so I don't gotta change it every commit.

I'll just fix this at the end so I don't gotta change it every commit.
jvyden (Migrated from github.com) requested changes 2025-09-08 22:19:11 +00:00
jvyden (Migrated from github.com) left a comment

Apologies for the late review, I haven't been feeling well lately.

Apologies for the late review, I haven't been feeling well lately.
@ -0,0 +1,84 @@
#include <stdlib.h>
jvyden (Migrated from github.com) commented 2025-09-08 22:00:14 +00:00

size meant to be size_t?

`size` meant to be `size_t`?
@ -0,0 +6,4 @@
#include <stdbool.h>
#include <sys/return_code.h>
#include <sys/syscall.h>
jvyden (Migrated from github.com) commented 2025-09-08 22:01:00 +00:00

Do we not have a memset function?

Do we not have a memset function?
jvyden (Migrated from github.com) commented 2025-09-08 22:13:14 +00:00

Can we eliminate this magic somehow?

As far as I understand, at some point the function in message.c was meant to do this, according to the comment at the top of the function. Is this no longer planned?

Can we eliminate this magic somehow? As far as I understand, at some point the function in `message.c` was meant to do this, according to the comment at the top of the function. Is this no longer planned?
FeTetra (Migrated from github.com) reviewed 2025-09-09 22:07:58 +00:00
@ -0,0 +6,4 @@
#include <stdbool.h>
#include <sys/return_code.h>
#include <sys/syscall.h>
FeTetra (Migrated from github.com) commented 2025-09-09 22:07:58 +00:00

Initially I had assumed memset didn't link correctly, which is why I thought this function was initially written. Seems to link fine though, so I'll change it.

Initially I had assumed memset didn't link correctly, which is why I thought this function was initially written. Seems to link fine though, so I'll change it.
FeTetra (Migrated from github.com) reviewed 2025-09-09 22:14:08 +00:00
FeTetra (Migrated from github.com) commented 2025-09-09 22:14:08 +00:00

I initially wasn't going mess with it because I didn't see a use case for it, but I missed this. Though I will probably use a "replace next character x in string" approach.

I initially wasn't going mess with it because I didn't see a use case for it, but I missed this. Though I will probably use a "replace next character x in string" approach.
FeTetra commented 2025-09-27 19:04:29 +00:00 (Migrated from github.com)

Sorry it took so long, been busy.

Sorry it took so long, been busy.
jvyden commented 2025-09-27 23:42:42 +00:00 (Migrated from github.com)

why does 2cf2c26449 change line endings (or some other formatting)?

why does 2cf2c264495355b5efc836969d4b320ee50b5d62 change line endings (or some other formatting)?
FeTetra commented 2025-09-29 13:48:21 +00:00 (Migrated from github.com)

why does 2cf2c26449 change line endings (or some other formatting)?

I have no clue, git just died I suppose. The only differences are that I increased the minor version and fixed a function header define I forgot to update.
Perhaps it might've accidentally occurred because I added the changed files to git from my msys2 shell rather than from powershell. I know git likes to mess with line endings.

> why does 2cf2c264495355b5efc836969d4b320ee50b5d62 change line endings (or some other formatting)? I have no clue, git just died I suppose. The only differences are that I increased the minor version and fixed a function header define I forgot to update. Perhaps it might've accidentally occurred because I added the changed files to git from my msys2 shell rather than from powershell. I know git likes to mess with line endings.
FeTetra commented 2025-10-02 00:02:19 +00:00 (Migrated from github.com)

Alright, I've set everything to use LF, should be okay now?

Alright, I've set everything to use LF, should be okay now?

Pull request closed

Sign in to join this conversation.
No description provided.