Debian Codegraph @

libcyberjack/libdialog/base/message.h

raw
1 /***************************************************************************
2 begin : Wed Jun 16 2010
3 copyright : (C) 2010 by Martin Preuss
4 email : [email protected]
5
6 ***************************************************************************
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library 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 GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 * *
23 ***************************************************************************/
24
25 #ifndef RSCT_MESSAGE_H
26 #define RSCT_MESSAGE_H
27
28
29 #include <inttypes.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 #if defined (__APPLE__) | defined (sun)
38 # pragma pack(1)
39 #else
40 # pragma pack(push, 1)
41 #endif
42
43
44 #define RSCT_MAX_MESSAGE_LEN (65*1024)
45 #define RSCT_MAX_BUFFER_LEN 4096
46
47
48
49
50 enum RSCT_MESSAGE_COMMANDS {
51 RSCT_Message_Command_OpenDialog,
52 RSCT_Message_Command_CloseDialog,
53 RSCT_Message_Command_SetStage,
54 RSCT_Message_Command_SetCharNum
55 };
56
57
58
59 struct RSCT_MESSAGE_OPENDIALOG {
60 uint32_t dialogId;
61 uint32_t stages;
62 uint8_t cla;
63 uint8_t ins;
64 uint8_t keyTimeout;
65 char title[128];
66 char textStage0[512];
67 char textStage1[512];
68 char textStage2[512];
69 int8_t result;
70 };
71 typedef struct RSCT_MESSAGE_OPENDIALOG RSCT_MESSAGE_OPENDIALOG;
72
73
74
75 struct RSCT_MESSAGE_CLOSEDIALOG {
76 uint32_t dialogId;
77 int8_t result;
78 };
79 typedef struct RSCT_MESSAGE_CLOSEDIALOG RSCT_MESSAGE_CLOSEDIALOG;
80
81
82
83 struct RSCT_MESSAGE_SETSTAGE {
84 uint32_t dialogId;
85 uint32_t stage;
86 int8_t result;
87 };
88 typedef struct RSCT_MESSAGE_SETSTAGE RSCT_MESSAGE_SETSTAGE;
89
90
91
92 struct RSCT_MESSAGE_SETCHARNUM {
93 uint32_t dialogId;
94 uint32_t charNum;
95 int8_t beep;
96 int8_t result;
97 };
98 typedef struct RSCT_MESSAGE_SETCHARNUM RSCT_MESSAGE_SETCHARNUM;
99
100
101
102 struct RSCT_MESSAGE_HEADER {
103 uint8_t type;
104 uint32_t len;
105 };
106 typedef struct RSCT_MESSAGE_HEADER RSCT_MESSAGE_HEADER;
107
108
109
110 struct RSCT_MESSAGE {
111 RSCT_MESSAGE_HEADER header;
112 union {
113 RSCT_MESSAGE_OPENDIALOG openDialog;
114 RSCT_MESSAGE_CLOSEDIALOG closeDialog;
115 RSCT_MESSAGE_SETSTAGE setStage;
116 RSCT_MESSAGE_SETCHARNUM setCharNum;
117 };
118 };
119 typedef struct RSCT_MESSAGE RSCT_MESSAGE;
120
121
122 #if defined (__APPLE__) | defined (sun)
123 # pragma pack()
124 #else
125 # pragma pack(pop)
126 #endif
127
128
129 #define RSCT_MSG_SIZE(tp) (\
130 sizeof(struct RSCT_MESSAGE_HEADER)+\
131 sizeof(tp))
132
133
134 const char *RSCT_MessageTypeToString(int t);
135
136
137 #ifdef __cplusplus
138 }
139 #endif
140
141
142 #endif
143