next up previous
Next: char *DirectoryFor(char *pkg, int Up: Package Storage in the Previous: Package Storage in the

Initialize the module

The standard JavaSoft Java Developer's Kit on UNIX stores all the Java packages and source and binary code in a set of directories and their subdirectories. This specification allows a user to provide the names of top-level directories via the -I option on the command line.

FileStorage.clp[1]:
PackageDirectories "-I" strings;
Source input;
This macro is attached to a product file.

The program also queries the CLASSPATH environment variable for additional directory names. Those directory names are appended to the PackageDirectories list. CLASSPATH must be read from the environment and the colon-separated directory names extracted:

void InitHostSystem(void)[2]:
{ char *dirs, *name;
  int SourceSym;

  dirs = getenv("CLASSPATH");
  if (dirs) {
    do {
      register char *rest;

      for (rest = dirs; *rest && *rest != ':'; rest++) ;

      { DefTableKey k = NewKey();
        CsmStrPtr = (char *)obstack_copy0(Csm_obstk, dirs, rest - dirs);
        ResetClpValue(k, MakeName(CsmStrPtr));
        PackageDirectories = AppElDefTableKeyList(PackageDirectories, k);
      }

      if (*rest == '\0') break;
      dirs = rest + 1;
    } while (*dirs);
  }

  if (!FilRootEnv) FilRootEnv = NewEnv();

  if (!PkgRootEnv) PkgRootEnv = NewEnv();
  if (!PtyRootEnv) PtyRootEnv = NewEnv();
  ImportPackage(
    "java.lang",
    DefineIdn(PkgRootEnv, MakeName("java.lang")));

  SourceSym = GetClpValue(Source, NoStrIndex);
  if (SourceSym == NoStrIndex) return;

  name = StringTable(SourceSym);
  if (*name == '/') SourceSym = MakeName(name);
  else {
    char cwd[MAX_PATH+1];

    if (!getcwd(cwd, MAX_PATH+1)) {
      (void)perror(cwd);
    }

    obstack_grow(Csm_obstk, cwd, strlen(cwd));
    obstack_1grow(Csm_obstk, '/');
    CsmStrPtr = (char *)obstack_copy0(Csm_obstk, name, strlen(name));
    SourceSym = MakeName(CsmStrPtr);
  }

  ResetIsDone(DefineIdn(FilRootEnv, SourceSym), 1);
}
This macro is invoked in definition 9.

FileStorage.init[3]:
InitHostSystem();
This macro is attached to a product file.


next up previous
Next: char *DirectoryFor(char *pkg, int Up: Package Storage in the Previous: Package Storage in the
2008-09-11