diff options
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | PACKAGE/lynx.iss | 221 | ||||
-rw-r--r-- | lib/dirent.c | 4 | ||||
-rw-r--r-- | src/LYUtils.c | 54 | ||||
-rw-r--r-- | src/UCdomap.c | 8 | ||||
-rw-r--r-- | userdefs.h | 10 |
6 files changed, 290 insertions, 12 deletions
diff --git a/CHANGES b/CHANGES index 8a04cbf8..895a1357 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,12 @@ --- $LynxId: CHANGES,v 1.379 2009/03/11 00:39:22 tom Exp $ +-- $LynxId: CHANGES,v 1.380 2009/03/17 00:39:31 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== 2009-03-?? (2.8.7dev.14) +* adapt features from vile's install-script to set registry variables, etc. -TD +* modify LYgetenv() for Win32 platforms to check also in the system registry + for settings, adapted from vile -TD * modify SGML_write() to check for UCS-2 BOMs, to provide support for UCS-2 pages (prompted by comment by TG) -TD * modify SGML_write() to check for UTF-8 BOM, using that as a hint to set the diff --git a/PACKAGE/lynx.iss b/PACKAGE/lynx.iss index 977918da..abba54f6 100644 --- a/PACKAGE/lynx.iss +++ b/PACKAGE/lynx.iss @@ -1,4 +1,5 @@ -; $LynxId: lynx.iss,v 1.1 2008/12/29 13:27:28 tom Exp $ +; $LynxId: lynx.iss,v 1.2 2009/03/17 00:25:56 tom Exp $ +; vile:ts=2 sw=2 notabinsert ; ; This is the BASE script for different flavors of the installer for Lynx. ; It can be overridden to select different source-executables (and their associated @@ -18,6 +19,8 @@ #define MyAppExeName "lynx.exe" #endif +#define MySendTo '{sendto}\' + myAppName + '.lnk' + #ifndef SourceExeName #define SourceExeName "lynx.exe" #endif @@ -80,8 +83,17 @@ SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" +[Components] +Name: main; Description: The Lynx executable; types: full custom compact +Name: explorer; Description: Windows Explorer integration; types: full custom + [Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: for_all_users; Description: Install for all users on this machine; GroupDescription: Configuration Settings; Components: main; Check: isGuru; Flags: unchecked +Name: register_vars; Description: Use registry for environment variables; GroupDescription: Configuration Settings; Components: main; Flags: unchecked +Name: use_sendto; Description: Add Send To Entry; GroupDescription: Windows Explorer; Components: explorer; Flags: unchecked +Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Components: main; Flags: unchecked +Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Components: main; Flags: unchecked + [Dirs] Name: "{app}\doc" @@ -93,7 +105,7 @@ Name: "{app}\icon" Name: "{app}\tmp" [Files] -#emit 'Source: "' + BinsSrcDir + '\' + SourceExeName + '"; DestDir: "{app}"; DestName: ' + MyAppExeName + '; Flags: ignoreversion' +#emit 'Source: "' + BinsSrcDir + '\' + SourceExeName + '"; DestDir: "{app}"; DestName: ' + MyAppExeName + '; AfterInstall: myPostExecutable; Flags: ignoreversion' #ifndef NoScreenDll #emit 'Source: "' + DllsSrcDir + '\' + ScreenDllName + '"; DestDir: "{app}"; DestName: ' + ScreenDllName + '; Flags: ignoreversion' #endif @@ -124,3 +136,206 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait postinstall skipifsilent +[UninstallDelete] +Type: files; Name: {app}\.lynx_cookies +Type: dirifempty; Name: {app} +#emit 'Type: files; Name: ' + mySendTo + +[Code] +#emit 'const MY_APP_NAME = ''{app}\' + myAppName + '.exe'';' + +function isGuru(): Boolean; +begin + Result := isAdminLoggedOn(); +end; + +function environRootKey(): Integer; +begin + Result := HKEY_CURRENT_USER; +end; + +function appKey(): string; +begin + Result := 'Software\Lynx'; +end; + +function envSubKey(): string; +begin + Result := 'Environment'; +end; + +function appSubKey(): string; +begin + Result := appKey() + '\' + envSubKey(); +end; + +function envSysKey(): string; +begin + Result := 'System\CurrentControlSet\Control\Session Manager\Environment'; +end; + +// Set the environment variable ValueName. +procedure addVarToEnv(const RootKey: Integer; const SubKeyName, ValueName, toAdd: String); +var + Updated : string; +begin + Updated := ExpandConstant(toAdd); + RegWriteStringValue(RootKey, SubKeyName, ValueName, Updated); + Log('Added ' + toAdd + ' to ' + ValueName); + // MsgBox('addVarToEnv: ' #13#13 + ValueName + '="' + Updated + '"', mbInformation, MB_OK) +end; + +// Remove the given environment variable ValueName. +function removeVarFromEnv(const RootKey: Integer; const SubKeyName, ValueName: String): Boolean; +var + Current : string; +begin + Result := False; + if RegQueryStringValue(RootKey, SubKeyName, ValueName, Current) then + begin + RegDeleteValue(RootKey, SubKeyName, ValueName); + Result := True; + Log('Removed ' + ValueName); + // MsgBox('removeVarFromEnv: ' #13#13 + ValueName + '="' + Current + '"', mbInformation, MB_OK) + end; +end; + +function selectedVarsRootKey(): Integer; +begin + if isTaskSelected('for_all_users') then + Result := HKEY_LOCAL_MACHINE + else + Result := HKEY_CURRENT_USER; +end; + +function selectedVarsSubKey(): String; +begin + if isTaskSelected('for_all_users') then + begin + if isTaskSelected('register_vars') then + Result := appSubKey() + else + Result := envSysKey(); + end else + begin + if isTaskSelected('register_vars') then + Result := appSubKey() + else + Result := envSubKey(); + end; +end; + +procedure addAnyVariable(const ValueName, newValue: String); +begin + addVarToEnv(selectedVarsRootKey(), selectedVarsSubKey(), ValueName, NewValue); +end; + +// FIXME: should only remove if it matches the installer's value +procedure removeAnyVariable(const ValueName: String); +begin + removeVarFromEnv(HKEY_CURRENT_USER, envSubKey(), ValueName); + removeVarFromEnv(HKEY_CURRENT_USER, appSubKey(), ValueName); + removeVarFromEnv(HKEY_LOCAL_MACHINE, appSubKey(), ValueName); + removeVarFromEnv(HKEY_LOCAL_MACHINE, envSysKey(), ValueName); +end; + +// http://www.delphidabbler.com/articles?article=12 +procedure AddSendTo(); +begin + CreateShellLink( +#emit 'ExpandConstant(''' + MySendTo + '''),' +#emit '''SendTo link for ' + myAppName + ''',' + ExpandConstant(MY_APP_NAME), // program + '', // option(s) will be followed by pathname + '', // no target directory + '', // no icon filename + -1, // no icon index + SW_SHOWNORMAL); +end; + +// This is called after installing the executable. +procedure myPostExecutable(); +var + Keypath : String; + AppDir : String; +begin + Keypath := appKey(); + AppDir := ExpandConstant('{app}'); + Log('Setting registry key "' + Keypath + '" to "' + AppDir + '"'); + if not RegWriteStringValue(selectedVarsRootKey(), Keypath, '', AppDir) then + Log('Failed to set key'); + + addAnyVariable('LYNX_CFG', AppDir + '/lynx.cfg'); + addAnyVariable('LYNX_LSS', AppDir + '/opaque.lss'); + addAnyVariable('LYNX_HELPFILE', AppDir + '/help/Lynx_users_guide.html.gz'); + + if isTaskSelected('use_sendto') then + begin + AddSendTo(); + end; +end; + +function CleanupMyKey(const theRootKey: Integer): Boolean; +var + Path : String; + Value : String; +begin + Result := False; + if RegQueryStringValue(theRootKey, appKey(), '', Value) then + begin + if Value <> '' then + begin + Result := True; + Log('Deleting value of "' + appKey() + '" = "' + Value + '"'); + if not RegDeleteValue(theRootKey, appKey(), '') then + Log('Failed to delete value'); + + Path := appKey() + '\Environment'; + Log('Checking for subkey "' + Path + '"'); + if RegValueExists(theRootKey, Path, '') then + begin + if RegDeleteKeyIncludingSubkeys(theRootKey, Path) then + Log('Deleted key "' + Path + '"') + else + Log('Failed to delete key "' + Path + '"'); + end; + + if RegDeleteKeyIfEmpty(theRootKey, appKey()) then + Log('Deleted key "' + appKey() + '"') + else + Log('Failed to delete key "' + appKey() + '"'); + end + end +end; + +// On uninstall, we do not know which registry setting was selected during install, so we remove all. +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + case CurUninstallStep of + usUninstall: + begin + // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall is about to start.', mbInformation, MB_OK) + // ...insert code to perform pre-uninstall tasks here... + end; + usPostUninstall: + begin + removeAnyVariable('LYNX_CFG'); + removeAnyVariable('LYNX_LSS'); + removeAnyVariable('LYNX_HELPFILE'); + + { + If we don't find the settings in the current user, try the local machine. + The setup program cannot pass the all-users flag to the uninstaller, so we + have to try both. + } + Log('Checking current-user registry key'); + if not CleanupMyKey(HKEY_CURRENT_USER) then + begin + Log('Checking local-machine registry key'); + CleanupMyKey(HKEY_LOCAL_MACHINE); + end; + + // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK); + end; + end; +end; diff --git a/lib/dirent.c b/lib/dirent.c index 3a92a6b1..3a19cfe5 100644 --- a/lib/dirent.c +++ b/lib/dirent.c @@ -1,5 +1,5 @@ /* - * $LynxId: dirent.c,v 1.2 2007/06/29 23:03:08 tom Exp $ + * $LynxId: dirent.c,v 1.3 2009/03/11 00:31:33 tom Exp $ * * dir.c for MS-DOS by Samuel Lam <skl@van-bc.UUCP>, June/87 */ @@ -199,7 +199,7 @@ struct dirent *readdir(DIR * dirp) dp.d_namlen = dp.d_reclen = strlen(dp.d_name); - dp.d_ino = dirp->dd_loc + 1; /* fake the inode */ + dp.d_ino = (ino_t) (dirp->dd_loc + 1); /* fake the inode */ dirp->dd_cp = dirp->dd_cp->_d_next; dirp->dd_loc++; diff --git a/src/LYUtils.c b/src/LYUtils.c index e5253db9..e55bcc11 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.182 2009/01/01 23:59:34 tom Exp $ + * $LynxId: LYUtils.c,v 1.183 2009/03/17 00:40:24 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -214,6 +214,31 @@ static LY_TEMP *FindTempfileByFP(FILE *fp) return p; } +#if defined(_WIN32) +/* + * Use RegQueryValueExA() rather than RegQueryValueEx() for compatibility + * with non-Unicode winvile + */ +int w32_get_reg_sz(HKEY hkey, const char *name, char *value, unsigned length) +{ + int result; + DWORD dwSzBuffer = length; + + CTRACE((tfp, "w32_get_reg_sz(%s)\n", name)); + result = RegQueryValueExA(hkey, + name, + NULL, + NULL, + (LPBYTE) value, + &dwSzBuffer); + if (result == ERROR_SUCCESS) { + value[dwSzBuffer] = 0; + CTRACE((tfp, "->%s\n", value)); + } + return result; +} +#endif + /* * Get an environment variable, rejecting empty strings */ @@ -221,6 +246,33 @@ char *LYGetEnv(const char *name) { char *result = getenv(name); +#if defined(_WIN32) + if (result == 0) { + static HKEY rootkeys[] = + {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE}; + + int j; + HKEY hkey; + char buffer[256]; + + for (j = 0; j < TABLESIZE(rootkeys); ++j) { + if (RegOpenKeyEx(rootkeys[j], + LYNX_SUBKEY W32_STRING("\\Environment"), + 0, + KEY_READ, + &hkey) == ERROR_SUCCESS) { + if (w32_get_reg_sz(hkey, name, buffer, sizeof(buffer)) == ERROR_SUCCESS) { + + result = strdup(buffer); + (void) RegCloseKey(hkey); + break; + } + + (void) RegCloseKey(hkey); + } + } + } +#endif return non_empty(result) ? result : 0; } diff --git a/src/UCdomap.c b/src/UCdomap.c index 48e91264..ad0a614c 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCdomap.c,v 1.75 2009/01/18 23:19:37 tom Exp $ + * $LynxId: UCdomap.c,v 1.76 2009/03/16 22:41:41 tom Exp $ * * UCdomap.c * ========= @@ -2354,9 +2354,9 @@ static char *nl_langinfo(nl_item item) if (item != CODESET) return NULL; - if (((l = getenv("LC_ALL")) && *l) || - ((l = getenv("LC_CTYPE")) && *l) || - ((l = getenv("LANG")) && *l)) { + if (((l = LYgetenv("LC_ALL")) != 0) || + ((l = LYgetenv("LC_CTYPE")) != 0) || + ((l = LYgetenv("LANG")) != 0)) { /* check standardized locales */ if (!strcmp(l, "C") || !strcmp(l, "POSIX")) return C_CODESET; diff --git a/userdefs.h b/userdefs.h index e43c62ec..6b143dab 100644 --- a/userdefs.h +++ b/userdefs.h @@ -1,5 +1,5 @@ /* - * $LynxId: userdefs.h,v 1.241 2009/02/02 01:50:56 tom Exp $ + * $LynxId: userdefs.h,v 1.242 2009/03/16 22:34:12 tom Exp $ * * Lynx - Hypertext navigation system * @@ -1428,6 +1428,14 @@ #define LYNX_DATE_OFF 5 /* truncate the automatically-generated date */ #define LYNX_DATE_LEN 11 /* truncate the automatically-generated date */ +#ifdef UNICODE +#define W32_STRING(s) L##s +#else +#define W32_STRING(s) s +#endif + +#define LYNX_SUBKEY W32_STRING("Software\\Lynx") + #define LINESIZE 1024 /* max length of line to read from file */ #define MAXLINKS 1024 /* max links on one screen */ |