diff options
Diffstat (limited to 'src/z_pack.pkg')
-rw-r--r-- | src/z_pack.pkg | 295 |
1 files changed, 0 insertions, 295 deletions
diff --git a/src/z_pack.pkg b/src/z_pack.pkg index c2582e45..5a46b3b2 100644 --- a/src/z_pack.pkg +++ b/src/z_pack.pkg @@ -396,298 +396,3 @@ extern s16b damroll(int num, int sides); * @note (see file z-rand.c) */ extern s16b maxroll(int num, int sides); - - - - - -/* - ****************** ZSOCKS *************** - */ - -/** @struct ip_connection - * This represents an IP connection - */ -struct ip_connection -{ - /** @var setup - * @brief Boolean - * @note Has it been setted up yet? - */ - bool setup; - - /** @var conn_ip - * @brief Number - * @note The IP where to connect to - */ - long conn_ip; - - /** @var conn_port - * @brief Number - * @note The port where to connect to - */ - int conn_port; - - /** @var conn_type - * @brief Number - * @note Type of connection - */ - byte conn_type; - - /** @var connected - * @brief Boolean - * @note The connection status - */ - bool connected; - - /** @var *socket - * @brief void - * @note The socket for the connection - */ - void *socket; - - /** @var server - * @brief Boolean - * @note Is it a server socket ? - */ - bool server; -}; - -/* - * Possible connection types - */ -/** @def ZSOCK_TYPE_TCP */ -#define ZSOCK_TYPE_TCP 1 - -/* #define ZSOCK_TYPE_UDP 2 */ - - -/** @def ZSOCK_TIMER_DELAY - * @note The time in milliseconds when to call the sockets callbacks for the - * timer - */ -#define ZSOCK_TIMER_DELAY 100 - - -/** @struct zsock_hooks - * @note Hooks needed for a main-foo.c to be sock-able - */ -struct zsock_hooks -{ - /** @fn *new_connection() - * @brief Creates an IP connection. - * @return ip_connection \n An IP connection. - * @note (see file z-sock.c) - */ - ip_connection *new_connection(); - - /** @fn free_connection(ip_connection *c) - * @brief Free IP connection "c".\n - * @param *c ip_connection \n an IP connection. - * @brief Ip connection - * @note (see file z-sock.c) - */ - void free_connection(ip_connection *c); - - /** @fn setup(ip_connection *conn, cptr conn_ip, int port, byte conn_type, bool server) - * @brief Setup a connection, but do NOT connect.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param conn_ip String \n IP address of host machine. - * @brief Host ip address - * @param port Number \n port of host machine. - * @brief Host port - * @param conn_type Number \n type of connection. - * @brief Connection type - * @param server Boolean \n TRUE if this is a server socket, - * otherwise FALSE. - * @brief Server socket? - * @return Boolean \n TRUE if socket setup successfully, otherwise FALSE. - * @note - * You can not setup a connection if it is setup. - * @note (see file z-sock.c) - */ - bool setup(ip_connection *conn, cptr conn_ip, int port, byte conn_type, bool server); - - /** @fn unsetup(ip_connection *conn) - * @brief Unsetup a connection, but and DO close before if needed.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @return Boolean \n TRUE if socket was setup, otherwise FALSE. - * @note - * You can not unset a connection if it is not setup. - * @note (see file z-sock.c) - */ - bool unsetup(ip_connection *conn); - - /** @fn open(ip_connection *conn) - * @brief Open(connect) a well setup-ed connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @return Boolean \n TRUE if connection was opened, otherwise FALSE. - * @note - * You can not open a connection if it is open. - * @note (see file z-sock.c) - */ - bool open(ip_connection *conn); - - /** @fn close(ip_connection *conn) - * @brief Close a connected connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @return Boolean \n TRUE if connection was closed, otherwise FALSE. - * @note - * You can not close a connection if it is closed. - * @note (see file z-sock.c) - */ - bool close(ip_connection *conn); - - /** @fn write(ip_connection *conn, cptr str, int *size) - * @brief Send data on the connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param str String \n the string to send along the connection. - * @brief String - * @param *size Number - * @brief Bytes sent - * @return Boolean \n TRUE if string was sent successfully, - * otherwise FALSE. - * @return *size \n the number of bytes sent. - * @note - * This function will return FALSE if you write to a connection which - * is not connected, or if the connection has died. - * @note (see file z-sock.c) - */ - bool write(ip_connection *conn, cptr str, int *size); - - /* Read data on the connection */ - /** @fn read(ip_connection *conn, char *str, int *len, bool raw) - * @brief Read data on connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param *str String - * @brief String - * @param *len Number \n the number of bytes to read. - * @brief Bytes to read - * @param raw Boolean \n TRUE if all data is to be read at once, - * otherwise FALSE. - * @brief Read raw data? - * @return Boolean \n TRUE if a string was returned, otherwise FALSE. - * @return *str String \n The string read. - * @return *len Number \n The number of bytes read. - * @note - * @note (see file z-sock.c) - */ - /* -- DG -- This is done in script.c since it needs a specific wrapper :( - bool read(ip_connection *conn, char *str, int *len, bool raw); - */ - - /** @fn write_simple(ip_connection *conn, cptr str) - * @brief Send data on the connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param str String \n the string to send along the connection. - * @brief String - * @return Boolean \n TRUE if string was sent successfully, - * otherwise FALSE. - * @note - * This is easy to use. - * @note (see file z-sock.c) - */ - bool write_simple(ip_connection *conn, cptr str); - - /* Read data on the connection -- easy to use */ - /** @fn read_simple(ip_connection *conn, char *str, int len) - * @brief Read data on the connection.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param *str String - * @brief String - * @param len Number \n the number of bytes to read. - * @brief Bytes to read - * @return Boolean \n TRUE if a string was returned, otherwise FALSE. - * @return *str String \n The string read. - * @note - * This function will return FALSE if you read from a connection which - * is not connected, or if the connection has died. - * @note (see file z-sock.c) - */ - bool read_simple(ip_connection *conn, char *str, int len); - - /* Accept a connection */ - /** @fn accept(ip_connection *conn, ip_connection *child) - * @brief Allow "conn" to accept a connection from "child".\n - * @param *conn ip_connection \n an IP connection. - * @brief Parent ip connection - * @param *child ip_connection \n another IP connection. - * @brief Child ip connection - * @return Boolean \n TRUE if child socket was accepted, otherwise - * FALSE. - * @note - * "conn" must be a server and must be connected. - * @note (see file z-sock.c) - */ - bool accept(ip_connection *conn, ip_connection *child); - - /** @fn can_read(ip_connection *conn) - * @brief Check if there is any data to be read and return instantly - * in any case.\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @return Boolean \n TRUE if there is something to read, otherwise - * FALSE. - * @note - * This function will return FALSE if you read from a connection which - * is not connected. - * @note (see file z-sock.c) - */ - bool can_read(ip_connection *conn); - - /** @fn wait(ip_connection *conn, int seconds) - * @brief Wait for up to "seconds" seconds for data to read from - * "conn".\n - * @param *conn ip_connection \n an IP connection. - * @brief Ip connection - * @param seconds Number \n number of seconds to wait for something to - * read. - * @brief Seconds to wait - * @return Boolean TRUE if there is something to read, otherwise - * FALSE. - * @note - * This function will return FALSE if you wait for a connection which - * is not connected. - * @note (see file z-sock.c) - */ - bool wait(ip_connection *conn, int seconds); - - - /* - * Timer stuff, I hope I can make that look better - */ - /** @fn add_timer(timer_callback callback) - * @brief Add "callback" to the list.\n - * @param callback timer_callback \n a callback timer. - * @brief Callback - * @return Boolean \n TRUE (always). - * @note - * If this is the first callback, the timer will be created. - * @note (see file z-sock.c) - */ - bool add_timer(timer_callback callback); - - /** @fn remove_timer(timer_callback callback) - * @brief Remove "callback" from the list.\n - * @param callback timer_callback \n a callback timer. - * @brief Callback - * @return Boolean \n TRUE (always). - * @note - * If this is the last callback, the timer will be deleted. - * @note (see file z-sock.c) - */ - bool remove_timer(timer_callback callback); -}; - -/** @var zsock - * @brief zsock_hooks - */ -extern zsock_hooks zsock; |