summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/gui.c29
-rwxr-xr-xamiga/misc.c27
-rw-r--r--atari/gui.c23
-rwxr-xr-xatari/misc.c22
-rwxr-xr-xatari/misc.h2
-rw-r--r--beos/gui.cpp7
-rw-r--r--cocoa/gui.m16
-rw-r--r--cocoa/utils.m13
-rw-r--r--content/fetchers/curl.c3
-rw-r--r--content/fetchers/file.c3
-rw-r--r--desktop/gui.h18
-rw-r--r--desktop/gui_factory.c7
-rw-r--r--desktop/gui_factory.h2
-rw-r--r--desktop/save_complete.c7
-rw-r--r--framebuffer/gui.c39
-rw-r--r--framebuffer/misc.c37
-rw-r--r--gtk/gui.c6
-rw-r--r--monkey/main.c41
-rw-r--r--monkey/utils.c38
-rw-r--r--riscos/gui.c6
-rw-r--r--utils/utils.h3
-rw-r--r--windows/gui.c39
-rw-r--r--windows/misc.c38
23 files changed, 236 insertions, 190 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 27e747a05..d651ef11e 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -209,6 +209,33 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
nsoptions[NSOPTION_##OPTION].value.i = VALUE; \
nsoptions_default[NSOPTION_##OPTION].value.i = VALUE
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+static char *filename_from_path(char *path)
+{
+ return strdup(FilePart(path));
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(AddPart(path, newpart, length)) return true;
+ else return false;
+}
+
STRPTR ami_locale_langs(void)
{
struct Locale *locale;
@@ -5130,6 +5157,8 @@ static struct gui_browser_table amiga_browser_table = {
.launch_url = gui_launch_url,
.create_form_select_menu = gui_create_form_select_menu,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
/** Normal entry point from OS */
diff --git a/amiga/misc.c b/amiga/misc.c
index 003a5fb6e..ac9d2453e 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -173,33 +173,6 @@ char *path_to_url(const char *path)
}
/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- return strdup(FilePart(path));
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(AddPart(path, newpart, length)) return true;
- else return false;
-}
-
-/**
* returns a string with escape chars translated.
* (based on remove_underscores from utils.c)
*/
diff --git a/atari/gui.c b/atari/gui.c
index 49e3046e2..55a23a84a 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -115,6 +115,27 @@ short aes_msg_out[8];
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '\\');
+ if( !leafname )
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
static void gui_poll(bool active)
{
@@ -1055,6 +1076,8 @@ static struct gui_browser_table atari_browser_table = {
.quit = gui_quit,
.get_resource_url = gui_get_resource_url,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
/* #define WITH_DBG_LOGFILE 1 */
diff --git a/atari/misc.c b/atari/misc.c
index d330859b9..ca9e993d9 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -71,28 +71,6 @@ void die(const char *error)
}
/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '\\');
- if( !leafname )
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
* Add a path component/filename to an existing path
*
* \param path buffer containing path + free space
diff --git a/atari/misc.h b/atari/misc.h
index 8d1719ce8..1bb5e8131 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -66,4 +66,6 @@ const char * file_select(const char * title, const char * name);
*/
long nkc_to_input_key(short nkc, long * ucs4_out);
+bool path_add_part(char *path, int length, const char *newpart);
+
#endif
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 3ee47c9e9..3600e85d0 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -1027,7 +1027,7 @@ static void *myrealloc(void *ptr, size_t len, void *pw)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
@@ -1049,7 +1049,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
if(path[strlen(path) - 1] != '/')
strncat(path, "/", length);
@@ -1067,9 +1067,10 @@ static struct gui_clipboard_table beos_clipboard_table = {
static struct gui_browser_table beos_browser_table = {
.poll = gui_poll,
.quit = gui_quit,
-
.get_resource_url = gui_get_resource_url,
.launch_url = gui_launch_url,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
diff --git a/cocoa/gui.m b/cocoa/gui.m
index c2cadfe5a..f9cb2e4c7 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -281,6 +281,20 @@ void gui_401login_open(nsurl *url, const char *realm,
cb( false, cbpw );
}
+static char *filename_from_path(char *path)
+{
+ return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
+}
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
+
+ strncpy( path, [newPath UTF8String], length );
+
+ return true;
+}
+
static struct gui_window_table window_table = {
.create = gui_window_create,
@@ -321,6 +335,8 @@ static struct gui_browser_table browser_table = {
.launch_url = gui_launch_url,
.create_form_select_menu = gui_create_form_select_menu,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
struct gui_browser_table *cocoa_browser_table = &browser_table;
diff --git a/cocoa/utils.m b/cocoa/utils.m
index cd9313d34..61226ad2a 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -41,16 +41,3 @@ void PDF_Password(char **owner_pass, char **user_pass, char *path)
UNIMPL();
}
-char *filename_from_path(char *path)
-{
- return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
-}
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
-
- strncpy( path, [newPath UTF8String], length );
-
- return true;
-}
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 7578ad4cb..92d4625b5 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -45,6 +45,7 @@
#include "content/fetchers/curl.h"
#include "content/urldb.h"
#include "desktop/netsurf.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -1268,7 +1269,7 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control)
if (control->file) {
char *leafname = 0;
- leafname = filename_from_path(control->value);
+ leafname = guit->browser->filename_from_path(control->value);
if (leafname == NULL)
continue;
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index c574c2160..26ef9069b 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -47,6 +47,7 @@
#include "content/fetchers/file.h"
#include "content/urldb.h"
#include "desktop/netsurf.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "utils/errors.h"
#include "utils/log.h"
@@ -574,7 +575,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
continue;
strncpy(urlpath, ctx->path, sizeof urlpath);
- if (path_add_part(urlpath, sizeof urlpath,
+ if (guit->browser->path_add_part(urlpath, sizeof urlpath,
ent->d_name) == false)
continue;
diff --git a/desktop/gui.h b/desktop/gui.h
index 686bb59d4..102aade45 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -344,6 +344,24 @@ struct gui_browser_table {
*/
void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
+ /**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+ char *(*filename_from_path)(char *path);
+
+ /**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+ bool (*path_add_part)(char *path, int length, const char *newpart);
+
};
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index f47b73007..cd5031b0d 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -316,6 +316,13 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
if (gbt->poll == NULL) {
return NSERROR_BAD_PARAMETER;
}
+ if (gbt->filename_from_path == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gbt->path_add_part == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
/* fill in the optional entries with defaults */
if (gbt->quit == NULL) {
diff --git a/desktop/gui_factory.h b/desktop/gui_factory.h
index c70ca8f37..50b5eb31e 100644
--- a/desktop/gui_factory.h
+++ b/desktop/gui_factory.h
@@ -23,7 +23,7 @@
#ifndef _NETSURF_DESKTOP_GUI_FACTORY_H_
#define _NETSURF_DESKTOP_GUI_FACTORY_H_
-struct gui_table;
+#include "desktop/gui.h"
extern struct gui_table *guit; /* the gui vtable */
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 3e5234af4..bd2ed4dea 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -37,6 +37,7 @@
#include "content/hlcache.h"
#include "css/css.h"
#include "desktop/save_complete.h"
+#include "desktop/gui_factory.h"
#include "render/box.h"
#include "render/html.h"
#include "utils/corestrings.h"
@@ -147,7 +148,7 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx,
char fullpath[PATH_MAX];
strncpy(fullpath, ctx->path, sizeof fullpath);
- error = path_add_part(fullpath, sizeof fullpath, leafname);
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, leafname);
if (error == false) {
warn_user("NoMemory", NULL);
return false;
@@ -1048,7 +1049,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx,
else
snprintf(filename, sizeof filename, "%p", c);
- error = path_add_part(fullpath, sizeof fullpath, filename);
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, filename);
if (error == false) {
warn_user("NoMemory", NULL);
return false;
@@ -1125,7 +1126,7 @@ static bool save_complete_inventory(save_complete_ctx *ctx)
char fullpath[PATH_MAX];
strncpy(fullpath, ctx->path, sizeof fullpath);
- error = path_add_part(fullpath, sizeof fullpath, "Inventory");
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, "Inventory");
if (error == false) {
warn_user("NoMemory", NULL);
return false;
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index b2edc030a..76ed397d3 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -1767,6 +1767,43 @@ gui_window_remove_caret(struct gui_window *g)
}
}
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
static struct gui_window_table framebuffer_window_table = {
.create = gui_window_create,
@@ -1791,6 +1828,8 @@ static struct gui_browser_table framebuffer_browser_table = {
.poll = gui_poll,
.quit = gui_quit,
.get_resource_url = gui_get_resource_url,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
/** Entry point from OS.
diff --git a/framebuffer/misc.c b/framebuffer/misc.c
index 2dd03677d..f5ad045a0 100644
--- a/framebuffer/misc.c
+++ b/framebuffer/misc.c
@@ -37,40 +37,3 @@ void die(const char *error)
exit(1);
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
-}
diff --git a/gtk/gui.c b/gtk/gui.c
index c3ee22850..1028528ed 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -1096,7 +1096,7 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
@@ -1118,7 +1118,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
if(path[strlen(path) - 1] != '/')
strncat(path, "/", length);
@@ -1141,6 +1141,8 @@ static struct gui_browser_table nsgtk_browser_table = {
.launch_url = gui_launch_url,
.create_form_select_menu = gui_create_form_select_menu,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
/**
diff --git a/monkey/main.c b/monkey/main.c
index 22aaf1e06..1922393a8 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -114,12 +114,53 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
static struct gui_browser_table monkey_browser_table = {
.poll = monkey_poll,
.quit = monkey_quit,
.get_resource_url = gui_get_resource_url,
.launch_url = gui_launch_url,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
int
diff --git a/monkey/utils.c b/monkey/utils.c
index 3e09106f7..aa7245533 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -70,44 +70,6 @@ char *url_to_path(const char *url)
return respath;
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
-}
void warn_user(const char *warning, const char *detail)
{
diff --git a/riscos/gui.c b/riscos/gui.c
index 50c1bdf62..c780abfcf 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -2288,7 +2288,7 @@ void PDF_Password(char **owner_pass, char **user_pass, char *path)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
char *temp;
@@ -2326,7 +2326,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
size_t path_len = strlen(path);
@@ -2360,6 +2360,8 @@ static struct gui_browser_table riscos_browser_table = {
.launch_url = gui_launch_url,
.create_form_select_menu = gui_create_form_select_menu,
.cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
diff --git a/utils/utils.h b/utils/utils.h
index f2241ae07..e3b3647ea 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -188,6 +188,5 @@ query_id query_user(const char *query, const char *detail,
const query_callback *cb, void *pw, const char *yes, const char *no);
void query_close(query_id);
void PDF_Password(char **owner_pass, char **user_pass, char *path);
-char *filename_from_path(char *path);
-bool path_add_part(char *path, int length, const char *newpart);
+
#endif
diff --git a/windows/gui.c b/windows/gui.c
index fa748254c..40124671d 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -1809,6 +1809,43 @@ nsws_create_main_class(HINSTANCE hinstance) {
return ret;
}
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '\\');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '\\')
+ strncat(path, "\\", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
static struct gui_window_table window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,
@@ -1840,6 +1877,8 @@ struct gui_clipboard_table *win32_clipboard_table = &clipboard_table;
static struct gui_table browser_table = {
.poll = gui_poll,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
};
struct gui_browser_table *win32_browser_table = &browser_table;
diff --git a/windows/misc.c b/windows/misc.c
index d820a5bca..b60eb512c 100644
--- a/windows/misc.c
+++ b/windows/misc.c
@@ -43,41 +43,3 @@ void die(const char *error)
exit(1);
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '\\');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '\\')
- strncat(path, "\\", length);
-
- strncat(path, newpart, length);
-
- return true;
-}