/* src/vmcore/suck.c - functions to read LE ordered types from a buffer
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "config.h"
#include <assert.h>
-#include <dirent.h>
-#include <sys/stat.h>
#include <stdlib.h>
#include "vm/types.h"
#include "toolbox/logging.h"
#include "toolbox/util.h"
-#include "vm/exceptions.h"
+#include "vm/exceptions.hpp"
#include "vm/properties.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
#include "vmcore/loader.h"
#include "vmcore/options.h"
#include "vmcore/suck.h"
+#include "vmcore/os.hpp"
#include "vmcore/zip.h"
bool suck_init(void)
{
+ TRACESUBSYSTEMINITIALIZATION("suck_init");
+
list_classpath_entries = list_create(OFFSET(list_classpath_entry, linkage));
/* everything's ok */
*******************************************************************************/
-#if defined(__LINUX__)
static int scandir_filter(const struct dirent *a)
-#else
-static int scandir_filter(struct dirent *a)
-#endif
{
s4 namlen;
*******************************************************************************/
-void suck_add_from_property(char *key)
+void suck_add_from_property(const char *key)
{
- char *value;
- char *start;
- char *end;
+ const char *value;
+ const char *start;
+ const char *end;
char *path;
s4 pathlen;
struct dirent **namelist;
/* scan the directory found for zip/jar files */
- n = scandir(path, &namelist, scandir_filter, alphasort);
+ n = os_scandir(path, &namelist, scandir_filter, alphasort);
/* On error, just continue, this should be ok. */
/* Allocate memory for bootclasspath. */
- boot_class_path = properties_get("sun.boot.class.path");
+ // FIXME Make boot_class_path const char*.
+ boot_class_path = (char*) properties_get("sun.boot.class.path");
p = MNEW(char,
pathlen + strlen("/") + namlen +
{
#ifdef ENABLE_VERIFIER
if (len < 0 || ((cb->data + cb->size) - cb->pos) < len) {
- exceptions_throw_classformaterror((cb)->class, "Truncated class file");
+ exceptions_throw_classformaterror(cb->clazz, "Truncated class file");
return false;
}
#endif /* ENABLE_VERIFIER */
strcpy(path, lce->path);
strcat(path, filename);
- classfile = fopen(path, "r");
+ classfile = os_fopen(path, "r");
if (classfile) { /* file exists */
- if (!stat(path, &buffer)) { /* read classfile data */
+ if (!os_stat(path, &buffer)) { /* read classfile data */
cb = NEW(classbuffer);
- cb->class = c;
+ cb->clazz = c;
cb->size = buffer.st_size;
cb->data = MNEW(u1, cb->size);
cb->pos = cb->data;
/* read class data */
- len = fread(cb->data, 1, cb->size, classfile);
+ len = os_fread((void *) cb->data, 1, cb->size,
+ classfile);
if (len != buffer.st_size) {
suck_stop(cb);
/* close the class file */
- fclose(classfile);
+ os_fclose(classfile);
}
}