/* more stuff */
static
int
GetHighestVersion(pattern)
char *pattern; {
int highestVersion = -1; /* result */
char directory[1024];
char fileNamePrefix[100];
int len;
int version = -1;
DIR *dirp;
struct dirent *dp;
ParseDirectoryAndFileName(directory, fileNamePrefix, pattern);
dirp = OpenDir(directory);
if (dirp == NULL) return(highestVersion);
len = strlen(fileNamePrefix);
for (dp = ReadDir(dirp); dp !=
NULL; dp = ReadDir(dirp)) {
if ( ! strncmp(dp->d←name, fileNamePrefix, len) ) {
version = GetVersionFromName(dp->d←name);
if ( version > highestVersion ) { highestVersion = version; };
};
};
(void)CloseDir (dirp);
return(highestVersion);
}
static
void
MakeUName(pattern, pathPrefix, base, version)
char *pattern, *pathPrefix, *base;
int version; {
char buf[10];
(void)strcpy(pattern, pathPrefix);
(void)strcat(pattern, STR←SLASH);
(void)strcat(pattern, base);
(void)strcat(pattern, STR←DOT←TILDE);
(void)XR←SPrintF(buf, "%d", version);
(void)strcat(pattern, buf);
(void)strcat(pattern, STR←TILDE);
}
static
void
ExpandFileVersion(oldfile, newfile)
char *oldfile, *newfile; {
char pathPrefix[1024];
char base[255];
int version;
(void)ParseUName(oldfile, pathPrefix, base);
GetPattern(newfile, pathPrefix, base);
version = GetHighestVersion(newfile);
MakeUName(newfile, pathPrefix, base, version);
}
extern
void
getnewfile(oldfile, newfile) char *oldfile, *newfile; { /* backward compat */
ExpandFileVersion(oldfile, newfile);
};
void
XR𡤌omment𡤌ommand(command)
char *command; {
};
void
XR←RequireFrom𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *pkg; char *module;
char *path; char *directory; char *file; char *cmd; char *fullname;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
pkg = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
module = strtok((char *)NULL, STR←PUNCTUATION);
file = LowerCase(module);
directory = XR←getenv(releasevar); StripSlash(directory);
path = (char *)XR←malloc((unsigned)(strlen(directory) + strlen(pkg) + strlen(file) + 20));
(void)XR←SPrintF(path, "%s/%s/sun4/%s.c2c.o", directory, pkg, file);
fullname = (char *)XR←malloc((unsigned)(strlen(path) + 20));
ExpandFileVersion(path, fullname);
cmd = (char *)XR←malloc((unsigned)(strlen(fullname) + strlen(module) + 20));
(void)XR←SPrintF(cmd, "LoadAndRun %s %s \n", fullname, module);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, pkg: {%s} module: {%s}]\n",
releasename, pkg, module);
(void)XR𡤏PrintF(stdout, " %s", cmd);
XR←SetCurrentCommand(cmd);
XR←loadAndRun𡤌ommand(cmd);
(void)free(scratch);
};
void
XR𡤍RequireFrom𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *pkg; char *module;
char *path; char *directory; char *file; char *cmd; char *fullname;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
pkg = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
module = strtok((char *)NULL, STR←PUNCTUATION);
file = LowerCase(module);
directory = XR←getenv(releasevar); StripSlash(directory);
path = (char *)XR←malloc((unsigned)(strlen(directory) + strlen(pkg) + strlen(file) + 20));
(void)XR←SPrintF(path, "%s/%s/sun4/%s.c2c.o", directory, pkg, file);
fullname = (char *)XR←malloc((unsigned)(strlen(path) + 20));
ExpandFileVersion(path, fullname);
cmd = (char *)XR←malloc((unsigned)(strlen(fullname) + strlen(module) + 20));
(void)XR←SPrintF(cmd, "LoadAndRun %s %s -d \n", fullname, module);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, pkg: {%s} module: {%s}]\n",
releasename, pkg, module);
(void)XR𡤏PrintF(stdout, " %s", cmd);
XR←SetCurrentCommand(cmd);
XR←loadAndRun𡤌ommand(cmd);
(void)free(scratch);
};
void
XR←ORequireFrom𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *pkg; char *module;
char *path; char *directory; char *file; char *cmd; char *fullname;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
pkg = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
module = strtok((char *)NULL, STR←PUNCTUATION);
file = LowerCase(module);
directory = XR←getenv(releasevar); StripSlash(directory);
path = (char *)XR←malloc((unsigned)(strlen(directory) + strlen(pkg) + strlen(file) + 20));
(void)XR←SPrintF(path, "%s/%s/sun4-o3/%s.c2c.o", directory, pkg, file);
fullname = (char *)XR←malloc((unsigned)(strlen(path) + 20));
ExpandFileVersion(path, fullname);
cmd = (char *)XR←malloc((unsigned)(strlen(fullname) + strlen(module) + 20));
(void)XR←SPrintF(cmd, "LoadAndRun %s %s -d \n", fullname, module);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, pkg: {%s} module: {%s}]\n",
releasename, pkg, module);
(void)XR𡤏PrintF(stdout, " %s", cmd);
XR←SetCurrentCommand(cmd);
XR←loadAndRun𡤌ommand(cmd);
(void)free(scratch);
};
void
XR←LoadFrom𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *pkg; char *module;
char *path; char *directory; char *file; char *cmd; char *fullname;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
pkg = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
module = strtok((char *)NULL, STR←PUNCTUATION);
file = LowerCase(module);
directory = XR←getenv(releasevar); StripSlash(directory);
path = (char *)XR←malloc((unsigned)(strlen(directory) + strlen(pkg) + strlen(file) + 20));
(void)XR←SPrintF(path, "%s/%s/sun4/%s.c2c.o", directory, pkg, file);
fullname = (char *)XR←malloc((unsigned)(strlen(path) + 20));
ExpandFileVersion(path, fullname);
cmd = (char *)XR←malloc((unsigned)(strlen(fullname) + strlen(module) + 20));
(void)XR←SPrintF(cmd, "Load %s %s \n", fullname, module);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, pkg: {%s} module: {%s}]\n",
releasename, pkg, module);
(void)XR𡤏PrintF(stdout, " %s", cmd);
XR←SetCurrentCommand(cmd);
XR←load𡤌ommand(cmd);
(void)free(scratch);
};
void
XR←RunFrom𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *pkg; char *module;
char *path; char *directory; char *file; char *cmd; char *fullname;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
pkg = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
module = strtok((char *)NULL, STR←PUNCTUATION);
file = LowerCase(module);
directory = XR←getenv(releasevar); StripSlash(directory);
path = (char *)XR←malloc((unsigned)(strlen(directory) + strlen(pkg) + strlen(file) + 20));
(void)XR←SPrintF(path, "%s/%s/sun4/%s.c2c.o", directory, pkg, file);
fullname = (char *)XR←malloc((unsigned)(strlen(path) + 20));
ExpandFileVersion(path, fullname);
cmd = (char *)XR←malloc((unsigned)(strlen(fullname) + strlen(module) + 20));
(void)XR←SPrintF(cmd, "Run %s %s \n", fullname, module);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, pkg: {%s} module: {%s}]\n",
releasename, pkg, module);
(void)XR𡤏PrintF(stdout, " %s", cmd);
XR←SetCurrentCommand(cmd);
XR←run𡤌ommand(cmd);
(void)free(scratch);
};
void
XR←ReleaseLocation𡤌ommand(command)
char *command; {
char *releasename; char *releasevar; char *directory;
char *scratch = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(scratch, command);
(void)strtok(scratch, STR←PUNCTUATION); /* skip the command name */
releasename = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
releasevar = LowerCaseAndDot(releasename);
directory = LowerCase(strtok((char *)NULL, STR←PUNCTUATION));
XR←setenv(releasevar, directory, 1);
if ( 0 == 1 ) (void)XR𡤏PrintF(stdout, "[release: {%s}, directory: {%s}]\n", releasename, directory);
(void)free(scratch);
};
void
XR←lrh𡤌ommand(command)
char *command; {
char *cmd←rememberer;
char *rest, *oldfile;
char *new = (char *)XR←malloc((unsigned)(strlen(command) + 100));
char *newcommand = (char *)XR←malloc((unsigned)(strlen(command) + 100));
(void)strcpy(new, command);
/* discard the lrh */
(void)strtok(new, STR←WHITESPACE);
oldfile = strtok((char *)NULL, STR←WHITESPACE);
rest = strtok((char *)NULL, STR←NULL);
StripCR(oldfile);
ExpandFileVersion(oldfile, new);
(void)strcpy(newcommand, "lr ");
(void)strcat(newcommand, new);
(void)strcat(newcommand, STR←BLANK);
if ( rest !=
NULL ) {
(void)strcat(newcommand, STR←BLANK);
(void)strcat(newcommand, rest);
}
cmd←rememberer = (char *)XR←malloc((unsigned)(strlen(newcommand) + 1));
(void)strcpy(cmd←rememberer, newcommand);
if ( XR←load𡤌ommand(newcommand) ) { XR←run𡤌ommand(cmd←rememberer); };
(void)free(new);
}
void
XR←run←LoaderUtilsImpl() { /* start trap */
RequireFrom PCedar1.1 SunPMap SunPMapClientStub
ReleaseLocation PCedar1.1 /pixel2/pcedar1.1/
XR←register("lrh", &lrh𡤌ommand←ptr, "Like lr, but use !h", 0);
XR←register("#", &Comment←ptr, "the obvious noop", 0);
XR←register("--", &Comment←ptr, "the obvious noop", 0);
XR←register("Comment", &Comment←ptr, "the obvious noop", 0);
XR←register("RequireFrom", &RequireFrom←ptr, "LoadAndRun(release, pkg, module)", 0);
XR←register("DRequireFrom", &DRequireFrom←ptr, "LoadAndRun(release, pkg, module) -d", 0);
XR←register("ORequireFrom", &ORequireFrom←ptr, "LoadAndRunOptimizedVersion(release, pkg, module) -d", 0);
XR←register("LoadFrom", &LoadFrom←ptr, "Load(release, pkg, module)", 0);
XR←register("RunFrom", &RunFrom←ptr, "Run(release, pkg, module)", 0);
XR←register("ReleaseLocation", &ReleaseLocation←ptr,
"setenv ReleaseLocation (release)", 0);
}