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