Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #include <pj/ioqueue.h> |
| 21 | #include <pj/os.h> |
| 22 | #include <pj/log.h> |
| 23 | #include <pj/list.h> |
| 24 | #include <pj/pool.h> |
| 25 | #include <pj/string.h> |
| 26 | #include <pj/assert.h> |
| 27 | #include <pj/sock.h> |
| 28 | #include <pj/errno.h> |
| 29 | |
| 30 | #define THIS_FILE "ioqueue" |
| 31 | |
| 32 | #define PJ_IOQUEUE_IS_READ_OP(op) \ |
| 33 | ((op & PJ_IOQUEUE_OP_READ) || (op & PJ_IOQUEUE_OP_RECV_FROM)) |
| 34 | #define PJ_IOQUEUE_IS_WRITE_OP(op) \ |
| 35 | ((op & PJ_IOQUEUE_OP_WRITE) || (op & PJ_IOQUEUE_OP_SEND_TO)) |
| 36 | |
| 37 | |
| 38 | #if PJ_HAS_TCP |
| 39 | # define PJ_IOQUEUE_IS_ACCEPT_OP(op) (op & PJ_IOQUEUE_OP_ACCEPT) |
| 40 | # define PJ_IOQUEUE_IS_CONNECT_OP(op) (op & PJ_IOQUEUE_OP_CONNECT) |
| 41 | #else |
| 42 | # define PJ_IOQUEUE_IS_ACCEPT_OP(op) 0 |
| 43 | # define PJ_IOQUEUE_IS_CONNECT_OP(op) 0 |
| 44 | #endif |
| 45 | |
| 46 | #if defined(PJ_DEBUG) && PJ_DEBUG != 0 |
| 47 | # define VALIDATE_FD_SET 1 |
| 48 | #else |
| 49 | # define VALIDATE_FD_SET 0 |
| 50 | #endif |
| 51 | |
| 52 | struct pj_ioqueue_key_t |
| 53 | { |
| 54 | PJ_DECL_LIST_MEMBER(struct pj_ioqueue_key_t) |
| 55 | pj_sock_t fd; |
| 56 | pj_ioqueue_operation_e op; |
| 57 | void *user_data; |
| 58 | pj_ioqueue_callback cb; |
| 59 | }; |
| 60 | |
| 61 | struct pj_ioqueue_t |
| 62 | { |
| 63 | }; |
| 64 | |
| 65 | PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool, |
| 66 | pj_size_t max_fd, |
| 67 | int max_threads, |
| 68 | pj_ioqueue_t **ptr_ioqueue) |
| 69 | { |
| 70 | return PJ_ENOTSUP; |
| 71 | } |
| 72 | |
| 73 | PJ_DEF(pj_status_t) pj_ioqueue_destroy(pj_ioqueue_t *ioque) |
| 74 | { |
| 75 | return PJ_ENOTSUP; |
| 76 | } |
| 77 | |
| 78 | PJ_DEF(pj_status_t) pj_ioqueue_set_lock( pj_ioqueue_t *ioque, |
| 79 | pj_lock_t *lock, |
| 80 | pj_bool_t auto_delete ) |
| 81 | { |
| 82 | return PJ_ENOTSUP; |
| 83 | } |
| 84 | |
| 85 | PJ_DEF(pj_status_t) pj_ioqueue_register_sock( pj_pool_t *pool, |
| 86 | pj_ioqueue_t *ioque, |
| 87 | pj_sock_t sock, |
| 88 | void *user_data, |
| 89 | const pj_ioqueue_callback *cb, |
| 90 | pj_ioqueue_key_t **ptr_key) |
| 91 | { |
| 92 | return PJ_ENOTSUP; |
| 93 | } |
| 94 | |
| 95 | PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_t *ioque, |
| 96 | pj_ioqueue_key_t *key) |
| 97 | { |
| 98 | return PJ_ENOTSUP; |
| 99 | } |
| 100 | |
| 101 | PJ_DEF(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key ) |
| 102 | { |
| 103 | return NULL; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | PJ_DEF(int) pj_ioqueue_poll( pj_ioqueue_t *ioque, const pj_time_val *timeout) |
| 108 | { |
| 109 | return -1; |
| 110 | } |
| 111 | |
| 112 | PJ_DEF(pj_status_t) pj_ioqueue_read( pj_ioqueue_t *ioque, |
| 113 | pj_ioqueue_key_t *key, |
| 114 | void *buffer, |
| 115 | pj_size_t buflen) |
| 116 | { |
| 117 | return -1; |
| 118 | } |
| 119 | |
| 120 | PJ_DEF(pj_status_t) pj_ioqueue_recv( pj_ioqueue_t *ioque, |
| 121 | pj_ioqueue_key_t *key, |
| 122 | void *buffer, |
| 123 | pj_size_t buflen, |
| 124 | unsigned flags) |
| 125 | { |
| 126 | return -1; |
| 127 | } |
| 128 | |
| 129 | PJ_DEF(pj_status_t) pj_ioqueue_recvfrom( pj_ioqueue_t *ioque, |
| 130 | pj_ioqueue_key_t *key, |
| 131 | void *buffer, |
| 132 | pj_size_t buflen, |
| 133 | unsigned flags, |
| 134 | pj_sockaddr_t *addr, |
| 135 | int *addrlen) |
| 136 | { |
| 137 | return -1; |
| 138 | } |
| 139 | |
| 140 | PJ_DEF(pj_status_t) pj_ioqueue_write( pj_ioqueue_t *ioque, |
| 141 | pj_ioqueue_key_t *key, |
| 142 | const void *data, |
| 143 | pj_size_t datalen) |
| 144 | { |
| 145 | return -1; |
| 146 | } |
| 147 | |
| 148 | PJ_DEF(pj_status_t) pj_ioqueue_send( pj_ioqueue_t *ioque, |
| 149 | pj_ioqueue_key_t *key, |
| 150 | const void *data, |
| 151 | pj_size_t datalen, |
| 152 | unsigned flags) |
| 153 | { |
| 154 | return -1; |
| 155 | } |
| 156 | |
| 157 | PJ_DEF(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_t *ioque, |
| 158 | pj_ioqueue_key_t *key, |
| 159 | const void *data, |
| 160 | pj_size_t datalen, |
| 161 | unsigned flags, |
| 162 | const pj_sockaddr_t *addr, |
| 163 | int addrlen) |
| 164 | { |
| 165 | return -1; |
| 166 | } |
| 167 | |
| 168 | #if PJ_HAS_TCP |
| 169 | /* |
| 170 | * Initiate overlapped accept() operation. |
| 171 | */ |
| 172 | PJ_DEF(pj_status_t) pj_ioqueue_accept( pj_ioqueue_t *ioqueue, |
| 173 | pj_ioqueue_key_t *key, |
| 174 | pj_sock_t *new_sock, |
| 175 | pj_sockaddr_t *local, |
| 176 | pj_sockaddr_t *remote, |
| 177 | int *addrlen) |
| 178 | { |
| 179 | return -1; |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | * Initiate overlapped connect() operation (well, it's non-blocking actually, |
| 184 | * since there's no overlapped version of connect()). |
| 185 | */ |
| 186 | PJ_DEF(pj_status_t) pj_ioqueue_connect( pj_ioqueue_t *ioqueue, |
| 187 | pj_ioqueue_key_t *key, |
| 188 | const pj_sockaddr_t *addr, |
| 189 | int addrlen ) |
| 190 | { |
| 191 | return -1; |
| 192 | } |
| 193 | #endif /* PJ_HAS_TCP */ |
| 194 | |