summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/filetype.c14
-rw-r--r--monkey/filetype.h5
-rw-r--r--monkey/main.c39
3 files changed, 31 insertions, 27 deletions
diff --git a/monkey/filetype.c b/monkey/filetype.c
index f89f2358c..db9c49ab4 100644
--- a/monkey/filetype.c
+++ b/monkey/filetype.c
@@ -26,14 +26,15 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "gtk/filetype.h"
#include "content/fetch.h"
#include "utils/log.h"
#include "utils/hashtable.h"
+#include "monkey/filetype.h"
+
static struct hash_table *mime_hash = NULL;
-void gtk_fetch_filetype_init(const char *mimefile)
+void monkey_fetch_filetype_init(const char *mimefile)
{
struct stat statbuf;
FILE *fh = NULL;
@@ -143,12 +144,12 @@ void gtk_fetch_filetype_init(const char *mimefile)
fclose(fh);
}
-void gtk_fetch_filetype_fin(void)
+void monkey_fetch_filetype_fin(void)
{
hash_destroy(mime_hash);
}
-const char *fetch_filetype(const char *unix_path)
+const char *monkey_fetch_filetype(const char *unix_path)
{
struct stat statbuf;
char *ext;
@@ -195,11 +196,6 @@ const char *fetch_filetype(const char *unix_path)
return type != NULL ? type : "text/plain";
}
-char *fetch_mimetype(const char *unix_path)
-{
- return strdup(fetch_filetype(unix_path));
-}
-
#ifdef TEST_RIG
int main(int argc, char *argv[])
diff --git a/monkey/filetype.h b/monkey/filetype.h
index 8bf98db7c..6c16db01b 100644
--- a/monkey/filetype.h
+++ b/monkey/filetype.h
@@ -17,5 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-void gtk_fetch_filetype_init(const char *mimefile);
-void gtk_fetch_filetype_fin(void);
+void monkey_fetch_filetype_init(const char *mimefile);
+void monkey_fetch_filetype_fin(void);
+const char *monkey_fetch_filetype(const char *unix_path);
diff --git a/monkey/main.c b/monkey/main.c
index b6f5c434d..1135f0e53 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -63,7 +63,7 @@ static void monkey_quit(void)
urldb_save(nsoption_charp(url_file));
free(nsoption_charp(cookie_file));
free(nsoption_charp(cookie_jar));
- gtk_fetch_filetype_fin();
+ monkey_fetch_filetype_fin();
}
static nsurl *gui_get_resource_url(const char *path)
@@ -124,15 +124,15 @@ static bool nslog_stream_configure(FILE *fptr)
static char *filename_from_path(char *path)
{
- char *leafname;
+ char *leafname;
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
- return strdup(leafname);
+ return strdup(leafname);
}
/**
@@ -146,22 +146,28 @@ static char *filename_from_path(char *path)
static bool path_add_part(char *path, int length, const char *newpart)
{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
- strncat(path, newpart, length);
+ strncat(path, newpart, length);
- return true;
+ return true;
}
+static struct gui_fetch_table monkey_fetch_table = {
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .filetype = monkey_fetch_filetype,
+
+ .get_resource_url = gui_get_resource_url,
+};
+
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,
.login = gui_401login_open,
};
@@ -176,6 +182,7 @@ main(int argc, char **argv)
.browser = &monkey_browser_table,
.window = monkey_window_table,
.download = monkey_download_table,
+ .fetch = &monkey_fetch_table,
};
/* Unbuffer stdin/out/err */
@@ -210,7 +217,7 @@ main(int argc, char **argv)
}
filepath_sfinddef(respaths, buf, "mime.types", "/etc/");
- gtk_fetch_filetype_init(buf);
+ monkey_fetch_filetype_init(buf);
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));