PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
24/** \ingroup captureinterface
25 *  @{
26 */
27
28/*! \file captureif.c
29  \brief Capture interface, init functions.
30
31  Implements functions used to init/destroy the data used by the
32  capture interface.
33
34*/
35
36#include "captureif.h"
37
38#include <stdlib.h>
39#include <string.h>
40#include <assert.h>
41#include <globaldefs.h>
42
43static const unsigned int moduleMask = MODULEMASK_BT_IF;
44
45void InitCaptureData(captureData* _cd,
46                     const configuration* _config,
47                     void* _p)
48{
49#if BDREMOTE_DEBUG
50   _cd->magic0 = 127;
51#endif /* BDREMOTE_DEBUG */
52   assert(_config != NULL);
53   assert(_cd != NULL);
54   assert(_p != NULL);
55   assert(_config->remote_addr != NULL);
56   assert(_config->disconnect_timeout > 0);
57
58   assert(_cd->config == NULL);
59   _cd->config = _config;
60
61   _cd->p = _p;
62
63   FREEVAL(_cd->bt_dev_address);
64   _cd->bt_dev_address = NULL;
65
66   if (_config->interface_addr_set)
67     {
68       SETVAL(_cd->bt_dev_address, _config->interface_addr);
69     }
70
71   FREEVAL(_cd->dest_address);
72   SETVAL(_cd->dest_address, _config->remote_addr);
73   
74   _cd->timeout = _config->disconnect_timeout;
75
76   memset(&_cd->sockets[0], 0, 2);
77}
78
79void DestroyCaptureData(captureData* _cd)
80{
81   _cd->p = NULL;
82
83   free(_cd->bt_dev_address);
84   _cd->bt_dev_address = NULL;
85
86   free(_cd->dest_address);
87   _cd->dest_address = NULL;
88}
89
90/*@}*/
91