Format project with clang-format
This commit is contained in:
parent
d7fe6cd476
commit
3efbddd3ee
4
.clang-format
Normal file
4
.clang-format
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
IndentWidth: 4
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
ColumnLimit: 0
|
||||||
|
SortIncludes: false
|
@ -217,7 +217,8 @@ int process_md(article_info article, char **out)
|
|||||||
while (buff[i + 2 + n] != ']')
|
while (buff[i + 2 + n] != ']')
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (buff[i + 2 + n + 1] == '(') {
|
if (buff[i + 2 + n + 1] == '(')
|
||||||
|
{
|
||||||
int k = 0;
|
int k = 0;
|
||||||
while (buff[i + 2 + n + 2 + k] != ')')
|
while (buff[i + 2 + n + 2 + k] != ')')
|
||||||
k++;
|
k++;
|
||||||
@ -259,7 +260,8 @@ int process_md(article_info article, char **out)
|
|||||||
while (buff[i + 1 + n] != ']')
|
while (buff[i + 1 + n] != ']')
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (buff[i + 1 + n + 1] == '(') {
|
if (buff[i + 1 + n + 1] == '(')
|
||||||
|
{
|
||||||
int k = 0;
|
int k = 0;
|
||||||
while (buff[i + 1 + n + 2 + k] != ')')
|
while (buff[i + 1 + n + 2 + k] != ')')
|
||||||
k++;
|
k++;
|
||||||
|
@ -36,7 +36,8 @@ char *gen_file_path(char *req_path)
|
|||||||
if (realpath(path, resolved_path) == NULL)
|
if (realpath(path, resolved_path) == NULL)
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
|
|
||||||
if (strncmp(resolved_path, webroot, strlen(webroot)) != 0) {
|
if (strncmp(resolved_path, webroot, strlen(webroot)) != 0)
|
||||||
|
{
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,12 +154,14 @@ int get_album_imgs(img_t **images_arr, int *size, char *title)
|
|||||||
char *gen_gallery_html()
|
char *gen_gallery_html()
|
||||||
{
|
{
|
||||||
FILE *album_template_fp = fopen("static/gallery/album.html", "r");
|
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";
|
return "500 Internal Error\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *image_template_fp = fopen("static/gallery/image.html", "r");
|
FILE *image_template_fp = fopen("static/gallery/image.html", "r");
|
||||||
if (image_template_fp == NULL) {
|
if (image_template_fp == NULL)
|
||||||
|
{
|
||||||
fclose(album_template_fp);
|
fclose(album_template_fp);
|
||||||
return "500 Internal Error\n";
|
return "500 Internal Error\n";
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ int get_listener_socket(char *port)
|
|||||||
*/
|
*/
|
||||||
void *get_in_addr(struct sockaddr *sa)
|
void *get_in_addr(struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
if (sa->sa_family == AF_INET) {
|
if (sa->sa_family == AF_INET)
|
||||||
|
{
|
||||||
return &(((struct sockaddr_in *)sa)->sin_addr);
|
return &(((struct sockaddr_in *)sa)->sin_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ void res_404(int fd, char *path)
|
|||||||
{
|
{
|
||||||
FILE *fp = fopen("static/404.html", "r");
|
FILE *fp = fopen("static/404.html", "r");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
|
{
|
||||||
res_500(fd);
|
res_500(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -108,7 +109,8 @@ int send_response(int fd, char *req_path)
|
|||||||
{
|
{
|
||||||
char *file_path = gen_file_path(req_path);
|
char *file_path = gen_file_path(req_path);
|
||||||
|
|
||||||
if (file_path == NULL) {
|
if (file_path == NULL)
|
||||||
|
{
|
||||||
res_404(fd, req_path);
|
res_404(fd, req_path);
|
||||||
free(file_path);
|
free(file_path);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -70,10 +70,10 @@ void handle_process_termination(int signum)
|
|||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
pid = waitpid(-1, &status, WNOHANG);
|
pid = waitpid(-1, &status, WNOHANG);
|
||||||
}
|
} while (pid > 0);
|
||||||
while (pid > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user