Changeset 206 in Main for trunk


Ignore:
Timestamp:
Oct 2, 2024, 11:33:40 AM (6 weeks ago)
Author:
Nishi
Message:

[release 2.03C] read registry

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Server/install.nsi

    r128 r206  
    2727
    2828Page license
     29Page directory
    2930Page components
    3031Page instfiles
     
    5859
    5960        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "DisplayName" "Tewi HTTPd"
     61        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "InstallDir" '"$INSTDIR"'
    6062        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"'
    6163
  • trunk/Server/main.c

    r200 r206  
    7272int startup(int argc, char** argv);
    7373
     74#ifdef __MINGW32__
     75char* get_registry(const char* main, const char* sub) {
     76        DWORD bufsize = 255;
     77        char* value = malloc(256);
     78        int err = RegGetValue(HKEY_LOCAL_MACHINE, main, sub, RRF_RT_ANY, NULL, (void*)value, &bufsize);
     79        if(err == ERROR_SUCCESS) {
     80                return value;
     81        } else {
     82                free(value);
     83                return NULL;
     84        }
     85}
     86#endif
     87
    7488#ifdef SERVICE
    7589SERVICE_STATUS status;
     
    87101
    88102void WINAPI servmain(DWORD argc, LPSTR* argv) {
    89         logfile = fopen(PREFIX "/logs/tewi.log", "a");
     103        char* path = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
     104        if(path != NULL) {
     105                char* lpath = cm_strcat(path, "/logs/tewi.log");
     106                logfile = fopen(lpath, "a");
     107                free(lpath);
     108                free(path);
     109        } else {
     110                logfile = fopen(PREFIX "/logs/tewi.log", "a");
     111        }
    90112        if(logfile == NULL) logfile = stderr;
    91113        status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     
    662684int startup(int argc, char** argv) {
    663685        int i;
     686#ifdef __MINGW32__
     687        char* confpath = cm_strdup(PREFIX "/etc/tewi.conf");
     688        char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
     689        if(regpath != NULL) {
     690                free(confpath);
     691                confpath = cm_strcat(regpath, "/etc/tewi.conf");
     692                free(regpath);
     693        }
     694#else
    664695        const char* confpath = PREFIX "/etc/tewi.conf";
     696#endif
    665697        if(argv != NULL) {
    666698                for(i = 1; i < argc; i++) {
  • trunk/Server/tw_version.h

    r205 r206  
    88#endif
    99
    10 #define TW_VERSION "2.03B\0"
     10#define TW_VERSION "2.03C\0"
    1111
    1212const char* tw_get_version(void);
  • trunk/installer.sh

    r153 r206  
    2323
    2424make clean || fail
    25 make PLATFORM=$1 -j4 || fail
     25make PLATFORM=$1 PREFIX=C:/srv/Tewi -j4 || fail
    2626cp Server/tewi.exe tewi.exe
    2727make clean || fail
    28 make PLATFORM=$1-service -j4 || fail
     28make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail
    2929cp Server/tewi.exe tewi-service.exe
    3030cd Server
    31 ../Tool/genconf "C:/Tewi" modules dll > ../generated.conf
     31../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf
    3232../Tool/itworks > ../itworks.html
    3333makensis -DVERSION=$VERSION install.nsi
     
    3939
    4040make clean || fail
    41 make PLATFORM=$1 -j4 || fail
     41make PLATFORM=$1 -j4 PREFIX=C:/srv/Tewi|| fail
    4242cp Server/tewi.exe tewi.exe
    4343make clean || fail
    44 make PLATFORM=$1-service -j4 || fail
     44make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail
    4545cp Server/tewi.exe tewi-service.exe
    4646cd Server
    47 ../Tool/genconf "C:/Tewi" modules dll > ../generated.conf
     47../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf
    4848../Tool/itworks > ../itworks.html
    4949makensis -DVERSION=$VERSION install.nsi
Note: See TracChangeset for help on using the changeset viewer.