/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

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