BodgeMaster
ecf3b14b5a
test/nbt_tags: I have no clue what’s going on here.
...
Committing so I can debug at my PC.
2022-10-06 09:59:48 +02:00
BodgeMaster
3b4c125ca2
tools/arraydump: Reimplement in C++
2022-10-05 05:26:04 +02:00
BodgeMaster
4cb1206839
lib/file: Fix isOpen not being set properly when closing and reopening; add destructor
2022-10-05 05:02:58 +02:00
BodgeMaster
39c5940200
lib/file: Fix a potential memory leak created by yours truly
2022-10-05 04:50:41 +02:00
BodgeMaster
f3e03710f6
lib/file: Ensure a file is actually open before attempting to read
2022-10-05 04:07:46 +02:00
BodgeMaster
72fc923839
lib/nbt: remove now useless comment
2022-10-05 04:02:32 +02:00
BodgeMaster
5059bd0193
lib/file: change File::eof to a function
...
This is just way easier to implement and less messy.
2022-10-05 04:01:18 +02:00
BodgeMaster
8bb633f118
lib/error and lib/file: reassign code 9 to FILE_NOT_OPEN
...
These are not exceptions so we don’t need multiple variants of
generic error in case someone wants to catch it somewhere
up the call stack.
It’s okay to use UNKNOWN for generic errors where we don’t know
exactly what happened.
2022-10-05 03:48:05 +02:00
BodgeMaster
ec44ac9531
lib/file: Check if there are enough bytes left to read
2022-10-05 03:46:42 +02:00
BodgeMaster
341b4c187e
lib/file: Fix (potential) memory leaks
2022-10-05 03:30:01 +02:00
BodgeMaster
79650e390e
lib/nbt: Implement the rest of the functions outline in the header
...
This concludes the implementation of the in-memory NBT representation.
This is still all untested code so it might just blow up in your face.
The next step will be writing tests (and probably a lot of cursing and
debugging)...
2022-10-05 01:12:38 +02:00
BodgeMaster
2d2b67373c
lib/nbt: Yesterday’s progress of implementing more of the functions in the header
2022-10-04 02:39:58 +02:00
BodgeMaster
4c4366f7e6
lib/nbt: Partially update documentation to current terminology.
...
Would probably be better if it were moved to doc/ and completely rewritten.
2022-10-02 07:48:03 +02:00
BodgeMaster
4ef1d2c44f
lib/nbt: Split serializer into two components
...
One for serializing full tags and one for serializing tags without
their header.
The former is what used to be `toRawData` - though a bunch of
duplicated code has been removed by just moving it to the Generic
type class instead of having an implementation on the sub-classes.
The latter is useful for serializing lists.
The previous warning that all of this is untested still applies.
2022-10-02 07:47:12 +02:00
Shwoomple
5920d1d004
commit merge
2022-10-02 08:42:33 +05:30
Shwoomple
056c1e6b11
lib/file.cpp: fix read fubctions.
2022-10-02 08:38:39 +05:30
BodgeMaster
8b1491c311
lib/nbt: Add missing class prefix to function names
2022-10-01 04:57:45 +02:00
BodgeMaster
fc2caf3bc0
lib/nbt: Implement more member functions for tag types
2022-10-01 04:51:53 +02:00
BodgeMaster
89baeebc65
lib/file: Switch to using pointers for passing File objects around
2022-09-30 20:10:28 +02:00
Shwoomple
c204aa7d76
lib/file.cpp:Fix exception warnings
2022-09-30 22:41:55 +05:30
BodgeMaster
09503d3dc7
lib/file: Remove accidentally included C header
2022-09-30 18:31:49 +02:00
BodgeMaster
aa97154474
lib/error: Remove misplaced code fragment
...
brea
2022-09-30 18:09:23 +02:00
Shwoomple
3449e3b9c4
lib/file: Implement broken file functions
2022-09-30 11:02:46 +05:30
Shwoomple
c1d7801436
complete merge
2022-09-28 08:22:09 +05:30
Shwoomple
9610f4a4a2
lib/file: implement open function
2022-09-28 08:21:39 +05:30
BodgeMaster
434c976cc5
lib/nbt: Continue implementing in-memory NBT tag data types
...
This is still all unvalidated work.
For all I know it might cause your computer to burst into flames,
grow an arm and a leg and an eye, and attack you with a sword.
But probably, it will just not work and I will realize that sleepy
past me was a fucking idiot (as always).
2022-09-28 03:43:54 +02:00
BodgeMaster
47fd1f8970
test/nbt_read_write_helpers: Change unnecessarily long string to be just one above the allowed size
2022-09-26 23:53:53 +02:00
BodgeMaster
10b1d9fa0c
lib/nbt: Start implementing NBT data types, make NBT::Helper::writeString() return an error instead of aborting the program
...
The former is finally some progress on getting NBT going,
though at this point it is all unvalidated work.
For all I know it might cause your computer to burst into flames,
grow an arm and a leg and an eye, and attack you with a sword.
But probably, it won’t do that and instead start working after I
have debugged it so much that I wish I could attack my PC with a sword.
The latter is the implementation of a change I prepared in a previous commit
when i added ErrorOrVoid.
2022-09-26 03:11:44 +02:00
BodgeMaster
398321e415
test/nbt*: Replace NBT::helper with NBT::Helper
...
Yes, I forgot to run the test suite before committing.
This is why we need CI.
2022-09-19 11:47:29 +02:00
BodgeMaster
53878c3e2b
lib/nbt: Start implementing the in-memory data structure for NBT
2022-09-15 06:06:47 +02:00
BodgeMaster
ad291ee77d
lib/nbt: Capitalize NBT::Helper because I feel like it
2022-09-15 02:00:07 +02:00
BodgeMaster
aab91a2523
lib/nbt: Fix NBT::validateRawNBTData() and NBT::validateRawListContents closing #52 and #53
2022-09-11 09:14:32 +02:00
BodgeMaster
58b1199e38
lib/javacompat: Fixed JavaCompat::importJavaString() hanging when trying to import long strings
...
This was caused by an integer overflow due to using a too small data type in a counter variable.
2022-09-11 09:08:08 +02:00
Shwoomple
48f8a7dcf2
tools/hexnet: start implementing console input
2022-08-30 00:52:06 +05:30
BodgeMaster
209d0828b4
tools/hexnet: un-comment problematic sections
2022-08-29 21:06:54 +02:00
BodgeMaster
b4d4ce77b2
tools/dumpnbt: better variable name and exit when data is invalid
2022-08-29 21:02:36 +02:00
BodgeMaster
ee5048331c
tools/dumpnbt: start implementing a preliminary version
...
for use until the full NBT library is in place...
2022-08-28 13:59:31 +02:00
BodgeMaster
629c999336
lib/nbt: Return correct error code from read functions ( fixes #17 )
2022-08-27 22:35:10 +02:00
BodgeMaster
cdd17045d1
test/nbt_read_write_helpers: add more tests according to issue #43
2022-08-27 20:10:29 +02:00
BodgeMaster
bb40f6553e
tools/hexnet: comment sections out temporarily to get rid of compile errors
...
Doesn’t compile on Void x86_32 glibc. This will need to be investigated.
I just wanted to get rid of the errors while working on other issues.
Compile command:
ccache g++ -std=c++20 -Wall -Wextra src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet
2022-08-27 11:50:36 +02:00
BodgeMaster
a9759e3bc2
lib/file: Clarify what the functions do, take cursor position into account for cut functions and add missing cut function
2022-08-24 01:38:44 +02:00
BodgeMaster
ab1164557d
lib/file: Write header
...
I hope I didn’t forget anything. Not exactly capable of thinking rn.
2022-08-24 01:27:34 +02:00
BodgeMaster
1b8819ffe5
lib/error: Add ErrorOrVoid
...
This allows for error propagation on functions that would otherwise
not return anything.
2022-08-24 01:21:38 +02:00
BodgeMaster
4934a78aaa
lib/error: Move definitions of constructors of ErrorOr<> inside class definition.
2022-08-24 01:19:59 +02:00
BodgeMaster
5272636cb8
test/nbt_read_write_helpers: fix unit tests for readString()
2022-08-15 13:30:53 +02:00
BodgeMaster
91d16ea451
test/javacompat: add test for mismatched size
2022-08-15 12:24:03 +02:00
BodgeMaster
a1fc0ce4b4
lib/nbt: Fix a possible buffer overflow in readString()
2022-08-15 12:02:58 +02:00
Shwoomple
ca7b121c4d
tools/hexnet: Implement udp partially.
2022-08-15 15:07:33 +05:30
BodgeMaster
25bec4c587
lib/nbt: Validator: Fix bytes not being added up correctly in multiple places
2022-08-15 10:51:50 +02:00
BodgeMaster
589cf1ddaf
lib/nbt: NBT validator: Fix wrong function declaration in the header, fix not using the currentPosition variable when accessing data
2022-08-15 09:53:06 +02:00
BodgeMaster
884a5239c6
lib/nbt: fix a bug in NBT::helper::readString() which caused it to asuume that dataSize is the size of the string
2022-08-15 09:51:46 +02:00
BodgeMaster
9190cad80d
lib/nbt: finish implementation of validateRawNBTData() and fix a critical macro-induced bug
...
I did a `#define return` and then tried to `if () return;` everywhere...
2022-08-15 08:50:07 +02:00
BodgeMaster
a862590370
lib/nbt: Start implementing the NBT validator
...
In theory, this is it. It’s just missing the portion that deals with lists
and unit tests. Both will each likely require similar effort to this.
2022-08-15 05:20:05 +02:00
BodgeMaster
3995e97f03
lib/javacompat: Make the endianness error message refer to the correct function
2022-08-15 02:07:00 +02:00
BodgeMaster
c9ec524db1
test/nbt_size_helpers: Implement tests for valid input
2022-08-13 17:32:47 +02:00
BodgeMaster
73ae58e522
test/assert: Add line number to assertion failed message
2022-08-13 17:32:47 +02:00
BodgeMaster
acc19ae100
lib/nbt: Change behavior of totalTagSize to treat encounters of compounds and lists as errors
...
I stumbled over this when writing the unit test. Previously, it would return
an error code but explicitly mark it as not being an error. This was intended
behavior but I decided to change it because I didn’t anticipate it when writing
the test.
Technically `ErrorOr<T>` can be used to pass any message alongside `T`,
but practically, it is reasonable to assume that the error code is
`ErrorCodes::SUCCESS` when `isError` is false. Therefore, this feature
should be really only used in the weirdest edge cases - if at all.
Even then, it is most likely still preferable to flag it as an error and
just hand the resulting `T` back using the long constructor
`ErrorOr<T>(bool, uint8_t, T)`.
2022-08-13 17:32:47 +02:00
BodgeMaster
149285c357
lib/nbt: Finish implementing containedDataLength, rename nextTagTotalSize->totalTagSize and nextTagDataLength->containedDataLength
2022-08-13 17:32:47 +02:00
BodgeMaster
0c92bdf8fd
test/nbt_size_helpers: begin adding unit tests for lib/nbt's new nextTag size helpers
2022-08-13 17:32:47 +02:00
BodgeMaster
86f1ef596f
lib/nbt: Begin implementing nextTagDataLength
2022-08-13 17:32:47 +02:00
BodgeMaster
027f324f03
lib/nbt: Fix a bug in nextTagTotalSize and significantly improve readability by removing redundant code
2022-08-13 17:32:47 +02:00
BodgeMaster
f5d85da98c
lib/nbt: Move the functions for getting tag sizes into the helper namespace, give up on handling lists the same as all other tags
...
I tried dealing with lists in the same way as with other more basic tags
but came to the conclusion that this is most likely not feasible in the same
way that it is not feasible for compounds. It would require a mini-parser
that can deal with all sorts of tags (including nested lists and compounds).
Instead, an approach more similar to the recursion for compound tags will
be used (using its own function to deal with the missing tag headers ofc).
2022-08-13 17:32:47 +02:00
BodgeMaster
396b9673fd
lib/nbt: Various minor fixes to get the program to compile properly
2022-08-13 17:32:47 +02:00
BodgeMaster
68fbf3ae20
lib/nbt: remove a function used to get the next tag type which introduced unnecessary complexity
2022-08-13 17:32:47 +02:00
BodgeMaster
5400790e78
test/nbt*: rename files, move byte tag object test from helper test file into its own file
2022-08-13 17:32:47 +02:00
BodgeMaster
c7dd5471dd
lib/nbt: Start implementing NBT validator
2022-08-13 17:32:47 +02:00
BodgeMaster
8048dc8891
tools/hexnet: Put the new usage generator to use and remove prefixes for IPv4 and IPv6
...
The prefixes were part of a planned feature but since a connection is
either IPv4 or IPv6 but never both, it would have been completely useless
to specify which to use. Instead, only TCP and UDP will need to be specified.
2022-08-12 12:30:55 +02:00
BodgeMaster
a1f16e6f6b
lib/cli: Fix the usage text generator not dealing well with absent sections
2022-08-12 11:59:42 +02:00
Shwoomple
cb7b5ddba7
lib/cli: Add usage generator.
2022-08-12 13:35:56 +05:30
Shwoomple
e0648720bb
tools/hexnet: Implement ipv6 support.
2022-08-11 22:55:12 +05:30
Shwoomple
ebcf436a18
lib/cli: delete duplicate header file.
2022-08-11 18:57:22 +05:30
BodgeMaster
aef91fe7cd
test/nbt_helpers: Fix wrong test pass message
2022-08-04 07:50:20 +02:00
BodgeMaster
4af9003761
Code style: I just decided to accept that float and double exist and that we can just assume they are 32 and 64 bits repectively.
...
This isn't going to run on an Arduino or anything like that anyway.
2022-08-04 07:47:24 +02:00
Milan Suman
704b440d5a
lib/nbt: Add tag classes
2022-08-04 00:01:12 +05:30
BodgeMaster
608767f5c2
tools/hexnet: Add more command line flags and options
...
This only adds the options to the parser. They aren't used anywhere in the code yet.
2022-08-02 03:42:37 +02:00
BodgeMaster
e31bff0802
test/nbt_writestring_failure_mode: Add license information
2022-08-02 03:37:10 +02:00
BodgeMaster
5c73308934
Rename all headers from .h++ to .hpp
...
Idk why I did that in the first place. Probably bc hpp looks stupid.
But having a + in a file name bugs me just as much. And other ppl as well.
So I changed it.
2022-08-02 03:35:08 +02:00
BodgeMaster
b59fe1857e
lib/cli: minor refactoring to make things less confusing and nicer to use
...
I renamed "unpositional arguments" to "options" and "positional arguments" to "arguments".
This is intended to make the code more readable and easier to type out.
2022-08-02 03:16:54 +02:00
BodgeMaster
69f15e928a
lib/cli: Add fields for a short description and additional usage information to the arguments parser
...
This is in preparation for building the help text generator.
2022-08-02 02:03:50 +02:00
BodgeMaster
d0d02fc8d2
tools/hexnet: Move the TCP reading portion to a thread
...
This was too straight-forward to not just do it when I previously worked
on hexnet. Why didn't I just do it? Idk.
2022-08-02 01:07:20 +02:00
BodgeMaster
1308327fae
tests: OCD fixes lol
...
sorry
2022-08-02 01:04:45 +02:00
BodgeMaster
4582c3e595
test/nbt_helpers: move the test that aborts to its own program
2022-08-02 00:41:11 +02:00
BodgeMaster
28719072bb
fix a compiler warning
2022-08-01 16:39:18 +02:00
Milan Suman
4f1ad714bd
lib/nbt.cpp: Implement writeString function
2022-07-28 17:15:04 +05:30
BodgeMaster
adc9a7f36b
tools/hexnet: prepare for multithreading
...
Multithreading will be needed to simultaneously receive and send data.
The preparations include:
- move all the settings of the program into global scope
- add mutexes
- move the code that reads from the TCP socket into a dedicated function
2022-07-25 15:55:40 +02:00
BodgeMaster
b044503951
test/cli_argument_parser: get rid of useless parameters
...
(pointed out by compiler warning)
2022-07-23 10:55:03 +02:00
BodgeMaster
6baff11ebd
test/cli_argument_parser: implement tests for generated error messages
2022-07-21 09:41:04 +02:00
BodgeMaster
c9d6cf0b5e
lib/cli: minor consistency changes
2022-07-21 09:39:45 +02:00
BodgeMaster
a51c65c9f2
test/javacompat: get rid of a compiler warning
2022-07-20 19:22:06 +02:00
BodgeMaster
0dcc579bb5
test/cli_arguments_parser: extend some tests, implement all remaining parser tests except checking for error messages
2022-07-20 19:16:02 +02:00
BodgeMaster
db3b133f88
lib/cli: fix trailing incomplete unpositional arguments
...
The parser used to rely on the next iteration of the loop to detect
if an unpositional argument was missing its value, this has now been
fixed by adding an additional check on unpositional arguments waiting
for a value that detects if the end of the loop has been reached
2022-07-20 18:30:25 +02:00
BodgeMaster
2cc2543b2a
lib/error: fix compiler error with g++11 or newer
...
This wasprobably a syntax error on my part.
2022-07-20 09:58:58 +02:00
BodgeMaster
a0d2974f0a
test/cli_argument_parser: fix programmer-generated segfault
2022-07-20 08:46:06 +02:00
Milan Suman
4659946a2f
src/test: free pointers
2022-07-20 12:13:47 +05:30
Milan Suman
b5312aeb58
lib/nbt: implement readString NBT helper function
2022-07-20 12:08:04 +05:30
BodgeMaster
9562ae7be9
Merge branch 'master' of https://lostcave.ddnss.de/git/BodgeMaster/FOSS-VG
2022-07-20 08:07:03 +02:00
BodgeMaster
b1733bc007
tools/hexnet: initial implementation of TCP receive only server
2022-07-20 08:06:45 +02:00
Milan Suman
d315c6fcfc
Merge branch 'broken'
2022-07-20 10:39:16 +05:30
Milan Suman
2f38636a27
lib/javacompat: implement exportJavaString
2022-07-20 10:38:55 +05:30
Milan Suman
0462756451
lib: rename java_string to javacompat
2022-07-20 08:44:56 +05:30