New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / nonvolatile / nvdisk / nvdisk_init.c
blob235010b4e36a6a0105f80482217b98d394693ef6
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Nonvolatile disk based storage library initialization code.
6 Lang: English
7 */
10 #define DEBUG 1
12 #include "nvdisk_intern.h"
14 #include <aros/debug.h>
16 #include <exec/types.h>
17 #include <exec/resident.h>
18 #include <proto/exec.h>
19 #include <proto/dos.h>
20 #include <devices/timer.h>
21 #include <aros/symbolsets.h>
23 #include <exec/libraries.h>
24 #include <exec/memory.h>
25 #include <exec/alerts.h>
26 #include LC_LIBDEFS_FILE
29 static int Init(LIBBASETYPEPTR LIBBASE)
32 This function is single-threaded by exec by calling Forbid.
33 If you break the Forbid() another task may enter this function
34 at the same time. Take care.
37 BOOL error = TRUE; // Notice the initialization to 'TRUE' here.
38 char *temp = NULL;
39 BPTR locFile;
41 D(bug("Init nvdisk.library\n"));
43 locFile = Open("SYS:prefs/env-archive/sys/nv_location", MODE_OLDFILE);
45 D(bug("Getting location\n"));
47 if(locFile != NULL)
49 D(bug("Location file exists!\n"));
51 temp = AllocVec(512, MEMF_CLEAR);
53 if(temp != NULL)
55 int i = 0; // Loop variable
57 Read(locFile, temp, 512);
59 // End string if a carriage return is encountered
60 while(temp[i] != 0)
62 if(temp[i] == '\n')
64 temp[i] = 0;
65 break;
68 i++;
71 nvdBase->nvd_location = Lock(temp, SHARED_LOCK);
73 D(bug("NV location = %s\n", temp));
75 FreeVec(temp);
77 D(bug("Got lock = %p\n", nvdBase->nvd_location));
79 if(nvdBase->nvd_location != NULL)
81 error = FALSE;
85 Close(locFile);
88 return !error;
91 static int Expunge(LIBBASETYPEPTR LIBBASE)
94 This function is single-threaded by exec by calling Forbid.
95 Never break the Forbid() or strange things might happen.
98 UnLock(nvdBase->nvd_location);
100 return TRUE;
103 ADD2INITLIB(Init, 0);
104 ADD2EXPUNGELIB(Expunge, 0);