X-Git-Url: https://git.cworth.org/git?p=ttt;a=blobdiff_plain;f=src%2Fttt-server.h;h=8d0f9c410ac6a9ef69e83ba41aa0e84693ae36c7;hp=77fb4bf79df7c023a2f971b27015131b8e7e09e9;hb=c25df0131987fe52be7430c5be03ec83fbaea9b3;hpb=907321c065fb1383e800f0794981df91d4327f57 diff --git a/src/ttt-server.h b/src/ttt-server.h index 77fb4bf..8d0f9c4 100644 --- a/src/ttt-server.h +++ b/src/ttt-server.h @@ -20,13 +20,15 @@ */ #include "ttt.h" +#include "ttt-error.h" #ifndef _TTT_SERVER_H_ #define _TTT_SERVER_H_ /* Register a new client with the server. - * - * Returns: the unique id of the client. + * + * Returns: TTT_ERROR_NONE on success, else TTT_ERROR_INVALIDNAME if client's + * name is not unique. * * Locking: The server mutex will be acquired and held throughout the * execution of this function. @@ -34,7 +36,7 @@ * Errors: If an error (such as out-of-memory) occurs, this function * will not return. */ -int +ttt_error_t ttt_server_register_client (ttt_server_t *server, ttt_client_t *client); /* Un-register a client from the server. @@ -57,4 +59,60 @@ ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client); void ttt_server_broadcast (ttt_server_t *server, const char *message); + +/* Returns the WHO response. The return string is allocated in this + * function and will need to be free'd by the caller. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. Each client mutex may also be acquired + * and held by functions called during the execution of this function. + * + * Errors: If an error such as an IO error occurs, this function will + * not return. + */ +const char* +ttt_server_who (ttt_server_t *server); + +/* Generates the statistics for the user. If the function does not + * return an error, the response will be allocated in this function + * and will need to be free'd by the caller. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. Each client mutex may also be acquired + * and held by functions called during the execution of this function. + * + * Errors: If an error such as an IO error occurs, this function will + * not return. + */ +ttt_error_t +ttt_server_statistics (ttt_server_t *server, + const char *username, + char **response); + +/* Checks to see if the username is registered. If the username exists + * will return TTT_ERROR_NONE, else TTT_ERROR_NO_USER. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. Each client mutex may also be acquired + * and held by functions called during the execution of this function. + * + * Errors: If an error such as an IO error occurs, this function will + * not return. + */ +ttt_error_t +ttt_server_verify_username (ttt_server_t *server, + const char *username); + +/* Gets the server hostname. + * + */ +const char* +ttt_server_get_host (ttt_server_t *server); + +/* Gets the server port + * + */ +const char* +ttt_server_get_port (ttt_server_t *server); + #endif /* _TTT_SERVER_H_ */