ibEvent.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /***************************************************************************
  2. lib/ibEvent.c
  3. -------------------
  4. copyright : (C) 2001,2002,2003 by Frank Mori Hess
  5. email : fmhess@users.sourceforge.net
  6. ***************************************************************************/
  7. /***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #include "ib_internal.h"
  16. int ibevent(int ud, short *event )
  17. {
  18. ibConf_t *conf;
  19. ibBoard_t *board;
  20. int retval;
  21. event_ioctl_t user_event;
  22. conf = general_enter_library( ud, 1, 1 );
  23. if( conf == NULL )
  24. return general_exit_library( ud, 1, 0, 0, 0, 0, 1 );
  25. if( conf->is_interface == 0 )
  26. {
  27. setIberr( EARG );
  28. return general_exit_library( ud, 1, 0, 0, 0, 0, 1 );
  29. }
  30. board = interfaceBoard( conf );
  31. retval = ioctl( board->fileno, IBEVENT, &user_event );
  32. if( retval < 0 )
  33. {
  34. switch( errno )
  35. {
  36. case EPIPE:
  37. setIberr( ETAB );
  38. break;
  39. default:
  40. setIberr( EDVR );
  41. setIbcnt( errno );
  42. break;
  43. }
  44. return general_exit_library( ud, 1, 0, 0, 0, 0, 1 );
  45. }
  46. *event = user_event;
  47. return general_exit_library( ud, 0, 0, 0, 0, 0, 1 );
  48. }