rewrite comments into one, unified style
This commit is contained in:
1 parent
6260de0085
commit
467a58c9c6
163 files changed
+3560
-2556
No files matched your search
@@ -1,18 +1,23 @@
|
||||
// User application entry points for tcpserve.
|
||||
|
||||
#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 port.
|
||||
static bool parse_port(const char* s, uint16_t* out) {
|
||||
if (!s || !*s || !out) return false;
|
||||
uint32_t v = 0;
|
||||
@@ -56,11 +64,13 @@ static bool parse_port(const char* s, uint16_t* out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements the usage operation.
|
||||
static void usage(void) {
|
||||
print("usage: tcpserve.exe [port]\n");
|
||||
print("default: tcpserve.exe 8080\n");
|
||||
}
|
||||
|
||||
// Runs the requested operation.
|
||||
int main(void) {
|
||||
uint16_t port = 8080;
|
||||
|
||||
|
||||
Reference in new issue
Block a user