jabberd2  2.7.0
mio_wsasync.c
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2007 Adam Strzelecki
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
18  */
19 
20 /*
21  MIO -- Managed Input/Output
22  ---------------------------
23 */
24 
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include "mio.h"
30 
31 
32 #ifdef MIO_WSASYNC
33 #include "mio_wsasync.h"
34 #include "mio_impl.h"
35 
36 mio_t mio_wsasync_new(int maxfd)
37 {
38  return _mio_new(maxfd);
39 }
40 
41 LONG CALLBACK _mio_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LONG lParam)
42 {
43  if(msg == WM_TIMER) {
44  return 1;
45  } else if(msg >= WM_MIO_EVENT) {
46  mio_priv_t m = (mio_priv_t)(GetWindowLongPtr(hwnd, GWLP_USERDATA));
47  if(msg - WM_MIO_EVENT >= m->count) {
48  mio_debug(ZONE, "mio event %d on socket id %d out of socket bounds %d", WSAGETSELECTEVENT(lParam), msg - WM_MIO_EVENT, m->count);
49  return 0;
50  }
51  if(!m->fds[msg - WM_MIO_EVENT].event & WSAGETSELECTEVENT(lParam)) {
52  mio_debug(ZONE, "unmatched mio event %d on socket #%d", WSAGETSELECTEVENT(lParam), m->fds[msg - WM_MIO_EVENT].mio_fd.fd);
53  return 0;
54  }
55  m->select_fd = &m->fds[msg - WM_MIO_EVENT];
56  m->select_fd->revent = WSAGETSELECTEVENT(lParam);
57  mio_debug(ZONE, "get mio event %d on socket #%d", m->select_fd->revent, m->select_fd->mio_fd.fd); \
58  return 1;
59  } else if(msg == WM_CREATE) {
60  SetWindowLongPtr(hwnd, GWLP_USERDATA,
61  (LONG_PTR)((LPCREATESTRUCT)lParam)->lpCreateParams);
62  } else {
63  return DefWindowProc(hwnd, msg, wParam, lParam);
64  }
65  return 0;
66 }
67 
68 #endif
#define mio_debug
Definition: mio_impl.h:80
#define WM_MIO_EVENT
Definition: mio_wsasync.h:26
Definition: mio.h:109
mio_t mio_wsasync_new(int maxfd)
static mio_t _mio_new(int maxfd)
eve
Definition: mio_impl.h:493
mio - manage i/o
struct mio_priv_st * mio_priv_t
now define our master data type
now define our master data type
Definition: mio_impl.h:62
#define ZONE
Definition: mio_impl.h:76