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 -1
View File
@@ -1,18 +1,23 @@
// User application entry points for udp.
#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,11 +29,13 @@ static void print_u64(uint64_t v) {
while (n > 0) print_char(buf[--n]);
}
// Prints ipv4.
static void print_ipv4(const uint8_t ip[4]) {
print_u64(ip[0]); print("."); print_u64(ip[1]); print(".");
print_u64(ip[2]); print("."); print_u64(ip[3]);
}
// 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++;
@@ -43,6 +50,7 @@ static const char* next_token(const char* s, char* out, size_t outSize) {
return s;
}
// Parses u8.
static bool parse_u8(const char** p, uint8_t* out) {
const char* s = *p;
uint32_t v = 0;
@@ -59,6 +67,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++) {
@@ -71,6 +80,7 @@ static bool parse_ipv4(const char* s, uint8_t ip[4]) {
return *s == 0;
}
// Parses port.
static bool parse_port(const char* s, uint16_t* out) {
if (!s || !*s || !out) return false;
uint32_t v = 0;
@@ -84,6 +94,7 @@ static bool parse_port(const char* s, uint16_t* out) {
return true;
}
// Implements the usage operation.
static void usage(void) {
print("usage:\n");
print(" udp.exe send <ipv4> <port> [message]\n");
@@ -93,6 +104,7 @@ static void usage(void) {
print(" udp.exe listen 9999\n");
}
// Runs send.
static int run_send(const char* cmd) {
char tok[256];
uint8_t ip[4];
@@ -103,7 +115,7 @@ static int run_send(const char* cmd) {
cmd = next_token(cmd, tok, sizeof(tok));
if (!tok[0] || !parse_port(tok, &port)) { usage(); return 1; }
// Skip leading whitespace, then take the entire remaining command line
// Skip leading whitespace, then take the entire remaining command line.
if (cmd) {
while (*cmd == ' ' || *cmd == '\t') {
cmd++;
@@ -151,6 +163,7 @@ static int run_send(const char* cmd) {
return 0;
}
// Runs listen.
static int run_listen(const char* cmd) {
char tok[64];
uint16_t port = 0;
@@ -211,6 +224,7 @@ static int run_listen(const char* cmd) {
return 0;
}
// Runs the requested operation.
int main(void) {
const char* cmd = SysGetPeb()->CommandLine.Data;
char tok[64];