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 typedef unsigned long int nfds_t;
00042
00043 #ifdef _WIN32
00044
00045 #ifndef POLLRDNORM
00046 #define POLLRDNORM 0x0100
00047 #endif
00048 #ifndef POLLRDBAND
00049 #define POLLRDBAND 0x0200
00050 #endif
00051 #ifndef POLLIN
00052 #define POLLIN (POLLRDNORM | POLLRDBAND)
00053 #endif
00054 #ifndef POLLPRI
00055 #define POLLPRI 0x0400
00056 #endif
00057
00058 #ifndef POLLWRNORM
00059 #define POLLWRNORM 0x0010
00060 #endif
00061 #ifndef POLLOUT
00062 #define POLLOUT (POLLWRNORM)
00063 #endif
00064 #ifndef POLLWRBAND
00065 #define POLLWRBAND 0x0020
00066 #endif
00067
00068 #ifndef POLLERR
00069 #define POLLERR 0x0001
00070 #endif
00071 #ifndef POLLHUP
00072 #define POLLHUP 0x0002
00073 #endif
00074 #ifndef POLLNVAL
00075 #define POLLNVAL 0x0004
00076 #endif
00077
00078 #else
00079
00080
00081 #ifndef POLLIN
00082 #define POLLIN 0x001
00083 #endif
00084 #ifndef POLLPRI
00085 #define POLLPRI 0x002
00086 #endif
00087 #ifndef POLLOUT
00088 #define POLLOUT 0x004
00089 #endif
00090
00091 #ifndef POLLERR
00092 #define POLLERR 0x008
00093 #endif
00094 #ifndef POLLHUP
00095 #define POLLHUP 0x010
00096 #endif
00097 #ifndef POLLNVAL
00098 #define POLLNVAL 0x020
00099 #endif
00100
00101 #ifndef POLLRDNORM
00102 #define POLLRDNORM 0x040
00103 #endif
00104 #ifndef POLLRDBAND
00105 #define POLLRDBAND 0x080
00106 #endif
00107 #ifndef POLLWRNORM
00108 #define POLLWRNORM 0x100
00109 #endif
00110 #ifndef POLLWRBAND
00111 #define POLLWRBAND 0x200
00112 #endif
00113
00114 #endif
00115 #endif
00116
00117 void ssh_poll_init(void);
00118 void ssh_poll_cleanup(void);
00119 int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
00120 typedef struct ssh_poll_ctx_struct *ssh_poll_ctx;
00121 typedef struct ssh_poll_handle_struct *ssh_poll_handle;
00122
00135 typedef int (*ssh_poll_callback)(ssh_poll_handle p, socket_t fd, int revents,
00136 void *userdata);
00137
00138
00139 ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
00140 void *userdata);
00141 void ssh_poll_free(ssh_poll_handle p);
00142 ssh_poll_ctx ssh_poll_get_ctx(ssh_poll_handle p);
00143 short ssh_poll_get_events(ssh_poll_handle p);
00144 void ssh_poll_set_events(ssh_poll_handle p, short events);
00145 void ssh_poll_add_events(ssh_poll_handle p, short events);
00146 void ssh_poll_remove_events(ssh_poll_handle p, short events);
00147 socket_t ssh_poll_get_fd(ssh_poll_handle p);
00148 void ssh_poll_set_fd(ssh_poll_handle p, socket_t fd);
00149 void ssh_poll_set_callback(ssh_poll_handle p, ssh_poll_callback cb, void *userdata);
00150 ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size);
00151 void ssh_poll_ctx_free(ssh_poll_ctx ctx);
00152 int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p);
00153 int ssh_poll_ctx_add_socket (ssh_poll_ctx ctx, struct ssh_socket_struct *s);
00154 void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p);
00155 int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout);
00156 ssh_poll_ctx ssh_poll_get_default_ctx(ssh_session session);
00157
00158 #endif