apr_poll.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_POLL_H
00018 #define APR_POLL_H
00019 
00023 #include "apr.h"
00024 #include "apr_pools.h"
00025 #include "apr_errno.h"
00026 #include "apr_inherit.h" 
00027 #include "apr_file_io.h" 
00028 #include "apr_network_io.h" 
00029 
00030 #if APR_HAVE_NETINET_IN_H
00031 #include <netinet/in.h>
00032 #endif
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif /* __cplusplus */
00037 
00048 #define APR_POLLIN    0x001     
00049 #define APR_POLLPRI   0x002     
00050 #define APR_POLLOUT   0x004     
00051 #define APR_POLLERR   0x010     
00052 #define APR_POLLHUP   0x020     
00053 #define APR_POLLNVAL  0x040     
00057 typedef enum { 
00058     APR_NO_DESC,                
00059     APR_POLL_SOCKET,            
00060     APR_POLL_FILE,              
00061     APR_POLL_LASTDESC           
00062 } apr_datatype_e ;
00063 
00065 typedef union {
00066     apr_file_t *f;              
00067     apr_socket_t *s;            
00068 } apr_descriptor;
00069 
00071 typedef struct apr_pollfd_t apr_pollfd_t;
00072 
00074 struct apr_pollfd_t {
00075     apr_pool_t *p;              
00076     apr_datatype_e desc_type;   
00077     apr_int16_t reqevents;      
00078     apr_int16_t rtnevents;      
00079     apr_descriptor desc;        
00080     void *client_data;          
00081 };
00082 
00090 APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new_poll, 
00091                                          apr_int32_t num,
00092                                          apr_pool_t *cont);
00093 
00111 APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t numsock,
00112                                    apr_int32_t *nsds, 
00113                                    apr_interval_time_t timeout);
00114 
00127 APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset, 
00128                                               apr_socket_t *sock,
00129                                               apr_int16_t event);
00130 
00143 APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
00144                                                apr_socket_t *sock,
00145                                                apr_int16_t events);
00152 APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset, 
00153                                                  apr_socket_t *sock);
00154 
00166 APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset, 
00167                                                  apr_int16_t events);
00168 
00185 APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event, 
00186                                           apr_socket_t *sock,
00187                                           apr_pollfd_t *aprset);
00188 
00189 /* General-purpose poll API for arbitrarily large numbers of
00190  * file descriptors
00191  */
00192 
00194 typedef struct apr_pollset_t apr_pollset_t;
00195 
00204 APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
00205                                              apr_uint32_t size,
00206                                              apr_pool_t *p,
00207                                              apr_uint32_t flags);
00208 
00213 APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset);
00214 
00223 APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
00224                                           const apr_pollfd_t *descriptor);
00225 
00231 APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
00232                                              const apr_pollfd_t *descriptor);
00233 
00241 APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
00242                                            apr_interval_time_t timeout,
00243                                            apr_int32_t *num,
00244                                            const apr_pollfd_t **descriptors);
00245 
00248 #ifdef __cplusplus
00249 }
00250 #endif
00251 
00252 #endif  /* ! APR_POLL_H */
00253 

Generated on Mon Nov 26 11:47:26 2007 for Apache Portable Runtime by  doxygen 1.5.2