Add support for -config-dir command line flag. That means mozilla can now

use a configdir other that ~/.netscape without having to do HOME environment
hacks.
Thanks to Aleksey Nogin (ayn2@cornell.edu) for doing all the work and being
patient for me to actually check the stuff in.
This commit is contained in:
ramiro%netscape.com 1998-09-02 14:29:42 +00:00
Родитель bb022be61f
Коммит b16a2d8da2
13 изменённых файлов: 285 добавлений и 258 удалений

Просмотреть файл

@ -75,39 +75,43 @@ void FE_InitAddrBook()
{
static XP_List *directories = NULL;
char oldFile[1024];
char *oldFile;
XP_File oldFp = 0;
char tmp[1024];
char *tmp2;
char *home = getenv("HOME");
/*DIR_Server *dir;*/
if (!home) home = "";
PR_snprintf(oldFile, sizeof (oldFile), "%.900s/.netscape/addrbook.db", home);
oldFp = XP_FileOpen(oldFile, xpAddrBook, "r");
if (oldFp) {
char newFile[256];
XP_File newFp = 0;
oldFile = fe_GetConfigDirFilename("addrbook.db");
if (oldFile) {
oldFp = XP_FileOpen(oldFile, xpAddrBook, "r");
if (oldFp) {
char newFile[256];
XP_File newFp = 0;
/* extern int XP_FileClose(XP_File file);
*/
XP_FileClose(oldFp);
PR_snprintf(newFile, sizeof (newFile), "%s", "abook.nab");
newFp = XP_FileOpen(newFile, xpAddrBookNew, "r");
if (!newFp) {
/* Rename file for backward compatibility reason
* extern int XP_FileRename(const char * from, XP_FileType fromtype,
* const char * to, XP_FileType totype);
/* extern int XP_FileClose(XP_File file);
*/
XP_FileRename(oldFile, xpAddrBook,
newFile, xpAddrBookNew);
}/* !newFp */
else
XP_FileClose(newFp);
XP_FileClose(oldFp);
PR_snprintf(newFile, sizeof (newFile), "%s", "abook.nab");
newFp = XP_FileOpen(newFile, xpAddrBookNew, "r");
if (!newFp) {
/* Rename file for backward compatibility reason
* extern int XP_FileRename(const char * from, XP_FileType fromtype,
* const char * to, XP_FileType totype);
*/
XP_FileRename(oldFile, xpAddrBook,
newFile, xpAddrBookNew);
}/* !newFp */
else
XP_FileClose(newFp);
}/* if */
}/* if */
free(oldFile);
}
/* all right, lets do the list of directories and stuff */
directories = XP_ListNew();
@ -117,14 +121,17 @@ void FE_InitAddrBook()
PR_snprintf(tmp, sizeof (tmp), "abook.nab");
DIR_GetServerPreferences (&directories, tmp);
PR_snprintf(tmp, sizeof (tmp),
"%.900s/.netscape/address-book.html", home);
tmp2 = fe_GetConfigDirFilename("address-book.html");
if (tmp2)
{
{
#ifndef MOZ_NEWADDR
DIR_Server *pabDir = NULL;
DIR_GetPersonalAddressBook(directories, &pabDir);
AB_InitializeAddressBook(pabDir, &AddrBook, tmp);
DIR_Server *pabDir = NULL;
DIR_GetPersonalAddressBook(directories, &pabDir);
AB_InitializeAddressBook(pabDir, &AddrBook, tmp);
#endif
}
free (tmp2);
}
}

Просмотреть файл

@ -1874,18 +1874,16 @@ int fe_WebfontsNeedReload(MWContext *context)
void fe_ShutdownWebfonts(void)
{
char buf[MAXPATHLEN];
char *home = NULL;
char *buf;
/* Load Catalog */
if (home = getenv("HOME"))
/* Form "$HOME/.netscape/dynfonts/fonts.cat" into buf */
buf = fe_GetConfigDirFilename("dynfonts/fonts.cat");
if (buf)
{
/* Form "$HOME/.netscape/dynfonts/fonts.cat" into buf */
strncpy(buf, home, sizeof(buf)-1);
strncat(buf, "/.netscape/dynfonts/fonts.cat",
sizeof(buf)-1 - strlen(buf));
buf[sizeof(buf)-1] = '\0';
nffbu_SaveCatalog(fe_FontUtility, buf, NULL);
nffbu_SaveCatalog(fe_FontUtility, buf, NULL);
free(buf);
}
}
@ -3794,7 +3792,6 @@ fe_loadUnicodePseudoFonts(Display *dpy, char *my_origFamily, int my_pitch)
#ifndef NO_WEB_FONTS
#define WF_FONT_DISPLAYER_PATH_1 "~/.netscape/dynfonts"
#define WF_FONT_DISPLAYER_PATH_4 "/usr/local/lib/netscape/dynfonts"
/* This static is outside of fe_InitializeWebfonts() 'cause HPUX has a
@ -3810,7 +3807,7 @@ fe_InitializeWebfonts(void)
struct nffbp *fbp;
char buf[MAXPATHLEN];
char *mozilla_home = NULL;
char *home = NULL;
char *pathname;
/* Initialize and obtain the font broker and font utility provider. */
fe_FontBroker = NF_FontBrokerInitialize();
@ -3818,14 +3815,13 @@ fe_InitializeWebfonts(void)
nffbc_getInterface(fe_FontBroker, &nffbu_ID, NULL);
/* Load Catalog */
if (home = getenv("HOME"))
/* Form "$HOME/.netscape/dynfonts/fonts.cat" into buf */
pathname = fe_GetConfigDirFilename("dynfonts/fonts.cat");
if (pathname)
{
/* Form "$HOME/.netscape/dynfonts/fonts.cat" into buf */
strncpy(buf, home, sizeof(buf)-1);
strncat(buf, "/.netscape/dynfonts/fonts.cat",
sizeof(buf)-1 - strlen(buf));
buf[sizeof(buf)-1] = '\0';
nffbu_LoadCatalog(fe_FontUtility, buf, NULL);
nffbu_LoadCatalog(fe_FontUtility, pathname, NULL);
free(pathname);
}
/* Load all font displayers */
@ -3843,7 +3839,10 @@ fe_InitializeWebfonts(void)
* the same name exists in more than one directory, then the
* first one takes priority.
*/
nffbp_ScanForFontDisplayers(fbp, WF_FONT_DISPLAYER_PATH_1, NULL);
/* WF_FONT_DISPLAYER_PATH_1 */
pathname = fe_GetConfigDirFilename("dynfonts");
nffbp_ScanForFontDisplayers(fbp, pathname, NULL);
free(pathname);
/* WF_FONT_DISPLAYER_PATH_2 */
if (mozilla_home = getenv("MOZILLA_HOME"))

Просмотреть файл

@ -386,6 +386,10 @@ static XrmOptionDescRec options [] = {
{ "-no-irix-session-management", ".irixSessionManagement", XrmoptionNoArg, "False" },
{ "-dont-force-window-stacking", ".dontForceWindowStacking", XrmoptionNoArg, "True" },
/* The location of the config dir ($HOME/.netscape by default) */
{ "-config-dir", ".configDir", XrmoptionSepArg, NULL },
};
extern char *fe_fallbackResources[];
@ -860,9 +864,14 @@ XtResource fe_GlobalResources [] =
#if (defined(IRIX) && !defined(IRIX6_2) && !defined(IRIX6_3))
(XtPointer) False },
#else
(XtPointer) True }
(XtPointer) True },
#endif
/* The location of the config dir ($HOME/.netscape by default) */
{ "configDir", XtCString, XtRString, sizeof (String),
XtOffset (fe_GlobalData *, config_dir), XtRString,
".netscape" },
# undef RES_ERROR
};
Cardinal fe_GlobalResourcesSize = XtNumber (fe_GlobalResources);
@ -890,6 +899,36 @@ usage (void)
fprintf (stderr, XP_GetString( XFE_USAGE_MSG5 ) );
}
char *fe_GetConfigDirFilename(char *filename)
{
return fe_GetConfigDirFilenameWithPrefix("", filename);
}
char *fe_GetConfigDirFilenameWithPrefix(char *prefix, char *filename)
{
return PR_smprintf("%s%s/%s", prefix, fe_GetConfigDir(), filename);
}
char *fe_GetConfigDir(void)
{
char *result, *home;
home = getenv("HOME");
if(!home) {
struct passwd *pw = getpwuid(getuid());
home = pw ? pw->pw_dir : "/";
}
if(fe_globalData.config_dir) {
result = PR_smprintf("%s/%s", home, fe_globalData.config_dir);
} else {
result = PR_smprintf("%s/.netscape", home);
}
return result;
}
/*******************
* Signal handlers *
*******************/
@ -1839,7 +1878,7 @@ Display *fe_dpy_kludge;
Screen *fe_screen_kludge;
static char *fe_home_dir;
static char *fe_config_dir;
static char *fe_config_dir = 0;
/*
* build_simple_user_agent_string
@ -2404,21 +2443,28 @@ main
while ((slash = strrchr(fe_home_dir, '/')) && slash[1] == '\0')
*slash = '\0';
}
toplevel = XtAppInitialize (&fe_XtAppContext, (char *) fe_progclass, options,
sizeof (options) / sizeof (options [0]),
&argc, argv, fe_fallbackResources, 0, 0);
fe_InitializeGlobalResources(toplevel);
fe_ensure_config_dir_exists(toplevel);
{
char buf [1024];
char buf [1024];
int32 profile_age;
XP_StatStruct statPrefs;
int status;
PR_snprintf (buf, sizeof (buf), "%s/%s", fe_home_dir,
#ifdef OLD_UNIX_FILES
".netscape-preferences"
#else
".netscape/preferences.js"
#endif
);
PR_snprintf (buf, sizeof (buf), "%s/%s", fe_home_dir, ".netscape-preferences");
fe_globalData.user_prefs_file = strdup (buf);
#else
fe_globalData.user_prefs_file = fe_GetConfigDirFilename("preferences.js");
PR_snprintf (buf, sizeof (buf), "%s", fe_globalData.user_prefs_file);
#endif
/* check if preferences previously existed */
status=XP_Stat(buf, &statPrefs, xpUserPrefs);
@ -2457,12 +2503,6 @@ main
#endif /* MOZ_FULLCIRCLE */
toplevel = XtAppInitialize (&fe_XtAppContext, (char *) fe_progclass, options,
sizeof (options) / sizeof (options [0]),
&argc, argv, fe_fallbackResources, 0, 0);
FE_SetToplevelWidget(toplevel);
/* we need to set the drag/drop protocol style to dynamic
@ -2690,7 +2730,7 @@ main
unsigned long addr;
pid_t pid;
name = PR_smprintf ("%s/lock", fe_config_dir);
name = fe_GetConfigDirFilename("lock");
addr = 0;
pid = 0;
if (name == NULL)
@ -2707,6 +2747,10 @@ main
else
{
char *fmt = NULL;
/* the hardcoded value below is only used if memory couldn't be */
/* allocated for the real filename. extremely unlikely, and */
/* if it happens, the program should probably just crash anyway */
/* because it's not going to be able to do much else. */
char *lock = name ? name : ".netscape/lock";
fmt = PR_sprintf_append(fmt, XP_GetString(XFE_APP_HAS_DETECTED_LOCK),
@ -2775,7 +2819,11 @@ main
sigfillset(&act.sa_mask);
sigaction (SIGCHLD, &act, NULL);
fe_InitializeGlobalResources (toplevel);
/* Add a timer to periodically flush out the global history and bookmark. */
fe_save_history_timer ((XtPointer) ((int) True), 0);
/* #### move to prefs */
LO_SetUserOverride (!fe_globalData.document_beats_user_p);
#ifndef OLD_UNIX_FILES
@ -2821,11 +2869,14 @@ main
}
{
char buf [1024];
PR_snprintf (buf, sizeof (buf), "%s/%s", fe_home_dir, ".netscape/user.js");
PREF_ReadUserJSFile(buf);
PR_snprintf (buf, sizeof (buf), "%s/%s", fe_home_dir, ".netscape/hook.js");
HK_ReadHookFile(buf);
char *buf;
buf = fe_GetConfigDirFilename("user.js");
PREF_ReadUserJSFile(buf);
free(buf);
buf = fe_GetConfigDirFilename("hooks.js");
HK_ReadHookFile(buf);
free(buf);
}
fe_startDisplayFactory(toplevel);
@ -3576,7 +3627,10 @@ fe_ensure_config_dir_exists (Widget toplevel)
struct stat st;
XP_Bool exists;
dir = PR_smprintf ("%s/.netscape", fe_home_dir);
if(fe_config_dir)
return TRUE;
dir = fe_GetConfigDir();
if (!dir)
return FALSE;
@ -3838,44 +3892,63 @@ fe_copy_init_files (Widget toplevel)
return;
PR_snprintf (file1, sizeof (file1), "%s/", fe_home_dir);
strcpy (file2, file1);
PR_snprintf (file2, sizeof (file2), "%s/%s/", fe_home_dir, fe_globalData.config_dir);
s1 = file1 + strlen (file1);
s2 = file2 + strlen (file2);
#define FROB(OLD1, OLD2, NEW, PERMS) \
strcpy (s1, OLD1); \
strcpy (s2, NEW); \
if (!stat (file2, &st2)) \
; /* new exists - leave it alone */ \
else if (!stat (file1, &st1)) \
{ \
fe_copied_init_files = TRUE; \
fe_copy_file (toplevel, file1, file2, 0); \
} \
else \
{ \
strcpy (s1, OLD2); \
if (!stat (file1, &st1)) \
{ \
fe_copied_init_files = TRUE; \
fe_copy_file (toplevel, file1, file2, 0); \
} \
#define FROB(NEW, OLD1, OLD2, OLD3, PERMS) \
strcpy (s1, OLD1); \
strcpy (s2, NEW); \
if (!stat (file2, &st2)) \
; /* new exists - leave it alone */ \
else if (!stat (file1, &st1)) \
{ \
fe_copied_init_files = TRUE; \
fe_copy_file (toplevel, file1, file2, PERMS); \
} \
else if (OLD2!=NULL) \
{ \
strcpy (s1, OLD2); \
if (!stat (file1, &st1)) \
{ \
fe_copied_init_files = TRUE; \
fe_copy_file (toplevel, file1, file2, PERMS); \
} \
else if (OLD3!=NULL) \
{ \
strcpy (s1, OLD3); \
if (!stat (file1, &st1)) \
{ \
fe_copied_init_files = TRUE; \
fe_copy_file (toplevel, file1, file2, PERMS); \
} \
} \
}
FROB(".netscape-preferences",
FROB("preferences",
"./netscape/preferences",
".netscape-preferences",
".MCOM-preferences",
".netscape/preferences",
0)
FROB(".netscape-bookmarks.html",
".MCOM-bookmarks.html",
".netscape/bookmarks.html",
0)
FROB(".netscape-cookies",
".MCOM-HTTP-cookie-file",
".netscape/cookies",
(S_IRUSR | S_IWUSR)) /* rw only by owner */
FROB("bookmarks.html",
".netscape/bookmarks.html",
".netscape-bookmarks.html",
".MCOM-bookmarks.html",
(S_IRUSR | S_IWUSR))
FROB("cookies",
".netscape/cookies",
".netscape-cookies",
".MCOM-HTTP-cookie-file",
(S_IRUSR | S_IWUSR))
FROB("preferences.js",
".netscape/preferences.js",
NULL,
NULL,
(S_IRUSR | S_IWUSR))
#undef FROB
}
@ -3910,8 +3983,7 @@ fe_clean_old_init_files (Widget toplevel)
/* spider begin */
/* TODO: where does this string get free'd? */
if (fe_globalPrefs.sar_cache_dir) free (fe_globalPrefs.sar_cache_dir);
PR_snprintf (buf, sizeof (buf), "%s/.netscape/archive/", fe_home_dir);
fe_globalPrefs.sar_cache_dir = strdup (buf);
fe_globalPrefs.sar_cache_dir = fe_GetConfigDirFilename("archive/");
/* spider end */
if (!fe_copied_init_files)
@ -3920,12 +3992,10 @@ fe_clean_old_init_files (Widget toplevel)
/* History and cache always go in the new place by default,
no matter what they were set to before. */
if (fe_globalPrefs.history_file) free (fe_globalPrefs.history_file);
PR_snprintf (buf, sizeof (buf), "%s/.netscape/history.db", fe_home_dir);
fe_globalPrefs.history_file = strdup (buf);
fe_globalPrefs.history_file = fe_GetConfigDirFilename("history.db");
if (fe_globalPrefs.cache_dir) free (fe_globalPrefs.cache_dir);
PR_snprintf (buf, sizeof (buf), "%s/.netscape/cache/", fe_home_dir);
fe_globalPrefs.cache_dir = strdup (buf);
fe_globalPrefs.cache_dir = fe_GetConfigDirFilename("cache/");
/* If they were already keeping their bookmarks file in a different
place, don't change that preferences setting. */
@ -3934,9 +4004,7 @@ fe_clean_old_init_files (Widget toplevel)
!XP_STRCMP (fe_globalPrefs.bookmark_file, buf))
{
if (fe_globalPrefs.bookmark_file) free (fe_globalPrefs.bookmark_file);
PR_snprintf (buf, sizeof (buf), "%s/.netscape/bookmarks.html",
fe_home_dir);
fe_globalPrefs.bookmark_file = strdup (buf);
fe_globalPrefs.bookmark_file = fe_GetConfigDirFilename("bookmarks.html");
}
/* If their home page was set to their bookmarks file (and that was
@ -3947,9 +4015,9 @@ fe_clean_old_init_files (Widget toplevel)
!XP_STRCMP (fe_globalPrefs.home_document, buf))
{
if (fe_globalPrefs.home_document) free (fe_globalPrefs.home_document);
PR_snprintf (buf, sizeof (buf), "file:%s/.netscape/bookmarks.html",
fe_home_dir);
fe_globalPrefs.home_document = strdup (buf);
fe_globalPrefs.home_document =
fe_GetConfigDirFilenameWithPrefix("file:", /* or "file://"? */
"bookmarks.html");
}
fe_copied_init_files = FALSE;

Просмотреть файл

@ -1071,38 +1071,6 @@ xfeUndefinedKeyAction(Widget w,
XBell(XtDisplay(w), 0);
}
// Stole this from xp_file.c
static const char *
fe_config_directory(char* buf)
{
static XP_Bool initted = FALSE;
const char *dir = ".netscape";
char *home;
if (initted)
return buf;
home = getenv ("HOME");
if (!home)
home = "";
#ifdef OLD_UNIX_FILES
sprintf (buf, "%.900s", home);
if (buf[strlen(buf)-1] == '/')
buf[strlen(buf)-1] = 0;
#else /* !OLD_UNIX_FILES */
if (*home && home[strlen(home)-1] == '/')
sprintf (buf, "%.900s%s", home, dir);
else
sprintf (buf, "%.900s/%s", home, dir);
#endif /* !OLD_UNIX_FILES */
return buf;
}
typedef enum {
XFE_STAT_ISDIR,
XFE_STAT_ISREG
@ -1210,8 +1178,7 @@ char * FE_GetNetHelpDir()
#endif
int filePrefixLen;
char *nethelpSuffix = "nethelp/";
static char configBuf[1024];
const char *conf_dir = fe_config_directory(configBuf);
char *conf_dir = fe_GetConfigDir();
char *helpPath = getenv("NS_NETHELP_PATH");
char *mozHome = getenv("MOZILLA_HOME");
char *lang = getenv("LANG");
@ -1238,6 +1205,7 @@ char * FE_GetNetHelpDir()
// Found it - result already copied into nethelpDir
;
}
free(conf_dir);
// Found it or not, we return a valid URL
return XP_STRDUP(nethelpDir);

Просмотреть файл

@ -154,6 +154,7 @@ xfe_netcaster_path(void)
* Netcaster by checking
* the following locations in order:
* $HOME/.netscape/netcast/tab.htm
* (now <configdir>/netcast/tab.htm)
* $MOZILLA_HOME/netcast/tab.htm
* Version Registry via VR_GetPath()
* fe_GetProgramDirectory()/netcast/tab.htm
@ -192,16 +193,7 @@ xfe_netcaster_path(void)
char * home;
REGERR code;
if (!private_xfe_netcaster_path)
{
private_xfe_netcaster_path = (char*)XP_ALLOC(MAXPATHLEN);
if (private_xfe_netcaster_path)
private_xfe_netcaster_path[0] = '\0';
else
return result;
}
if (private_xfe_netcaster_path[0])
if (private_xfe_netcaster_path && private_xfe_netcaster_path[0])
{
result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
@ -210,28 +202,29 @@ xfe_netcaster_path(void)
return result;
}
/* who knows what was here before */
if (private_xfe_netcaster_path)
XP_FREE(private_xfe_netcaster_path);
//
// CHECK $HOME/.netscape
//
home = getenv("HOME");
if (home)
{
XP_STRCPY(private_xfe_netcaster_path, home);
if (xfe_last_character(private_xfe_netcaster_path) != '/')
XP_STRCAT(private_xfe_netcaster_path,"/");
XP_STRCAT(private_xfe_netcaster_path,".netscape/");
XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath);
if (xfe_path_exists(private_xfe_netcaster_path))
{
result = private_xfe_netcaster_path;
private_xfe_netcaster_path = fe_GetConfigDirFilename(netcasterTabHtmlPath);
if (private_xfe_netcaster_path &&
xfe_path_exists(private_xfe_netcaster_path))
{
result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
printf("DEBUG_rodt: Netcaster path b %s\n",result);
printf("DEBUG_rodt: Netcaster path b %s\n",result);
#endif
return result;
}
}
return result;
}
private_xfe_netcaster_path = (char*)XP_ALLOC(MAXPATHLEN);
if (private_xfe_netcaster_path)
private_xfe_netcaster_path[0] = '\0';
else
return result;
//
// CHECK $MOZILLA_HOME

Просмотреть файл

@ -412,25 +412,17 @@ XFE_SpellHandler::nukeSpellChecker()
char *
XFE_SpellHandler::getSpellCheckerDir()
{
char *home = NULL;
char *configdir_spelldir;
char *mozilla_home = NULL;
char buf[MAXPATHLEN];
if (home = getenv("HOME")) {
XP_MEMSET(buf, '\0', sizeof(buf));
// Form "$HOME/.netscape/spell/" into buf...
//
XP_STRNCPY_SAFE(buf, home, sizeof(buf)-1);
XP_STRNCAT_SAFE(buf, "/.netscape/spell/",
sizeof(buf)-1 - XP_STRLEN(buf));
buf[sizeof(buf)-1] = '\0';
if (fe_isDir(buf)) {
return XP_STRDUP(buf);
}
}
// check the "$HOME/.netscape"-type directory
configdir_spelldir = fe_GetConfigDirFilename("spell/");
if(configdir_spelldir) {
if(fe_isDir(configdir_spelldir))
return configdir_spelldir;
free(configdir_spelldir);
}
if (mozilla_home = getenv("MOZILLA_HOME")) {
XP_MEMSET(buf, '\0', sizeof(buf));
@ -478,19 +470,7 @@ XFE_SpellHandler::getSpellCheckerDir()
char *
XFE_SpellHandler::getPersonalDicPath()
{
char buf[MAXPATHLEN];
char *home = NULL;
if (home = getenv("HOME"))
{
/* Form "$HOME/.netscape/custom.dic" into buf */
XP_STRNCPY_SAFE(buf, home, sizeof(buf)-1);
XP_STRNCAT_SAFE(buf, "/.netscape/custom.dic",
sizeof(buf)-1 - XP_STRLEN(buf));
buf[sizeof(buf)-1] = '\0';
}
return XP_STRDUP(buf);
return fe_GetConfigDirFilename("custom.dic");
}
XP_Bool

Просмотреть файл

@ -771,14 +771,15 @@ static void dumpPluginInfo(NPX_PlugIn *info)
void FE_RegisterPlugins()
{
#ifdef X_PLUGINS
char filename[MAXPATHLEN];
char newFilename[MAXPATHLEN];
char oldFilename[MAXPATHLEN];
char *filename;
char *newFilename;
char *oldFilename;
char *npxPluginPath = getenv("NPX_PLUGIN_PATH");
char *mozHome = getenv("MOZILLA_HOME");
char *pluginPath = NULL;
char *home = getenv ("HOME");
char *configdir_pluginsdir = fe_GetConfigDirFilename("plugins");
if (!home)
home = "";
else if (!strcmp (home, "/"))
@ -798,10 +799,10 @@ void FE_RegisterPlugins()
} else {
/* Stuff in $MOZILLA_HOME if it's defined. */
if(mozHome) {
pluginPath = PR_smprintf("%s:%s/plugins:%.900s/.netscape/plugins",
DEFAULT_LEGACY_PLUGIN_PATH,
mozHome,
home);
pluginPath = PR_smprintf("%s:%s/plugins:%s",
DEFAULT_LEGACY_PLUGIN_PATH,
mozHome,
configdir_pluginsdir);
} else {
/* Try to stuff argv[0] into the path */
char buf[MAXPATHLEN];
@ -811,16 +812,17 @@ void FE_RegisterPlugins()
strncat(buf, "plugins", sizeof(buf)-1 - strlen(buf));
buf[sizeof(buf)-1] = '\0';
pluginPath = PR_smprintf("%s:%s:%.900s/.netscape/plugins",
DEFAULT_LEGACY_PLUGIN_PATH,
buf,
home);
pluginPath = PR_smprintf("%s:%s:%s",
DEFAULT_LEGACY_PLUGIN_PATH,
buf,
configdir_pluginsdir);
}
}
free(configdir_pluginsdir);
PR_snprintf(filename, sizeof(filename), "%.900s/.netscape/plugin-list", home);
PR_snprintf(newFilename, sizeof(newFilename), "%.900s/.netscape/plugin-list.new", home);
PR_snprintf(oldFilename, sizeof(oldFilename), "%.900s/.netscape/plugin-list.BAK", home);
filename = fe_GetConfigDirFilename("plugin-list");
newFilename = fe_GetConfigDirFilename("plugin-list.new");
oldFilename = fe_GetConfigDirFilename("plugin-list.BAK");
if (pluginList == NULL) {
pluginList = getPluginList(32);
@ -833,7 +835,11 @@ void FE_RegisterPlugins()
rename(filename, oldFilename);
rename(newFilename, filename);
}
free(filename);
free(newFilename);
free(oldFilename);
if (!npxPluginPath)
XP_FREE(pluginPath); /* Free if we used PR_smprintf(). */

Просмотреть файл

@ -141,7 +141,7 @@ struct fe_MWContext_cons *fe_all_MWContexts = 0;
void fe_delete_cb (Widget, XtPointer, XtPointer);
static void fe_save_history_timer (XtPointer closure, XtIntervalId *id);
void fe_save_history_timer (XtPointer closure, XtIntervalId *id);
extern void fe_MakeAddressBookWidgets(Widget shell, MWContext *context);
extern void fe_ab_destroy_cb (Widget, XtPointer, XtPointer);
@ -1986,12 +1986,6 @@ fe_InitializeGlobalResources (Widget toplevel)
else
fe_globalData.wm_icon_policy = "color";
}
/* Add a timer to periodically flush out the global history and bookmark. */
fe_save_history_timer ((XtPointer) ((int) True), 0);
/* #### move to prefs */
LO_SetUserOverride (!fe_globalData.document_beats_user_p);
}
@ -2111,7 +2105,7 @@ fe_set_scrolled_default_size(MWContext *context)
}
static void
void
fe_save_history_timer (XtPointer closure, XtIntervalId *id)
{
Boolean init_only_p = (Boolean) ((int) closure);
@ -3382,10 +3376,17 @@ PRBool FE_HandleEmbedEvent(MWContext *context, LO_EmbedStruct *embed,
char* fe_GetLDAPTmpFile(char *name) {
char* home = getenv("HOME");
static char tmp[1024];
char *configdir;
if (!home) home = "";
if (!name) return NULL;
PR_snprintf(tmp, sizeof(tmp), "%.900s/.netscape/", home);
configdir = fe_GetConfigDirFilename("");
if (configdir)
{
strncpy(tmp, configdir, sizeof(tmp));
free(configdir);
} else snprintf(tmp, sizeof(tmp), "%.900s/.netscape/", home);
#ifdef _XP_TMP_FILENAME_FOR_LDAP_
/* we need to write this */

Просмотреть файл

@ -640,6 +640,12 @@ void fe_WidgetAddDocumentString(MWContext *context, Widget widget);
extern void fe_PrimarySelectionFetchURL(MWContext *context);
/* return the name of the config directory (e.g. ~/.netscape)
or files therein. */
extern char *fe_GetConfigDir(void);
extern char *fe_GetConfigDirFilename(char *filename);
extern char *fe_GetConfigDirFilenameWithPrefix(char *prefix, char *filename);
/*
* Search Callback
*/
@ -1474,6 +1480,9 @@ typedef struct
Boolean all_databases_locked;
Cardinal editor_update_delay;
/* The location of the config dir (~/.netscape by default) */
String config_dir;
} fe_GlobalData;
extern fe_GlobalData fe_globalData;

Просмотреть файл

@ -499,33 +499,20 @@ PUBLIC char *FE_SARCacheDir = 0;
PUBLIC char *FE_GlobalHist = 0;
/* these should probably be promoted to FE_* exported functions */
/* but then other front-ends would (kind of) be required to */
/* implement them. Unix front ends will already have to */
/* this or they will break--other front ends wouldn't have to */
/* necessarily implement the FE_* versions because they'll */
/* never be called. */
extern char *fe_GetConfigDir(void);
static const char *
xp_unix_config_directory(char* buf)
{
static XP_Bool initted = FALSE;
const char *dir = ".netscape";
char *home;
if (initted)
return buf;
home = getenv ("HOME");
if (!home)
home = "";
#ifdef OLD_UNIX_FILES
sprintf (buf, "%.900s", home);
if (buf[strlen(buf)-1] == '/')
buf[strlen(buf)-1] = 0;
#else /* !OLD_UNIX_FILES */
if (*home && home[strlen(home)-1] == '/')
sprintf (buf, "%.900s%s", home, dir);
else
sprintf (buf, "%.900s/%s", home, dir);
#endif /* !OLD_UNIX_FILES */
char *configdir = fe_GetConfigDir();
strcpy(buf, configdir);
free(configdir);
return buf;
}
@ -1136,7 +1123,6 @@ xp_FileName (const char *name, XP_FileType type, char* buf, char* configBuf)
char *policyFN = "moz40p3";
char *mozHome = getenv("MOZILLA_HOME");
char *lang = getenv("LANG");
int result;
char dirName[1024];
name = buf;

Просмотреть файл

@ -29,8 +29,6 @@ pref("mail.check_new_mail", true);
pref("mail.sort_by", 0);
pref("news.sort_by", 0);
pref("browser.startup.license_accepted", "");
pref("browser.cache.directory", "~/.netscape/cache");
pref("browser.sarcache.directory", "~/.netscape/sarcache");
pref("browser.cache.memory_cache_size", 3000);
pref("browser.cache.disk_cache_size", 5000);
pref("mail.directory", "~/nsmail/");
@ -57,9 +55,6 @@ pref("mail.sash_geometry", "");
pref("news.cache_xover", false);
pref("news.show_first_unread", false);
pref("news.sash_geometry", "");
pref("browser.bookmark_file", "~/.netscape/bookmarks.html");
pref("browser.history_file", "~/.netscape/history.db");
pref("browser.user_history_file", "~/.netscape/history.list");
pref("helpers.global_mime_types_file", "/usr/local/lib/netscape/mime.types");
pref("helpers.global_mailcap_file", "/usr/local/lib/netscape/mailcap");
pref("helpers.private_mime_types_file", "~/.mime.types");

Просмотреть файл

@ -40,6 +40,8 @@ static struct fe_icon_type* splash_screen = NULL;
* Needed by PREF_Init.
* Sets the default preferences.
*/
extern char *fe_GetConfigDirFilename(char *filename);
JSBool
pref_InitInitialObjects(void)
{
@ -49,6 +51,18 @@ pref_InitInitialObjects(void)
status = PREF_EvaluateJSBuffer(pref_init_buffer, strlen(pref_init_buffer));
/* these strings never get freed, but that's probably the way it should be */
PREF_SetDefaultCharPref("browser.cache.directory",
fe_GetConfigDirFilename("cache"));
PREF_SetDefaultCharPref("browser.sarcache.directory",
fe_GetConfigDirFilename("sarcache"));
PREF_SetDefaultCharPref("browser.bookmark_file",
fe_GetConfigDirFilename("bookmarks.html"));
PREF_SetDefaultCharPref("browser.history_file",
fe_GetConfigDirFilename("history.db"));
PREF_SetDefaultCharPref("browser.user_history_file",
fe_GetConfigDirFilename("history.list"));
#if defined(__sgi) || (defined(__sun) && defined(__svr4__))
PREF_SetDefaultCharPref("print.print_command", "lp");
#endif

Просмотреть файл

@ -52,6 +52,7 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
fe_GetProgramDirectory( Path, MAXPATHLEN-1 );
XP_STRCAT(Path, "plugins/");
directory = XP_STRDUP( Path );
}
else
{ /* Use local plugins path: $HOME/.netscape/plugins/ */
@ -61,9 +62,8 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
Home = "";
else if (!strcmp (Home, "/"))
Home = "";
PR_snprintf(Path, MAXPATHLEN, "%.900s/.netscape/plugins/", Home);
directory = fe_GetConfigDirFilename("plugins/");
}
directory = XP_STRDUP( Path );
}
break;
@ -131,6 +131,7 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
fe_GetProgramDirectory( Path, MAXPATHLEN-1 );
XP_STRCAT(Path, "java/download/");
directory = XP_STRDUP( Path );
}
else
{
@ -141,7 +142,7 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
else if (!strcmp (Home, "/"))
Home = "";
PR_snprintf(Path, MAXPATHLEN, "%.900s/.netscape/java/download/", Home);
directory = fe_GetConfigDirFilename("/java/download/");
}
directory = XP_STRDUP( Path );
}