commit d353408058d6088ddcb2a9e3940aa1a7b1102bdb
parent 200061530d6bc8edfef4adbebf90497dbdf14c3a
Author: benjamin paul <bpaul@bpaul.xyz>
Date: Thu, 5 Aug 2021 16:42:43 +1000
clang-format
Diffstat:
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/file.c b/file.c
@@ -1,7 +1,7 @@
-#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -23,7 +23,7 @@ bool
is_directory(const char *name) {
struct stat st;
- stat (name, &st);
+ stat(name, &st);
return S_ISDIR(st.st_mode);
}
@@ -34,9 +34,9 @@ read_file(const char *name) {
size_t length;
FILE *f = fopen(name, "r");
- length = fsize(name);
+ length = fsize(name);
- buf = calloc(length+1, 1);
+ buf = calloc(length + 1, 1);
fread(buf, 1, length, f);
diff --git a/file.h b/file.h
@@ -1,7 +1,7 @@
#pragma once
-#include <stdio.h>
#include <stdbool.h>
+#include <stdio.h>
size_t fsize(FILE *f);
bool valid_path(const char *name);
diff --git a/http.c b/http.c
@@ -25,7 +25,7 @@ respond(char *payload) {
"%s";
length = snprintf(NULL, 0, format, strlen(payload), payload);
- response = calloc(length+1, 1);
+ response = calloc(length + 1, 1);
sprintf(response, format, strlen(payload), payload);
diff --git a/main.c b/main.c
@@ -11,7 +11,6 @@ main() {
int sock, asock;
sock = create_socket();
-
char *buf;
for (;;) {
diff --git a/tcp.c b/tcp.c
@@ -75,7 +75,7 @@ read_socket(int sock) {
read_size = recv(sock, buf2, BUF_SIZE, 0);
cur_size += read_size;
- buf = realloc(buf, cur_size+1);
+ buf = realloc(buf, cur_size + 1);
strcat(buf, buf2);
} while (read_size == BUF_SIZE);