Introduce EIBC_RETURN_BUF
[bcusdk.git] / eibd / client / getgroupsrc.c
bloba87ccc55a8863fbc97ca707c6454ae2be80cb33d
1 /*
2 EIBD client library
3 Copyright (C) 2005-2007 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 In addition to the permissions in the GNU General Public License,
11 you may link the compiled version of this file into combinations
12 with other programs, and distribute those combinations without any
13 restriction coming from the use of this file. (The General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked into
16 a combine executable.)
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "eibclient.h"
29 #include "eibclient-int.h"
31 static int
32 EIBGetGroup_Src_complete (EIBConnection * con)
34 EIBC_GETREQUEST
35 EIBC_CHECKRESULT (EIB_GROUP_PACKET, 6)
36 if (con->req.ptr5)
37 *con->req.ptr5 = (con->buf[2] << 8) | (con->buf[3]);
38 if (con->req.ptr6)
39 *con->req.ptr6 = (con->buf[4] << 8) | (con->buf[5]);
40 EIBC_RETURN_BUF (6)
43 int
44 EIBGetGroup_Src_async (EIBConnection * con, int maxlen, uint8_t * buf,
45 eibaddr_t * src, eibaddr_t * dest)
47 if (!con || !buf)
49 errno = EINVAL;
50 return -1;
53 con->req.buf = buf;
54 con->req.len = maxlen;
55 con->req.ptr5 = src;
56 con->req.ptr6 = dest;
57 con->complete = EIBGetGroup_Src_complete;
58 return 0;
61 int
62 EIBGetGroup_Src (EIBConnection * con, int maxlen, uint8_t * buf,
63 eibaddr_t * src, eibaddr_t * dest)
65 if (EIBGetGroup_Src_async (con, maxlen, buf, src, dest) == -1)
66 return -1;
67 return EIBComplete (con);