diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .gitmodules | 6 | ||||
| -rwxr-xr-x | build.sh | 22 | ||||
| -rw-r--r-- | compile_flags.txt | 2 | ||||
| m--------- | libs/iceys-c-libs | 0 | ||||
| m--------- | libs/socket | 0 | ||||
| -rwxr-xr-x | public_html/beans.html | 10 | ||||
| -rwxr-xr-x | public_html/index.html | 9 | ||||
| -rwxr-xr-x | src/main.c | 41 |
9 files changed, 92 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a0795f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/** +obj/** diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..efc6035 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "libs/iceys-c-libs"] + path = libs/iceys-c-libs + url = https://git.iceyfox.xyz/iceyrazor/iceys-c-libs +[submodule "libs/socket"] + path = libs/socket + url = https://git.iceyfox.xyz/iceyrazor/socket diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3dfb60a --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +DEBUG_FLAGS="" +LIB="-Ilibs/iceys-c-libs -Ilibs/socket" + +mkdir -p bin +mkdir -p obj + +while getopts "d" opt; do + case "$opt" in + d) DEBUG_FLAGS="-Wall -fsanitize=address -g" + ;; + esac +done + +shift $((OPTIND-1)) +[ "${1:-}" = "--" ] && shift + +printf "\n\nmaking project\n" +clang -Ilibs/iceys-c-libs -c libs/iceys-c-libs/iceys-utils.c -o obj/iceys-utils.o +clang obj/iceys-utils.o -o bin/Server src/main.c $LIB $DEBUG_FLAGS -lm
\ No newline at end of file diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..edd63a2 --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,2 @@ +-I/home/iceyrazor/stuff/scripts/c/my_utils/socket +-Ilibs/iceys-c-libs
\ No newline at end of file diff --git a/libs/iceys-c-libs b/libs/iceys-c-libs new file mode 160000 +Subproject a5e1191ad6c34636eb49c0ddaeb9af1bd5c07a2 diff --git a/libs/socket b/libs/socket new file mode 160000 +Subproject 7e287a8ca7164e871965339196511fdcf024892 diff --git a/public_html/beans.html b/public_html/beans.html new file mode 100755 index 0000000..c930946 --- /dev/null +++ b/public_html/beans.html @@ -0,0 +1,10 @@ +<html> +<head> + <meta charset="UTF-8"> + <title>beans</title> +</head> +<body> + <h1>beans</h1> + <p>ビーンズ</p> +</body> +</html> diff --git a/public_html/index.html b/public_html/index.html new file mode 100755 index 0000000..f6fc9d9 --- /dev/null +++ b/public_html/index.html @@ -0,0 +1,9 @@ +<html> +<head> +<meta charset="UTF-8"> +<title>basic</title> +</head> +<body> +<p>HI</p> +</body> +</html> diff --git a/src/main.c b/src/main.c new file mode 100755 index 0000000..47619e5 --- /dev/null +++ b/src/main.c @@ -0,0 +1,41 @@ +#include <launch-web.c> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +// dont use stdio in these +sig_atomic_t running = 1; +void sig_int_handler(int num) +{ + running = 0; +} + +int main(int argc, char* argv[]) +{ + if (argc<2){ + fprintf(stderr, "arg1 must be set for port\n"); + exit(-1); + } + int port = atoi(argv[1]); + if (port == 0) { + fprintf(stderr, "port must not be 0\n"); + exit(-1); + } + + struct Server server = server_constructor(AF_INET, SOCK_STREAM, 0, INADDR_ANY, port, 10, launch); + server.html_folder = "./public_html/"; + + struct sigaction act = { 0 }; + act.sa_handler = &sig_int_handler; + sigaction(SIGINT, &act, NULL); + + server.launch(&server); + + while (running) { } + + usleep(1); + server_close(&server); + + return 0; +}
\ No newline at end of file |
