Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
qa_ipc_msg.cpp
1
2
/***************************************************************************
3
* qa_ipc_msg.h - QA for IPC message queues
4
*
5
* Generated: Mon Sep 18 23:13:10 2006
6
* Copyright 2005-2006 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
// Do not include in api reference
25
///@cond QA
26
27
#include <utils/ipc/msg.h>
28
29
#include <stdio.h>
30
#include <unistd.h>
31
#include <string.h>
32
33
#define QA_MTYPE 1
34
35
using namespace
fawkes;
36
37
typedef
struct
{
38
long
mtype;
39
char
msg[20];
40
} simple_msg_t;
41
42
int
43
main(
int
argc,
char
**argv )
44
{
45
// Create message queue, destroy on delete
46
IPCMessageQueue
*m1 =
new
IPCMessageQueue
(
"."
,
'A'
,
true
,
true
);
47
48
// Open, do not create, do not destroy
49
IPCMessageQueue
*m2 =
new
IPCMessageQueue
(
"."
,
'A'
,
false
,
false
);
50
51
for
(
unsigned
int
i = 0; i < 10; ++i) {
52
simple_msg_t smsg;
53
simple_msg_t rmsg;
54
memset(&smsg, 0,
sizeof
(smsg));
55
memset(&rmsg, 0,
sizeof
(rmsg));
56
57
smsg.mtype = QA_MTYPE;
58
sprintf(smsg.msg,
"%u"
, i);
59
60
m1->
send
((
IPCMessageQueue::MessageStruct
*)&smsg,
sizeof
(smsg));
61
m2->
recv
(QA_MTYPE, (
IPCMessageQueue::MessageStruct
*)&rmsg,
sizeof
(rmsg));
62
63
printf(
"Sent: %s Received: %s\n"
, smsg.msg, rmsg.msg);
64
}
65
66
delete
m2;
67
delete
m1;
68
69
return
0;
70
}
71
72
73
74
/// @endcond
src
libs
utils
qa
qa_ipc_msg.cpp
Generated by
1.8.3.1