/* Copyright 2010 Nathan Phillip Brink This file is a part of DistRen. DistRen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DistRen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with DistRen. If not, see . */ struct distrend_clientset; struct distrend_listen; struct distrend_client; #ifndef _DISTREN_LISTEN_H #define _DISTREN_LISTEN_H #include "distrend.h" #include enum distrend_client_state { DISTREND_CLIENT_PREAUTH, DISTREND_CLIENT_GOODDOGGY, DISTREND_CLIENT_BADBOY, DISTREND_CLIENT_DEAD }; struct distrend_listen { int port; int sock; }; struct distrend_client { int sock; enum distrend_client_state state; QUEUE *inmsgs; QUEUE *outmsgs; }; /** initializes the listens and clientset @param config the configuration from distrend @param clients a pointer to a struct distrend_clientset pointer which will be set to memory allocated for the clientset */ int distrend_listen(struct distrend_config *config, struct distrend_clientset **clients); /** checks states of the sockets I'm managing. If there are any new connections, or activity on any sockets, I'll call the appropriate function. I will block until there is some sort of activity, including signals. If you want to cleanly shut down, it's best to register signal handlers somewhere */ int distrend_accept(struct distrend_config *config, struct distrend_clientset *clients); /** cleans listening socket. Unnecessary for a working server, currently a stub. */ int distrend_unlisten(struct distrend_listen *listens, struct distrend_clientset *clients); /** writes message to client. @param towrite the caller is expected to free this string. This function will strdup() it, in essence. */ int distrend_client_write(struct distrend_client *client, char *towrite, size_t msglen); /** This is probably just NOT a placeholder for remotio */ void remotio_send_to_client(); #endif