/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. * History:
  26. * ================================================================
  27. * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #include "ftk_source_win32.h"
  31. typedef struct _PrivInfo
  32. {
  33. void* user_data;
  34. }PrivInfo;
  35. static int ftk_source_win32_get_fd(FtkSource* thiz)
  36. {
  37. return -1;
  38. }
  39. static int ftk_source_win32_check(FtkSource* thiz)
  40. {
  41. return 0;
  42. }
  43. static Ret ftk_source_win32_dispatch(FtkSource* thiz)
  44. {
  45. MSG msg;
  46. DECL_PRIV(thiz, priv);
  47. if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  48. {
  49. TranslateMessage(&msg);
  50. DispatchMessage(&msg);
  51. }
  52. if(!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  53. {
  54. Sleep(10);
  55. }
  56. return RET_OK;
  57. }
  58. static void ftk_source_win32_destroy(FtkSource* thiz)
  59. {
  60. FTK_ZFREE(thiz, sizeof(FtkSource) + sizeof(PrivInfo));
  61. return;
  62. }
  63. FtkSource* ftk_source_win32_create(void)
  64. {
  65. FtkSource* thiz = NULL;
  66. thiz = (FtkSource*)FTK_ZALLOC(sizeof(FtkSource) + sizeof(PrivInfo));
  67. if(thiz != NULL)
  68. {
  69. DECL_PRIV(thiz, priv);
  70. thiz->get_fd = ftk_source_win32_get_fd;
  71. thiz->check = ftk_source_win32_check;
  72. thiz->dispatch = ftk_source_win32_dispatch;
  73. thiz->destroy = ftk_source_win32_destroy;
  74. thiz->ref = 1;
  75. }
  76. return thiz;
  77. }