ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/xpram_unix.cpp
Revision: 1.7
Committed: 2004-01-12T15:29:25Z (20 years, 5 months ago) by cebix
Branch: MAIN
CVS Tags: nigel-build-16, nigel-build-15
Changes since 1.6: +1 -1 lines
Log Message:
Happy New Year! :)

File Contents

# Content
1 /*
2 * xpram_unix.cpp - XPRAM handling, Unix specific stuff
3 *
4 * Basilisk II (C) 1997-2004 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
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. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include "sysdeps.h"
22
23 #include <stdlib.h>
24
25 #include "xpram.h"
26
27
28 // XPRAM file name and path
29 #if POWERPC_ROM
30 const char XPRAM_FILE_NAME[] = ".sheepshaver_nvram";
31 #else
32 const char XPRAM_FILE_NAME[] = ".basilisk_ii_xpram";
33 #endif
34 static char xpram_path[1024];
35
36
37 /*
38 * Load XPRAM from settings file
39 */
40
41 void LoadXPRAM(void)
42 {
43 // Construct XPRAM path
44 xpram_path[0] = 0;
45 char *home = getenv("HOME");
46 if (home != NULL && strlen(home) < 1000) {
47 strncpy(xpram_path, home, 1000);
48 strcat(xpram_path, "/");
49 }
50 strcat(xpram_path, XPRAM_FILE_NAME);
51
52 // Load XPRAM from settings file
53 int fd;
54 if ((fd = open(xpram_path, O_RDONLY)) >= 0) {
55 read(fd, XPRAM, XPRAM_SIZE);
56 close(fd);
57 }
58 }
59
60
61 /*
62 * Save XPRAM to settings file
63 */
64
65 void SaveXPRAM(void)
66 {
67 int fd;
68 if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0666)) >= 0) {
69 write(fd, XPRAM, XPRAM_SIZE);
70 close(fd);
71 }
72 }
73
74
75 /*
76 * Delete PRAM file
77 */
78
79 void ZapPRAM(void)
80 {
81 // Construct PRAM path
82 xpram_path[0] = 0;
83 char *home = getenv("HOME");
84 if (home != NULL && strlen(home) < 1000) {
85 strncpy(xpram_path, home, 1000);
86 strcat(xpram_path, "/");
87 }
88 strcat(xpram_path, XPRAM_FILE_NAME);
89
90 // Delete file
91 unlink(xpram_path);
92 }