made the repo a bit more presentable...

This commit is contained in:
chickfilla 2021-10-08 17:33:38 -04:00
parent 0d5d44069e
commit eafdddd122
6 changed files with 42 additions and 29 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
build/
build/
*.o
tildebin

View File

@ -1,10 +0,0 @@
cmake_minimum_required(VERSION 3.0)
project(tildebind)
set(CMAKE_C_STANDARD 99)
add_compile_options(-Wall -Wextra -pedantic)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
add_subdirectory(source)

18
Makefile Normal file
View File

@ -0,0 +1,18 @@
TARGET ?= tildebin
SRC_DIRS ?= ./
SRCS := $(shell find $(SRC_DIRS) -name *.c)
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS) $(DEPS)
-include $(DEPS)

View File

@ -1,7 +0,0 @@
file(GLOB SOURCES "*.c")
include_directories("${CMAKE_SOURCE_DIR}/source")
add_executable(${PROJECT_NAME}
${SOURCES}
)

View File

@ -28,7 +28,7 @@
#define IDENTIFIER ".EOH."
#define OUTPUTFILE "index.html"
#define OUTPUT_MASK 0755
#define SERVER_SOCKET_MASK 0000
#define SOCKET_MASK 0000
#define MEM_CATCH(_e) STD_CATCHER( _e, "memory allocation error")
@ -53,13 +53,24 @@ const char* const default_template = {
"</html>"
};
static volatile bool keep_running;
static bool curate_html;
static volatile bool k_r;
static int server_socket, client_sockets[MAX_CLIENTS];
static int
server_socket,
client_sockets[MAX_CLIENTS];
static char client_buffer[MAX_BUFFER];
static const char *output_dir, *template, *username, *output_file_name;
static const char
*output_dir,
*template,
*username,
*output_file_name;
static FILE *output_fd;
static struct passwd *passwd;
GENERIC_VECTOR(string, char)
static string output_path;
static string custom_template;
@ -271,7 +282,7 @@ signal_handler( int sig )
sn = sn == NULL ? "UNKNOWN" : sn;
INFO("%s signal detected, terminating...", sn);
k_r = false;
keep_running = false;
}
void
@ -311,7 +322,6 @@ main( int argc, char const **argv )
struct sockaddr_un s_addr;
struct timeval tv;
struct uinfo ui;
struct passwd* passwd;
size_t len;
const char* us_path, *template_path;
FILE *template_file;
@ -401,7 +411,7 @@ main( int argc, char const **argv )
strncpy(s_addr.sun_path, us_path, GET_LEN(s_addr.sun_path));
unlink(us_path);
len = sizeof(s_addr);
ou = umask(SERVER_SOCKET_MASK);
ou = umask(SOCKET_MASK);
CATCHER_CRITICAL(
bind(server_socket, (const struct sockaddr *) &s_addr, sizeof(s_addr)),
"cannot bind network socket"
@ -412,8 +422,8 @@ main( int argc, char const **argv )
"cannot set socket backlog"
);
k_r = true;
while(k_r)
keep_running = true;
while(keep_running)
{
FD_ZERO(&client_sockets_set);

View File

@ -1,5 +1,5 @@
#ifndef FAKETABLETD_UTILITIES_H__
#define FAKETABLETD_UTILITIES_H__
#ifndef __UTILITIES_H__
#define __UTILITIES_H__
#include <stdio.h>
#include <string.h>