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