Format project with clang-format

This commit is contained in:
Dmitriy Shishkov 2025-05-30 23:00:00 +03:00
parent d7fe6cd476
commit 3efbddd3ee
Signed by: dm1sh
GPG Key ID: 027994B0AA357688
11 changed files with 131 additions and 119 deletions

4
.clang-format Normal file
View File

@ -0,0 +1,4 @@
IndentWidth: 4
BreakBeforeBraces: Allman
ColumnLimit: 0
SortIncludes: false

View File

@ -217,7 +217,8 @@ int process_md(article_info article, char **out)
while (buff[i + 2 + n] != ']')
n++;
if (buff[i + 2 + n + 1] == '(') {
if (buff[i + 2 + n + 1] == '(')
{
int k = 0;
while (buff[i + 2 + n + 2 + k] != ')')
k++;
@ -259,7 +260,8 @@ int process_md(article_info article, char **out)
while (buff[i + 1 + n] != ']')
n++;
if (buff[i + 1 + n + 1] == '(') {
if (buff[i + 1 + n + 1] == '(')
{
int k = 0;
while (buff[i + 1 + n + 2 + k] != ')')
k++;

View File

@ -36,7 +36,8 @@ char *gen_file_path(char *req_path)
if (realpath(path, resolved_path) == NULL)
goto exit_error;
if (strncmp(resolved_path, webroot, strlen(webroot)) != 0) {
if (strncmp(resolved_path, webroot, strlen(webroot)) != 0)
{
goto exit_error;
}

View File

@ -154,12 +154,14 @@ int get_album_imgs(img_t **images_arr, int *size, char *title)
char *gen_gallery_html()
{
FILE *album_template_fp = fopen("static/gallery/album.html", "r");
if (album_template_fp == NULL) {
if (album_template_fp == NULL)
{
return "500 Internal Error\n";
}
FILE *image_template_fp = fopen("static/gallery/image.html", "r");
if (image_template_fp == NULL) {
if (image_template_fp == NULL)
{
fclose(album_template_fp);
return "500 Internal Error\n";
}

View File

@ -72,12 +72,13 @@ int get_listener_socket(char *port)
*
* @param {struct sockaddr*} sa
* @return void*
*/
*/
void *get_in_addr(struct sockaddr *sa)
{
if (sa->sa_family == AF_INET) {
return &(((struct sockaddr_in*)sa)->sin_addr);
if (sa->sa_family == AF_INET)
{
return &(((struct sockaddr_in *)sa)->sin_addr);
}
return &(((struct sockaddr_in6*)sa)->sin6_addr);
return &(((struct sockaddr_in6 *)sa)->sin6_addr);
}

View File

@ -17,7 +17,8 @@ void res_404(int fd, char *path)
{
FILE *fp = fopen("static/404.html", "r");
if (fp == NULL) {
if (fp == NULL)
{
res_500(fd);
return;
}
@ -108,7 +109,8 @@ int send_response(int fd, char *req_path)
{
char *file_path = gen_file_path(req_path);
if (file_path == NULL) {
if (file_path == NULL)
{
res_404(fd, req_path);
free(file_path);
return 0;
@ -205,7 +207,7 @@ void handle_get_request(int fd, char *request)
fread(template, file_size, 1, fp);
fclose(fp);
template[file_size-1] = '\0';
template[file_size - 1] = '\0';
article_info *articles = NULL;
int amount = list_articles(&articles);

View File

@ -70,15 +70,15 @@ void handle_process_termination(int signum)
int status;
pid_t pid;
do {
pid = waitpid(-1, &status, WNOHANG);
}
while (pid > 0);
do
{
pid = waitpid(-1, &status, WNOHANG);
} while (pid > 0);
}
/**
* Main
*/
* Main
*/
int main(int argc, char *argv[])
{
int client_fd;

View File

@ -4,7 +4,7 @@
* @brief Prints error
*
* @param {char *} msg
*/
*/
void err_msg(char *msg)
{
fprintf(stderr, "Error: %s\n", msg);