3 * \author written by Emmanuel Roullit emmanuel.roullit@gmail.com (c) 2012
7 /* __LICENSE_HEADER_BEGIN__ */
10 * Copyright (C) 2012 Emmanuel Roullit <emmanuel.roullit@gmail.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
28 /* __LICENSE_HEADER_END__ */
35 #include <dabba/ipc.h>
38 * \brief Communicate via IPC to the dabba daemon
39 * \param[in,out] msg IPC message
40 * \return 0 on success, else on failure.
42 * This function coordinates the communication between dabba and the dabba
43 * daemon. It first sends a command request packed in an IPC message and
44 * awaits for a response from the dabba daemon which contains the request error
45 * code and the requested data.
48 int dabba_ipc_msg(struct dabba_ipc_msg
*msg
)
56 qid
= dabba_get_ipc_queue_id(0660);
59 perror("Cannot get IPC id");
63 snd
= msgsnd(qid
, msg
, sizeof(msg
->msg_body
), 0);
66 perror("Error while sending IPC msg");
72 rcv
= msgrcv(qid
, msg
, sizeof(msg
->msg_body
), 0, 0);
75 perror("Error while receiving IPC msg");
79 if (msg
->msg_body
.error
!= 0) {
80 printf("The daemon reported: %s\n",
81 strerror(msg
->msg_body
.error
));
82 return msg
->msg_body
.error
;