1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 /*************************************************************************
25  *
26  *	  ATTENTION
27  *	  This file is intended to work inside and outside the StarOffice environment.
28  *	  Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
29  *
30  ************************************************************************/
31 
32 #include <automation/commtypes.hxx>
33 #include <osl/endian.h>
34 
35 #ifndef MAKEDWORD
36 #define MAKEDWORD(wl, wh)   ((comm_DWORD)((wl) & 0xFFFF) | (((comm_DWORD)(wh) & 0xFFFF) << 16))
37 #endif
38 #ifndef LOWORD
39 #define LOWORD(d)           ((comm_WORD)((comm_DWORD)(d) & 0xFFFF))
40 #endif
41 #ifndef HIWORD
42 #define HIWORD(d)           ((comm_WORD)(((comm_DWORD)(d) >> 16) & 0xFFFF))
43 #endif
44 #ifndef MAKEWORD
45 #define MAKEWORD(bl, bh)    ((comm_WORD)((bl) & 0xFF) | (((comm_WORD)(bh) & 0xFF) << 8))
46 #endif
47 #ifndef LOBYTE
48 #define LOBYTE(w)           ((comm_BYTE)((comm_WORD)(w) & 0xFF))
49 #endif
50 #ifndef HIBYTE
51 #define HIBYTE(w)           ((comm_BYTE)(((comm_WORD)(w) >> 8) & 0xFF))
52 #endif
53 #ifndef MAKEBYTE
54 #define MAKEBYTE(nl, nh)    ((comm_BYTE)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
55 #endif
56 #ifndef LONIBBLE
57 #define LONIBBLE(b)         ((comm_BYTE)((b) & 0x0F))
58 #endif
59 #ifndef HINIBBLE
60 #define HINIBBLE(b)         ((comm_BYTE)(((b) >> 4) & 0x0F))
61 #endif
62 
63 #ifndef SWAPWORD
64 #define SWAPWORD(w)         MAKEWORD(HIBYTE(w),LOBYTE(w))
65 #endif
66 #ifndef SWAPDWORD
67 #define SWAPDWORD(d)        MAKEDWORD(SWAPWORD(HIWORD(d)),SWAPWORD(LOWORD(d)))
68 #endif
69 
70 #ifdef OSL_BIGENDIAN
71 #ifndef NETWORD
72 #define NETWORD(w)          (comm_WORD)(w)
73 #endif
74 #ifndef NETDWORD
75 #define NETDWORD(d)         (comm_DWORD)(d)
76 #endif
77 #endif // OSL_BIGENDIAN
78 
79 #ifdef OSL_LITENDIAN
80 #ifndef NETWORD
81 #define NETWORD(w)          MAKEWORD(HIBYTE(w),LOBYTE(w))
82 #endif
83 #ifndef NETDWORD
84 #define NETDWORD(d)         MAKEDWORD(NETWORD(HIWORD(d)),NETWORD(LOWORD(d)))
85 #endif
86 #endif // OSL_LITENDIAN
87 
88 /**
89 	Es gibt zwei arten von Datenpaketen
90 	die erste enth�lt in den ersten 4 Byte die L�ngenangabe und in den Darauffolgenden die Daten
91 	Die L�ngenangabe bezieht sich nur auf die Daten ohne die L�ngenangabe selbst.
92 
93 	Die Zweite Art von Datenpaketen enth�lt Header mit weitere Informationen
94 	wie unten beschrieben.
95 
96 	Umgeschaltet wird mit dem Boolean bUseMultiChannel im Konstruktor des Managers.
97 **/
98 /**
99 Defines f�r Header Typen:
100 
101 Allgemeiner Header:
102 		Byte	L�nge		Inhalt
103 		0..3		4		L�nge des Paketes ohne diese 4 Byte
104 		4			1		Pr�fsumme �ber die L�nge. Stimmt sie nicht wird die Verbindung geschlossen
105 		5..6		2		L�nge des Headers ohne diese 2 Byte
106 		7..8		2		Typ des Headers
107 
108 CH_SimpleMultiChannel:
109 		9..10		2		Channel
110 CH_Handshake				Internal Use ONLY
111 							Keine Weiteren Daten!
112 
113 **/
114 typedef comm_UINT16 CMProtocol;
115 
116 #define CM_PROTOCOL_OLDSTYLE		(CMProtocol)0x0001
117 #define CM_PROTOCOL_MARS			(CMProtocol)0x0001
118 #define CM_PROTOCOL_BROADCASTER		(CMProtocol)0x0002
119 #define CM_PROTOCOL_USER_START		(CMProtocol)0x0100
120 
121 typedef comm_USHORT HandshakeType;
122 typedef comm_USHORT CommunicationOption;
123 
124 #define CH_NoHeader					0x0000
125 #define CH_SimpleMultiChannel		0x0001
126 #define CH_Handshake				0x0002
127 
128 #define CH_REQUEST_HandshakeAlive	((HandshakeType)0x0101)	/// Fordert eine Alive Antwort an
129 #define CH_RESPONSE_HandshakeAlive	((HandshakeType)0x0102)	/// Alive Antwort
130 
131 /**
132 	Announce supported options:
133 	Client announces available options
134 	Server returns subset of these options (note that the sbset can be the entire set also)
135 **/
136 #define CH_SUPPORT_OPTIONS			((HandshakeType)0x0103)
137 #define OPT_USE_SHUTDOWN_PROTOCOL	((CommunicationOption)0x0001)
138 
139 /// these are for making sure all Data is read prior to shutting sown the link
140 #define CH_REQUEST_ShutdownLink		((HandshakeType)0x0104)	/// Request to Shutdown this link
141 #define CH_ShutdownLink				((HandshakeType)0x0105)	/// Shutdown this link
142 
143 #define CH_SetApplication			((HandshakeType)0x0106)	/// Set Description of Client
144 
145