PageRenderTime 28ms CodeModel.GetById 15ms app.highlight 11ms RepoModel.GetById 0ms app.codeStats 0ms

/packages/palmunits/src/sysutil.pp

https://github.com/slibre/freepascal
Puppet | 92 lines | 65 code | 27 blank | 0 comment | 1 complexity | d960494bc72308d8d94ff761b457677c MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
 1{$MACRO ON}
 2
 3{$define Rsc := }
 4(******************************************************************************
 5 *
 6 * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
 7 * All rights reserved.
 8 *
 9 * File: SysUtils.h
10 *
11 * Release: Palm OS SDK 4.0 (63220)
12 *
13 * Description:
14 *   These are miscellaneous routines.
15 *
16 * History:
17 *    April 27, 1995 Created by Roger Flores
18 *
19 *****************************************************************************)
20
21unit sysutil;
22
23interface
24
25uses palmos, coretraps;
26
27//typedef Int16 _comparF (const void *, const void *, Int16 other);
28type
29  _comparF = function(p1, p2: Pointer; other: Int32): Int16;
30  CmpFuncPtr = _comparF;
31
32
33  _searchF = function(const searchData, arrayData: Pointer; other: Int32): Int16;
34  SearchFuncPtr = _searchF;
35
36// For backwards compatibility
37//const
38//  GremlinIsOn = hostSelectorGremlinIsRunning;
39
40(************************************************************
41 * Constants
42 *************************************************************)
43
44const
45  sysRandomMax = $7FFF; // Max value returned from SysRandom()
46
47(************************************************************
48 * Macros
49 *************************************************************)
50
51// Abs(a) (((a) >= 0) ? (a) : -(a))
52
53(************************************************************
54 * procedures
55 *************************************************************)
56
57function SysBinarySearch(const baseP: Pointer; numOfElements, width: Int16;
58                         searchF: SearchFuncPtr; const searchData: Pointer;
59                         other: Int32; var position: Int32; findFirst: Boolean): Boolean; syscall sysTrapSysBinarySearch;
60
61procedure SysInsertionSort(baseP: Pointer; numOfElements, width: Int16;
62                           comparF: CmpFuncPtr; other: Int32); syscall sysTrapSysInsertionSort;
63
64procedure SysQSort(baseP: Pointer; numOfElements, width: Int16;
65                   comparF: CmpFuncPtr; other: Int32); syscall sysTrapSysQSort;
66
67procedure SysCopyStringResource(string_: PChar; theID: Int16); syscall sysTrapSysCopyStringResource;
68
69function SysFormPointerArrayToStrings(c: PChar; stringCount: Int16): MemHandle; syscall sysTrapSysFormPointerArrayToStrings;
70
71
72// Return a random number ranging from 0 to sysRandomMax.
73// Normally, 0 is passed unless you want to start with a new seed.
74function SysRandom(newSeed: Int32): Int16; syscall sysTrapSysRandom;
75
76
77function SysStringByIndex(resID, index: UInt16; strP: PChar; maxLen: UInt16): PChar; syscall sysTrapSysStringByIndex;
78
79function SysErrString(err: Err; strP: PChar; maxLen: UInt16): PChar; syscall sysTrapSysErrString;
80
81// This function is not to be called directly.  Instead, use the various Emu* calls
82// in EmuTraps.h because they work for Poser, the device, and the simulator, and
83// they are safer because of the type checking.
84//!!!function HostControl(selector: HostControlTrapNumber, ...): UInt32; syscall sysTrapHostControl;
85
86// For backwards compatibility
87//const
88//  SysGremlins = HostControl;
89
90implementation
91
92end.