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";
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,13 @@ int get_listener_socket(char *port)
|
|||||||
*
|
*
|
||||||
* @param {struct sockaddr*} sa
|
* @param {struct sockaddr*} sa
|
||||||
* @return void*
|
* @return void*
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &(((struct sockaddr_in6*)sa)->sin6_addr);
|
return &(((struct sockaddr_in6 *)sa)->sin6_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;
|
||||||
@ -205,7 +207,7 @@ void handle_get_request(int fd, char *request)
|
|||||||
|
|
||||||
fread(template, file_size, 1, fp);
|
fread(template, file_size, 1, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
template[file_size-1] = '\0';
|
template[file_size - 1] = '\0';
|
||||||
|
|
||||||
article_info *articles = NULL;
|
article_info *articles = NULL;
|
||||||
int amount = list_articles(&articles);
|
int amount = list_articles(&articles);
|
||||||
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @brief Prints error
|
* @brief Prints error
|
||||||
*
|
*
|
||||||
* @param {char *} msg
|
* @param {char *} msg
|
||||||
*/
|
*/
|
||||||
void err_msg(char *msg)
|
void err_msg(char *msg)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: %s\n", msg);
|
fprintf(stderr, "Error: %s\n", msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user