00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef POLL_H_
00023 #define POLL_H_
00024 #include "config.h"
00025
00026 #ifdef HAVE_POLL
00027
00028 #include <poll.h>
00029 typedef struct pollfd ssh_pollfd_t;
00030
00031 #else
00032
00033
00034
00035 typedef struct ssh_pollfd_struct {
00036 socket_t fd;
00037 short events;
00038 short revents;
00039 } ssh_pollfd_t;
00040
00041
00042 #ifndef POLLIN
00043 # define POLLIN 0x001
00044 #endif
00045 #ifndef POLLPRI
00046 #define POLLPRI 0x002
00047 #endif
00048 #ifndef POLLOUT
00049 #define POLLOUT 0x004
00050 #endif
00051
00052 #ifndef POLLERR
00053 #define POLLERR 0x008
00054 #endif
00055 #ifndef POLLHUP
00056 #define POLLHUP 0x010
00057 #endif
00058 #ifndef POLLNVAL
00059 #define POLLNVAL 0x020
00060 #endif
00061
00062 typedef unsigned long int nfds_t;
00063 #endif
00064
00065 int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
00066 typedef struct ssh_poll_ctx_struct *ssh_poll_ctx;
00067 typedef struct ssh_poll_handle_struct *ssh_poll_handle;
00068
00080 typedef int (*ssh_poll_callback)(ssh_poll_handle p, int fd, int revents,
00081 void *userdata);
00082
00083
00084 ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
00085 void *userdata);
00086 void ssh_poll_free(ssh_poll_handle p);
00087 ssh_poll_ctx ssh_poll_get_ctx(ssh_poll_handle p);
00088 short ssh_poll_get_events(ssh_poll_handle p);
00089 void ssh_poll_set_events(ssh_poll_handle p, short events);
00090 void ssh_poll_add_events(ssh_poll_handle p, short events);
00091 void ssh_poll_remove_events(ssh_poll_handle p, short events);
00092 socket_t ssh_poll_get_fd(ssh_poll_handle p);
00093 void ssh_poll_set_callback(ssh_poll_handle p, ssh_poll_callback cb, void *userdata);
00094 ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size);
00095 void ssh_poll_ctx_free(ssh_poll_ctx ctx);
00096 int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p);
00097 void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p);
00098 int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout);
00099
00100
00101
00102 #endif