]> Git repositories of Nishi - tewi.git/commitdiff
[release 2.03C] read registry
authorNishi <nishi@nishi.boats>
Wed, 2 Oct 2024 02:33:40 +0000 (02:33 +0000)
committerNishi <nishi@nishi.boats>
Wed, 2 Oct 2024 02:33:40 +0000 (02:33 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@206 8739d7e6-ffea-ec47-b151-bdff447c6205

Server/install.nsi
Server/main.c
Server/tw_version.h
installer.sh

index d98f24b753bf1deaee076fc97604cb6055becec3..e3c7bc4fdf9df047637cbec369c38cd5411b9765 100644 (file)
@@ -26,6 +26,7 @@ LangString WAIT_STOP ${LANG_JAPANESE} "サービスが止まるのを待って
 !include "Sections.nsh"
 
 Page license
+Page directory
 Page components
 Page instfiles
 UninstPage uninstConfirm
@@ -57,6 +58,7 @@ Section
        CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" ""
 
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "DisplayName" "Tewi HTTPd"
+       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "InstallDir" '"$INSTDIR"'
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"'
 
        WriteUninstaller "$INSTDIR\uninstall.exe"
index 2e81f712beb73493585722cbcfcbe7241d756897..4b3c832f96396a8e8cf9896ecada7bae46ec50ba 100644 (file)
@@ -71,6 +71,20 @@ char tw_server[2048];
 
 int startup(int argc, char** argv);
 
+#ifdef __MINGW32__
+char* get_registry(const char* main, const char* sub) {
+       DWORD bufsize = 255;
+       char* value = malloc(256);
+       int err = RegGetValue(HKEY_LOCAL_MACHINE, main, sub, RRF_RT_ANY, NULL, (void*)value, &bufsize);
+       if(err == ERROR_SUCCESS) {
+               return value;
+       } else {
+               free(value);
+               return NULL;
+       }
+}
+#endif
+
 #ifdef SERVICE
 SERVICE_STATUS status;
 SERVICE_STATUS_HANDLE status_handle;
@@ -86,7 +100,15 @@ void WINAPI servhandler(DWORD control) {
 }
 
 void WINAPI servmain(DWORD argc, LPSTR* argv) {
-       logfile = fopen(PREFIX "/logs/tewi.log", "a");
+       char* path = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
+       if(path != NULL) {
+               char* lpath = cm_strcat(path, "/logs/tewi.log");
+               logfile = fopen(lpath, "a");
+               free(lpath);
+               free(path);
+       } else {
+               logfile = fopen(PREFIX "/logs/tewi.log", "a");
+       }
        if(logfile == NULL) logfile = stderr;
        status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
        status.dwCurrentState = SERVICE_START_PENDING;
@@ -661,7 +683,17 @@ int main(int argc, char** argv) {
 
 int startup(int argc, char** argv) {
        int i;
+#ifdef __MINGW32__
+       char* confpath = cm_strdup(PREFIX "/etc/tewi.conf");
+       char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
+       if(regpath != NULL) {
+               free(confpath);
+               confpath = cm_strcat(regpath, "/etc/tewi.conf");
+               free(regpath);
+       }
+#else
        const char* confpath = PREFIX "/etc/tewi.conf";
+#endif
        if(argv != NULL) {
                for(i = 1; i < argc; i++) {
                        if(argv[i][0] == '-') {
index c138d35b6dcb8f7dc7f3bcaca4ca6a173beee8f6..9f40e32076af513526ff10af3b579766cd777f48 100644 (file)
@@ -7,7 +7,7 @@
 extern "C" {
 #endif
 
-#define TW_VERSION "2.03B\0"
+#define TW_VERSION "2.03C\0"
 
 const char* tw_get_version(void);
 const char* tw_get_platform(void);
index 6dfc91d27a4b193f171c8c17a3021f72a85b16e3..768855a1d5a8ce746008227d76238a6d8d3a1407 100755 (executable)
@@ -22,13 +22,13 @@ VERSION=`make get-version`
 sed "s/undef NO_SSL/define NO_SSL/g" config.h.tmpl > config.h
 
 make clean || fail
-make PLATFORM=$1 -j4 || fail
+make PLATFORM=$1 PREFIX=C:/srv/Tewi -j4 || fail
 cp Server/tewi.exe tewi.exe
 make clean || fail
-make PLATFORM=$1-service -j4 || fail
+make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail
 cp Server/tewi.exe tewi-service.exe
 cd Server
-../Tool/genconf "C:/Tewi" modules dll > ../generated.conf
+../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf
 ../Tool/itworks > ../itworks.html
 makensis -DVERSION=$VERSION install.nsi
 cp install.exe ../install-nossl.exe
@@ -38,13 +38,13 @@ cd ..
 sed "s/define NO_SSL/undef NO_SSL/g" config.h.tmpl > config.h
 
 make clean || fail
-make PLATFORM=$1 -j4 || fail
+make PLATFORM=$1 -j4 PREFIX=C:/srv/Tewi|| fail
 cp Server/tewi.exe tewi.exe
 make clean || fail
-make PLATFORM=$1-service -j4 || fail
+make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail
 cp Server/tewi.exe tewi-service.exe
 cd Server
-../Tool/genconf "C:/Tewi" modules dll > ../generated.conf
+../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf
 ../Tool/itworks > ../itworks.html
 makensis -DVERSION=$VERSION install.nsi
 cp install.exe ../install-ssl.exe