nonvolatile.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Added the defines use_amiga_smartlink and
  15. use_auto_openlib. Implemented autoopening
  16. of the library.
  17. 14 Jan 2003.
  18. Update for Amigaos 3.9
  19. Changed startcode for unit.
  20. 09 Feb 2003.
  21. [email protected] Nils Sjoholm
  22. }
  23. {$PACKRECORDS 2}
  24. UNIT nonvolatile;
  25. INTERFACE
  26. USES exec;
  27. Type
  28. pNVInfo = ^tNVInfo;
  29. tNVInfo = record
  30. nvi_MaxStorage,
  31. nvi_FreeStorage : ULONG;
  32. end;
  33. {***************************************************************************}
  34. pNVEntry = ^tNVEntry;
  35. tNVEntry = record
  36. nve_Node : tMinNode;
  37. nve_Name : STRPTR;
  38. nve_Size,
  39. nve_Protection : ULONG;
  40. end;
  41. const
  42. { bit definitions for mask in SetNVProtection(). Also used for
  43. * NVEntry.nve_Protection.
  44. }
  45. NVEB_DELETE = 0 ;
  46. NVEB_APPNAME = 31;
  47. NVEF_DELETE = 1;
  48. NVEF_APPNAME = -2147483648;
  49. {***************************************************************************}
  50. { errors from StoreNV() }
  51. NVERR_BADNAME = 1;
  52. NVERR_WRITEPROT = 2;
  53. NVERR_FAIL = 3;
  54. NVERR_FATAL = 4;
  55. { --- functions in V40 or higher (Release 3.1) --- }
  56. VAR NVBase : pLibrary = nil;
  57. const
  58. NONVOLATILENAME : PChar = 'nonvolatile.library';
  59. FUNCTION DeleteNV(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; killRequesters : LONGINT location 'd1') : LongBool; syscall NVBase 048;
  60. PROCEDURE FreeNVData(data : POINTER location 'a0'); syscall NVBase 036;
  61. FUNCTION GetCopyNV(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; killRequesters : LONGINT location 'd1') : POINTER; syscall NVBase 030;
  62. FUNCTION GetNVInfo(killRequesters : LONGINT location 'd1') : pNVInfo; syscall NVBase 054;
  63. FUNCTION GetNVList(const appName : pCHAR location 'a0'; killRequesters : LONGINT location 'd1') : pMinList; syscall NVBase 060;
  64. FUNCTION SetNVProtection(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; mask : LONGINT location 'd2'; killRequesters : LONGINT location 'd1') : LongBool; syscall NVBase 066;
  65. FUNCTION StoreNV(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; const data : POINTER location 'a2'; length : ULONG location 'd0'; killRequesters : LONGINT location 'd1') : WORD; syscall NVBase 042;
  66. IMPLEMENTATION
  67. const
  68. { Change VERSION and LIBVERSION to proper values }
  69. VERSION : string[2] = '0';
  70. LIBVERSION : longword = 0;
  71. initialization
  72. NVBase := OpenLibrary(NONVOLATILENAME,LIBVERSION);
  73. finalization
  74. if Assigned(NVBase) then
  75. CloseLibrary(NVBase);
  76. END. (* UNIT NONVOLATILE *)