Authors: Christian Thalinger
- $Id: properties.c 5988 2006-11-15 17:58:25Z twisti $
+ $Id: properties.c 6249 2006-12-27 23:00:59Z twisti $
*/
#include "vm/global.h"
#include "native/include/java_lang_String.h"
-#include "native/include/java_util_Properties.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_util_Properties.h"
+#endif
+
#include "toolbox/list.h"
#include "toolbox/util.h"
#include "vm/method.h"
char *extdirs;
char *lang;
char *country;
- struct utsname utsnamebuf;
+ struct utsname *utsnamebuf;
s4 len;
#endif
env_home = getenv("HOME");
env_lang = getenv("LANG");
- uname(&utsnamebuf);
+ utsnamebuf = NEW(struct utsname);
+
+ uname(utsnamebuf);
/* set JAVA_HOME to default prefix if not defined */
properties_add("java.home", java_home);
- MFREE(java_home, char, len);
-
properties_add("java.vm.specification.version", "1.0");
properties_add("java.vm.specification.vendor", "Sun Microsystems Inc.");
properties_add("java.vm.specification.name", "Java Virtual Machine Specification");
properties_add("java.vm.version", VERSION);
properties_add("java.vm.vendor", "CACAO Team");
properties_add("java.vm.name", "CACAO");
- properties_add("java.specification.version", "1.4");
+ properties_add("java.specification.version", "1.5");
properties_add("java.specification.vendor", "Sun Microsystems Inc.");
properties_add("java.specification.name", "Java Platform API Specification");
properties_add("java.class.version", CLASS_VERSION);
properties_add("java.ext.dirs", extdirs);
- MFREE(extdirs, char, len);
-
properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
#if defined(DISABLE_GC)
# else
/* default to what uname returns */
- properties_add("os.arch", utsnamebuf.machine);
+ properties_add("os.arch", utsnamebuf->machine);
# endif
- properties_add("os.name", utsnamebuf.sysname);
- properties_add("os.version", utsnamebuf.release);
+ properties_add("os.name", utsnamebuf->sysname);
+ properties_add("os.version", utsnamebuf->release);
#endif
properties_add("file.separator", "/");
properties_add("user.language", "en");
properties_add("user.country", "US");
}
-
- /* clean up */
-
- MFREE(cwd, char, 0);
#elif defined(ENABLE_JAVAME_CLDC1_1)
properties_add("microedition.configuration", "CLDC-1.1");
- properties_add("microedition.platform", "PowerPC");
- properties_add("microedition.encoding", "ISO-8859-1");
+ properties_add("microedition.platform", "generic");
+ properties_add("microedition.encoding", "ISO8859_1");
properties_add("microedition.profiles", "");
#else
#error unknown Java configuration
/* properties_add **************************************************************
- Adds a property entry to the internal property list.
+ Adds a property entry to the internal property list. If there's
+ already an entry with the same key, replace it.
*******************************************************************************/
void properties_add(char *key, char *value)
{
- list_properties_entry *p;
+ list_properties_entry *pe;
+
+ /* search for the entry */
+
+ for (pe = list_first_unsynced(list_properties); pe != NULL;
+ pe = list_next_unsynced(list_properties, pe)) {
+ if (strcmp(pe->key, key) == 0) {
+ /* entry was found, replace the value */
+
+ pe->value = value;
+
+ return;
+ }
+ }
+
+ /* entry was not found, insert a new one */
- p = NEW(list_properties_entry);
+ pe = NEW(list_properties_entry);
- p->key = key;
- p->value = value;
+ pe->key = key;
+ pe->value = value;
- list_add_last_unsynced(list_properties, p);
+ list_add_last_unsynced(list_properties, pe);
}
/* We search backwards, so we get the newest entry for a key, as
the list may contain more than one entry for a specific key. */
- for (pe = list_last(list_properties); pe != NULL;
- pe = list_prev(list_properties, pe)) {
+ for (pe = list_last_unsynced(list_properties); pe != NULL;
+ pe = list_prev_unsynced(list_properties, pe)) {
if (strcmp(pe->key, key) == 0)
return pe->value;
}