1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
{$MACRO ON}
(***********************************************************************
*
* Copyright (c) 1999-2000 Palm, Inc. or its subsidiaries.
* All rights reserved.
*
* File: UDAMgr.h
*
* Release: Palm OS SDK 4.0 (63220)
*
* Description:
* Unified Data Manager header file
* Define type and generic macro to access data
*
* History:
* Jun 08, 2000 Created by Alain BASTY
*
************************************************************************)
unit udamgr;
interface
uses palmos, coretraps, errorbase, exgmgr;
(***********************************************************************
* Generic options flags
************************************************************************)
const
kUDAEndOfReader = 1;
kUDAMoreData = 2;
(***********************************************************************
* Generic control
************************************************************************)
const
kUDAReinitialize = 1;
(***********************************************************************
* Generic error codes
************************************************************************)
const
udaErrControl = udaErrorClass or 1;
(***********************************************************************
* General types
************************************************************************)
type
UDABufferSize = UInt16;
const
kUDAZeroTerminatedBuffer = $FFFF;
(***********************************************************************
* Types of callback functions
************************************************************************)
type
UDAObjectPtr = ^UDAObjectType;
UDAReaderPtr = ^UDAReaderType;
UDAWriterPtr = ^UDAWriterType;
UDADeleteFunction = procedure (var ioObject: UDAObjectPtr);
//!!! UDAControlFunction = function (ioObject: UDAObjectPtr; parameter: UInt16; args: va_list): Err;
UDAReadFunction = function (ioReader: UDAReaderPtr; var buffer: UInt8; bufferSize: UDABufferSize; var error: Err): UDABufferSize;
UDAWriteFunction = function (ioWriter: UDAWriterPtr): Err;
UDAFlushFunction = function (ioWriter: UDAWriterPtr): Err;
UDAObjectType = record
optionFlags: UInt16;
deleteF: UDADeleteFunction;
controlF: Pointer; //!!!UDAControlFunction;
end;
UDAObjectTag = UDAObjectType;
UDAReaderType = record
// The Reader is a base object
optionFlags: UInt16 ;
deleteF: UDADeleteFunction;
controlF: Pointer; //!!!UDAControlFunction;
// Specific Reader fields
readF: UDAReadFunction;
end;
UDAReaderTag = UDAReaderType;
UDAFilterType = record
// The Filter is a base Object
optionFlags: UInt16;
deleteF: UDADeleteFunction;
controlF: Pointer; //!!!UDAControlFunction;
// The Filter is a Reader
readF: UDAReadFunction;
// Specific Filter fields
upperReader: ^UDAReaderType;
end;
UDAFilterTag = UDAFilterType;
UDAWriterType = record
// The Writer is a base Object
optionFlags: UInt16;
deleteF: UDADeleteFunction;
controlF: Pointer; //!!!UDAControlFunction;
// Specific Writer fields
initiateWriteF: UDAWriteFunction;
flushF: UDAFlushFunction;
upperReader: ^UDAReaderType;
end;
UDAWriterTag = UDAWriterType;
(***********************************************************************
* Generic macro to access generic functions
************************************************************************)
(*
#define UDADelete(ioObject) (( *(ioObject->deleteF))((UDAObjectType** )(&(ioObject))))
#define UDARead(ioReader, bufferToFillP, bufferSizeInBytes, error) (( *(ioReader->readF))((UDAReaderType* )(ioReader), (bufferToFillP), (bufferSizeInBytes), (error)))
#define UDAEndOfReader(ioReader) (((ioReader)->optionFlags & kUDAEndOfReader) != 0)
#define UDAMoreData(ioReader) (((ioReader)->optionFlags & kUDAMoreData) != 0)
#define UDAFilterJoin(ioFilter, ioReader) (((UDAFilterType* )(ioFilter))->upperReader = ioReader)
#define UDAWriterJoin(ioWriter, ioReader) (ioWriter->upperReader = ioReader)
#define UDAInitiateWrite(ioWriter) (( *(ioWriter)->initiateWriteF))(ioWriter)
#define UDAWriterFlush(ioWriter) (( *(ioWriter)->flushF))(ioWriter)
*)
(*****************************************************************
* UDA API
****************************************************************)
// Public UDAMgr function selectors
const
sysUdaControl = 0;
sysUdaMemoryReaderNew = 1;
sysUdaExchangeReaderNew = 11;
sysUdaExchangeWriterNew = 12;
// UDAMgr function prototypes
//!!! function UDAControl(var ioObject: UDAObjectType; parameter: UInt16, ...): Err; syscall sysTrapUdaMgrDispatch, sysUdaControl;
function UDAExchangeReaderNew(var socket: ExgSocketType): UDAReaderPtr;
function UDAExchangeWriterNew(var socket: ExgSocketType; bufferSize: UDABufferSize): UDAWriterPtr;
(***********************************************************************
* Memory reader
************************************************************************)
function UDAMemoryReaderNew(var bufferP: UInt8; bufferSizeInBytes: UDABufferSize): UDAReaderPtr;
implementation
function __UDAExchangeReaderNew(var socket: ExgSocketType): UDAReaderPtr; syscall sysTrapUdaMgrDispatch;
function __UDAExchangeWriterNew(var socket: ExgSocketType; bufferSize: UDABufferSize): UDAWriterPtr; syscall sysTrapUdaMgrDispatch;
function __UDAMemoryReaderNew(var bufferP: UInt8; bufferSizeInBytes: UDABufferSize): UDAReaderPtr; syscall sysTrapUdaMgrDispatch;
function UDAExchangeReaderNew(var socket: ExgSocketType): UDAReaderPtr;
begin
asm
move.l #$sysUdaExchangeReaderNew, D2;
end;
UDAExchangeReaderNew := __UDAExchangeReaderNew(socket);
end;
function UDAExchangeWriterNew(var socket: ExgSocketType; bufferSize: UDABufferSize): UDAWriterPtr;
begin
asm
move.l #$sysUdaExchangeWriterNew, D2;
end;
UDAExchangeWriterNew := __UDAExchangeWriterNew(socket, bufferSize);
end;
function UDAMemoryReaderNew(var bufferP: UInt8; bufferSizeInBytes: UDABufferSize): UDAReaderPtr;
begin
asm
move.l #$sysUdaMemoryReaderNew, D2;
end;
UDAMemoryReaderNew := __UDAMemoryReaderNew(bufferP, bufferSizeInBytes);
end;
end.
|