Compare commits

..

No commits in common. "cfa7a065b291c0630a7192de0fd964d64d5f664f" and "8e58873ea94ad208d2b9c845a4c17e4006a32ce4" have entirely different histories.

8 changed files with 11 additions and 34 deletions

View file

@ -2,14 +2,6 @@
## Upcoming Changes
## Version 1.5
Add flag `--generate-static-enable-overwrite`. This flag enables overwriting of
files from static-dir to generate-dir (if static-dir was specified). Previous
implementation relied on `--generate-enable-ovewrite` for this behavior.
Minor refactorings related to `printf` and `uintX_t`/`size_t` types.
## Version 1.4
Implemented "IF", "ELSEIF", "ELSE", "ENDIF", and "INDEX" for templates.
@ -87,7 +79,3 @@ Features:
- Reload configuration on SIGUSR1 or by listening (enabled by cmd parameter).
- Cache served html (enabled by cmd parameter).
- Serve static files from "static-dir" (enabled by cmd parameter).
<!--
vim: textwidth=80 et sw=2 ts=2 sts=2
-->

View file

@ -17,7 +17,6 @@ A simple HTTP/1.1 server written in C.
--enable-static-dir=<DIR>
--generate-dir=<DIR>
--generate-enable-overwrite
--generate-static-enable-overwrite
## Changelog

View file

@ -46,7 +46,6 @@ void print_usage(void) {
puts(" --enable-static-dir=<DIR>");
puts(" --generate-dir=<DIR>");
puts(" --generate-enable-overwrite");
puts(" --generate-static-enable-overwrite");
}
Args parse_args(int32_t argc, char **argv) {
@ -129,7 +128,7 @@ Args parse_args(int32_t argc, char **argv) {
exit(1);
} else {
printf(
"NOTICE set cache-entry-lifetime to %zu\n",
"NOTICE set cache-entry-lifetime to %lu\n",
args.cache_lifespan_seconds);
}
} else if (strncmp(argv[0], "--enable-static-dir=", 20) == 0) {
@ -190,8 +189,6 @@ Args parse_args(int32_t argc, char **argv) {
}
} else if (strcmp(argv[0], "--generate-enable-overwrite") == 0) {
args.flags |= 4;
} else if (strcmp(argv[0], "--generate-static-enable-overwrite") == 0) {
args.flags |= 8;
} else {
fprintf(stderr, "ERROR: Invalid args!\n");
print_usage();

View file

@ -29,7 +29,6 @@ typedef struct Args {
// xxxx xx0x - disable listen on config file for reloading.
// xxxx xx1x - enable listen on config file for reloading.
// xxxx x1xx - enable overwrite on generate.
// xxxx 1xxx - enable overwrite on generate for static dir.
uint16_t flags;
uint16_t port;
// Does not need to be free'd, this should point to a string in argv.

View file

@ -19,7 +19,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
// Linux/Unix includes.
#include <sys/socket.h>
@ -233,7 +232,7 @@ int c_simple_http_manage_connections(void *data, void *ud) {
snprintf(
content_length_buf + content_length_buf_size,
127 - content_length_buf_size,
"%zu\n%n",
"%lu\n%n",
response_size,
&written);
if (written <= 0) {
@ -305,7 +304,7 @@ int c_simple_http_manage_connections(void *data, void *ud) {
snprintf(
content_length_buf,
content_str_len + 1 + 16 + 1,
"Content-Length: %" PRIu64 "\n",
"Content-Length: %lu\n",
file_info.buf_size);
CHECK_ERROR_WRITE_NO_FD(write(
citem->fd, content_length_buf, content_str_len + 1 + 16));
@ -364,7 +363,7 @@ int main(int argc, char **argv) {
puts("Static dir option specified, copying over static dir entries...");
if (c_simple_http_static_copy_over_dir(args.static_dir,
args.generate_dir,
(args.flags & 8) != 0 ? 1 : 0)
(args.flags & 4) != 0 ? 1 : 0)
!= 0) {
fprintf(stderr, "ERROR during static-dir-entires copying!\n");
return 1;
@ -386,8 +385,7 @@ int main(int argc, char **argv) {
socklen_t size = sizeof(ipv6_addr);
int ret = getsockname(tcp_socket, (struct sockaddr*)&ipv6_addr, &size);
if (ret == 0) {
printf("Listening on port: %" PRIu16 "\n",
u16_be_swap(ipv6_addr.sin6_port));
printf("Listening on port: %u\n", u16_be_swap(ipv6_addr.sin6_port));
} else {
fprintf(
stderr,
@ -464,7 +462,7 @@ int main(int argc, char **argv) {
++config_try_reload_attempts;
fprintf(
stderr,
"Attempting to reload config now (try %" PRIu32 " of %u)...\n",
"Attempting to reload config now (try %u of %u)...\n",
config_try_reload_attempts,
C_SIMPLE_HTTP_TRY_CONFIG_RELOAD_MAX_ATTEMPTS);
C_SIMPLE_HTTP_ParsedConfig new_parsed_config =
@ -534,7 +532,7 @@ int main(int argc, char **argv) {
}
} else if (read_ret > 0) {
#ifndef NDEBUG
printf("DEBUG inotify_event->mask: %" PRIx32 "\n", inotify_event->mask);
printf("DEBUG inotify_event->mask: %x\n", inotify_event->mask);
#endif
if ((inotify_event->mask & IN_MODIFY) != 0
|| (inotify_event->mask & IN_CLOSE_WRITE) != 0) {

View file

@ -421,8 +421,8 @@ int c_simple_http_static_copy_over_dir(const char *from,
if (fd) {
fprintf(
stderr,
"WARNING \"%s\" already exists and "
"--generate-static-enable-overwrite not specified, skipping!\n",
"WARNING \"%s\" already exists and --generate-enable-overwrite not "
"specified, skipping!\n",
combined_to);
continue;
}

View file

@ -3,7 +3,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
// POSIX includes.
#include <unistd.h>
@ -29,10 +28,7 @@ static int32_t checks_passed = 0;
#define RETURN() \
do { \
fprintf(stderr, \
"checked %" PRId32 "\npassed %" PRId32 "\n", \
checks_checked, \
checks_passed); \
fprintf(stderr, "checked %d\npassed %d\n", checks_checked, checks_passed);\
return checks_checked == checks_passed ? 0 : 1; \
} while (0);

@ -1 +1 @@
Subproject commit 78a36b48dbd3888f56e26ac71115e5f775a74c2c
Subproject commit ce7400a298a95b60d0d482058ed9eae4142f8061