/src/captureif.c

http://bdremote-ng.googlecode.com/ · C · 91 lines · 40 code · 18 blank · 33 comment · 6 complexity · 5efde3c711f180e8e87a9d4daa2baa11 MD5 · raw file

  1. /*
  2. * bdremoteng - helper daemon for Sony(R) BD Remote Control
  3. * Based on bdremoted, written by Anton Starikov <antst@mail.ru>.
  4. *
  5. * Copyright (C) 2009 Michael Wojciechowski <wojci@wojci.dk>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program 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
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. /** \ingroup captureinterface
  24. * @{
  25. */
  26. /*! \file captureif.c
  27. \brief Capture interface, init functions.
  28. Implements functions used to init/destroy the data used by the
  29. capture interface.
  30. */
  31. #include "captureif.h"
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <assert.h>
  35. #include <globaldefs.h>
  36. static const unsigned int moduleMask = MODULEMASK_BT_IF;
  37. void InitCaptureData(captureData* _cd,
  38. const configuration* _config,
  39. void* _p)
  40. {
  41. #if BDREMOTE_DEBUG
  42. _cd->magic0 = 127;
  43. #endif /* BDREMOTE_DEBUG */
  44. assert(_config != NULL);
  45. assert(_cd != NULL);
  46. assert(_p != NULL);
  47. assert(_config->remote_addr != NULL);
  48. assert(_config->disconnect_timeout > 0);
  49. assert(_cd->config == NULL);
  50. _cd->config = _config;
  51. _cd->p = _p;
  52. FREEVAL(_cd->bt_dev_address);
  53. _cd->bt_dev_address = NULL;
  54. if (_config->interface_addr_set)
  55. {
  56. SETVAL(_cd->bt_dev_address, _config->interface_addr);
  57. }
  58. FREEVAL(_cd->dest_address);
  59. SETVAL(_cd->dest_address, _config->remote_addr);
  60. _cd->timeout = _config->disconnect_timeout;
  61. memset(&_cd->sockets[0], 0, 2);
  62. }
  63. void DestroyCaptureData(captureData* _cd)
  64. {
  65. _cd->p = NULL;
  66. free(_cd->bt_dev_address);
  67. _cd->bt_dev_address = NULL;
  68. free(_cd->dest_address);
  69. _cd->dest_address = NULL;
  70. }
  71. /*@}*/