event.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*------------------------------------------------------------------------
  2. * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  3. *
  4. * This file is part of the ZBar Bar Code Reader.
  5. *
  6. * The ZBar Bar Code Reader is free software; you can redistribute it
  7. * and/or modify it under the terms of the GNU Lesser Public License as
  8. * published by the Free Software Foundation; either version 2.1 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * The ZBar Bar Code Reader is distributed in the hope that it will be
  12. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  13. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser Public License
  17. * along with the ZBar Bar Code Reader; if not, write to the Free
  18. * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301 USA
  20. *
  21. * http://sourceforge.net/projects/zbar
  22. *------------------------------------------------------------------------*/
  23. #ifndef _ZBAR_EVENT_H_
  24. #define _ZBAR_EVENT_H_
  25. #include <config.h>
  26. #include "mutex.h"
  27. #include "timer.h"
  28. /* platform synchronization "event" abstraction
  29. */
  30. #if defined(_WIN32)
  31. # include <windows.h>
  32. typedef HANDLE zbar_event_t;
  33. #else
  34. # ifdef HAVE_LIBPTHREAD
  35. # include <pthread.h>
  36. # endif
  37. typedef struct zbar_event_s {
  38. int state;
  39. # ifdef HAVE_LIBPTHREAD
  40. pthread_cond_t cond;
  41. # endif
  42. int pollfd;
  43. } zbar_event_t;
  44. #endif
  45. extern int _zbar_event_init(zbar_event_t*);
  46. extern void _zbar_event_destroy(zbar_event_t*);
  47. extern void _zbar_event_trigger(zbar_event_t*);
  48. extern int _zbar_event_wait(zbar_event_t*, zbar_mutex_t*, zbar_timer_t*);
  49. #endif