Commit graph

49 commits

Author SHA1 Message Date
539fde773f Fix CanonicalJson and ArraySort. 2023-06-21 02:37:56 +00:00
e3badbd55c Format source code. 2023-06-18 02:53:52 +00:00
1f14169284 Apply #70: Fix warnings of unused variables. 2023-06-12 14:10:08 +00:00
af15234799 Make the debug server more accurately mimic the actual server. 2023-06-10 13:16:41 +00:00
88f73a6131 Fix a few segfaults in http and json. 2023-05-29 22:48:50 +00:00
d81600d944 Fix more memory leaks in json.
By doing a little reference tracking, we can make sure we don't miss any
JsonValues that may be floating around by the time we're done.
2023-05-26 22:11:07 +00:00
2693b89598 Add sane default memory hook to Cytoplasm, fix more leaks in json. 2023-05-23 22:43:37 +00:00
e22cf38eac Fix leaks in json. 2023-05-23 20:34:27 +00:00
b1049a9a70 Fix leak in http. 2023-05-23 20:19:27 +00:00
441599b088 Don't leak so much memory. 2023-05-23 17:53:19 +00:00
f2f972bb9d Fix memory leaks in hdoc. 2023-05-15 22:38:52 +00:00
4043285413 Telodendria and all tools now use the Cytoplasm runtime stub.
This reduces the amount of manual work programs have to do, and gives us
some free features, like automatic leak reports in all tools.
2023-05-14 22:15:48 +00:00
8021cff122 Make Telodendria use Cytoplasm.
This commit removes all the duplicate code and makes Telodendria use the
new Cytoplasm library.
2023-05-14 19:35:23 +00:00
0b11b97022 Add StrEquals(), as equality checking is the most common use for strcmp().
This allows us to get rid of the hideous MATRIX_PATH_PART_EQUALS macro,
and prevents inconsistent usage of strcmp() (for example, !strcmp() vs
strcmp() == 0).

StrEquals() also has sensible behavior for dealing with NULL strings (it
doesn't just segfault like strcmp()).
2023-05-06 22:34:36 +00:00
95ceba0645 Add length calculations to JsonEncode() so we can set Content-Length. 2023-05-06 19:23:13 +00:00
f819093b7d Don't spew unknown expression warnings if @suppress-warnings is set. 2023-04-29 15:28:42 +00:00
0b1b4a8b29 Cope with preprocessor macro usage at the top level of the header.
This workaround allows us to parse the Routes.h properly, although it
notably lacks support for multi-word unknown expressions.
2023-04-29 15:24:46 +00:00
71fa96d10d Format source code. 2023-04-27 20:05:08 +00:00
a00ded6d06 Add support for parsing global variables, not just function declarations. 2023-04-27 20:04:15 +00:00
9292f1d9da Add docs recipe for generating documentation from the headers.
Note that since all the headers are not documented yet, this will fail
because an undocumented function is a fatal error in hdoc.
2023-04-27 18:39:05 +00:00
9880aac674 Split format recipe into format and license.
Format formats only C source code. License applies the license file to
C source code *and* header files.
2023-04-27 18:03:32 +00:00
72467f6503 Begin moving documentation to headers. 2023-04-27 03:08:39 +00:00
3b06ab120b Add some flags to hdoc to make it more useful. 2023-04-27 02:30:44 +00:00
2447bb63cc Add hdoc, a simple tool for generating documentation from a C header.
This is a very early prototype. It works, but it is probably not efficient
or reliable. However, the documentation format it parses is stable, so I
will begin moving the documentation into the headers.
2023-04-27 01:34:49 +00:00
459b2e856f Format source code. 2023-04-25 22:13:28 +00:00
d933d12e1b Make Rand use a provided Mersenne Twister.
This implementation is loosely inspired by the original paper on the
Mersenne Twister, and borrows code from a public-domain implementation of
it, adapting it to fit the style of Telodendria's code, and fixing a few
bugs regarding the size of the data type used.

Neither C nor POSIX provide a good, thread-safe pseudorandom number
generator. The OpenBSD linker started complaining about the use of
rand_r(), and no standard alternative presented itself as worthy of
consideration, so I finally decided it was time to roll my own PRNG.
2023-04-25 21:28:55 +00:00
e0c8530b12 Clean up http client enough to replace curl in send-patch. 2023-04-01 02:46:07 +00:00
e592840c99 Clean up some HTTP client stuff. 2023-04-01 02:13:41 +00:00
7b3d537175 Remove UtilStreamCopy() 2023-04-01 00:20:18 +00:00
2441f07848 Add support for spinning up multiple HTTP servers.
This is useful for having a TLS and a non-TLS version port, like Synapse.
I verified that the multiple-servers does in fact work as intended,
although the TLS server part is broken; I must be doing something
incorrectly with LibreSSL in setting up the server.
2023-03-23 02:12:45 +00:00
fccd15b239 Don't unconditionally close standard input; it may have been used and
closed before. If it was never used, it was never opened.
2023-03-22 18:12:46 +00:00
b58ca7d22e Start working on adding TLS support to HttpServer. 2023-03-22 01:46:24 +00:00
63d07365db Don't close standard output twice, that leads to a segfault! 2023-03-22 00:12:04 +00:00
5289c16e2b Convert all code to new Stream API.
Also made a number of improvmements to tt, making it compatible with more
shells.
2023-03-18 14:32:09 +00:00
65f4c90df3 Rename HttpStream() to HttpServerStream() to match HttpClientStream() 2023-03-16 02:17:48 +00:00
62cd1cdc98 Misc changes. 2023-03-12 03:37:57 +00:00
64add9c9ab Fix unused variable warning. 2023-03-10 20:12:25 +00:00
3037f12907 Add tt and http-debug-server tools. 2023-03-10 18:48:52 +00:00
2d9b706f38 Fix I/O in JsonConsumeWhitespace() and UtilStreamCopy().
These functions previously operated on the assumption that fgetc() would
block; however it will not block on HttpServer streams because those are
non-blocking. They now check error conditions properly before failing
prematurely.
2023-03-10 18:46:03 +00:00
fd12dee62e Make sure a newline is printed after JSON object is pretty-printed. 2023-03-10 04:30:56 +00:00
ca053a12b1 Break out main() into Main.c, fix some compile warnings on Cygwin. 2023-03-09 02:46:04 +00:00
9a1300ff2e Make sure input is initialized. 2023-03-09 02:22:13 +00:00
20ebeb9c32 Switch tp from using jq to json; format td 2023-03-08 22:47:40 +00:00
efdf168085 Allow encoding user-provided strings. 2023-03-08 20:31:49 +00:00
50e599f1cd Implement a mostly-functional query language for JSON. 2023-03-08 19:49:06 +00:00
7b22fb02a2 Implement pretty-printing option in Json.
Telodendria itself doesn't use it, but the json CLI tool does.
2023-03-08 17:15:43 +00:00
cb8c4fceb5 Begin working on JSON CLI tool.
This is a similar situation to the HTTP CLI tool: since we have the
Json API anyway, we might as well have a little command line tool to
replace jq.
2023-03-08 04:06:43 +00:00
1a169d1a2e Fix usage message. 2023-03-08 03:31:34 +00:00
8d75d8a023 Add simple HTTP CLI tool that uses the HttpClient API.
You might be asking why I would just write a simple curl replacement
when curl does the job just fine. Well, the most immediate reason is
to test the HttpClient API, but since Telodendria's goal is to not
be dependent on any third-party code if at all possible, it makes
sense to have a simple HTTP client to use not only for testing
Telodendria, but also for configuring it. When we move the
configuration to the database, we'll ship a script that uses this
tool to allow admins to easily submit API requests.

Do not be concerned that HttpClient does not support TLS yet. TLS
support is necessary for federation to work, so it is coming
eventually.
2023-03-08 03:30:36 +00:00