Skip to content

Commit

Permalink
Search for runtime files in shared directory
Browse files Browse the repository at this point in the history
Check directories relative to the directory xecutable is run from.

If runtime files dir is not found under ${exedir}/root/lotus
try searching in ${exedir}/../share/lotus

This should help support system-wide installation and packaging.
  • Loading branch information
vrza committed Jun 2, 2022
1 parent 5e5aab0 commit 09f5cd9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions extract.sh
Expand Up @@ -62,3 +62,6 @@ fi

echo "==> Copying the banner template over"
cp -v "${ROOT}/usr/tmp/lotus_install/123/banner" "${LOTUS}/ri/USA-English/123ban.ri"

echo "==> Copying default configuration file"
cp -v "${BASE}/l123set.cf" "${ROOT}/lotus/l123set.cf"
26 changes: 22 additions & 4 deletions filemap.c
Expand Up @@ -9,17 +9,35 @@
// Figure out where our runtime files are located.
static const char *get_lotus_runtimefile(const char *file)
{
static char procpath[PATH_MAX];
static char filepath[PATH_MAX];
static char *lotusdir;
static char exepath[PATH_MAX];
static char *exedir;
static char filepath[PATH_MAX];
static char localcheck[PATH_MAX];
static char localpath[PATH_MAX];
static char sharecheck[PATH_MAX];
static char sharepath[PATH_MAX];

// Cache this path so it only has to be looked up once.
if (lotusdir == NULL) {
if (readlink("/proc/self/exe", procpath, PATH_MAX) == -1) {
if (readlink("/proc/self/exe", exepath, PATH_MAX) == -1) {
err(EXIT_FAILURE, "Failed to determine the lotus root directory");
}
// Figure out the containing directory from the exe path.
lotusdir = dirname(procpath);
exedir = dirname(exepath);
snprintf(localcheck, PATH_MAX, "%s/%s", exedir, "root/lotus/123.v10");
if (access(localcheck, F_OK) == 0) {
snprintf(localpath, PATH_MAX, "%s/%s", exedir, "root/lotus");
lotusdir = localpath;
} else {
snprintf(sharecheck, PATH_MAX, "%s/%s", exedir, "../share/lotus/123.v10");
if (access(sharecheck, F_OK) == 0) {
snprintf(sharepath, PATH_MAX, "%s/%s", exedir, "../share/lotus");
lotusdir = sharepath;
} else {
lotusdir = localpath;
}
}
}

// Append the requested filename, obviously this is not reentrant, but 123
Expand Down
2 changes: 1 addition & 1 deletion l123set.cf
@@ -1,5 +1,5 @@
1001 Lotus 1-2-3 Version "10"
1002 Base Directory "/{LOTUSROOT}/root/lotus"
1002 Base Directory "/{LOTUSROOT}"
1003 Printer Interface "lpr -o dest={dest} {file}"
1004 Graphics Driver "dumb" "ega egas25cc.vbd"
1007 Help Language "USA English" "USA-English"
Expand Down

0 comments on commit 09f5cd9

Please sign in to comment.