PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/backend/win32/ftk_source_win32.c

http://ftk.googlecode.com/
C | 91 lines | 48 code | 14 blank | 29 comment | 4 complexity | bcbf6eb83fe8a6eb836e90fdb29e54ad MD5 | raw file
 1/*
 2 * File: ftk_source_win32.c    
 3 * Author:  Li XianJing <xianjimli@hotmail.com>
 4 * Brief:   win32 source 
 5 *
 6 * Copyright (c) 2009 - 2010  Li XianJing <xianjimli@hotmail.com>
 7 *
 8 * Licensed under the Academic Free License version 2.1
 9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 */
24
25/*
26 * History:
27 * ================================================================
28 * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
29 *
30 */
31#include "ftk_source_win32.h"
32
33typedef struct _PrivInfo
34{
35	void* user_data;
36}PrivInfo;
37
38static int ftk_source_win32_get_fd(FtkSource* thiz)
39{
40	return -1;
41}
42
43static int ftk_source_win32_check(FtkSource* thiz)
44{
45	return 0;
46}
47
48static Ret ftk_source_win32_dispatch(FtkSource* thiz)
49{
50	MSG msg;
51	DECL_PRIV(thiz, priv);
52
53	if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
54	{
55		TranslateMessage(&msg);
56		DispatchMessage(&msg);
57	}
58	
59	if(!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
60	{
61		Sleep(10);
62	}
63
64	return RET_OK;
65}
66
67static void ftk_source_win32_destroy(FtkSource* thiz)
68{
69	FTK_ZFREE(thiz, sizeof(FtkSource) + sizeof(PrivInfo));
70
71	return;
72}
73
74FtkSource* ftk_source_win32_create(void)
75{
76	FtkSource* thiz = NULL;
77
78	thiz = (FtkSource*)FTK_ZALLOC(sizeof(FtkSource) + sizeof(PrivInfo));
79	if(thiz != NULL)
80	{
81		DECL_PRIV(thiz, priv);
82		thiz->get_fd   = ftk_source_win32_get_fd;
83		thiz->check    = ftk_source_win32_check;
84		thiz->dispatch = ftk_source_win32_dispatch;
85		thiz->destroy  = ftk_source_win32_destroy;
86
87		thiz->ref = 1;
88	}
89
90	return thiz;
91}