diff options
author | Ian Moffett <ian@osmora.org> | 2024-09-24 02:38:56 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-09-24 02:38:56 -0400 |
commit | 39f5e0d6dda6d7af7199f744b7b0f4d7a5ca9478 (patch) | |
tree | aefecca84b21eafdf8b9662e80bcc76aea2dfa6a | |
parent | 7e5e0f49dcb6ba416da5fc9e536109c04f338f95 (diff) |
ostp.d: init: Move main() to otd_init.c
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | ostp.d/include/net/listen.h | 35 | ||||
-rw-r--r-- | ostp.d/init/otd_init.c | 37 | ||||
-rw-r--r-- | ostp.d/net/otd_listen.c | 8 |
3 files changed, 78 insertions, 2 deletions
diff --git a/ostp.d/include/net/listen.h b/ostp.d/include/net/listen.h new file mode 100644 index 0000000..03ba7a4 --- /dev/null +++ b/ostp.d/include/net/listen.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Hyra nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NET_LISTEN_H_ +#define NET_LISTEN_H_ + +int net_listen(void); + +#endif /* NET_LISTEN_H_ */ diff --git a/ostp.d/init/otd_init.c b/ostp.d/init/otd_init.c new file mode 100644 index 0000000..4b899b4 --- /dev/null +++ b/ostp.d/init/otd_init.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Hyra nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <net/listen.h> +#include <stdio.h> + +int +main(void) +{ + return net_listen(); +} diff --git a/ostp.d/net/otd_listen.c b/ostp.d/net/otd_listen.c index 87744c2..df4473b 100644 --- a/ostp.d/net/otd_listen.c +++ b/ostp.d/net/otd_listen.c @@ -180,8 +180,12 @@ read_clients(void) close(serv_sock); } +/* + * Begin listening for incoming connections + * and handle them. + */ int -main(void) +net_listen(void) { struct sockaddr_in saddr; int error; @@ -211,5 +215,5 @@ main(void) } read_clients(); - return 0; + __builtin_unreachable(); } |