Tabs to spaces, more consistent formatting.
[AROS.git] / workbench / libs / nonvolatile / storenv.c
blob1868e32352bc5411e95c4f16efdda397dee2a58e
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 #include <string.h>
6 #include <dos/dosextens.h>
8 /*****************************************************************************
10 NAME */
12 // # define DEBUG 1
13 // #include <aros/debug.h>
15 #include <libraries/nonvolatile.h>
16 #include <proto/exec.h>
17 #include <proto/nvdisk.h>
19 AROS_LH5(LONG, StoreNV,
21 /* SYNOPSIS */
23 AROS_LHA(STRPTR, appName, A0),
24 AROS_LHA(STRPTR, itemName, A1),
25 AROS_LHA(APTR, data, A2),
26 AROS_LHA(ULONG, length, D0),
27 AROS_LHA(BOOL, killRequesters, D1),
29 /* LOCATION */
31 struct Library *, nvBase, 7, Nonvolatile)
33 /* FUNCTION
35 Save data in the nonvolatile storage.
37 INPUTS
39 appName -- the application to save an item in the nonvolatile
40 storage
41 itemName -- the name of the item to save
42 data -- the data to save
43 length -- number of tens of bytes of the data to save rounded
44 upwards (for instance to save 24 bytes specify 3).
45 killRequesters -- if TRUE no system requesters will be displayed during
46 the operation of this function
48 RESULT
50 Indication of the success of the operation
52 0 -- no error
53 NVERR_BADNAME -- 'appName' or 'itemName' were not correctly
54 specified names
55 NVERR_WRITEPROT -- the nonvolatile storage is read only
56 NVERR_FAIL -- failure in data saving (storage is full or write
57 protected)
58 NVERR_FATAL -- fatal error (possible loss of previously saved
59 data)
61 NOTES
63 The strings 'appName' and 'itemName' should be descripive but short as the
64 size of the nonvolatile storage may be very limited. The strings may not
65 contatin the characters ':' or '/'. The maximum length for each of these
66 strings is 31.
68 EXAMPLE
70 BUGS
72 SEE ALSO
74 GetCopyNV(), GetNVInfo()
76 INTERNALS
78 ******************************************************************************/
81 AROS_LIBFUNC_INIT
83 struct Process *me = (struct Process *)FindTask(NULL);
84 APTR oldReq = me->pr_WindowPtr;
85 LONG retval;
87 if(data == NULL)
88 return NVERR_FAIL; /* There is no good (defined) error to
89 report... */
91 if(appName == NULL || itemName == NULL)
92 return NVERR_BADNAME;
94 if(strpbrk(appName, ":/") != NULL ||
95 strpbrk(itemName, ":/") != NULL)
96 return NVERR_BADNAME;
98 if(killRequesters)
99 me->pr_WindowPtr = (APTR)-1;
101 // kprintf("Calling writedata");
103 retval = WriteNVDData(appName, itemName, data, length*10);
105 if(killRequesters)
106 me->pr_WindowPtr = oldReq;
108 return retval;
110 AROS_LIBFUNC_EXIT
111 } /* StoreNV */