summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/palmunits/src/exglib.pp
blob: aa90086322572e47158c71be6572aec878375ec5 (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
{$MACRO ON}

(******************************************************************************
 *
 * Copyright (c) 1997-2000 Palm, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: ExgLib.h
 *
 * Release: Palm OS SDK 4.0 (63220)
 *
 * Description:
 *    Include file the Exchange Library interface. The Exchange Library is a
 *    generic interface to any number of librarys. Any Exchange Library
 *    MUST have entrypoint traps in exactly the order listed here.
 *    The System Exchange manager functions call these functions when
 *    applications make calls to the Exchange manager. Applications will
 *    usually not make direct calls to this API.
 *
 * History:
 *    5/23/97 Created by Gavin Peacock
 *
 *****************************************************************************)

unit exglib;

interface

uses  palmos, libtraps, exgmgr;

// special exchange mgr event key
const
  exgIntDataChr = $01ff;

//-----------------------------------------------------------------------------
//  Obx library call ID's. Each library call gets the trap number:
//   exgTrapXXXX which serves as an index into the library's dispatch table.
//   The constant sysLibTrapCustom is the first available trap number after
//   the system predefined library traps Open,Close,Sleep & Wake.
//
// WARNING!!! This order of these traps MUST match the order of the dispatch
//  table in and Exchange library!!!
//-----------------------------------------------------------------------------

type
  ExgLibTrapNumberEnum = Enum;

const
  exgLibTrapHandleEvent = sysLibTrapCustom;
  exgLibTrapConnect = Succ(exgLibTrapHandleEvent);
  exgLibTrapAccept = Succ(exgLibTrapConnect);
  exgLibTrapDisconnect = Succ(exgLibTrapAccept);
  exgLibTrapPut = Succ(exgLibTrapDisconnect);
  exgLibTrapGet = Succ(exgLibTrapPut);
  exgLibTrapSend = Succ(exgLibTrapGet);
  exgLibTrapReceive = Succ(exgLibTrapSend);
  exgLibTrapControl = Succ(exgLibTrapReceive);
  exgLibTrapRequest = Succ(exgLibTrapControl);
  exgLibTrapReserved1 = Succ(exgLibTrapRequest);
  exgLibTrapReserved2 = Succ(exgLibTrapReserved1);
  exgLibTrapReserved3 = Succ(exgLibTrapReserved2);
  exgLibTrapReserved4 = Succ(exgLibTrapReserved3);
  exgLibTrapReserved5 = Succ(exgLibTrapReserved4);
  exgLibTrapReserved6 = Succ(exgLibTrapReserved5);
  exgLibTrapReserved7 = Succ(exgLibTrapReserved6);
  exgLibTrapReserved8 = Succ(exgLibTrapReserved7);
  exgLibTrapReserved9 = Succ(exgLibTrapReserved8);
  exgLibTrapReserved10 = Succ(exgLibTrapReserved9);
  exgLibTrapLast = Succ(exgLibTrapReserved10);

(************************************************************
 * Net Library procedures.
 *************************************************************)

//--------------------------------------------------
// Library initialization, shutdown, sleep and wake
//--------------------------------------------------
// Open the library - enable server for receiving data.
function ExgLibOpen(libRefnum: UInt16): Err; syscall sysLibTrapOpen;

function ExgLibClose(libRefnum: UInt16): Err; syscall sysLibTrapClose;

function ExgLibSleep(libRefnum: UInt16): Err; syscall sysLibTrapSleep;

function ExgLibWake(libRefnum: UInt16): Err; syscall sysLibTrapWake;

//  MemHandle events that this library needs. This will be called by
//  sysHandle event when certain low level events are triggered.
function ExgLibHandleEvent(libRefnum: UInt16; eventP: Pointer): Boolean; syscall exgLibTrapHandleEvent;

//  Establish a new connection
function ExgLibConnect(libRefNum: UInt16; exgSocketP: ExgSocketPtr): Err; syscall exgLibTrapConnect;

// Accept a connection request from remote end
function ExgLibAccept(libRefnum: UInt16; exgSocketP: ExgSocketPtr): Err; syscall exgLibTrapAccept;

// Disconnect
function ExgLibDisconnect(libRefnum: UInt16; exgSocketP: ExgSocketPtr; error: Err): Err; syscall exgLibTrapDisconnect;

// Initiate a Put command. This passes the name and other information about
// an object to be sent
function ExgLibPut(libRefnum: UInt16; exgSocketP: ExgSocketPtr): Err; syscall exgLibTrapPut;

// Initiate a Get command. This requests an object from the remote end.
function ExgLibGet(libRefNum: UInt16; exgSocketP: ExgSocketPtr): Err; syscall exgLibTrapGet;

// Send data to remote end - called after a Put command
function ExgLibSend(libRefNum: UInt16; exgSocketP: ExgSocketPtr; const bufP: Pointer; const bufLen: UInt32; var errP: Err): UInt32; syscall exgLibTrapSend;

// Receive data from remote end -- called after Accept
function ExgLibReceive(libRefNum: UInt16; exgSocketP: ExgSocketPtr; bufP: Pointer; const bufSize: UInt32; var errP: Err): UInt32; syscall exgLibTrapReceive;

// Send various option commands to the Exg library
function ExgLibControl(libRefNum: UInt16; op: UInt16; valueP: Pointer; var valueLenP: UInt16): Err; syscall exgLibTrapControl;

// Tell the Exg library to check for incoming data
function ExgLibRequest(libRefNum: UInt16; socketP: ExgSocketPtr): Err; syscall exgLibTrapRequest;

implementation

end.