diff options
Diffstat (limited to 'pullreqd.c')
-rw-r--r-- | pullreqd.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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); } |