From 703289d102e6abc2cab6869be3bb681203398bf0 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Mon, 4 May 2020 22:06:41 +0000
Subject: [PATCH] Move expected location of jsexec.ini from exec directory to
 ctrl directory: - argv[0] does not always contain the full path to the
 executable, so that is   not a good way to locate the exec directory. - since
 we already need to know the ctrl dir and that is the normal place to   put
 config files, that's where it shall be. - jsdoor builds don't get a .ini file
 - I don't think they need it (?)

---
 {exec => ctrl}/jsexec.ini |  0
 src/sbbs3/jsexec.c        | 16 ++++++----------
 2 files changed, 6 insertions(+), 10 deletions(-)
 rename {exec => ctrl}/jsexec.ini (100%)

diff --git a/exec/jsexec.ini b/ctrl/jsexec.ini
similarity index 100%
rename from exec/jsexec.ini
rename to ctrl/jsexec.ini
diff --git a/src/sbbs3/jsexec.c b/src/sbbs3/jsexec.c
index 0097bb36dd..23cdd89b37 100644
--- a/src/sbbs3/jsexec.c
+++ b/src/sbbs3/jsexec.c
@@ -1195,15 +1195,17 @@ int main(int argc, char **argv, char** env)
 	if(!winsock_startup())
 		return(do_bail(2));
 
-	SAFECOPY(ini_fname, argv[0]);
-	if((p = getfext(ini_fname)) != NULL)
-		*p = 0;
-	SAFECAT(ini_fname, ".ini");
+#ifndef JSDOOR
+	SAFECOPY(scfg.ctrl_dir, get_ctrl_dir());
+	iniFileName(ini_fname, sizeof(ini_fname), scfg.ctrl_dir, "jsexec.ini");
 	if((fp = iniOpenFile(ini_fname, /* create: */FALSE)) != NULL) {
 		ini = iniReadFile(fp);
 		iniCloseFile(fp);
+	} else {
+		fprintf(stderr, "Error %d (%s) opening %s\n", errno, strerror(errno), ini_fname);
 	}
 	get_ini_values(ini, /* section (global): */NULL, &cb);
+#endif
 
 	getcwd(orig_cwd, sizeof(orig_cwd));
 	backslash(orig_cwd);
@@ -1362,12 +1364,6 @@ int main(int argc, char **argv, char** env)
 		get_ini_values(ini, ini_section, &cb);
 	}
 
-#ifndef JSDOOR
-	if(scfg.ctrl_dir[0]==0) {
-		SAFECOPY(scfg.ctrl_dir, get_ctrl_dir());
-	}	
-#endif
-
 	if(umask_val >= 0)
 		umask(umask_val);
 
-- 
GitLab