filename | src/ioutil.h |
changeset | 1077:136fc24d17ef |
prev | 1021:848db285a184 |
next | 1204:c4b725d901b1 |
author | nkeynes |
date | Wed Oct 07 17:53:56 2009 +1000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Create a host attachment for the SCIF serial port. By default, uses /dev/console Add general fd listening to netutil, and rename to ioutil Add SCIF update on port read/write - fixes KOS timing problems but needs to be redone properly. |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/ioutil.h Wed Oct 07 17:53:56 2009 +10001.3 @@ -0,0 +1,67 @@1.4 +/**1.5 + * $Id$1.6 + *1.7 + * GDB RDP server stub - SH4 + ARM1.8 + *1.9 + * Copyright (c) 2009 Nathan Keynes.1.10 + *1.11 + * This program is free software; you can redistribute it and/or modify1.12 + * it under the terms of the GNU General Public License as published by1.13 + * the Free Software Foundation; either version 2 of the License, or1.14 + * (at your option) any later version.1.15 + *1.16 + * This program is distributed in the hope that it will be useful,1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.19 + * GNU General Public License for more details.1.20 + */1.21 +1.22 +#ifndef lxdream_netutil_H1.23 +#define lxdream_netutil_H 11.24 +1.25 +#include <netinet/in.h>1.26 +#include "lxdream.h"1.27 +1.28 +typedef void *io_listener_t;1.29 +1.30 +/**1.31 + * Construct a server socket listening on the given interface and port. If port1.32 + * is 0, a dynamic port will be bound instead.1.33 + * This method does not register a listener.1.34 + * @return newly created socket fd, or -1 on failure.1.35 + */1.36 +int io_create_server_socket(const char *interface, int port );1.37 +1.38 +/**1.39 + * Callback invoked when data is available from the remote peer, or when the peer1.40 + * connects/disconnects.1.41 + *1.42 + * @param fd file descriptor of the connected socket1.43 + * @param data data supplied when the callback was registered1.44 + * @return TRUE to maintain the connection, FALSE to immediately disconnected + close.1.45 + */1.46 +typedef gboolean (*io_callback_t)( int fd, void *data );1.47 +1.48 +/**1.49 + * Register a TCP server socket listener on an already open (and listening)1.50 + * socket. The socket must not have been previously registered.1.51 + * @return NULL on failure, otherwise an io listener handle.1.52 + *1.53 + * Note: Implementation is platform specific1.54 + */1.55 +io_listener_t io_register_tcp_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void*) );1.56 +1.57 +/**1.58 + * Register an I/O listener on an open file descriptor. The fd must not have1.59 + * been previously registered.1.60 + * @return TRUE on success, FALSE on failure.1.61 + */1.62 +io_listener_t io_register_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void *) );1.63 +1.64 +/**1.65 + * Unregister a socket that was previously registered with the system. This1.66 + * does not close the socket, but will remove any callbacks associated with the socket.1.67 + */1.68 +void io_unregister_listener( io_listener_t handle );1.69 +1.70 +#endif /* !lxdream_netutil_H */
.