aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/Palm/Platform/Incs/Core/System/DLCommon.h
blob: af8a44936d96b6dd1b81d44e8c4c60396eee8c08 (plain)
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
/******************************************************************************
 *
 * Copyright (c) 1995-1999 Palm Computing, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: DLCommon.h
 *
 * Description:
 *		Desktop Link Protocol(DLP) function id's, parameters, and frame
 *		structures.
 *
 * History:
 *   	6/7/95	vmk	Created by Vitaly Marty Kruglikov
 *		6/15/95	vmk	Changed dlp/Read/Write/UserID to dlp/Read/Write/UserInfo and
 *							added the last sync PC id field to their arguments at Laura's request.
 *		6/15/95	vmk	Added option to dlpDeleteRecord to delete all records in DB. 
 *
 *****************************************************************************/

#ifndef __DLCOMMON_H__
#define __DLCOMMON_H__

#include <PalmTypes.h>

/************************************************************
 * DesktopLink function codes
 *************************************************************/

// DlpFuncID -- function id's used in request blocks sent to
// the DesktopLink application on Pilot.  The width of the function
// id base is 7 bits.  The high order bit(the 8th bit) is used to
// distinguish requests from their responses --  it is cleared in request
// blocks and is set in response blocks (i.e., the response to a particular
// command will have the same function code base as the command and the
// high order bit set).  See dlpFuncRespFlag defined below.
//
typedef enum DlpFuncID {

	dlpReservedFunc = 0x0F,			// range reserved for internal use

	// DLP 1.0 FUNCTIONS START HERE (PalmOS v1.0)
	dlpReadUserInfo,
	
	dlpWriteUserInfo,
	
	dlpReadSysInfo,
	
	dlpGetSysDateTime,
	
	dlpSetSysDateTime,
	
	dlpReadStorageInfo,
	
	dlpReadDBList,
	
	dlpOpenDB,
	
	dlpCreateDB,
	
	dlpCloseDB,
	
	dlpDeleteDB,
	
	dlpReadAppBlock,
	
	dlpWriteAppBlock,

	dlpReadSortBlock,

	dlpWriteSortBlock,

	dlpReadNextModifiedRec,

	dlpReadRecord,

	dlpWriteRecord,

	dlpDeleteRecord,

	dlpReadResource,

	dlpWriteResource,

	dlpDeleteResource,

	dlpCleanUpDatabase,

	dlpResetSyncFlags,

	dlpCallApplication,

	dlpResetSystem,
	
	dlpAddSyncLogEntry,
	
	dlpReadOpenDBInfo,
	
	dlpMoveCategory,
	
	dlpProcessRPC,					// remote procedure calls interface
	
	dlpOpenConduit,				// this command is sent before each conduit is opened
	
	dlpEndOfSync,					// ends the sync session
	
	dlpResetRecordIndex,			// resets "modified record" index
	
	dlpReadRecordIDList,			// LAST 1.0 FUNCTION
	
	
	// DLP 1.1 FUNCTIONS ADDED HERE (PalmOS v2.0 Personal, and Professional)
	dlpReadNextRecInCategory,	// iterate through all records in category
	
	dlpReadNextModifiedRecInCategory,	// iterate through modified records in category
	
	dlpReadAppPreference,		// read application preference
	
	dlpWriteAppPreference,		// write application preference
	
	dlpReadNetSyncInfo,			// read Network HotSync settings
	
	dlpWriteNetSyncInfo,			// write Network HotSync settings

	dlpReadFeature,				// read a feature from Feature Manager
	
	
	// DLP 1.2 FUNCTIONS ADDED HERE (PalmOS v3.0)
	dlpFindDB,						// find a database given creator and type, or name, or
										// get info on currently-open db
	dlpSetDBInfo,					// change database information (name, attributes, version,
										// creation, modification, backup dates, type and creator

	
	
	
	dlpLastFunc						// ***ALWAYS KEEP LAST***

	} DlpFuncID;

#define	dlpLastPilotV10FuncID	dlpReadRecordIDList


// Desktop Link function error codes returned in the response errorCode
// field.
typedef enum DlpRespErrorCode {
	dlpRespErrNone = 0,					// reserve 0 for no error
	dlpRespErrSystem,						// general Pilot system error
	dlpRespErrIllegalReq,				// unknown function ID
	dlpRespErrMemory,						// insufficient dynamic heap memory
	dlpRespErrParam,						// invalid parameter
	dlpRespErrNotFound,					// database, record, or resource not found
	dlpRespErrNoneOpen,					// there are no open databases
	dlpRespErrDatabaseOpen,				// database is open by someone else
	dlpRespErrTooManyOpenDatabases,	// there are too many open databases
	dlpRespErrAlreadyExists,			// DB already exists
	dlpRespErrCantOpen,					// couldn't open DB
	dlpRespErrRecordDeleted,			// record is deleted
	dlpRespErrRecordBusy,				// record is in use by someone else
	dlpRespErrNotSupported,				// the requested operation is not supported
												// on the given database type(record or resource)
	dlpRespErrUnused1,					// was dlpRespErrROMBased
	dlpRespErrReadOnly,					// caller does not have write access(or DB is in ROM)
	dlpRespErrNotEnoughSpace,			// not enough space in data store for record/resource/etc.
	dlpRespErrLimitExceeded,			// size limit exceeded
	dlpRespErrCancelSync,				// cancel the sync
	
	dlpRespErrBadWrapper,				// bad arg wrapper(for debugging)
	dlpRespErrArgMissing,				// required arg not found(for debugging)
	dlpRespErrArgSize,					// invalid argument size
	
	dlpRespErrLastReserved = 127		// last error code reserved for Palm
												// *KEEP THIS ENTRY LAST*
	} DlpRespErrorCode;


// Database flags
// NOTE: THESE *MUST* MATCH THE TOUCHDOWN DB ATTRIBUTES(AT LEAST IN THE FIRST VERSION).
// ANY CHANGES MUST BE REFLECTED IN "READ DB LIST" AND 
#define	dlpDBFlagResDB				0x0001	// resource DB if set; record DB if cleared

#define	dlpDBFlagReadOnly			0x0002	// DB is read only if set; read/write if cleared

#define	dlpDBFlagAppInfoDirty	0x0004	// Set if Application Info block is dirty
														// Optionally supported by an App's conduit

#define	dlpDBFlagBackup			0x0008	//	Set if database should be backed up to PC if
														//	no app-specific synchronization conduit has
														//	been supplied.

#define	dlpDBFlagOKToInstallNewer 	0x0010	// This tells the backup conduit that it's OK
															//  for it to install a newer version of this database
															//  with a different name if the current database is
															//  open. This mechanism is used to update the 
															//  Graffiti Shortcuts database, for example. 

#define	dlpDBFlagResetAfterInstall	0x0020 	// Device requires a reset after this database is 
															// installed.

#define	dlpDBFlagCopyPrevention		0x0040	// This database should not be copied to 
															//  another deviced.

#define	dlpDBFlagOpen					0x8000	// DB is open




// Database record attributes
#define	dlpRecAttrDeleted			0x80	// delete this record next sync
#define	dlpRecAttrDirty			0x40	// archive this record next sync
#define	dlpRecAttrBusy				0x20	// record currently in use
#define	dlpRecAttrSecret			0x10	// "secret" record - password protected
#define	dlpRecAttrArchived		0x08	// archived record


// Date/time will be described in the following format
//			yr(2 bytes), mo(1 byte, 1-12), dy(1 byte, 1-31),
//			hr(1 byte, 0-23), min(1 byte, 0-59), sec(1 byte, 0-59),
//			unused(1 byte).

typedef struct DlpDateTimeType {	// OFFSET
	UInt16	year;						// 0;		year (high, low)
	UInt8		month;					// 2;		month: 1-12
	UInt8		day;						// 3;		day: 1-31
	UInt8		hour;						// 4;		hour: 0-23
	UInt8		minute;					// 5;		minute: 0-59
	UInt8		second;					// 6;		second: 0-59
	UInt8		unused;					// 7;		unused -- set to null!
	} DlpDateTimeType;				// TOTAL: 8 bytes


// Version structure
typedef struct DlpVersionType {
												// OFFSET
	UInt16				wMajor;			// 0;		major version number (0 = ignore)
	UInt16				wMinor;			// 2;		minor version number
												// TOTAL: 4 bytes										
	} DlpVersionType;

 
/************************************************************
 * Request and Response headers.
 *
 * Each DLP request and response data block begins with the
 * corresponding header structure which identifies the function
 * id, argument count, and error code(responses only).
 *************************************************************/

// Request header:
//
typedef struct DlpReqHeaderType {
												// OFFSET
	UInt8					id;				// 0;		request function ID
	UInt8					argc;				// 2;		count of args that follow this header
												// TOTAL: 2 bytes
	} DlpReqHeaderType;

typedef DlpReqHeaderType*		DlpReqHeaderPtr;

typedef struct DlpReqType {
												// OFFSET
	DlpReqHeaderType	header;			// 0;		request header
												// FIXED SIZE: 2 bytes
	UInt8					args[2];			// 2;		request arguments -- var size
	} DlpReqType;

typedef DlpReqType*		DlpReqPtr;
 
// Response header:
//
typedef struct DlpRespHeaderType {
												// OFFSET
	UInt8					id;				// 0;		response function ID
	UInt8					argc;				// 1;		count of arguments that follow this header
	UInt16				errorCode;		// 2;		error code
												// TOTAL: 4 bytes
	} DlpRespHeaderType;

typedef DlpRespHeaderType*		DlpRespHeaderPtr;

typedef struct DlpRespType {
												// OFFSET
	DlpRespHeaderType	header;			// 0;		response header
												// FIXED SIZE: 4 bytes
	UInt8					args[2];			// 4;		response arguments -- var size
	} DlpRespType;
	
typedef DlpRespType*		DlpRespPtr;


// Generic request/response body type(for utility routines)
//
typedef union DlpGenericBodyType {
	UInt8					id;				// request/response id
	DlpReqType			req;				// request body
	DlpRespType			resp;				// response body
	} DlpGenericBodyType;
	
typedef DlpGenericBodyType*		DlpGenericBodyPtr;


// dlpFuncRespFlag is used to form a function response ID from a
// function ID by or'ing it with the function ID.  For example: if
// dlpFuncDeleteResource is the request ID, the correct response ID
// must be (dlpFuncDeleteResource | dlpFuncRespFlag).
//
#define dlpFuncRespFlag				0x80

// dlpFuncIDMask is used to mask out the function ID value
#define dlpFuncIDMask				0x7f

// dlpFirstArgID is the value of the first argument ID to be defined for
// functions.  Values below it are reserved.
//
#define dlpFirstArgID				0x20


/************************************************************
 *
 * Argument headers used to "wrap" request and response arguments
 *
 * IMPORTANT:	ARGUMENT WRAPPERS IN REQUESTS AND RESPONSES MUST
 *					ALWAYS START ON AN EVEN-BYTE BOUNDARY.  The server
 *					implementation expects this to be the case.
 *
 *************************************************************/

// dlpSmallArgFlag is used to identify "small" argument wrappers by
// or'ing it with the argument id in argument header.
//
#define dlpSmallArgFlag			0x080

// dlpShortArgIDMask is used to mask out the argument id value
//
#define dlpShortArgIDMask	0x7F


// dlpLongArgFlag is used to identify "long" argument wrappers by
// or'ing it with the argument id in argument header.
//
#define dlpLongArgFlag			0xC000

// dlpLongArgIDMask is used to mask out the argument id value
//
#define dlpLongArgIDMask		0x3FFF


//-------------------------------------------------------------------------
// Int16 argument wrappers (v1.0-compatible)
//-------------------------------------------------------------------------

// Maximum Int16 argument size which can be "wrapped"
#define dlpMaxTinyArgSize				0x000000FFL
#define dlpMaxSmallArgSize				0x0000FFFFL
#define dlpMaxShortArgSize				dlpMaxSmallArgSize



// Tiny argument header for data sizes up to 255 bytes(optimization)
//
typedef struct DlpTinyArgWrapperType {
												// OFFSET
	UInt8					bID;				// 0;		argument ID
	UInt8					bSize;			// 1;		argument size (does NOT include this arg header)
												// TOTAL: 2 bytes
	} DlpTinyArgWrapperType;
	
typedef struct DlpTinyArgType {
	DlpTinyArgWrapperType	wrapper;	// 0;		argument header
	UInt8							data[2];	// 2;		argument data -- var size
	} DlpTinyArgType;
	

// Small argument header for data sizes above 255 bytes(*may also be used for
// smaller arguments when convenient*)
//
typedef struct DlpSmallArgWrapperType {
												// OFFSET
	UInt8					bID;				// 0;		argument ID
	UInt8					unused;			// 1;		unused(for alignment) -- set to null!
	UInt16					wSize;			// 2;		argument size (does NOT include this arg header)
												// TOTAL: 4 bytes
	} DlpSmallArgWrapperType;

typedef struct DlpSmallArgType {
	DlpSmallArgWrapperType	wrapper;	// 0;		argument header
	UInt8							data[2];	// 4;		argument data -- var size
	} DlpSmallArgType;

// Unions of Int16 argument types
typedef union DlpShortArgWrapperType {
	UInt8							bID;		// arg id
	DlpTinyArgWrapperType	tiny;		// "tiny" arg wrapper
	DlpSmallArgWrapperType	small;	// "tiny" arg wrapper
	} DlpShortArgWrapperType;
typedef DlpShortArgWrapperType*	DlpShortArgWrapperPtr;
	
typedef union DlpShortArgType {
	UInt8							bID;		// arg id
	DlpTinyArgType				tiny;		// "tiny" arg
	DlpSmallArgType			small;	// "small" arg
	} DlpShortArgType;

typedef DlpShortArgType*			DlpShortArgPtr;



//-------------------------------------------------------------------------
// Int32 argument wrapper (v2.0 extension)
//-------------------------------------------------------------------------
// NOTE: Pilot v2.0 will implement the capability to parse long arguments
// but will not originate them.  This will assure backwards compatibility with
// the 1.0 desktop as well as compatibility with the future version of the
// desktop software which may originate the "long" argument wrappers.
//
// Int32 argument wrappers are identified by the dlpLongArgFlag bits set
// in the argument id field.

// Maximum long argument size which can be "wrapped"
#define dlpMaxLongArgSize				0xFFFFFFFFL

typedef struct DlpLongArgWrapperType {
												// OFFSET
	UInt16				wID;				// 0;		argument ID
	UInt32				dwSize;			// 2;		argument size (does NOT include this arg header)
												// TOTAL: 6 bytes
	} DlpLongArgWrapperType;
typedef DlpLongArgWrapperType*		DlpLongArgWrapperPtr;

typedef struct DlpLongArgType {
												// OFFSET
	DlpLongArgWrapperType	wrapper;	// 0;		argument header
	UInt8							data[2];	// 6;		argument data -- var size
	} DlpLongArgType;
typedef DlpLongArgType*	DlpLongArgPtr;


//-------------------------------------------------------------------------
// Unions of all argument and wrapper types
//-------------------------------------------------------------------------

// Union of all argument wrapper types
typedef union DlpGenericArgWrapperType {
	DlpShortArgWrapperType	shortWrap;	// "Int16" arg wrapper(tiny and small)
	DlpLongArgWrapperType	longWrap;	// "long" arg wrapper
	} DlpGenericArgWrapperType;
typedef DlpGenericArgWrapperType*		DlpGenericArgWrapperPtr;


// Union of all argument types
typedef union DlpGenericArgType {
	DlpShortArgType			shortArg;	// "Int16" arg(tiny and small)
	DlpLongArgType				longArg;		// "long" arg
	} DlpGenericArgType;
typedef DlpGenericArgType*			DlpGenericArgPtr;


/********************************************************************
 * Desktop Link Protocol Parameters
 ********************************************************************/

// dlpCmdTimeoutSec -- this is the number of seconds to wait for a command
// to begin coming in before timing out
//
#define dlpCmdTimeoutSec				30



/************************************************************
 * DLP function argument structures
 *************************************************************/


//////////////////////////////////////////////////////////////////////////
// dlpReadUserInfo
//////////////////////////////////////////////////////////////////////////
//		Request arguments: none
//
//		Response arguments:
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory

// Request argument structure:
//
//		none.
	
// Response argument structure:
//
#define dlpReadUserInfoRespArgID		dlpFirstArgID

typedef struct DlpReadUserInfoRespHdrType {
												// OFFSET
	UInt32				userID;			//	0;		user ID number (0 if none)
	UInt32				viewerID;		// 4;		id assigned to viewer by the desktop
	UInt32				lastSyncPC;		// 8;		last sync PC id (0 if none)
	DlpDateTimeType	succSyncDate;	//	12;	last successful sync (year = 0 if none)
	DlpDateTimeType	lastSyncDate;	//	20;	last sync date(year = 0 if none)
	UInt8					userNameLen;	//	28;	length of user name field,
												//			including null (0 = no user name)
	UInt8					passwordLen;	//	29;	length of encrypted password
												//			(0 = no password set)
												// TOTAL: 30 bytes										
	} DlpReadUserInfoRespHdrType;

typedef struct DlpReadUserInfoRespType {
												// OFFSET
	DlpReadUserInfoRespHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 30 bytes										
	UInt8					nameAndPassword[2];	// 30;	user name -- var size
	// User name begins at the nameAndPassword field and is null-terminated.
	// The encrypted password follows the user name and is NOT null-terminated.
	// The encrypted password may contain any byte values(0-255).
	} DlpReadUserInfoRespType;


	
//////////////////////////////////////////////////////////////////////////
//	dlpWriteUserInfo
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//			user id (4 bytes)
//			last sync PC id(4 bytes)
//			user name
//
//		Response arguments: none
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotEnoughSpace,
//			dlpRespErrParam

// Request argument structure:
//
#define dlpWriteUserInfoReqArgID		dlpFirstArgID

#define dlpMaxUserNameSize		41		// max user name size, including null byte

typedef struct DlpWriteUserInfoReqHdrType {
												// OFFSET
	UInt32				userID;			//	0;		user ID number
	UInt32				viewerID;		// 4;		id assigned to viewer by the desktop
	UInt32				lastSyncPC;		// 8;		last sync PC id
	DlpDateTimeType	lastSyncDate;	//	12;	last sync date(year = 0 if none)
	UInt8					modFlags;		// 20;	flags indicating which values are being
												//			modified; see the dlpUserInfoMod...
												//			flags defined below
	UInt8					userNameLen;	//	21;	user name length, including null
												// TOTAL: 22 bytes										
	} DlpWriteUserInfoReqHdrType;

// Flags indicating which values are being changed by the dlpWriteUserInfo
// request.  These flags are used in the modFlags field of DlpWriteUserInfoReqHdrType.
// These flags are additive.
//
#define dlpUserInfoModUserID			0x80	// changing the user id
#define dlpUserInfoModSyncPC			0x40	// changing the last sync PC id
#define dlpUserInfoModSyncDate		0x20	// changing sync date
#define dlpUserInfoModName				0x10	// changing user name
#define dlpUserInfoModViewerID		0x08	// changing the viewer id

typedef struct DlpWriteUserInfoReqType {
												// OFFSET
	DlpWriteUserInfoReqHdrType
							header;			//	0;		fixed-size header
												// FIXED SIZE: 22 bytes										
	UInt8					userName[2];	// 22;	user name -- var size
	// User name begins at the userName field and is null-terminated.
	} DlpWriteUserInfoReqType;

	
// Response argument structure:
//
//		none.


	
//////////////////////////////////////////////////////////////////////////
//	dlpReadSysInfo
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem
//

// Request argument structure:
//
//		none. DLP v1.0 and v1.1

enum {
	// NEW FOR DLP v1.2:
	dlpReadSysInfoReqArgID		= dlpFirstArgID
	};


// dlpReadSysInfoReqArgID request arg structure
//
typedef struct DlpReadSysInfoReqType {
												// OFFSET
	DlpVersionType		dlpVer;			// 0;		DLP version of the caller
												// TOTAL: 4 bytes										
	} DlpReadSysInfoReqType;
	
	
// Response argument structure:
//
// Both response arguments are returned in one reply
enum {
	dlpReadSysInfoRespArgID		= dlpFirstArgID,
	
	// NEW FOR DLP v1.2:
	dlpReadSysInfoVerRespArgID
	};

// dlpReadSysInfoRespArgID response arg structure:
//
typedef struct DlpReadSysInfoRespType {
												// OFFSET
	UInt32				romSWVersion;	// 0;		ROM-based sys software version
	UInt32				localizationID;// 4;		localization ID
	UInt8					unused;			//	8;		unused(for alignment) -- set to null!
	UInt8					prodIDSize;		// 9;		size of productID/model field
	UInt32				prodID;			// 10;	product id (was variable size)
												// TOTAL: 14 bytes
	} DlpReadSysInfoRespType;
	

// dlpReadSysInfoVerRespArgID response arg structure:
//
typedef struct DlpReadSysInfoVerRespType {
												// OFFSET
	DlpVersionType		dlpVer;			// 0;		DLP version of the device
	DlpVersionType		compVer;			// 4;		product compatibility version of the device
	UInt32				dwMaxRecSize;	// 8;		maximum record/resource size that may be allocated on
												//			the device given that sufficient free memory exists
												//			(0xFFFFFFFF = up to available memory)
												// TOTAL: 12 bytes
	} DlpReadSysInfoVerRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpGetSysDateTime
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes: none

// Request argument structure:
//
//		none.
	
// Response argument structure:
//
#define dlpGetSysDateTimeRespArgID		dlpFirstArgID

typedef struct DlpGetSysDateTimeRespType {
												// OFFSET
	DlpDateTimeType	dateTime;		// 0;		system date/time
												// TOTAL: 8 bytes
	} DlpGetSysDateTimeRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpSetSysDateTime
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//			new system date/time
//
//		Response arguments: none
//
//		Possible error codes
//			dlpRespErrParam

// Request argument structure:
//
#define dlpSetSysDateTimeReqArgID		dlpFirstArgID

typedef struct DlpSetSysDateTimeReqType {
												// OFFSET
	DlpDateTimeType	dateTime;		// 0;		new system date/time
												// TOTAL: 8 bytes
	} DlpSetSysDateTimeReqType;

typedef DlpSetSysDateTimeReqType*	DlpSetSysDateTimeReqPtr;
	
// Response argument structure:
//
//		none.


	
//////////////////////////////////////////////////////////////////////////
//	dlpReadStorageInfo
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrNotFound

// Request argument structure:
//
enum {
	dlpReadStorageInfoReqArgID		= dlpFirstArgID
	};

typedef struct DlpReadStorInfoReqType {
												// OFFSET
	UInt8					startCardNo;	// 0;		card number to start at
												//			(0 = first)
	UInt8					unused;			//	1;		unused -- set to null!
												// TOTAL: 2 bytes
	} DlpReadStorInfoReqType;


// Response argument structure:
//
enum {
	dlpReadStorageInfoRespArgID		= dlpFirstArgID,
	dlpReadStorageInfoExRespArgID		// v1.1 extension
	};

//
// dlpReadStorageInfoRespArgID:
//

// Card info structure of variable size
typedef struct DlpCardInfoHdrType {
												// OFFSET
	UInt8					totalSize;		// 0;		total size of this card info
												//			*ROUNDED UP TO EVEN SIZE*
	UInt8					cardNo;			// 1;		card number
	UInt16				cardVersion;	// 2;		card version
	DlpDateTimeType	crDate;			// 4;		creation date/time
	UInt32				romSize;			// 12;	ROM size
	UInt32				ramSize;			// 16;	RAM size
	UInt32				freeRam;			// 20;	total free data store RAM - Fixed in DLP v1.2 to exclude
												//			dynamic heap RAM
	UInt8					cardNameSize;	// 24;	size of card name string
	UInt8					manufNameSize;	// 25;	size of manuf. name string
												// TOTAL: 26 bytes;
	} DlpCardInfoHdrType;

typedef struct DlpCardInfoType {
												// OFFSET
	DlpCardInfoHdrType					//
							header;			// 0;		fixed-size header
												// FIXED SIZE: 26 bytes;
	UInt8					cardNameAndManuf[2];
												// 26;	card name and manuf. text -- var size
	// Card name is the cardNameSize bytes of text at cardNameAndManuf,
	// followed immediately by manufNameSize bytes of manufacturer name.
	} DlpCardInfoType;

	
typedef struct DlpReadStorInfoRespHdrType {
												// OFFSET
	UInt8					lastCardNo;		// 0;		card number of last card retrieved
	UInt8					more;				//	1;		non-zero if there are more cards
	UInt8					unused;			//	2;		unused -- set to null!
	UInt8					actCount;		// 3;		actual count of structures returned
												// TOTAL: 4 bytes
	} DlpReadStorInfoRespHdrType;

typedef struct DlpReadStorInfoRespType {
												// OFFSET
	DlpReadStorInfoRespHdrType			//
							header;			// 0;		fixed-size header
												// FIXED SIZE: 4 bytes
	DlpCardInfoType	cardInfo[1];	// 4;		actCount of card info structures -- var size
	} DlpReadStorInfoRespType;


//
// EXTENDED ARGUMENTS(DL v1.1): dlpReadStorageInfoExRespArgID
//
typedef struct DlpReadStorInfoExRespType {
												// OFFSET
	UInt16				romDBCount;		// 0;		ROM database count
	UInt16				ramDBCount;		// 2;		RAM database count
	UInt32				dwReserved1;	// 4;		RESERVED -- SET TO NULL!
	UInt32				dwReserved2;	// 8;		RESERVED -- SET TO NULL!
	UInt32				dwReserved3;	// 12;	RESERVED -- SET TO NULL!
	UInt32				dwReserved4;	// 16;	RESERVED -- SET TO NULL!
												// TOTAL: 20 bytes
	} DlpReadStorInfoExRespType;
	
	
	
	
//////////////////////////////////////////////////////////////////////////
//	dlpReadDBList
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrNotFound

// Request argument structure:
//
#define dlpReadDBListReqArgID		dlpFirstArgID

typedef struct DlpReadDBListReqType {
												// OFFSET
	UInt8					srchFlags;		// 0;		search flags
	UInt8					cardNo;			// 1;		card number -- 0-based
	UInt16				startIndex;		// 2;		DB index to start at
												//			(0 = from beginning)
												// TOTAL: 4 bytes
	} DlpReadDBListReqType;

#define dlpReadDBListFlagRAM			0x80		// Search for RAM-based
#define dlpReadDBListFlagROM			0x40		// Search for ROM-based
#define dlpReadDBListFlagMultiple	0x20		// OK to return multiple entries (DEFINED FOR DLP v1.2)


// Response argument structure:
//
#define dlpReadDBListRespArgID		dlpFirstArgID

// Database info structure of variable size
typedef struct DlpDBInfoHdrType {
												// OFFSET
	UInt8					totalSize;		// 0;		total size of the DB info (DlpDBInfoHdrType + name)
												//			*ROUNDED UP TO EVEN SIZE*
	UInt8					miscFlags;		//	1;		dlpDbInfoMiscFlag... flags(v1.1) -- set all unused bits to null!
	UInt16				dbFlags;			// 2;		DB flags: dlpDBFlagReadOnly,
												//			dlpDBFlagResDB, dlpDBFlagAppInfoDirty, dlpDBFlagOpen,
												//			dlpDBFlagBackup, etc;
	UInt32				type;				// 4;		database type
	UInt32				creator;			// 8;		database creator
	UInt16				version;			// 12;	database version
	UInt32				modNum;			// 14;	modification number
	DlpDateTimeType	crDate;			// 18;	creation date
	DlpDateTimeType	modDate;			// 26;	latest modification date
	DlpDateTimeType	backupDate;		// 34;	latest backup date
	UInt16				dbIndex;			//	42;	DB index (or dlpDbInfoUnknownDbIndex for dlpFindDB)
												// TOTAL: 44 bytes;
	} DlpDBInfoHdrType;

// Flags for the miscFlags field of DlpDBInfoHdrType
#define dlpDbInfoMiscFlagExcludeFromSync	0x80		// DEFINED FOR DLP v1.1
#define dlpDbInfoMiscFlagRamBased			0x40		// DEFINED FOR DLP v1.2

// Unknown index value for the dbIndex field of DlpDBInfoHdrType
#define dlpDbInfoUnknownDbIndex		0xFFFF


typedef struct DlpDBInfoType {
												// OFFSET
	DlpDBInfoHdrType	header;			// 0;		fixed-size header
												// FIXED SIZE: 44 bytes;
	UInt8					name[2];			// 44;	databse name text -- var size and
												//			null-terminated
	} DlpDBInfoType;

	
typedef struct DlpReadDBListRespHdrType {
												// OFFSET
	UInt16				lastIndex;		// 0;		DB index of last entry retrieved
	UInt8					flags;			// 2;		flags: dlpReadDBListRespFlagMore
	UInt8					actCount;		// 3;		actual count of structures returned
												// TOTAL: 4 bytes
	} DlpReadDBListRespHdrType;

// dlpReadDBListRespFlagMore flag: if set, indicates that there are more
// databases to list -- this enables the server to send the listing
// incrementally, reducing server memory requirements if necessary
#define dlpReadDBListRespFlagMore	0x80
	
typedef struct DlpReadDBListRespType {
												// OFFSET
	DlpReadDBListRespHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 4 bytes
	DlpDBInfoType		dbInfo[1];		// 4;		actCount of DB info structures -- var size
	} DlpReadDBListRespType;
	

//////////////////////////////////////////////////////////////////////////
//	dlpOpenDB
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrTooManyOpenDatabases
//			dlpRespErrCantOpen

// Request argument structure:
//
#define dlpOpenDBReqArgID		dlpFirstArgID

typedef struct DlpOpenDBReqHdrType {
												// OFFSET
	UInt8					cardNo;			// 0;		memory module number
	UInt8					mode;				// 1;		open mode
												// TOTAL: 2 bytes;
	} DlpOpenDBReqHdrType;

#define dlpOpenDBModeRead			0x80
#define dlpOpenDBModeWrite			0x40
#define dlpOpenDBModeExclusive	0x20
#define dlpOpenDBModeShowSecret	0x10


typedef struct DlpOpenDBReqType {
												// OFFSET
	DlpOpenDBReqHdrType					//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 2 bytes;
	UInt8					name[2];			// 2;		databse name text -- var size
												//			zero-terminated
	} DlpOpenDBReqType;

typedef DlpOpenDBReqType*		DlpOpenDBReqPtr;

	
// Response argument structure:
//
#define dlpOpenDBRespArgID		dlpFirstArgID
//
// The response argument is the 1-byte database ID to be passed in
// subsequent read/write requests.

	
	
//////////////////////////////////////////////////////////////////////////
//	dlpCreateDB
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrAlreadyExists,
//			dlpRespErrCantOpen,
//			dlpRespErrNotEnoughSpace,
//			dlpRespErrTooManyOpenDatabases

// Request argument structure:
//
#define dlpCreateDBReqArgID		dlpFirstArgID

typedef struct DlpCreateDBReqHdrType {
												// OFFSET
	UInt32				creator;			// 0;		DB creator
	UInt32				type;				// 4;		DB type
	UInt8					cardNo;			// 8;		memory module number
	UInt8					unused;			//	9;		unused -- set to null
	UInt16				dbFlags;			// 10;	allowed flags: dlpDBFlagResDB,
												//			dlpDBFlagBackup, dlpDBFlagOKToInstallNewer,
												//			dlpDBFlagResetAfterInstall
	UInt16				version;			// 12;	DB version #
												// TOTAL: 14 bytes;
	} DlpCreateDBReqHdrType;

typedef struct DlpCreateDBReqType {
												// OFFSET
	DlpCreateDBReqHdrType				//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 12 bytes;
	UInt8					name[2];			// 14;	DB name text -- var size
												//			zero-terminated
	} DlpCreateDBReqType;

typedef DlpCreateDBReqType*		DlpCreateDBReqPtr;

	
// Response argument structure:
//
#define dlpCreateDBRespArgID		dlpFirstArgID

// The response argument is the 1-byte database ID to be passed in
// subsequent read/write requests.


	
//////////////////////////////////////////////////////////////////////////
//	dlpCloseDB
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrParam,
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrNoneOpen

// Request argument structure:
//
typedef enum {
	dlpCloseDBReqArgID = dlpFirstArgID,				// close a specific database
	dlpCloseDBAllReqArgID,								// close all databases
	dlpCloseDBExReqArgID									// close a specific db and update backup
																// and/or modification dates (PalmOS v3.0)
	} DlpCloseDBReqArgID;

// Argument structure to close a specific database(dlpCloseDBDBIDReqArgID):
//
// The request argument is the 1-byte database ID returned in open/create
// DB responses.
typedef UInt8 DlpCloseDBReqType;

// Argument structure to close all databases(dlpCloseDBReqAllArgID):
//
// This request argument contains no data


// Request type for dlpCloseDBExReqArgID (PalmOS v3.0):
typedef struct DlpCloseDBExReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id to close
	UInt8					bOptFlags;		// 1;		bitfield of dlpCloseDBExOptFlag... flags
												// TOTAL: 2 bytes										
	} DlpCloseDBExReqType;

// Option flags
#define dlpCloseDBExOptFlagUpdateBackupDate	0x80	// Update the backup date after closing
#define dlpCloseDBExOptFlagUpdateModDate		0x40	// Update the modification date after closing


#define dlpCloseDBExOptAllFlags	(dlpCloseDBExOptFlagUpdateBackupDate | dlpCloseDBExOptFlagUpdateModDate)


// Response argument structure:
//
//		none.


	
//////////////////////////////////////////////////////////////////////////
//	dlpDeleteDB
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound,
//			dlpRespErrCantOpen,
//			dlpRespErrDatabaseOpen

// Request argument structure:
//
#define dlpDeleteDBReqArgID		dlpFirstArgID

typedef struct DlpDeleteDBReqHdrType {
												// OFFSET
	UInt8					cardNo;			// 0;		memory module number
	UInt8					unused;			// 1;		unused -- set to null!
												// TOTAL: 2 bytes;
	} DlpDeleteDBReqHdrType;


typedef struct DlpDeleteDBReqType {
												// OFFSET
	DlpDeleteDBReqHdrType				//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 2 bytes;
	UInt8					name[2];			// 2;		databse name text -- var size
												//			zero-terminated
	} DlpDeleteDBReqType;

typedef DlpDeleteDBReqType*		DlpDeleteDBReqPtr;


// Response argument structure:
//
//		none.


//////////////////////////////////////////////////////////////////////////
//	dlpReadOpenDBInfo
//////////////////////////////////////////////////////////////////////////
//		Get information on an open database
//
//		Possible error codes
//			dlpRespErrNoneOpen
//			dlpRespErrParam

// Request argument structure:
//
#define dlpReadOpenDBInfoArgID			dlpFirstArgID

// The request argument is the 1-byte database ID returned in open/create
// DB responses.
	

// Response argument structure:
//
#define dlpReadOpenDBInfoRespArgID		dlpFirstArgID


typedef struct DlpReadOpenDBInfoRespType {
												// OFFSET
	UInt16				numRec;			//	0;		number of records or resources
												// TOTAL: 2 bytes
	} DlpReadOpenDBInfoRespType;

	
//////////////////////////////////////////////////////////////////////////
//	dlpMoveCategory
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrNoneOpen
//			dlpRespErrParam
//			dlpRespErrNotSupported
//			dlpRespErrReadOnly

// Request argument structure:
//
#define dlpMoveCategoryReqArgID			dlpFirstArgID

typedef struct DlpMoveCategoryReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					fromCategory;	//	1;		id of the "from" category
	UInt8					toCategory;		//	2;		id of the "to" category
	UInt8					unused;			//	3;		unused -- set to null!
												// TOTAL: 4 bytes;
	} DlpMoveCategoryReqType;
	

// Response argument structure:
//
//		none.

	
//////////////////////////////////////////////////////////////////////////
//	dlpReadAppBlock
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrNotFound
//			dlpRespErrNoneOpen
//			dlpRespErrParam

// Request argument structure:
//
#define dlpReadBlockReqArgID			dlpFirstArgID

typedef struct DlpReadBlockReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt16				offset;			//	2;		offset into the block
	UInt16				numBytes;		//	4;		number of bytes to read starting
												//			at offset(-1 = to the end)
												// TOTAL: 6 bytes;
	} DlpReadBlockReqType;
	

// Response argument structure:
//
#define dlpReadBlockRespArgID			dlpFirstArgID

typedef struct DlpReadBlockRespHdrType {
												// OFFSET
	UInt16				blockSize;		//	0;		actual block size -- may be greater
												//			than the amount of data returned
												//	TOTAL: 2 bytes
	} DlpReadBlockRespHdrType;

typedef struct DlpReadBlockRespType {
												// OFFSET
	DlpReadBlockRespHdrType				//
							header;			//	0;		fixed size header
												//	FIXED SIZE: 2 bytes
	UInt8					data[2];			// 2;		block data -- var size
	} DlpReadBlockRespType;

	
//////////////////////////////////////////////////////////////////////////
//	dlpWriteAppBlock
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrReadOnly
//			dlpRespErrNotEnoughSpace
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpWriteBlockReqArgID			dlpFirstArgID

typedef struct DlpWriteBlockReqHdrType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt16				blockSize;		//	2;		total block size(0 = free existing block)
												// TOTAL: 4 bytes;
	} DlpWriteBlockReqHdrType;


typedef struct DlpWriteBlockReqType {
												// OFFSET
	DlpWriteBlockReqHdrType				//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 4 bytes;
	UInt8					data[2];			// 4;		block data -- var size
	} DlpWriteBlockReqType;


// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpReadSortBlock
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory
//			dlpRespErrNotFound
//			dlpRespErrNoneOpen

// Request argument structure:
//
// see dlpReadAppBlock


// Response argument structure:
//
// see dlpReadAppBlock


//////////////////////////////////////////////////////////////////////////
//	dlpWriteSortBlock
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrNoneOpen

// Request argument structure:
//
// see dlpWriteAppBlock


// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpReadNextModifiedRec
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			see dlpReadRecord
//

// Request argument structure:
//
#define dlpReadNextModRecReqArgID		dlpFirstArgID
// The request argument is the 1-byte database ID returned in open/create
// DB responses.


// Response argument structure:
//
// Response argument id = dlpReadRecordRespArgID

//	Response argument structure = DlpReadRecordRespType



//////////////////////////////////////////////////////////////////////////
//	dlpResetRecordIndex
//////////////////////////////////////////////////////////////////////////
//	Resets the "next modified record" index to the beginning
//
//		Possible error codes
//			dlpRespErrParam
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpResetRecordIndexReqArgID		dlpFirstArgID

// The request argument is the 1-byte database ID returned in open/create
// DB responses.

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpReadRecord
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrNotSupported,
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrNotFound,
//			dlpRespErrRecordBusy,
//			dlpRespErrNoneOpen

typedef enum {
	dlpReadRecordIdArgID = dlpFirstArgID,
	dlpReadRecordIndexArgID
	} DlpReadRecordReqArgID;

// dlpReadRecordIdArgID request argument structure:
//
typedef struct DlpReadRecordByIDReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt32				recordID;		// 2;		unique record id
	UInt16				offset;			//	6;		offset into the record
	UInt16				numBytes;		//	8;		number of bytes to read starting
												//			at the offset(-1 = "to the end")
												// TOTAL: 10 bytes;
	} DlpReadRecordByIDReqType;

// dlpReadRecordIndexArgID request argument structure:
//
typedef struct DlpReadRecordByIndexReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt16				index;			// 2;		record index
	UInt16				offset;			//	4;		offset into the record
	UInt16				numBytes;		//	6;		number of bytes to read starting
												//			at the offset(-1 = "to the end")
												// TOTAL: 8 bytes;
	} DlpReadRecordByIndexReqType;


// Response argument structure:
//
#define dlpReadRecordRespArgID		dlpFirstArgID

typedef struct DlpReadRecordRespHdrType {
												// OFFSET
	UInt32				recordID;		// 0;		unique record id
	UInt16				index;			//	4;		record index
	UInt16				recSize;			//	6;		total record size in bytes
	UInt8					attributes;		// 8;		record attributes
	UInt8					category;		// 9;		record category index
												// TOTAL: 10 bytes;
	} DlpReadRecordRespHdrType;

typedef struct DlpReadRecordRespType {
												// OFFSET
	DlpReadRecordRespHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 8 bytes;
	UInt8					data[2];			// 8;		record data -- var size
	} DlpReadRecordRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpReadRecordIDList
//////////////////////////////////////////////////////////////////////////
//	Returns a list of unique record id's.  May need to call more than once
// to get the entire list.  dlpRespErrNotFound is returned when "start"
// is out of bounds
//
//		Possible error codes
//			dlpRespErrNotSupported,
//			dlpRespErrParam,
//			dlpRespErrNotFound,
//			dlpRespErrNoneOpen

#define dlpReadRecordIDListReqArgID		dlpFirstArgID

// dlpReadRecordIDListReqArgID request argument structure:
//
typedef struct DlpReadRecordIDListReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					flags;			//	1;		request flags
	UInt16				start;			// 2;		starting record index (0-based)
	UInt16				maxEntries;		//	4;		maximum number of entries, or
												//			0xFFFF to return as many as possible
												// TOTAL: 6 bytes;
	} DlpReadRecordIDListReqType;

// dlpReadRecordIDListFlagSortDB: if set, DL Server will call the creator
// application to resort the database before returning the list.
#define dlpReadRecordIDListFlagSortDB	0x80


// Response argument structure:
//
#define dlpReadRecordIDListRespArgID		dlpFirstArgID

typedef struct DlpReadRecordIDListRespHdrType {
												// OFFSET
	UInt16				numEntries;		// 0;		number of entries returned
												// TOTAL: 2 bytes;
	} DlpReadRecordIDListRespHdrType;

typedef struct DlpReadRecordIDListRespType {
												// OFFSET
	DlpReadRecordIDListRespHdrType	//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 2 bytes;
	UInt32				recID[1];		// 8;		list of record id's -- var size
	} DlpReadRecordIDListRespType;

	

//////////////////////////////////////////////////////////////////////////
//	dlpWriteRecord
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrNotEnoughSpace
//			dlpRespErrNotSupported
//			dlpRespErrReadOnly
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpWriteRecordReqArgID		dlpFirstArgID

// dlpWriteRecordReqArgID -- required
typedef struct DlpWriteRecordReqHdrType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					flags;			//	1;		set unused bits to null!
	UInt32				recordID;		// 2;		unique record id or null
	UInt8					attributes;		// 6;		record attributes -- only
												//			dlpRecAttrSecret is allowed here
												//			v1.1 extension:
												//			dlpRecAttrDeleted, dlpRecAttrArchived and
												//			dlpRecAttrDirty are also allowed.
	UInt8					category;		// 7;		record category
												// TOTAL: 8 bytes;
	} DlpWriteRecordReqHdrType;

#define dlpWriteRecordReqFlagDataIncluded	0x80	// original implementer of destop software always
																// set this bit.  Define it here for compatibility

typedef struct DlpWriteRecordReqType {
												// OFFSET
	DlpWriteRecordReqHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 8 bytes;
	UInt8					data[2];			// 8;		record data -- var size
	} DlpWriteRecordReqType;


// Response argument structure:
//
#define dlpWriteRecordRespArgID		dlpFirstArgID

typedef struct DlpWriteRecordRespType {
												// OFFSET
	UInt32				recordID;		// 0;		record ID
												// TOTAL: 4 bytes
	} DlpWriteRecordRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpDeleteRecord
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrNotSupported
//			dlpRespErrReadOnly
//			dlpRespErrNoneOpen
//

// Request argument structure:
//
#define dlpDeleteRecordReqArgID	dlpFirstArgID

// Argument structure to delete by record ID(dlpDeleteRecordReqIDArgID):
typedef struct DlpDeleteRecordReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					flags;			//	1;		flags (dlpDeleteRecFlagDeleteAll)
	UInt32				recordID;		// 2;		unique record id (see flags)
												// TOTAL: 6 bytes;
	} DlpDeleteRecordReqType;

// dlpDeleteRecFlagDeleteAll: if this flag is set, the reocordID field
// is ignored and all database records will be deleted
#define dlpDeleteRecFlagDeleteAll		0x80

// dlpDeleteRecFlagByCategory: if this flag is set, the least significant byte
// of the reocordID field contains the category id of records to be deleted (PalmOS 2.0)
#define dlpDeleteRecFlagByCategory		0x40

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpReadResource
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrNoneOpen

typedef enum {
	dlpReadResourceIndexArgID = dlpFirstArgID,
	dlpReadResourceTypeArgID
	} DlpReadResourceReqArgID;

// dlpReadResourceIndexArgID request argument structure:
//
typedef struct DlpReadResourceByIndexReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt16				index;			// 2;		resource index
	UInt16				offset;			//	4;		offset into the resource
	UInt16				numBytes;		//	6;		number of bytes to read starting
												//			at the offset(-1 = "to the end")
												// TOTAL: 8 bytes;
	} DlpReadResourceByIndexReqType;

// dlpReadResourceTypeArgID request argument structure:
//
typedef struct DlpReadResourceByTypeReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		unused -- set to null!
	UInt32				type;				// 2;		resource type
	UInt16				id;				// 6;		resource id
	UInt16				offset;			//	8;		offset into the resource
	UInt16				numBytes;		//	10;	number of bytes to read starting
												//			at the offset(-1 = "to the end")
												// TOTAL: 12 bytes;
	} DlpReadResourceByTypeReqType;
	

// Response argument structure:
//
#define dlpReadResourceRespArgID		dlpFirstArgID

typedef struct DlpReadResourceRespHdrType {
												// OFFSET
	UInt32				type;				// 0;		resource type
	UInt16				id;				// 4;		resource id
	UInt16				index;			//	6;		resource index
	UInt16				resSize;			//	8;		total resource size in bytes
												// TOTAL: 10 bytes;
	} DlpReadResourceRespHdrType;

typedef struct DlpReadResourceRespType {
												// OFFSET
	DlpReadResourceRespHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 6 bytes;
	UInt8					resData[2];		// 6;		resource data -- var size
	} DlpReadResourceRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpWriteResource
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotEnoughSpace,
//			dlpRespErrParam,
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpWriteResourceReqArgID		dlpFirstArgID

typedef struct DlpWriteResourceReqHdrType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					unused;			//	1;		inused -- set to null!
	UInt32				type;				// 2;		resource type
	UInt16				id;				// 6;		resource id
	UInt16				resSize;			//	8;		total resource size
												// TOTAL: 10 bytes;
	} DlpWriteResourceReqHdrType;

typedef struct DlpWriteResourceReqType {
												// OFFSET
	DlpWriteResourceReqHdrType			//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 10 bytes;
	UInt8					data[2];			// 10;		resource data -- var size
	} DlpWriteResourceReqType;

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpDeleteResource
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrNotSupported
//			dlpRespErrReadOnly
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpDeleteResourceReqArgID		dlpFirstArgID

typedef struct DlpDeleteResourceReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					flags;			//	1;		flags (dlpDeleteResFlagDeleteAll)
	UInt32				type;				// 2;		resource type
	UInt16				id;				// 6;		resource id
												// TOTAL: 8 bytes;
	} DlpDeleteResourceReqType;

// dlpDeleteResFlagDeleteAll: if set, all resources in the db will be deleted
#define dlpDeleteResFlagDeleteAll	0x80


// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpCleanUpDatabase
//////////////////////////////////////////////////////////////////////////
//		Deletes all records which are marked as archived or deleted in the
//		record database
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrReadOnly,
//			dlpRespErrNotSupported
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpCleanUpDatabaseReqArgID		dlpFirstArgID

// The request argument is the 1-byte database ID returned in open/create
// DB responses.

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpResetSyncFlags
//////////////////////////////////////////////////////////////////////////
//		For record databases, reset all dirty flags.
//		For both record and resource databases, set the last sync time to NOW
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam
//			dlpRespErrReadOnly,
//			dlpRespErrNoneOpen

// Request argument structure:
//
#define dlpResetSyncFlagsReqArgID		dlpFirstArgID

// The request argument is the 1-byte database ID returned in open/create
// DB responses.


// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpCallApplication
//////////////////////////////////////////////////////////////////////////
//		Call an application entry point via an action code
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrNotFound

// Request argument structure:
//
enum	{
	dlpCallApplicationReqArgIDV10 = dlpFirstArgID,	// req id for Pilot v1.0
	dlpCallAppReqArgID										// req id for Pilot v2.0 and later
	};

// dlpCallApplicationReqArgIDV10:
typedef struct DlpCallApplicationReqHdrTypeV10 {
												// OFFSET
	UInt32				creator;			// 0;		app DB creator id
	UInt16				action;			// 4;		action code
	UInt16				paramSize;		// 6;	custom param size
												// TOTAL: 8 bytes
	} DlpCallApplicationReqHdrTypeV10;

typedef struct DlpCallApplicationReqTypeV10 {
												// OFFSET
	DlpCallApplicationReqHdrTypeV10	//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 8 bytes
	UInt8					paramData[2];	// 8;	custom param data -- var size
	} DlpCallApplicationReqTypeV10;


// dlpCallAppReqArgID (Pilot v2.0):
typedef struct DlpCallAppReqHdrType {
												// OFFSET
	UInt32				creator;			// 0;		DB creator id of target executable
	UInt32				type;				// 4;		DB type id of target executable
	UInt16				action;			// 8;		action code
	UInt32				dwParamSize;	// 10;	custom param size in number of bytes
	UInt32				dwReserved1;	// 14;	RESERVED -- set to NULL!!!
	UInt32				dwReserved2;	// 18;	RESERVED -- set to NULL!!!
												// TOTAL: 22 bytes
	} DlpCallAppReqHdrType;

typedef struct DlpCallAppReqType {
												// OFFSET
	DlpCallAppReqHdrType					//
							hdr;				//	0;		fixed-size header
												// FIXED SIZE: 22 bytes
	UInt8					paramData[2];	// 22;	custom param data -- var size
	} DlpCallAppReqType;



// Response argument structure:
//
enum	{
	dlpCallApplicationRespArgIDV10 = dlpFirstArgID,		// resp id for Pilot v1.0
	dlpCallAppRespArgID											// resp id for Pilot v2.0 and later
	};

// dlpCallApplicationRespArgIDV10:
typedef struct DlpCallApplicationRespHdrTypeV10 {
												// OFFSET
	UInt16				action;			// 0;		action code which was called
	UInt16				resultCode;		// 2;		result error code returned by action
	UInt16				resultSize;		// 4;		custom result data size
												// TOTAL: 6 bytes
	} DlpCallApplicationRespHdrTypeV10;

typedef struct DlpCallApplicationRespTypeV10 {
												// OFFSET
	DlpCallApplicationRespHdrTypeV10	//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 6 bytes
	UInt8					resultData[2];	// 6;		custom result data -- var size
	} DlpCallApplicationRespTypeV10;

// dlpCallAppRespArgID:
typedef struct DlpCallAppRespHdrType {
												// OFFSET
	UInt32					dwResultCode;	// 0;		result error code returned by handler
	UInt32					dwResultSize;	// 4;		custom result data size
	UInt32					dwReserved1;	// 8;		RESERVED -- SET TO NULL!!!
	UInt32					dwReserved2;	// 12;	RESERVED -- SET TO NULL!!!
												// TOTAL: 16 bytes
	} DlpCallAppRespHdrType;

typedef struct DlpCallAppRespType {
												// OFFSET
	DlpCallAppRespHdrType				//
							hdr;				//	0;		fixed-size header
												// FIXED SIZE: 16 bytes
	UInt8					resultData[2];	// 16;		custom result data -- var size
	} DlpCallAppRespType;



//////////////////////////////////////////////////////////////////////////
//	dlpResetSystem
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem

// Request argument structure:
//
//		none.

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
// dlpAddSyncLogEntry
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotEnoughSpace,
//			dlpRespErrLimitExceeded,
//			dlpRespErrParam

// Request argument structure:
//
#define dlpAddSyncLogEntryReqArgID		dlpFirstArgID

typedef struct DlpAddSyncLogEntryReqType {
												// OFFSET
	UInt8					text[2];			// 0;		entry text -- var size and
												//			null-terminated
	} DlpAddSyncLogEntryReqType;

// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
// dlpProcessRPC
//////////////////////////////////////////////////////////////////////////
//		Remote Procedure Call interface
//
//		Request arguments:
//			RPC command block
//
//		Response arguments:
//			RPC reply block
//
//		Possible error codes
//			0 on success; otherwise error code from the TouchDown
//			RPC executor
//
// NOTE: this is a low-level system command which does not use arg wrappers.

// Request argument structure:
//
// Block of RPC command data (no arg wrapper)

// Response argument structure:
//
// Block of RPC reply data of same length as command block(no arg wrapper)

	

//////////////////////////////////////////////////////////////////////////
// dlpOpenConduit
//////////////////////////////////////////////////////////////////////////
//		This command is sent before each conduit is opened by the desktop.
//		If the viewer has a cancel pending, it will return dlpRespErrCancelSync
//		in the response header's errorCode field.
//
//		Request arguments:	none.
//
//		Response arguments:	none.
//
//		Possible error codes
//			dlpRespErrCancelSync

// Request argument structure:
//
//		none.

// Response argument structure:
//
//		none.


	
//////////////////////////////////////////////////////////////////////////
// dlpEndOfSync
//////////////////////////////////////////////////////////////////////////
//		This command is sent by the desktop to end the sync.
//
//		Request arguments:	termination code: 0 = normal termination;
//									otherwise the client is aborting the sync
//
//		Possible error codes
//			0

// Request argument structure:
//
#define dlpEndOfSyncReqArgID		dlpFirstArgID

typedef enum DlpSyncTermCode {
	dlpTermCodeNormal = 0,				// normal termination
	dlpTermCodeOutOfMemory,				// termination due to low memory on TD
	dlpTermCodeUserCan,					// user cancelled from desktop
	dlpTermCodeOther,						// catch-all abnormal termination code
	dlpTermCodeIncompatibleProducts	// incompatibility between desktop and handheld hotsync products
	} DlpSyncTermCode;
	
	
typedef struct DlpEndOfSyncReqType {
												// OFFSET
	UInt16				termCode;		// 0;		termination code
												// TOTAL: 2 bytes
	} DlpEndOfSyncReqType;


// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
//	dlpReadNextRecInCategory
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			see dlpReadRecord

#define dlpReadNextRecInCategoryReqArgID	dlpFirstArgID

// dlpReadNextRecInCategoryReqArgID request argument structure:
//
typedef struct DlpReadNextRecInCategoryReqType {
												// OFFSET
	UInt8					dbID;				//	0;		database id
	UInt8					category;		//	1;		category id
												// TOTAL: 2 bytes;
	} DlpReadNextRecInCategoryReqType;


// Response argument structure:
//
// Response argument id = dlpReadRecordRespArgID

//	Response argument structure = DlpReadRecordRespType



//////////////////////////////////////////////////////////////////////////
//	dlpReadNextModifiedRecInCategory
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			see dlpReadNextRecInCategory

// Request argument structure:
//
// same as dlpReadNextRecInCategory

// Response argument structure:
//
// same as dlpReadNextRecInCategory



//////////////////////////////////////////////////////////////////////////
//	dlpReadAppPreference
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory,
//			dlpRespErrParam,
//			dlpRespErrNotFound,

#define dlpReadAppPreferenceReqArgID	dlpFirstArgID

// dlpReadAppPreferenceReqArgID request argument structure:
//
typedef struct DlpReadAppPreferenceReqType {
												// OFFSET
	UInt32				creator;			//	0;		application creator type
	UInt16				id;				// 4;		preference id
	UInt16				reqBytes;		//	6;		max. number of preference bytes requested;
												//			pass 0xFFFF for actual size
	UInt8					flags;			// 8;		command flags: dlpAppPrefReqFlagBackedUp - if set, use backed-up pref db
	UInt8					unused;			// 9;		reserved/padding -- set to NUL!
												// TOTAL: 10 bytes;
	} DlpReadAppPreferenceReqType;

#define dlpReadAppPrefActualSize		0xFFFF
#define dlpAppPrefReqFlagBackedUp	0x80

// Response argument structure:
//
#define dlpReadAppPreferenceRespArgID		dlpFirstArgID

typedef struct DlpReadAppPreferenceRespHdrType {
												// OFFSET
	UInt16				version;			// 0;		version number of the application
	UInt16				actualSize;		// 2;		actual preference data size
	UInt16				retBytes;		// 4;		number of preference bytes returned
												// TOTAL: 6 bytes
	} DlpReadAppPreferenceRespHdrType;

typedef struct DlpReadAppPreferenceRespType {
												// OFFSET
	DlpReadAppPreferenceRespHdrType	//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 6 bytes
	UInt8					data[2];			// 6;		custom result data -- var size
	} DlpReadAppPreferenceRespType;

	
//////////////////////////////////////////////////////////////////////////
//	dlpWriteAppPreference
//////////////////////////////////////////////////////////////////////////
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotEnoughSpace

// Request argument structure:
//
#define dlpWriteAppPreferenceReqArgID		dlpFirstArgID

typedef struct DlpWriteAppPreferenceReqHdrType {
												// OFFSET
	UInt32				creator;			//	0;		application creator type
	UInt16				id;				// 4;		preference id
	UInt16				version;			// 6;		version number of the application
	UInt16				prefSize;		// 8;		preference size(in number of bytes)
	UInt8					flags;			// 10;	command flags: dlpAppPrefReqFlagBackedUp - if set, use backed-up pref db
	UInt8					unused;			// 11;	reserved/padding -- set to NUL!
												// TOTAL: 12 bytes;
	} DlpWriteAppPreferenceReqHdrType;

typedef struct DlpWriteAppPreferenceReqType {
												// OFFSET
	DlpWriteAppPreferenceReqHdrType	//
							header;			//	0;		fixed-size header
												// FIXED SIZE: 12 bytes;
	UInt8					data[2];			// 12;	record data -- var size
	} DlpWriteAppPreferenceReqType;


// Response argument structure:
//
// none.



//////////////////////////////////////////////////////////////////////////
// dlpReadNetSyncInfo
//////////////////////////////////////////////////////////////////////////
//		Request arguments: none
//
//		Response arguments:
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrMemory

// Request argument structure:
//
//		none.
	
// Response argument structure:
//
#define dlpReadNetSyncInfoRespArgID		dlpFirstArgID

typedef struct DlpReadNetSyncInfoRespHdrType {
												// OFFSET
	UInt8					lanSyncOn;		//	0;		non-zero if Lan Sync is enabled
	UInt8					bReserved1;		// 1;		reserved -- SET TO NULL!
	UInt32				dwReserved1;	// 2;		reserved -- SET TO NULL!
	UInt32				dwReserved2;	// 6;		reserved -- SET TO NULL!
	UInt32				dwReserved3;	// 10;	reserved -- SET TO NULL!
	UInt32				dwReserved4;	// 14;	reserved -- SET TO NULL!
	UInt16				syncPCNameSize;//	18;	length of sync PC host name,
												//			including null (0 = no host name)
	UInt16				syncPCAddrSize;//	20;	length of sync PC address,
												//			including null (0 = no address)
	UInt16				syncPCMaskSize;//	22;	length of sync PC subnet mask,
												//			including null (0 = no mask)
												// TOTAL: 24 bytes										
	} DlpReadNetSyncInfoRespHdrType;

typedef struct DlpReadNetSyncInfoRespType {
												// OFFSET
	DlpReadNetSyncInfoRespHdrType		//
							hdr;				//	0;		fixed-size header
												// FIXED SIZE: 24 bytes										
	UInt8					syncAddr[2];	// 24;	sync IP address/host name -- var size,
												//			null-terminated
	} DlpReadNetSyncInfoRespType;


	
//////////////////////////////////////////////////////////////////////////
//	dlpWriteNetSyncInfo
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//
//		Response arguments: none
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotEnoughSpace,
//			dlpRespErrParam

// Request argument structure:
//
#define dlpWriteNetSyncInfoReqArgID		dlpFirstArgID

#define dlpMaxHostAddrLength	255	// maximum PC host name length, not including NULL

typedef struct DlpWriteNetSyncInfoReqHdrType {
												// OFFSET
	UInt8					modFlags;		// 0;		flags indicating which values are being
												//			modified; see the dlpNetSyncInfoMod...
												//			flags defined below
	UInt8					lanSyncOn;		//	1;		non-zero if Lan Sync is enabled
	UInt32				dwReserved1;	// 2;		reserved -- SET TO NULL!
	UInt32				dwReserved2;	// 6;		reserved -- SET TO NULL!
	UInt32				dwReserved3;	// 10;	reserved -- SET TO NULL!
	UInt32				dwReserved4;	// 14;	reserved -- SET TO NULL!
	UInt16				syncPCNameSize;//	18;	length of sync PC host name,
												//			including null (0 = no address/host name)
	UInt16				syncPCAddrSize;//	20;	length of sync PC address,
												//			including null (0 = no address)
	UInt16				syncPCMaskSize;//	22;	length of sync PC subnet mask,
												//			including null (0 = no mask)
												// TOTAL: 24 bytes										
	} DlpWriteNetSyncInfoReqHdrType;

// Flags indicating which values are being changed by the dlpWriteNetSyncInfo
// request.  These flags are used in the modFlags field of DlpWriteNetSyncInfoReqHdrType.
// These flags are additive.
//
#define dlpNetSyncInfoModLanSyncOn	0x80	// changing the "lan sync on" setting
#define dlpNetSyncInfoModSyncPCName	0x40	// changing the sync PC host name
#define dlpNetSyncInfoModSyncPCAddr	0x20	// changing the sync PC address
#define dlpNetSyncInfoModSyncPCMask	0x10	// changing the sync PC subnet mask

typedef struct DlpWriteNetSyncInfoReqType {
												// OFFSET
	DlpWriteNetSyncInfoReqHdrType
							hdr;				//	0;		fixed-size header
												// FIXED SIZE: 24 bytes										
	UInt8					syncAddr[2];	// 24;	sync IP address/host name -- var size,
												//			null-terminated
	} DlpWriteNetSyncInfoReqType;

	
// Response argument structure:
//
//		none.



//////////////////////////////////////////////////////////////////////////
// dlpReadFeature
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//
//		Response arguments:
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotFound,
//			dlpRespErrParam

// Request argument structure:
//
#define dlpReadFeatureReqArgID		dlpFirstArgID

typedef struct DlpReadFeatureReqType {
												// OFFSET
	UInt32				dwFtrCreator;	// 0;		feature creator
	UInt16				wFtrNum;			// 4;		feature number
												// TOTAL: 6 bytes										
	} DlpReadFeatureReqType;
	
	
// Response argument structure:
//
#define dlpReadFeatureRespArgID		dlpFirstArgID

typedef struct DlpReadFeatureRespType {
												// OFFSET
	UInt32				dwFeature;		//	0;		feature value
												// TOTAL: 4 bytes
	} DlpReadFeatureRespType;



//////////////////////////////////////////////////////////////////////////
// dlpFindDB
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//
//		Response arguments:
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrNotFound,
//			dlpRespErrParam

// Request argument structure:
//

// dlpFindDBByNameReqArgID, dlpFindDBByTypeCreatorReqArgID and dlpFindDBByOpenHandleReqArgID
// are mutually exclusive
enum	{
	dlpFindDBByNameReqArgID = dlpFirstArgID,		// req id for card + name based search
	dlpFindDBByOpenHandleReqArgID,					// req id for search given an open db handle 
	dlpFindDBByTypeCreatorReqArgID					// req id for type + creator based iterative search
	};

// Option flags
#define dlpFindDBOptFlagGetAttributes	0x80		// get database attributes -- this is
																// an option to allow find operations to skip
																// returning this data as a performance optimization

#define dlpFindDBOptFlagGetSize			0x40		// get record count and data size also -- this is
																// an option because the operation can take a long
																// time, which we would rather avoid if it is not needed
																
#define dlpFindDBOptFlagGetMaxRecSize	0x20		// get max rec/resource size -- this is
																// an option because the operation can take a long
																// time, which we would rather avoid if it is not needed
																// (dlpFindDBOptFlagGetMaxRecSize is only supported for
																// dlpFindDBByOpenHandleReqArgID)

// Request type for dlpdlpFindDBByNameReqArgID:
typedef struct DlpFindDBByNameReqHdrType {
												// OFFSET
	UInt8					bOptFlags;		// 0;		bitfield of dlpFindDBOptFlag... flags
	UInt8					bCardNo;			// 2;		card number to search
												// TOTAL: 4 bytes										
	} DlpFindDBByNameReqHdrType;

typedef struct DlpFindDBByNameReqType {
												// OFFSET
	DlpFindDBByNameReqHdrType			//
							header;			// 0;		fixed size header
												// FIXED SIZE: 4 bytes
	UInt8					name[2];			// variable size -- zero-terminated database name string
	} DlpFindDBByNameReqType;


// Request type for dlpFindDBByOpenHandleReqArgID:
typedef struct DlpFindDBByOpenHandleReqType {
												// OFFSET
	UInt8					bOptFlags;		// 0;		bitfield of dlpFindDBOptFlag... flags
	UInt8					bDbID;			// 1;		database id returned by dlpOpenDB or dlpCreateDB
												// TOTAL: 2 bytes										
	} DlpFindDBByOpenHandleReqType;


// Request type for dlpFindDBByTypeCreatorReqArgID:
typedef struct DlpFindDBByTypeCreatorReqType {
												// OFFSET
	UInt8					bOptFlags;		// 0;		bitfield of dlpFindDBOptFlag... flags
	UInt8					bSrchFlags;		// 1;		bitfield of dlpFindDBSrchFlag... flags
	UInt32				dwType;			// 2;		db type id (zero = wildcard)
	UInt32				dwCreator;		// 6;		db creator id (zero = wildcard)
												// TOTAL: 10 bytes
	} DlpFindDBByTypeCreatorReqType;

#define dlpFindDBSrchFlagNewSearch		0x80			// set to beging a new search
#define dlpFindDBSrchFlagOnlyLatest		0x40			// set to search for the latest version

	
	
// Response argument structures for dlpFindDBByNameReqArgID, dlpFindDBByOpenHandleReqArgID and
// dlpFindDBByTypeCreatorReqArgID (if found):
//
enum	{
	dlpFindDBBasicRespArgID = dlpFirstArgID,		// resp arg id for basic info
																// (if dlpFindDBOptFlagGetAttributes is set)
	dlpFindDBSizeRespArgID								// resp arg id for size info
																// (if dlpFindDBOptFlagGetSize or dlpFindDBOptFlagGetMaxRecSize
																// are set)
	};


// dlpFindDBBasicRespArgID (returned only if dlpFindDBOptFlagGetAttributes is set):

typedef struct DlpFindDBBasicRespHdrType {
												// OFFSET
	UInt8					bCardNo;			// 0;		card number of database
	UInt8					bReserved;		// 1;		RESERVED -- SET TO NULL
	UInt32				dwLocalID;		// 2;		local id of the database (for internal use)
	UInt32				dwOpenRef;		// 6;		db open ref of the database if it is currently opened
												//			by the caller; zero otherwise (for internal use) can
												//			change after read record list
	DlpDBInfoHdrType	info;				//10;		database info (creator, type, flags, etc.) MUST BE LAST FIELD
												// TOTAL: 54 bytes
	} DlpFindDBBasicRespHdrType;

typedef struct DlpFindDBBasicRespType {
												// OFFSET
	DlpFindDBBasicRespHdrType			//
							header;			// 0;		fixed-size header
												// FIXED SIZE: 54 bytes
	UInt8					name[2];			// variable size -- zero-terminated database name string
	} DlpFindDBBasicRespType;



// dlpFindDBSizeRespArgID (returned only if dlpFindDBOptFlagGetSize or dlpFindDBOptFlagGetMaxRecSize is set):

typedef struct DlpFindDBSizeRespType {
												// OFFSET
	
	// Returned if dlpFindDBOptFlagGetSize is set for all queries:
	// (otherwise, fields are set to zero)
	UInt32				dwNumRecords;	// 0;		record/resource count
	UInt32				dwTotalBytes;	// 4;		total bytes used by db
	UInt32				dwDataBytes;	// 8;		bytes used for data
	
	// Returned if dlpFindDBOptFlagGetSize is set for dlpFindDBByOpenHandleReqArgID only:
	// (otherwise, fields are set to zero)
	UInt32				dwAppBlkSize;	//12;		size of app info block size (for
												//			dlpFindDBByOpenHandleReqArgID only)
	UInt32				dwSortBlkSize;	//16;		size of sort info block size(for
												//			dlpFindDBByOpenHandleReqArgID only)
												//
	// Returned if dlpFindDBOptFlagGetMaxRecSize is set for dlpFindDBByOpenHandleReqArgID only:
	// (otherwise, field is set to zero)
	UInt32				dwMaxRecSize;	//20;		size of largest record or resource in the database (for
												//			dlpFindDBByOpenHandleReqArgID + dlpFindDBOptFlagGetMaxRecSize only)
												//	TOTAL: 24 bytes
	} DlpFindDBSizeRespType;




//////////////////////////////////////////////////////////////////////////
// dlpSetDBInfo
//////////////////////////////////////////////////////////////////////////
//		Request arguments:
//
//		Response arguments:
//
//		Possible error codes
//			dlpRespErrSystem,
//			dlpRespErrParam,
//			dlpRespErrNotFound
//			dlpRespErrNotEnoughSpace
//			dlpRespErrNotSupported
//			dlpRespErrReadOnly
//			dlpRespErrNoneOpen

// Request argument structure:
//

enum	{
	dlpSetDBInfoReqArgID = dlpFirstArgID
	};


typedef struct DlpSetDBInfoReqHdrType {
												// OFFSET
	UInt8					dbID;				// 0;		database id returned by dlpOpenDB or dlpCreateDB
	UInt8					bReserved;		// 1;		RESERVED -- SET TO NULL
	UInt16				wClrDbFlags;	// 2;		flags to clear; allowed DB flags: dlpDBFlagAppInfoDirty,
												//			dlpDBFlagBackup, dlpDBFlagOKToInstallNewer,
												//			dlpDBFlagResetAfterInstall, dlpDBFlagCopyPrevention;
												//			0 = don't change
	UInt16				wSetDbFlags;	// 4;		flags to set; allowed DB flags: dlpDBFlagAppInfoDirty,
												//			dlpDBFlagBackup, dlpDBFlagOKToInstallNewer,
												//			dlpDBFlagResetAfterInstall, dlpDBFlagCopyPrevention;
												//			0 = don't change
	UInt16				wDbVersion;		// 6;		database version; dlpSetDBInfoNoVerChange = don't change
	DlpDateTimeType	crDate;			// 8;		creation date; zero year = don't change
	DlpDateTimeType	modDate;			//16;		modification date; zero year = don't change
	DlpDateTimeType	bckUpDate;		//24;		backup date; zero year = don't change
	UInt32				dwType;			//32;		database type id; zero = don't change
	UInt32				dwCreator;		//36;		database creator id; zero = don't change
												// TOTAL: 40 bytes										
	} DlpSetDBInfoReqHdrType;

#define dlpSetDBInfoNoVerChange		0xFFFF

typedef struct DlpSetDBInfoReqType {
												// OFFSET
	DlpSetDBInfoReqHdrType				//
							header;			// 0;		fixed size header
												// FIXED SIZE: 40 bytes
	UInt8					name[2];			// variable size -- zero-terminated database name string
	} DlpSetDBInfoReqType;


// Response argument structure:
//
//		none.



/************************************************************
 * Macros
 *************************************************************/


#endif // __DLCOMMON_H__