summaryrefslogtreecommitdiff
path: root/pullreqd.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-09 22:02:05 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-09 22:02:05 -0400
commit750a6d8d361ba61e59b88d698d24189659637da0 (patch)
tree89f09dbbb447e1fff9b57c8116520b14120d64e7 /pullreqd.c
parent3348b3f64d933a8bdaf0f076646cc0073f161db1 (diff)
Started work on adding the socket initialization code.
Diffstat (limited to 'pullreqd.c')
-rw-r--r--pullreqd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pullreqd.c b/pullreqd.c
index 635a69c..c7764d7 100644
--- a/pullreqd.c
+++ b/pullreqd.c
@@ -79,6 +79,26 @@ int init_config(char *config_file, config **cfg) {
return (*cfg != NULL);
}
+int init_socket(config *cfg) {
+ union sock_addr {
+ struct sockaddr sa;
+ struct sockaddr_un sa_un;
+ struct sockaddr_in sa_in;
+ } sock_addr;
+ /* Set socket type to unix socket, if socket-type was set to unix, otherwise set it to network socket. */
+ const int sock_type = (!strcasecmp(cfg->sock_type, "unix")) ? AF_UNIX : AF_INET;
+ /* Create a new listen socket. */
+ int fd = socket(sock_type, SOCK_SEQPACKET, 0);
+
+ /* TODO: Add rest of init code. */
+
+ if (sock_type == AF_UNIX) {
+
+ }
+
+ return fd;
+}
+
int main_loop(config *cfg, int listen_socket) {
int done = 0;
@@ -91,6 +111,7 @@ int main(int argc, char **argv) {
config *cfg;
char *config_file = "test.conf";
int config_read = 0;
+ int listen_socket = -1;
int exit_status = EXIT_FAILURE;
init_daemon(1, "/");
@@ -101,6 +122,12 @@ int main(int argc, char **argv) {
/* Did we successfully read the config file? */
if (config_read) {
+ /* Create the Listen socket. */
+ listen_socket = init_socket(cfg);
+ }
+
+ /* Did we successfully read the config file, and create the listen socket? */
+ if (config_read && listen_socket >= 0) {
exit_status = main_loop(cfg, listen_socket);
}