rewrite comments into one, unified style

This commit is contained in:
maksw committed 2026-06-15 10:17:48 +02:00
1 parent 6260de0085
commit 467a58c9c6
163 files changed
+3560 -2556

No files matched your search

+15
View File
@@ -1,18 +1,23 @@
// User application entry points for httpget.
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include <ntlite/syscall.h>
// Prints the requested operation.
static void print(const char* s) {
if (s) { SYS_WRITE_CONSOLE_REQUEST req = { SysSvFromCstr(s) }; SysWriteConsole(&req); }
}
// Prints char.
static void print_char(char c) {
SYS_WRITE_CONSOLE_REQUEST req = { SysSvFromParts(&c, 1) };
SysWriteConsole(&req);
}
// Prints u64.
static void print_u64(uint64_t v) {
char buf[32];
int n = 0;
@@ -24,6 +29,7 @@ static void print_u64(uint64_t v) {
while (n > 0) print_char(buf[--n]);
}
// Appends char.
static void append_char(char* dst, size_t cap, size_t* off, char c) {
if (!dst || !off || cap == 0 || *off + 1 >= cap) return;
dst[*off] = c;
@@ -31,11 +37,13 @@ static void append_char(char* dst, size_t cap, size_t* off, char c) {
dst[*off] = 0;
}
// Appends str.
static void append_str(char* dst, size_t cap, size_t* off, const char* s) {
if (!s) return;
while (*s) append_char(dst, cap, off, *s++);
}
// Appends u8.
static void append_u8(char* dst, size_t cap, size_t* off, uint8_t v) {
if (v >= 100) {
append_char(dst, cap, off, (char)('0' + v / 100));
@@ -50,6 +58,7 @@ static void append_u8(char* dst, size_t cap, size_t* off, uint8_t v) {
}
}
// Implements the format ipv4 operation.
static void format_ipv4(char* dst, size_t cap, const uint8_t ip[4]) {
size_t off = 0;
if (!dst || cap == 0) return;
@@ -60,6 +69,7 @@ static void format_ipv4(char* dst, size_t cap, const uint8_t ip[4]) {
append_u8(dst, cap, &off, ip[3]);
}
// Parses u8.
static bool parse_u8(const char** p, uint8_t* out) {
const char* s = *p;
uint32_t v = 0;
@@ -76,6 +86,7 @@ static bool parse_u8(const char** p, uint8_t* out) {
return true;
}
// Parses ipv4.
static bool parse_ipv4(const char* s, uint8_t ip[4]) {
if (!s || !ip) return false;
for (int i = 0; i < 4; i++) {
@@ -88,6 +99,7 @@ static bool parse_ipv4(const char* s, uint8_t ip[4]) {
return *s == 0;
}
// Implements the next token operation.
static const char* next_token(const char* s, char* out, size_t outSize) {
if (!s || !out || outSize == 0) return NULL;
while (*s == ' ' || *s == '\t') s++;
@@ -102,11 +114,13 @@ static const char* next_token(const char* s, char* out, size_t outSize) {
return s;
}
// Implements the usage operation.
static void usage(void) {
print("usage: httpget.exe [host-or-ipv4] [path]\n");
print("default: httpget.exe 10.0.2.2 /\n");
}
// Implements the resolve host operation.
static uint32_t resolve_host(const char* host, uint8_t ip[4]) {
if (parse_ipv4(host, ip))
return SYS_STATUS_SUCCESS;
@@ -134,6 +148,7 @@ static uint32_t resolve_host(const char* host, uint8_t ip[4]) {
return SYS_STATUS_SUCCESS;
}
// Runs the requested operation.
int main(void) {
uint8_t ip[4] = {10, 0, 2, 2};
char host[256];