commit ee1b8836e6c86b2b962c15f364a8277194bea92f
parent 6eafb16761358da31984aad2b8254970c5e477e4
Author: Francesco Saccone <francesco@francescosaccone.com>
Date: Tue, 1 Apr 2025 10:51:01 +0200
style: wrap long lines when considering tab 8 characters
Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>
Diffstat:
4 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/file.c b/file.c
@@ -54,7 +54,8 @@ get_file_name(char *path) {
}
if (*character_after_last_slash == '\0') {
- /* If path ends in '/', the file name will be considered empty */
+ /* If path ends in '/', the file name will be considered
+ empty */
return "";
}
diff --git a/http.c b/http.c
@@ -26,7 +26,9 @@ parse_http_request(char *request) {
}
if (path_string != NULL) {
- strncpy(result->path, path_string, HTTP_REQUEST_PATH_MAX_LENGTH - 1);
+ strncpy(result->path,
+ path_string,
+ HTTP_REQUEST_PATH_MAX_LENGTH - 1);
result->path[HTTP_REQUEST_PATH_MAX_LENGTH - 1] = '\0';
}
@@ -94,8 +96,8 @@ compose_http_response_full(struct http_response response) {
char *buffer;
/*
- * Read the comment inside the compose_http_response_head function in this
- * same file.
+ * Read the comment inside the compose_http_response_head function in
+ * this same file.
*/
size = strlen(template)
+ strlen(head)
diff --git a/main.c b/main.c
@@ -52,8 +52,8 @@ main(int argc, char *argv[]) {
switch (argument[1]) {
case 'd':
if (strlen(argv[i + 1]) >= DIRECTORY_MAX_LENGTH) {
- print_error("error: directory length must be less than "
- "%u characters",
+ print_error("error: directory length must be "
+ "less than %u characters",
DIRECTORY_MAX_LENGTH);
}
snprintf(directory,
@@ -67,15 +67,16 @@ main(int argc, char *argv[]) {
case 'p':
port = atoi(argv[i + 1]);
if (port < 1 || port > 65535) {
- print_error("error: port must be between 1 and 65535.");
+ print_error("error: port must be between 1 "
+ "and 65535.");
return 1;
};
i++;
break;
case 'i':
if (strlen(argv[i + 1]) >= DIRECTORY_INDEX_MAX_LENGTH) {
- print_error("error: directory index must be less than "
- "%u characters",
+ print_error("error: directory index must be "
+ "less than %u characters",
DIRECTORY_INDEX_MAX_LENGTH);
}
snprintf(directory_index,
@@ -87,8 +88,8 @@ main(int argc, char *argv[]) {
break;
case 'u':
if (strlen(argv[i + 1]) >= USER_NAME_MAX_LENGTH) {
- print_error("error: the user name must be less than "
- "%u characters",
+ print_error("error: the user name must be "
+ "less than %u characters",
USER_NAME_MAX_LENGTH);
}
strncpy(user_name, argv[i + 1], sizeof(user_name) - 1);
@@ -97,8 +98,8 @@ main(int argc, char *argv[]) {
break;
case 'g':
if (strlen(argv[i + 1]) >= GROUP_NAME_MAX_LENGTH) {
- print_error("error: the group name must be less than "
- "%u characters",
+ print_error("error: the group name must be "
+ "less than %u characters",
GROUP_NAME_MAX_LENGTH);
}
strncpy(group_name, argv[i + 1], sizeof(group_name) - 1);
@@ -132,17 +133,20 @@ main(int argc, char *argv[]) {
server_socket_fd = create_socket(port);
if (setgid(group->gr_gid) == -1) {
- print_error("error: could not drop privileges to given group");
+ print_error("error: could not drop privileges to given "
+ "group");
return 1;
}
if (setuid(user->pw_uid) == -1) {
- print_error("error: could not drop privileges to given user");
+ print_error("error: could not drop privileges to given "
+ "user");
return 1;
}
if (access(directory, R_OK) == -1) {
- print_error("error: directory is nonexistent or inaccessible");
+ print_error("error: directory is nonexistent or "
+ "inaccessible");
return 1;
}
@@ -152,7 +156,8 @@ main(int argc, char *argv[]) {
}
if (chdir("/") == -1) {
- print_error("error: could not change directory after chrooting");
+ print_error("error: could not change directory after "
+ "chrooting");
return 1;
}
diff --git a/socket.c b/socket.c
@@ -23,7 +23,9 @@ create_socket(unsigned int port) {
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(port);
- if (bind(socket_fd, (struct sockaddr *)&address, sizeof(address)) == -1) {
+ if (bind(socket_fd,
+ (struct sockaddr *)&address,
+ sizeof(address)) == -1) {
print_error("error: bind socket to address");
return -1;
}
@@ -71,7 +73,8 @@ read_client_request(int client_socket_fd,
ssize_t bytes_received;
if (buffer == NULL || buffer_size == 0) {
- print_error("error: invalid buffer provided in read_client_request");
+ print_error("error: invalid buffer provided in "
+ "read_client_request");
return -1;
}