ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Windows/user_strings_windows.cpp
Revision: 1.1
Committed: 2004-12-07T22:36:29Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Log Message:
add Windows-specific localizable strings

File Contents

# Content
1 /*
2 * user_strings_windows.cpp - Localizable strings, Windows specific strings
3 *
4 * SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig
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 #include "user_strings.h"
23
24
25 // Platform-specific string definitions
26 user_string_def platform_strings[] = {
27 // Common strings that have a platform-specific variant
28 {STR_EXTFS_VOLUME_NAME, "My Computer"},
29
30 // Purely platform-specific strings
31 {STR_LOW_MEM_MMAP_ERR, "Cannot map Low Memory Globals: %s."},
32 {STR_KD_SHMGET_ERR, "Cannot create SHM segment for Kernel Data: %s."},
33 {STR_KD_SHMAT_ERR, "Cannot map first Kernel Data area: %s."},
34 {STR_KD2_SHMAT_ERR, "Cannot map second Kernel Data area: %s."},
35 {STR_ROM_MMAP_ERR, "Cannot map ROM: %s."},
36 {STR_RAM_MMAP_ERR, "Cannot map RAM: %s."},
37 {STR_DR_CACHE_MMAP_ERR, "Cannot map DR Cache: %s."},
38 {STR_DR_EMULATOR_MMAP_ERR, "Cannot map DR Emulator: %s."},
39 {STR_SHEEP_MEM_MMAP_ERR, "Cannot map SheepShaver Data area: %s."},
40 {STR_NO_XVISUAL_ERR, "Cannot obtain appropriate X visual."},
41 {STR_NO_AUDIO_WARN, "No audio device found, audio output will be disabled."},
42 {STR_KEYCODE_FILE_WARN, "Cannot open keycode translation file %s (%s)."},
43 {STR_KEYCODE_VENDOR_WARN, "Cannot find vendor '%s' in keycode translation file %s."},
44 {STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},
45
46 {STR_OPEN_WINDOW_ERR, "Cannot open Mac window."},
47 {STR_WINDOW_TITLE_GRABBED, "SheepShaver (mouse grabbed, press Ctrl-F5 to release)"},
48
49 {-1, NULL} // End marker
50 };
51
52
53 /*
54 * Search for main volume name
55 */
56
57 static const char *get_volume_name(void)
58 {
59 HKEY hHelpKey;
60 DWORD key_type, cbData;
61
62 static char volume[256];
63 memset(volume, 0, sizeof(volume));
64
65 // Try Windows 2000 key first
66 if (ERROR_SUCCESS == RegOpenKey(
67 HKEY_CURRENT_USER,
68 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
69 &hHelpKey))
70 {
71 cbData = sizeof(volume);
72 RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData );
73 RegCloseKey(hHelpKey);
74 }
75
76 if (volume[0] == 0 &&
77 ERROR_SUCCESS == RegOpenKey(
78 HKEY_CURRENT_USER,
79 "Software\\Classes\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
80 &hHelpKey))
81 {
82 cbData = sizeof(volume);
83 RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData );
84 RegCloseKey(hHelpKey);
85 }
86
87 if (volume[0] == 0 &&
88 ERROR_SUCCESS == RegOpenKey(
89 HKEY_CLASSES_ROOT,
90 "CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
91 &hHelpKey))
92 {
93 cbData = sizeof(volume);
94 RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData );
95 RegCloseKey(hHelpKey);
96 }
97
98 // Fix the error that some "tweak" apps do.
99 if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0)
100 volume[0] = '\0';
101
102 // No volume name found, default to "My Computer"
103 if (volume[0] == 0)
104 strcpy(volume, "My Computer");
105
106 return volume;
107 }
108
109
110 /*
111 * Fetch pointer to string, given the string number
112 */
113
114 const char *GetString(int num)
115 {
116 // First, search for platform-specific variable string
117 switch (num) {
118 case STR_EXTFS_VOLUME_NAME:
119 return get_volume_name();
120 }
121
122 // Next, search for platform-specific string
123 int i = 0;
124 while (platform_strings[i].num >= 0) {
125 if (platform_strings[i].num == num)
126 return platform_strings[i].str;
127 i++;
128 }
129
130 // Not found, search for common string
131 i = 0;
132 while (common_strings[i].num >= 0) {
133 if (common_strings[i].num == num)
134 return common_strings[i].str;
135 i++;
136 }
137 return NULL;
138 }