summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-12-10 22:48:42 +0000
committerVincent Sanders <vince@kyllikki.org>2019-12-10 23:12:10 +0000
commit77d184913b64b1613ac70acb23c1230c5ec41e67 (patch)
treecb3c7e023def8a5047bf783c46a09172d460355e
parent56ddeed96c10bae6e67b7e15ee6fa982a0f40b3f (diff)
downloadnetsurf-77d184913b64b1613ac70acb23c1230c5ec41e67.tar.gz
netsurf-77d184913b64b1613ac70acb23c1230c5ec41e67.tar.bz2
rename global resource path variables in win32 frontend
-rw-r--r--frontends/windows/fetch.c2
-rw-r--r--frontends/windows/gui.c12
-rw-r--r--frontends/windows/gui.h17
-rw-r--r--frontends/windows/main.c37
-rw-r--r--frontends/windows/prefs.c2
5 files changed, 44 insertions, 26 deletions
diff --git a/frontends/windows/fetch.c b/frontends/windows/fetch.c
index f69d7ad19..287f20f6c 100644
--- a/frontends/windows/fetch.c
+++ b/frontends/windows/fetch.c
@@ -79,7 +79,7 @@ static nsurl *nsw32_get_resource_url(const char *path)
char buf[PATH_MAX];
nsurl *url = NULL;
- netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url);
+ netsurf_path_to_nsurl(filepath_sfind(G_resource_pathv, buf, path), &url);
return url;
}
diff --git a/frontends/windows/gui.c b/frontends/windows/gui.c
index 490f23433..fdfafcf42 100644
--- a/frontends/windows/gui.c
+++ b/frontends/windows/gui.c
@@ -41,13 +41,15 @@
#include "windows/window.h"
#include "windows/gui.h"
-/**
- * win32 application instance handle.
- *
- * This handle is set in the main windows entry point.
- */
+/* exported global defined in windows/gui.h */
HINSTANCE hinst;
+/* exported global defined in windows/gui.h */
+char **G_resource_pathv;
+
+/* exported global defined in windows/gui.h */
+char *G_config_path;
+
static bool win32_quit = false;
struct dialog_list_entry {
diff --git a/frontends/windows/gui.h b/frontends/windows/gui.h
index 8f8f0bcbf..0633c93e8 100644
--- a/frontends/windows/gui.h
+++ b/frontends/windows/gui.h
@@ -22,13 +22,22 @@
struct gui_window;
+/**
+ * win32 application instance handle.
+ *
+ * This handle is set in the main windows entry point.
+ */
extern HINSTANCE hinst;
-/** Directory where all configuration files are held. */
-extern char *nsw32_config_home;
+/**
+ * path to where all user config files are held.
+ */
+extern char *G_config_path;
-/** resource search path vector. */
-extern char **respaths;
+/**
+ * resource search path vector.
+ */
+extern char **G_resource_pathv;
/* bounding box */
typedef struct bbox_s {
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index cf94712c1..2dd403edb 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -57,9 +57,6 @@
#include "windows/clipboard.h"
#include "windows/gui.h"
-char **respaths; /** exported global defined in windows/gui.h */
-
-char *nsw32_config_home; /* exported global defined in windows/gui.h */
/**
* Obtain the DPI of the display.
@@ -224,28 +221,28 @@ static nserror set_defaults(struct nsoption_s *defaults)
/* cookie file default */
fname = NULL;
- netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Cookies");
+ netsurf_mkpath(&fname, NULL, 2, G_config_path, "Cookies");
if (fname != NULL) {
nsoption_setnull_charp(cookie_file, fname);
}
/* cookie jar default */
fname = NULL;
- netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Cookies");
+ netsurf_mkpath(&fname, NULL, 2, G_config_path, "Cookies");
if (fname != NULL) {
nsoption_setnull_charp(cookie_jar, fname);
}
/* url database default */
fname = NULL;
- netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "URLs");
+ netsurf_mkpath(&fname, NULL, 2, G_config_path, "URLs");
if (fname != NULL) {
nsoption_setnull_charp(url_file, fname);
}
/* bookmark database default */
fname = NULL;
- netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Hotlist");
+ netsurf_mkpath(&fname, NULL, 2, G_config_path, "Hotlist");
if (fname != NULL) {
nsoption_setnull_charp(hotlist_path, fname);
}
@@ -257,11 +254,16 @@ static nserror set_defaults(struct nsoption_s *defaults)
/**
* Initialise user options location and contents
*/
-static nserror nsw32_option_init(int *pargc, char** argv)
+static nserror
+nsw32_option_init(int *pargc, char** argv, char **respaths, char *config_path)
{
nserror ret;
char *choices = NULL;
+ /* set the globals that will be used in the set_defaults() callback */
+ G_resource_pathv = respaths;
+ G_config_path = config_path;
+
/* user options setup */
ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
if (ret != NSERROR_OK) {
@@ -269,7 +271,7 @@ static nserror nsw32_option_init(int *pargc, char** argv)
}
/* Attempt to load the user choices */
- ret = netsurf_mkpath(&choices, NULL, 2, nsw32_config_home, "Choices");
+ ret = netsurf_mkpath(&choices, NULL, 2, config_path, "Choices");
if (ret == NSERROR_OK) {
nsoption_read(choices, nsoptions);
free(choices);
@@ -311,6 +313,10 @@ static nserror nsw32_messages_init(char **respaths)
/**
* Construct a unix style argc/argv
+ *
+ * \param argc_out number of commandline arguments
+ * \param argv_out string vector of command line arguments
+ * \return NSERROR_OK on success else error code
*/
static nserror win32_to_unix_commandline(int *argc_out, char ***argv_out)
{
@@ -318,6 +324,7 @@ static nserror win32_to_unix_commandline(int *argc_out, char ***argv_out)
char **argv;
int cura;
LPWSTR *argvw;
+ size_t len;
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argvw == NULL) {
@@ -367,9 +374,10 @@ static struct gui_misc_table win32_misc_table = {
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
{
- char **argv = NULL;
- int argc = 0;
- size_t len;
+ int argc;
+ char **argv;
+ char **respaths;
+ char *nsw32_config_home = NULL;
nserror ret;
const char *addr;
nsurl *url;
@@ -414,13 +422,12 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
if (ret != NSERROR_OK) {
NSLOG(netsurf, INFO,
"Unable to locate a configuration directory.");
- nsw32_config_home = NULL;
}
/* Initialise user options */
- ret = nsw32_option_init(&argc, argv);
+ ret = nsw32_option_init(&argc, argv, respaths, nsw32_config_home);
if (ret != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Options failed to initialise (%s)\n",
+ NSLOG(netsurf, ERROR, "Options failed to initialise (%s)\n",
messages_get_errorcode(ret));
return 1;
}
diff --git a/frontends/windows/prefs.c b/frontends/windows/prefs.c
index b2cb7b2d6..9937f2e42 100644
--- a/frontends/windows/prefs.c
+++ b/frontends/windows/prefs.c
@@ -699,7 +699,7 @@ nserror nsws_prefs_save(void)
char *choices = NULL;
nserror res;
- res = netsurf_mkpath(&choices, NULL, 2, nsw32_config_home, "Choices");
+ res = netsurf_mkpath(&choices, NULL, 2, G_config_path, "Choices");
if (res == NSERROR_OK) {
nsoption_write(choices, NULL, NULL);
free(choices);