jabberd2
2.2.16
|
00001 /* 00002 * jabberd - Jabber Open Source Server 00003 * Copyright (c) 2007 Adam Strzelecki 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA 00018 */ 00019 00020 /* 00021 MIO -- Managed Input/Output 00022 --------------------------- 00023 */ 00024 00025 #ifdef HAVE_CONFIG_H 00026 # include <config.h> 00027 #endif 00028 00029 #include "mio.h" 00030 00031 00032 #ifdef MIO_WSASYNC 00033 #include "mio_wsasync.h" 00034 #include "mio_impl.h" 00035 00036 mio_t mio_wsasync_new(int maxfd) 00037 { 00038 return _mio_new(maxfd); 00039 } 00040 00041 LONG CALLBACK _mio_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LONG lParam) 00042 { 00043 if(msg == WM_TIMER) { 00044 return 1; 00045 } else if(msg >= WM_MIO_EVENT) { 00046 mio_priv_t m = (mio_priv_t)(GetWindowLongPtr(hwnd, GWLP_USERDATA)); 00047 if(msg - WM_MIO_EVENT >= m->count) { 00048 mio_debug(ZONE, "mio event %d on socket id %d out of socket bounds %d", WSAGETSELECTEVENT(lParam), msg - WM_MIO_EVENT, m->count); 00049 return 0; 00050 } 00051 if(!m->fds[msg - WM_MIO_EVENT].event & WSAGETSELECTEVENT(lParam)) { 00052 mio_debug(ZONE, "unmatched mio event %d on socket #%d", WSAGETSELECTEVENT(lParam), m->fds[msg - WM_MIO_EVENT].mio_fd.fd); 00053 return 0; 00054 } 00055 m->select_fd = &m->fds[msg - WM_MIO_EVENT]; 00056 m->select_fd->revent = WSAGETSELECTEVENT(lParam); 00057 mio_debug(ZONE, "get mio event %d on socket #%d", m->select_fd->revent, m->select_fd->mio_fd.fd); \ 00058 return 1; 00059 } else if(msg == WM_CREATE) { 00060 SetWindowLongPtr(hwnd, GWLP_USERDATA, 00061 (LONG_PTR)((LPCREATESTRUCT)lParam)->lpCreateParams); 00062 } else { 00063 return DefWindowProc(hwnd, msg, wParam, lParam); 00064 } 00065 return 0; 00066 } 00067 00068 #endif