BSignal.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @file BSignal.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * @section DESCRIPTION
  23. *
  24. * A global object for catching program termination requests.
  25. */
  26. #ifndef BADVPN_SYSTEM_BSIGNAL_H
  27. #define BADVPN_SYSTEM_BSIGNAL_H
  28. #include <misc/debug.h>
  29. #include <system/BReactor.h>
  30. typedef void (*BSignal_handler) (void *user);
  31. /**
  32. * Initializes signal handling.
  33. * The object is created in not capturing state.
  34. * {@link BLog_Init} must have been done.
  35. *
  36. * @param reactor {@link BReactor} from which the handler will be called
  37. * @param handler callback function invoked from the reactor
  38. * @param user value passed to callback function
  39. * @return 1 on success, 0 on failure
  40. */
  41. int BSignal_Init (BReactor *reactor, BSignal_handler handler, void *user) WARN_UNUSED;
  42. /**
  43. * Finishes signal handling.
  44. * {@link BSignal_Init} must not be called again.
  45. */
  46. void BSignal_Finish (void);
  47. #endif