r2543 bursa - /trunk/netsurf/utils/url.c
by netsurf@semichrome.net
Author: bursa
Date: Sat Apr 22 10:07:28 2006
New Revision: 2543
URL: http://svn.semichrome.net?rev=2543&view=rev
Log:
Fix crash when a relative URL contains "//../".
Modified:
trunk/netsurf/utils/url.c
Modified: trunk/netsurf/utils/url.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/url.c?rev=2543&r1=2542&r2=2...
==============================================================================
--- trunk/netsurf/utils/url.c (original)
+++ trunk/netsurf/utils/url.c Sat Apr 22 10:07:28 2006
@@ -47,7 +47,7 @@
"(#([^[:space:]]*))?"
"[[:space:]]*$", REG_EXTENDED);
regcomp_wrapper(&url_up_re,
- "/([^/]|[.][^./]|[^./][.]|[^./][^./]|[^/][^/][^/]+)?"
+ "/([^/]?|[.][^./]|[^./][.]|[^./][^./]|[^/][^/][^/]+)"
"/[.][.](/|$)",
REG_EXTENDED);
}
@@ -863,15 +863,15 @@
printf("<== '%s'\n", s);
free(s);
}*/
-/* if (1 != i) {
+ if (1 != i) {
res = url_join(argv[i], argv[1], &s);
if (res == URL_FUNC_OK) {
printf("'%s' + '%s' \t= '%s'\n", argv[1],
argv[i], s);
free(s);
}
- }*/
- printf("'%s' => ", argv[i]);
+ }
+/* printf("'%s' => ", argv[i]);
res = url_nice(argv[i], &s, true);
if (res == URL_FUNC_OK) {
printf("'%s', ", s);
@@ -886,7 +886,7 @@
} else {
printf("failed %u, ", res);
}
- printf("\n");
+ printf("\n");*/
}
return 0;
}
16 years, 9 months
r2541 rjw - in /trunk/netsurf: riscos/filename.c riscos/filename.h utils/filename.c utils/filename.h
by netsurf@semichrome.net
Author: rjw
Date: Sat Apr 22 00:50:36 2006
New Revision: 2541
URL: http://svn.semichrome.net?rev=2541&view=rev
Log:
Apparently I need to specify add/deletions too...
Added:
trunk/netsurf/utils/filename.c
trunk/netsurf/utils/filename.h
Removed:
trunk/netsurf/riscos/filename.c
trunk/netsurf/riscos/filename.h
Removed: trunk/netsurf/riscos/filename.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/filename.c?rev=2540&view=auto
==============================================================================
--- trunk/netsurf/riscos/filename.c (original)
+++ trunk/netsurf/riscos/filename.c (removed)
@@ -1,427 +1,0 @@
-/*
- * This file is part of NetSurf, http://netsurf.sourceforge.net/
- * Licensed under the GNU General Public License,
- * http://www.opensource.org/licenses/gpl-license
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- */
-
-/** \file
- * Provides a central method of obtaining unique filenames.
- *
- * A maximum of 2^24 files can be allocated at any point in time.
- */
-
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "oslib/hourglass.h"
-#include "oslib/osgbpb.h"
-#include "oslib/osfile.h"
-#include "netsurf/riscos/filename.h"
-#include "netsurf/utils/log.h"
-
-#define FULL_WORD (unsigned int)4294967295
-/* '0' + '0' * 10 */
-#define START_PREFIX 528
-
-struct directory {
- int numeric_prefix; /** numeric representation of prefix */
- char prefix[10]; /** directory prefix, eg '00.11.52.' */
- unsigned int low_used; /** first 32 files, 1 bit per file */
- unsigned int high_used; /** last 32 files, 1 bit per file */
- struct directory *next; /** next directory (sorted by prefix) */
-};
-
-
-static struct directory *root = NULL;
-static char ro_filename_buffer[12];
-static char ro_filename_directory[256];
-
-static struct directory *ro_filename_create_directory(const char *prefix);
-static bool ro_filename_flush_directory(const char *folder, int depth);
-static bool ro_filename_delete_recursive(char *folder);
-
-/**
- * Request a new, unique, filename.
- *
- * \return a pointer to a shared buffer containing the new filename
- */
-char *ro_filename_request(void) {
- struct directory *dir;
- int i = -1;
-
- for (dir = root; dir; dir = dir->next)
- if ((dir->low_used & dir->high_used) != FULL_WORD) {
- if (dir->low_used != FULL_WORD) {
- for (i = 0; (dir->low_used & (1 << i)); i++);
- } else {
- for (i = 0; (dir->high_used & (1 << i)); i++);
- i += 32;
- }
- break;
- }
- if (i == -1) {
- /* no available slots - create a new directory */
- dir = ro_filename_create_directory(NULL);
- if (!dir) {
- LOG(("Failed to create a new directory."));
- return NULL;
- }
- i = 63;
- }
- if (i < 32)
- dir->low_used |= (1 << i);
- else
- dir->high_used |= (1 << (i - 32));
- sprintf(ro_filename_buffer, "%s%.2i", dir->prefix, i);
- return ro_filename_buffer;
-}
-
-
-/**
- * Claim a specific filename.
- *
- * \param filename the filename to claim
- * \return whether the claim was successful
- */
-bool ro_filename_claim(const char *filename) {
- char dir_prefix[9];
- int file;
- struct directory *dir;
-
- /* filename format is always '01.23.45.XX' */
- strncpy(dir_prefix, filename, 9);
- dir_prefix[9] = '\0';
- file = (filename[10] + filename[9] * 10 - START_PREFIX);
-
- /* create the directory */
- dir = ro_filename_create_directory(dir_prefix);
- if (!dir)
- return false;
-
- /* update the entry */
- if (file < 32) {
- if (dir->low_used & (1 << file))
- return false;
- dir->low_used |= (1 << file);
- } else {
- if (dir->high_used & (1 << (file - 32)))
- return false;
- dir->high_used |= (1 << (file - 32));
- }
- return true;
-}
-
-
-/**
- * Releases a filename for future use.
- *
- * \param filename the filename to release
- */
-void ro_filename_release(const char *filename) {
- struct directory *dir;
- int index, file;
-
- /* filename format is always '01.23.45.XX' */
- index = ((filename[7] + filename[6] * 10 - START_PREFIX) |
- ((filename[4] + filename[3] * 10 - START_PREFIX) << 6) |
- ((filename[1] + filename[0] * 10 - START_PREFIX) << 12));
- file = (filename[10] + filename[9] * 10 - START_PREFIX);
-
- /* modify the correct directory entry */
- for (dir = root; dir; dir = dir->next)
- if (dir->numeric_prefix == index) {
- if (file < 32)
- dir->low_used &= ~(1 << file);
- else
- dir->high_used &= ~(1 << (file - 32));
- return;
- }
-}
-
-
-/**
- * Initialise the filename provider.
- */
-bool ro_filename_initialise(void) {
- /* create the 'CACHE_FILENAME_PREFIX' structure */
- xosfile_create_dir("<Wimp$ScrapDir>.WWW", 0);
- xosfile_create_dir("<Wimp$ScrapDir>.WWW.NetSurf", 0);
- xosfile_create_dir("<Wimp$ScrapDir>.WWW.NetSurf.Cache", 0);
- return true;
-}
-
-
-/**
- * Deletes all files in the cache directory that are not accounted for.
- */
-void ro_filename_flush(void) {
- xhourglass_on();
- while (ro_filename_flush_directory(CACHE_FILENAME_PREFIX, 0));
- xhourglass_off();
-}
-
-
-/**
- * Deletes some files in a directory that are not accounted for.
- *
- * A single call to this function may not delete all the files in
- * a directory. It should be called until it returns false.
- *
- * \param folder the folder to search
- * \param depth the folder depth
- * \returns whether further calls may be needed
- */
-bool ro_filename_flush_directory(const char *folder, int depth) {
- bool changed = false;
- bool del;
- int number, i;
- int prefix = 0;
- unsigned int prefix_mask = (63 << 12);
- int context = 0;
- int read_count;
- osgbpb_INFO(100) info;
- os_error *error;
- char child[256];
- const char *prefix_start = NULL;
- struct directory *dir = NULL;
-
- /* find out directory details */
- if (depth > 0)
- prefix_start = folder + strlen(folder) - depth * 3 + 1;
- for (i = 0; ((i < depth) && (i < 3)); i++) {
- number = prefix_start[1] + prefix_start[0] * 10 - START_PREFIX;
- prefix |= (number << (12 - i * 6));
- prefix_mask |= (63 << (6 - i * 6));
- prefix_start += 3;
- }
- if (depth == 3) {
- for (dir = root; dir; dir = dir->next)
- if (dir->numeric_prefix == prefix)
- break;
- if ((!dir) || (dir->numeric_prefix != prefix))
- return false;
- }
-
- while (context != -1) {
- /* read some directory info */
- error = xosgbpb_dir_entries_info(folder,
- (osgbpb_info_list *) &info, 1, context,
- sizeof(info), 0, &read_count, &context);
- if (error) {
- LOG(("xosgbpb_dir_entries_info: 0x%x: %s",
- error->errnum, error->errmess));
- if (error->errnum == 0xd6) /* no such dir */
- return false;
- break;
- }
- /* ensure we read some data */
- if (read_count == 0)
- continue;
- /* first 3 depths are directories only, then files only */
- del = false;
- if (depth < 3) {
- if (info.obj_type != fileswitch_IS_DIR)
- del = true;
- } else {
- if (info.obj_type != fileswitch_IS_FILE)
- del = true;
- }
- /* check we are a file numbered '00' -> '63' */
- if ((!del) && (info.name[0] >= '0') && (info.name[0] <= '6') &&
- (info.name[1] >= '0') && (info.name[1] <= '9') &&
- (info.name[2] == '\0')) {
- number = atoi(info.name);
- if ((number >= 0) && (number <= 63)) {
- if (depth == 3) {
- if (number < 32)
- del = !(dir->low_used &
- (1 << number));
- else
- del = !(dir->high_used &
- (1 << (number - 32)));
- } else {
- del = true;
- prefix &= ~(63 << (12 - depth * 6));
- prefix |= (number << (12 - depth * 6));
- for (dir = root; dir; dir = dir->next) {
- number = dir->numeric_prefix &
- prefix_mask;
- if (number == prefix) {
- del = false;
- break;
- }
- }
- }
- } else {
- del = true;
- }
- } else {
- del = true;
- }
- /* continue if we are a valid reference so far */
- if ((!del) && (info.obj_type != fileswitch_IS_DIR))
- continue;
- /* delete or recurse */
- snprintf(child, 256, "%s.%s", folder, info.name);
- child[255] = '\0';
- if (del) {
- if (info.obj_type == fileswitch_IS_DIR)
- ro_filename_delete_recursive(child);
- error = xosfile_delete(child, 0, 0, 0, 0, 0);
- if (error)
- LOG(("xosfile_delete: 0x%x: %s",
- error->errnum, error->errmess));
- else
- changed = true;
- } else {
- while (ro_filename_flush_directory(child, depth + 1));
- }
- }
- return changed;
-}
-
-
-/**
- * Recursively deletes the contents of a directory
- *
- * \param directory the directory to delete
- * \return true on success, false otherwise
- */
-bool ro_filename_delete_recursive(char *folder) {
- int context = 0;
- int read_count;
- osgbpb_INFO(100) info;
- os_error *error;
- char child[256];
-
- while (context != -1) {
- /* read the first entry */
- error = xosgbpb_dir_entries_info(folder,
- (osgbpb_info_list *) &info, 1, 0,
- sizeof(info), 0, &read_count, &context);
- if (error) {
- LOG(("xosgbpb_dir_entries_info: 0x%x: %s",
- error->errnum, error->errmess));
- if (error->errnum == 0xd6) /* no such dir */
- return false;
- break;
- }
- /* ensure we read some data */
- if (read_count == 0)
- continue;
- snprintf(child, 256, "%s.%s", folder, info.name);
- /* recurse for files */
- if (info.obj_type == fileswitch_IS_DIR) {
- if (!ro_filename_delete_recursive(child))
- return false;
- }
- error = xosfile_delete(child, 0, 0, 0, 0, 0);
- if (error) {
- LOG(("xosfile_delete: 0x%x: %s",
- error->errnum, error->errmess));
- return false;
- }
- }
- return true;
-}
-
-
-/**
- * Creates a new directory.
- *
- * \param prefix the prefix to use, or NULL to allocate a new one
- * \return a new directory structure, or NULL on memory exhaustion
- *
- * Empty directories are never deleted, except by an explicit call to
- * ro_filename_flush().
- */
-static struct directory *ro_filename_create_directory(const char *prefix) {
- char *last_1, *last_2;
- int index;
- struct directory *old_dir, *new_dir, *prev_dir = NULL;
- char dir_prefix[16];
- os_error *error;
-
- /* get the lowest unique prefix, or use the provided one */
- if (!prefix) {
- for (index = 0, old_dir = root; old_dir; index++,
- prev_dir = old_dir, old_dir = old_dir->next)
- if (old_dir->numeric_prefix != index)
- break;
- sprintf(dir_prefix, "%.2i.%.2i.%.2i.",
- ((index >> 12) & 63),
- ((index >> 6) & 63),
- ((index >> 0) & 63));
- prefix = dir_prefix;
- } else {
- /* prefix format is always '01.23.45.' */
- index = ((prefix[7] + prefix[6] * 10 - START_PREFIX) |
- ((prefix[4] + prefix[3] * 10 - START_PREFIX) << 6) |
- ((prefix[1] + prefix[0] * 10 - START_PREFIX) << 12));
- for (old_dir = root; old_dir; prev_dir = old_dir,
- old_dir = old_dir->next) {
- if (old_dir->numeric_prefix == index)
- return old_dir;
- else if (old_dir->numeric_prefix > index)
- break;
- }
- }
-
- /* allocate a new directory */
- new_dir = (struct directory *)malloc(sizeof(struct directory));
- if (!new_dir) {
- LOG(("No memory for malloc()"));
- return NULL;
- }
- strncpy(new_dir->prefix, prefix, 9);
- new_dir->prefix[9] = '\0';
- new_dir->low_used = new_dir->high_used = 0;
- new_dir->numeric_prefix = index;
-
- if (!prev_dir) {
- new_dir->next = root;
- root = new_dir;
- } else {
- new_dir->next = prev_dir->next;
- prev_dir->next = new_dir;
- }
-
- /* if the previous directory has the same parent then we can simply
- * create the child. */
- if ((prev_dir) && (!strncmp(prev_dir->prefix, new_dir->prefix, 6))) {
- new_dir->prefix[8] = '\0';
- sprintf(ro_filename_directory, "%s.%s",
- CACHE_FILENAME_PREFIX, new_dir->prefix);
- new_dir->prefix[8] = '.';
- error = xosfile_create_dir(ro_filename_directory, 0);
- /* the user has probably deleted the parent directory whilst
- * we are running if there is an error, so we don't report this
- * yet and try to create the structure normally. */
- if (!error)
- return new_dir;
- LOG(("xosfile_create_dir: 0x%x: %s",
- error->errnum, error->errmess));
- }
-
- /* create the directory structure */
- sprintf(ro_filename_directory, "%s.", CACHE_FILENAME_PREFIX);
- last_1 = ro_filename_directory + strlen(CACHE_FILENAME_PREFIX) + 1;
- last_2 = new_dir->prefix;
- for (int i = 0; i < 3 && *last_2; i++) {
- *last_1++ = *last_2++;
- while (*last_2 && *last_2 != '.')
- *last_1++ = *last_2++;
- if (*last_2) {
- last_1[0] = '\0';
- error = xosfile_create_dir(ro_filename_directory, 0);
- if (error) {
- LOG(("xosfile_create_dir: 0x%x: %s",
- error->errnum, error->errmess));
- return NULL;
- }
- }
- }
- return new_dir;
-}
Removed: trunk/netsurf/riscos/filename.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/filename.h?rev=2540&view=auto
==============================================================================
--- trunk/netsurf/riscos/filename.h (original)
+++ trunk/netsurf/riscos/filename.h (removed)
@@ -1,22 +1,0 @@
-/*
- * This file is part of NetSurf, http://netsurf.sourceforge.net/
- * Licensed under the GNU General Public License,
- * http://www.opensource.org/licenses/gpl-license
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- */
-
-#ifndef _NETSURF_RISCOS_FILENAME_H_
-#define _NETSURF_RISCOS_FILENAME_H_
-
-#include <stdbool.h>
-
-#define CACHE_FILENAME_PREFIX "<Wimp$ScrapDir>.WWW.NetSurf.Cache"
-
-char *ro_filename_request(void);
-bool ro_filename_claim(const char *filename);
-void ro_filename_release(const char *filename);
-bool ro_filename_initialise(void);
-void ro_filename_flush(void);
-
-
-#endif
Added: trunk/netsurf/utils/filename.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/filename.c?rev=2541&view=auto
==============================================================================
--- trunk/netsurf/utils/filename.c (added)
+++ trunk/netsurf/utils/filename.c Sat Apr 22 00:50:36 2006
@@ -1,0 +1,417 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2006 Richard Wilson <info(a)tinct.net>
+ */
+
+/** \file
+ * Provides a central method of obtaining unique filenames.
+ *
+ * A maximum of 2^24 files can be allocated at any point in time.
+ */
+
+#include <dirent.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "netsurf/utils/filename.h"
+#include "netsurf/utils/log.h"
+#include <unixlib/local.h>
+
+#define FULL_WORD (unsigned int)4294967295
+/* '0' + '0' * 10 */
+#define START_PREFIX 528
+
+struct directory {
+ int numeric_prefix; /** numeric representation of prefix */
+ char prefix[10]; /** directory prefix, eg '00/11/52/' */
+ unsigned int low_used; /** first 32 files, 1 bit per file */
+ unsigned int high_used; /** last 32 files, 1 bit per file */
+ struct directory *next; /** next directory (sorted by prefix) */
+};
+
+
+static struct directory *root = NULL;
+static char filename_buffer[12];
+static char filename_directory[256];
+
+static struct directory *filename_create_directory(const char *prefix);
+static bool filename_flush_directory(const char *folder, int depth);
+static bool filename_delete_recursive(char *folder);
+
+/**
+ * Request a new, unique, filename.
+ *
+ * \return a pointer to a shared buffer containing the new filename
+ */
+char *filename_request(void) {
+ struct directory *dir;
+ int i = -1;
+
+ for (dir = root; dir; dir = dir->next)
+ if ((dir->low_used & dir->high_used) != FULL_WORD) {
+ if (dir->low_used != FULL_WORD) {
+ for (i = 0; (dir->low_used & (1 << i)); i++);
+ } else {
+ for (i = 0; (dir->high_used & (1 << i)); i++);
+ i += 32;
+ }
+ break;
+ }
+ if (i == -1) {
+ /* no available slots - create a new directory */
+ dir = filename_create_directory(NULL);
+ if (!dir) {
+ LOG(("Failed to create a new directory."));
+ return NULL;
+ }
+ i = 63;
+ }
+ if (i < 32)
+ dir->low_used |= (1 << i);
+ else
+ dir->high_used |= (1 << (i - 32));
+ sprintf(filename_buffer, "%s%.2i", dir->prefix, i);
+ return filename_buffer;
+}
+
+
+/**
+ * Claim a specific filename.
+ *
+ * \param filename the filename to claim
+ * \return whether the claim was successful
+ */
+bool filename_claim(const char *filename) {
+ char dir_prefix[9];
+ int file;
+ struct directory *dir;
+
+ /* filename format is always '01/23/45/XX' */
+ strncpy(dir_prefix, filename, 9);
+ dir_prefix[9] = '\0';
+ file = (filename[10] + filename[9] * 10 - START_PREFIX);
+
+ /* create the directory */
+ dir = filename_create_directory(dir_prefix);
+ if (!dir)
+ return false;
+
+ /* update the entry */
+ if (file < 32) {
+ if (dir->low_used & (1 << file))
+ return false;
+ dir->low_used |= (1 << file);
+ } else {
+ if (dir->high_used & (1 << (file - 32)))
+ return false;
+ dir->high_used |= (1 << (file - 32));
+ }
+ return true;
+}
+
+
+/**
+ * Releases a filename for future use.
+ *
+ * \param filename the filename to release
+ */
+void filename_release(const char *filename) {
+ struct directory *dir;
+ int index, file;
+
+ /* filename format is always '01/23/45/XX' */
+ index = ((filename[7] + filename[6] * 10 - START_PREFIX) |
+ ((filename[4] + filename[3] * 10 - START_PREFIX) << 6) |
+ ((filename[1] + filename[0] * 10 - START_PREFIX) << 12));
+ file = (filename[10] + filename[9] * 10 - START_PREFIX);
+
+ /* modify the correct directory entry */
+ for (dir = root; dir; dir = dir->next)
+ if (dir->numeric_prefix == index) {
+ if (file < 32)
+ dir->low_used &= ~(1 << file);
+ else
+ dir->high_used &= ~(1 << (file - 32));
+ return;
+ }
+}
+
+
+/**
+ * Initialise the filename provider.
+ */
+bool filename_initialise(void) {
+ char *directory, *start;
+
+ directory = strdup(TEMP_FILENAME_PREFIX);
+ if (!directory)
+ return false;
+
+ for (start = directory; *start != '\0'; *start++) {
+ if (*start == '/') {
+ *start = '\0';
+ mkdir(directory, S_IRWXU);
+ *start = '/';
+ }
+ }
+ LOG((directory));
+ mkdir(directory, S_IRWXU);
+ free(directory);
+ return true;
+}
+
+
+/**
+ * Deletes all files in the cache directory that are not accounted for.
+ */
+void filename_flush(void) {
+ while (filename_flush_directory(TEMP_FILENAME_PREFIX, 0));
+}
+
+
+/**
+ * Deletes some files in a directory that are not accounted for.
+ *
+ * A single call to this function may not delete all the files in
+ * a directory. It should be called until it returns false.
+ *
+ * \param folder the folder to search
+ * \param depth the folder depth
+ * \returns whether further calls may be needed
+ */
+bool filename_flush_directory(const char *folder, int depth) {
+ DIR *parent;
+ struct dirent *entry;
+ bool changed = false;
+ bool del;
+ int number, i;
+ int prefix = 0;
+ unsigned int prefix_mask = (63 << 12);
+ char child[256];
+ const char *prefix_start = NULL;
+ struct directory *dir = NULL;
+
+ /* find out directory details */
+ if (depth > 0)
+ prefix_start = folder + strlen(folder) - depth * 3 + 1;
+ for (i = 0; ((i < depth) && (i < 3)); i++) {
+ number = prefix_start[1] + prefix_start[0] * 10 - START_PREFIX;
+ prefix |= (number << (12 - i * 6));
+ prefix_mask |= (63 << (6 - i * 6));
+ prefix_start += 3;
+ }
+ if (depth == 3) {
+ for (dir = root; dir; dir = dir->next)
+ if (dir->numeric_prefix == prefix)
+ break;
+ if ((!dir) || (dir->numeric_prefix != prefix))
+ return false;
+ }
+
+ parent = opendir(folder);
+
+ while ((entry = readdir(parent))) {
+ if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) ||
+ (!strcmp(entry->d_name, "..")))
+ continue;
+
+ /* first 3 depths are directories only, then files only */
+ if (depth < 3)
+ del = (entry->d_type != DT_DIR);
+ else
+ del = (entry->d_type == DT_DIR);
+
+ /* check we are a file numbered '00' -> '63' */
+ if ((!del) && (entry->d_name[0] >= '0') &&
+ (entry->d_name[0] <= '6') &&
+ (entry->d_name[1] >= '0') &&
+ (entry->d_name[1] <= '9') &&
+ (entry->d_name[2] == '\0')) {
+ number = atoi(entry->d_name);
+ if ((number >= 0) && (number <= 63)) {
+ if (depth == 3) {
+ if (number < 32)
+ del = !(dir->low_used &
+ (1 << number));
+ else
+ del = !(dir->high_used &
+ (1 << (number - 32)));
+ } else {
+ del = true;
+ prefix &= ~(63 << (12 - depth * 6));
+ prefix |= (number << (12 - depth * 6));
+ for (dir = root; dir; dir = dir->next) {
+ number = dir->numeric_prefix &
+ prefix_mask;
+ if (number == prefix) {
+ del = false;
+ break;
+ }
+ }
+ }
+ } else {
+ del = true;
+ }
+ } else {
+ del = true;
+ }
+ /* continue if we are a valid reference so far */
+ if ((!del) && (entry->d_type != DT_DIR))
+ continue;
+ /* delete or recurse */
+ snprintf(child, 256, "%s/%s", folder, entry->d_name);
+ child[255] = '\0';
+ if (del) {
+ if (entry->d_type == DT_DIR)
+ filename_delete_recursive(child);
+ if (remove(child))
+ LOG(("Failed to remove '%s'", child));
+ else
+ changed = true;
+ } else {
+ while (filename_flush_directory(child, depth + 1));
+ }
+ }
+
+ closedir(parent);
+ return changed;
+}
+
+
+/**
+ * Recursively deletes the contents of a directory
+ *
+ * \param directory the directory to delete
+ * \return true on success, false otherwise
+ */
+bool filename_delete_recursive(char *folder) {
+ DIR *parent;
+ struct dirent *entry;
+ char child[256];
+
+ parent = opendir(folder);
+
+ while ((entry = readdir(parent))) {
+ if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) ||
+ (!strcmp(entry->d_name, "..")))
+ continue;
+ snprintf(child, 256, "%s/%s", folder, entry->d_name);
+ if (entry->d_type == DT_DIR) {
+ if (!filename_delete_recursive(child)) {
+ closedir(parent);
+ return false;
+ }
+ }
+ if (remove(child)) {
+ LOG(("Failed to remove '%s'", child));
+ closedir(parent);
+ return false;
+ }
+ }
+
+ closedir(parent);
+ return true;
+}
+
+
+/**
+ * Creates a new directory.
+ *
+ * \param prefix the prefix to use, or NULL to allocate a new one
+ * \return a new directory structure, or NULL on memory exhaustion
+ *
+ * Empty directories are never deleted, except by an explicit call to
+ * filename_flush().
+ */
+static struct directory *filename_create_directory(const char *prefix) {
+ char *last_1, *last_2;
+ int index;
+ struct directory *old_dir, *new_dir, *prev_dir = NULL;
+ char dir_prefix[16];
+
+ /* get the lowest unique prefix, or use the provided one */
+ if (!prefix) {
+ for (index = 0, old_dir = root; old_dir; index++,
+ prev_dir = old_dir, old_dir = old_dir->next)
+ if (old_dir->numeric_prefix != index)
+ break;
+ sprintf(dir_prefix, "%.2i/%.2i/%.2i/",
+ ((index >> 12) & 63),
+ ((index >> 6) & 63),
+ ((index >> 0) & 63));
+ prefix = dir_prefix;
+ } else {
+ /* prefix format is always '01/23/45/' */
+ index = ((prefix[7] + prefix[6] * 10 - START_PREFIX) |
+ ((prefix[4] + prefix[3] * 10 - START_PREFIX) << 6) |
+ ((prefix[1] + prefix[0] * 10 - START_PREFIX) << 12));
+ for (old_dir = root; old_dir; prev_dir = old_dir,
+ old_dir = old_dir->next) {
+ if (old_dir->numeric_prefix == index)
+ return old_dir;
+ else if (old_dir->numeric_prefix > index)
+ break;
+ }
+ }
+
+ /* allocate a new directory */
+ new_dir = (struct directory *)malloc(sizeof(struct directory));
+ if (!new_dir) {
+ LOG(("No memory for malloc()"));
+ return NULL;
+ }
+ strncpy(new_dir->prefix, prefix, 9);
+ new_dir->prefix[9] = '\0';
+ new_dir->low_used = new_dir->high_used = 0;
+ new_dir->numeric_prefix = index;
+
+ if (!prev_dir) {
+ new_dir->next = root;
+ root = new_dir;
+ } else {
+ new_dir->next = prev_dir->next;
+ prev_dir->next = new_dir;
+ }
+
+ /* if the previous directory has the same parent then we can simply
+ * create the child. */
+ if ((prev_dir) && (!strncmp(prev_dir->prefix, new_dir->prefix, 6))) {
+ new_dir->prefix[8] = '\0';
+ sprintf(filename_directory, "%s/%s",
+ TEMP_FILENAME_PREFIX,
+ new_dir->prefix);
+ new_dir->prefix[8] = '/';
+ if (!mkdir(filename_directory, S_IRWXU))
+ return new_dir;
+
+ /* the user has probably deleted the parent directory whilst
+ * we are running if there is an error, so we don't report
+ * this yet and try to create the structure normally. */
+ LOG(("Failed to create optimised structure '%s'",
+ filename_directory));
+ }
+
+ /* create the directory structure */
+ sprintf(filename_directory, "%s/",
+ TEMP_FILENAME_PREFIX);
+ last_1 = filename_directory + strlen(TEMP_FILENAME_PREFIX) + 1;
+ last_2 = new_dir->prefix;
+ for (int i = 0; i < 3 && *last_2; i++) {
+ *last_1++ = *last_2++;
+ while (*last_2 && *last_2 != '/')
+ *last_1++ = *last_2++;
+ if (*last_2) {
+ last_1[0] = '\0';
+ if (mkdir(filename_directory, S_IRWXU)) {
+ LOG(("Failed to create directory '%s'",
+ filename_directory));
+ return NULL;
+ }
+ }
+ }
+ return new_dir;
+}
Added: trunk/netsurf/utils/filename.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/filename.h?rev=2541&view=auto
==============================================================================
--- trunk/netsurf/utils/filename.h (added)
+++ trunk/netsurf/utils/filename.h Sat Apr 22 00:50:36 2006
@@ -1,0 +1,25 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2006 Richard Wilson <info(a)tinct.net>
+ */
+
+#ifndef _NETSURF_UTILS_FILENAME_H_
+#define _NETSURF_UTILS_FILENAME_H_
+
+#include <stdbool.h>
+
+#ifdef riscos
+#define TEMP_FILENAME_PREFIX "<Wimp$ScrapDir>/WWW/NetSurf/Cache"
+#else
+#define TEMP_FILENAME_PREFIX "/tmp/WWW/NetSurf/Cache"
+#endif
+
+char *filename_request(void);
+bool filename_claim(const char *filename);
+void filename_release(const char *filename);
+bool filename_initialise(void);
+void filename_flush(void);
+
+#endif
16 years, 9 months
r2540 rjw - in /trunk/netsurf: content/urldb.c makefile riscos/bitmap.c riscos/configure/con_cache.c riscos/gui.c
by netsurf@semichrome.net
Author: rjw
Date: Sat Apr 22 00:49:52 2006
New Revision: 2540
URL: http://svn.semichrome.net?rev=2540&view=rev
Log:
Remove RISC OS dependencies from filename code.
Modified:
trunk/netsurf/content/urldb.c
trunk/netsurf/makefile
trunk/netsurf/riscos/bitmap.c
trunk/netsurf/riscos/configure/con_cache.c
trunk/netsurf/riscos/gui.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=2540&r1=2539&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sat Apr 22 00:49:52 2006
@@ -425,6 +425,13 @@
/* ensure filename is 'XX.XX.XX.XX' */
if ((s[2] == '.') && (s[5] == '.') &&
(s[8] == '.')) {
+ s[2] = '/';
+ s[5] = '/';
+ s[8] = '/';
+ s[11] = '\0';
+ p->thumb = bitmap_create_file(s);
+ } else if ((s[2] == '/') && (s[5] == '/') &&
+ (s[8] == '/')) {
s[11] = '\0';
p->thumb = bitmap_create_file(s);
}
Modified: trunk/netsurf/makefile
URL: http://svn.semichrome.net/trunk/netsurf/makefile?rev=2540&r1=2539&r2=2540...
==============================================================================
--- trunk/netsurf/makefile (original)
+++ trunk/netsurf/makefile Sat Apr 22 00:49:52 2006
@@ -22,7 +22,7 @@
OBJECTS_COMMON += box.o box_construct.o box_normalise.o form.o \
html.o html_redraw.o imagemap.o layout.o list.o \
table.o textplain.o # render/
-OBJECTS_COMMON += messages.o talloc.o url.o utf8.o \
+OBJECTS_COMMON += filename.o messages.o talloc.o url.o utf8.o \
utils.o # utils/
OBJECTS_COMMON += options.o tree.o # desktop/
@@ -34,7 +34,7 @@
textinput.o version.o # desktop/
OBJECTS_RISCOS += 401login.o artworks.o assert.o awrender.o bitmap.o \
buffer.o configure.o debugwin.o \
- dialog.o download.o draw.o filename.o filetype.o font.o \
+ dialog.o download.o draw.o filetype.o font.o \
global_history.o gui.o help.o history.o hotlist.o image.o \
menus.o message.o mouseactions.o palettes.o plotters.o plugin.o print.o \
query.o save.o save_complete.o save_draw.o save_text.o \
Modified: trunk/netsurf/riscos/bitmap.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/bitmap.c?rev=2540&r1=2539&...
==============================================================================
--- trunk/netsurf/riscos/bitmap.c (original)
+++ trunk/netsurf/riscos/bitmap.c Sat Apr 22 00:49:52 2006
@@ -17,17 +17,18 @@
#include <stdbool.h>
#include <string.h>
#include <swis.h>
+#include <unixlib/local.h>
#include "oslib/osfile.h"
#include "oslib/osspriteop.h"
#include "netsurf/content/content.h"
#include "netsurf/image/bitmap.h"
#include "netsurf/riscos/bitmap.h"
-#include "netsurf/riscos/filename.h"
#include "netsurf/riscos/image.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/palettes.h"
#include "netsurf/riscos/sprite.h"
#include "netsurf/riscos/tinct.h"
+#include "netsurf/utils/filename.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@@ -82,6 +83,7 @@
unsigned int input_size;
};
+char bitmap_unixname[256];
char bitmap_filename[256];
@@ -209,7 +211,7 @@
if (file[0] == '\0')
return NULL;
- if (!ro_filename_claim(file))
+ if (!filename_claim(file))
return NULL;
bitmap = calloc(1, sizeof(struct bitmap));
if (!bitmap)
@@ -806,13 +808,20 @@
int len;
fileswitch_object_type obj_type;
os_error *error;
+ char *r;
struct bitmap_compressed_header *bitmap_compressed;
osspriteop_header *bitmap_direct;
assert(bitmap->filename);
- sprintf(bitmap_filename, "%s.%s", CACHE_FILENAME_PREFIX,
+ sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX,
bitmap->filename);
+ r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX,
+ bitmap_filename, 256, 0);
+ if (r == 0) {
+ LOG(("__riscosify failed"));
+ return;
+ }
error = xosfile_read_stamped_no_path(bitmap_filename,
&obj_type, 0, 0, &len, 0, 0);
if ((error) || (obj_type != fileswitch_IS_FILE))
@@ -879,7 +888,7 @@
void bitmap_save_file(struct bitmap *bitmap)
{
unsigned int area_size;
- char *filename;
+ char *filename, *r;
os_error *error;
struct bitmap_compressed_header *header;
@@ -897,10 +906,16 @@
}
/* dump the data (compressed or otherwise) to disk */
- filename = ro_filename_request();
+ filename = filename_request();
strcpy(bitmap->filename, filename);
- sprintf(bitmap_filename, "%s.%s", CACHE_FILENAME_PREFIX,
+ sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX,
bitmap->filename);
+ r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX,
+ bitmap_filename, 256, 0);
+ if (r == 0) {
+ LOG(("__riscosify failed"));
+ return;
+ }
if (bitmap->compressed) {
header = (struct bitmap_compressed_header *)bitmap->compressed;
area_size = header->input_size +
@@ -940,7 +955,7 @@
void bitmap_delete_file(struct bitmap *bitmap)
{
assert(bitmap->filename[0]);
- ro_filename_release(bitmap->filename);
+ filename_release(bitmap->filename);
bitmap->filename[0] = 0;
}
Modified: trunk/netsurf/riscos/configure/con_cache.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/configure/con_cache.c?rev=...
==============================================================================
--- trunk/netsurf/riscos/configure/con_cache.c (original)
+++ trunk/netsurf/riscos/configure/con_cache.c Sat Apr 22 00:49:52 2006
@@ -5,15 +5,16 @@
* Copyright 2005 Richard Wilson <info(a)tinct.net>
*/
+#include "oslib/hourglass.h"
#include "netsurf/desktop/options.h"
#include "netsurf/riscos/dialog.h"
-#include "netsurf/riscos/filename.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/riscos/wimp_event.h"
#include "netsurf/riscos/configure.h"
#include "netsurf/riscos/configure/configure.h"
+#include "netsurf/utils/filename.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
@@ -63,7 +64,9 @@
28, 0);
return true;
case CACHE_MAINTAIN_BUTTON:
- ro_filename_flush();
+ xhourglass_on();
+ filename_flush();
+ xhourglass_off();
return true;
}
return false;
Modified: trunk/netsurf/riscos/gui.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.c?rev=2540&r1=2539&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Sat Apr 22 00:49:52 2006
@@ -50,7 +50,6 @@
#include "netsurf/riscos/bitmap.h"
#include "netsurf/riscos/buffer.h"
#include "netsurf/riscos/dialog.h"
-#include "netsurf/riscos/filename.h"
#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
@@ -78,6 +77,7 @@
#include "netsurf/riscos/url_complete.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/riscos/wimp_event.h"
+#include "netsurf/utils/filename.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
@@ -307,7 +307,7 @@
prev_sigs.sigterm == SIG_ERR)
die("Failed registering signal handlers");
- ro_filename_initialise();
+ filename_initialise();
#ifdef WITH_SAVE_COMPLETE
save_complete_init();
@@ -1300,9 +1300,9 @@
*/
void ro_gui_user_message(wimp_event_no event, wimp_message *message)
{
- /* attempt automatic routing */
- if (ro_message_handle_message(event, message))
- return;
+ /* attempt automatic routing */
+ if (ro_message_handle_message(event, message))
+ return;
switch (message->action) {
case message_DATA_LOAD:
@@ -2139,8 +2139,9 @@
void ro_gui_view_source(struct content *content)
{
os_error *error;
- char *temp_name;
- wimp_full_message_data_xfer message;
+ char full_name[256];
+ char *temp_name, *r;
+ wimp_full_message_data_xfer message;
if (!content || !content->source_data) {
warn_user("MiscError", "No document source");
@@ -2159,13 +2160,19 @@
bother releasing it and simply allow it to be re-used next time NetSurf
is started. The memory overhead from doing this is under 1 byte per
filename. */
- temp_name = ro_filename_request();
+ temp_name = filename_request();
if (!temp_name) {
- warn_user("NoMemory", 0);
- return;
+ warn_user("NoMemory", 0);
+ return;
}
- snprintf(message.file_name, 212, "%s.%s",
- CACHE_FILENAME_PREFIX, temp_name);
+ snprintf(full_name, 256, "%s/%s", TEMP_FILENAME_PREFIX, temp_name);
+ full_name[255] = '\0';
+ r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX, message.file_name,
+ 212, 0);
+ if (r == 0) {
+ LOG(("__riscosify failed"));
+ return;
+ }
message.file_name[211] = '\0';
error = xosfile_save_stamped(message.file_name,
ro_content_filetype(content),
16 years, 9 months
r2539 rjek - /trunk/netsurf/gtk/gtk_window.c
by netsurf@semichrome.net
Author: rjek
Date: Thu Apr 20 17:26:26 2006
New Revision: 2539
URL: http://svn.semichrome.net?rev=2539&view=rev
Log:
Basic support for typing text into textual form elements.
Modified:
trunk/netsurf/gtk/gtk_window.c
Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_window.c?rev=2539&r1=2538...
==============================================================================
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Thu Apr 20 17:26:26 2006
@@ -18,6 +18,7 @@
#include "netsurf/desktop/netsurf.h"
#include "netsurf/desktop/plotters.h"
#include "netsurf/desktop/options.h"
+#include "netsurf/desktop/textinput.h"
#include "netsurf/gtk/gtk_gui.h"
#include "netsurf/gtk/gtk_plotters.h"
#include "netsurf/gtk/gtk_window.h"
@@ -47,6 +48,7 @@
float scale;
struct gtk_history_window *history_window;
GtkWidget *history_window_widget;
+ int caretx, carety, careth;
};
struct gtk_history_window {
@@ -93,8 +95,11 @@
GdkEventButton *event, gpointer data);
static void gui_window_size_allocate_event(GtkWidget *widget,
GtkAllocation *allocation, gpointer data);
-
+static gboolean gui_window_key_press_event(GtkWidget *widget,
+ GdkEventKey *event, gpointer data);
static void gtk_perform_deferred_resize(void *p);
+
+static wchar_t gdkkey_to_nskey(GdkEventKey *key);
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone)
@@ -118,6 +123,9 @@
return 0;
}
+ /* a height of zero means no caret */
+ g->careth = 0;
+
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 600, 600);
gtk_window_set_title(GTK_WINDOW(window), "NetSurf");
@@ -215,11 +223,16 @@
GDK_EXPOSURE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK |
- GDK_POINTER_MOTION_MASK);
+ GDK_POINTER_MOTION_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK);
+ GTK_WIDGET_SET_FLAGS(GTK_WIDGET(drawing_area),
+ GTK_CAN_FOCUS);
gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL,
&((GdkColor) { 0, 0xffff, 0xffff, 0xffff }));
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled),
drawing_area);
+
gtk_widget_show(drawing_area);
history_area = gtk_drawing_area_new();
@@ -275,6 +288,8 @@
G_CALLBACK(gui_window_button_press_event), g);
g_signal_connect(G_OBJECT(scrolled), "size_allocate",
G_CALLBACK(gui_window_size_allocate_event), g);
+ g_signal_connect(G_OBJECT(drawing_area), "key_press_event",
+ G_CALLBACK(gui_window_key_press_event), g);
g_signal_connect(G_OBJECT(zoomin_button), "clicked",
G_CALLBACK(gui_window_zoomin_button_event), g);
@@ -426,6 +441,10 @@
event->area.y + event->area.height,
g->scale, 0xFFFFFF);
+ if (g->careth != 0)
+ plot.line(g->caretx, g->carety,
+ g->caretx, g->carety + g->careth, 1, 0, false, false);
+
g_object_unref(current_gc);
#ifdef CAIRO_VERSION
cairo_destroy(current_cr);
@@ -499,6 +518,14 @@
return TRUE;
}
+gboolean gui_window_key_press_event(GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
+{
+ struct gui_window *g = data;
+ wchar_t nskey = gdkkey_to_nskey(event);
+ browser_window_key_press(g->bw, nskey);
+}
gboolean gui_window_configure_event(GtkWidget *widget,
GdkEventConfigure *event, gpointer data)
@@ -751,14 +778,34 @@
schedule_remove(nsgtk_throb, g);
}
+static void gui_window_redraw_caret(struct gui_window *g)
+{
+ if (g->careth == 0)
+ return;
+
+ gui_window_redraw(g, g->caretx, g->carety,
+ g->caretx, g->carety + g->careth);
+}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
+ gui_window_redraw_caret(g);
+
+ g->caretx = x;
+ g->carety = y + 1;
+ g->careth = height;
+
+ gui_window_redraw_caret(g);
+
+ gtk_widget_grab_focus(g->drawing_area);
}
void gui_window_remove_caret(struct gui_window *g)
{
+ gui_window_redraw_caret(g);
+
+ g->careth = 0;
}
@@ -828,3 +875,42 @@
{
return false;
}
+
+wchar_t gdkkey_to_nskey(GdkEventKey *key)
+{
+ /* this function will need to become much more complex to support
+ * everything that the RISC OS version does. But this will do for
+ * now. I hope.
+ */
+
+ switch (key->keyval)
+ {
+ case GDK_BackSpace: return KEY_DELETE_LEFT;
+ case GDK_Delete: return KEY_DELETE_RIGHT;
+ case GDK_Linefeed: return 13;
+ case GDK_Return: return 10;
+ case GDK_Left: return KEY_LEFT;
+ case GDK_Right: return KEY_RIGHT;
+ case GDK_Up: return KEY_UP;
+ case GDK_Down: return KEY_DOWN;
+
+ /* Modifiers - do nothing for now */
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ case GDK_Control_L:
+ case GDK_Control_R:
+ case GDK_Caps_Lock:
+ case GDK_Shift_Lock:
+ case GDK_Meta_L:
+ case GDK_Meta_R:
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ case GDK_Super_L:
+ case GDK_Super_R:
+ case GDK_Hyper_L:
+ case GDK_Hyper_R: return 0;
+
+ default: return key->keyval;
+ }
+}
+
16 years, 9 months
r2537 bursa - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: bursa
Date: Sun Apr 16 11:30:51 2006
New Revision: 2537
URL: http://svn.semichrome.net?rev=2537&view=rev
Log:
Make static function names consistent.
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=2537&r1=2536&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Apr 16 11:30:51 2006
@@ -194,8 +194,8 @@
} while (p != ring); \
} else sizevar = 0
-static void ns_internal_cache_handle(CURL *handle, char *hostname);
-static void ns_internal_dispatch_jobs(void);
+static void fetch_cache_handle(CURL *handle, char *hostname);
+static void fetch_dispatch_jobs(void);
/**
* Initialise the fetcher.
@@ -439,7 +439,7 @@
/* Dump us in the queue and ask the queue to run. */
RING_INSERT(queue_ring, fetch);
- ns_internal_dispatch_jobs();
+ fetch_dispatch_jobs();
return fetch;
failed:
@@ -465,7 +465,7 @@
*
* This will return whether or not the fetch was successfully initiated.
*/
-static bool ns_internal_initiate_fetch(struct fetch *fetch, CURL *handle)
+static bool fetch_initiate_fetch(struct fetch *fetch, CURL *handle)
{
CURLcode code;
CURLMcode codem;
@@ -490,7 +490,7 @@
/**
* Find a CURL handle to use to dispatch a job
*/
-static CURL *ns_internal_get_handle(char *host)
+static CURL *fetch_get_handle(char *host)
{
struct cache_handle *h;
CURL *ret;
@@ -509,10 +509,10 @@
/**
* Dispatch a single job
*/
-static bool ns_internal_dispatch_job(struct fetch *fetch)
+static bool fetch_dispatch_job(struct fetch *fetch)
{
RING_REMOVE(queue_ring, fetch);
- if (!ns_internal_initiate_fetch(fetch, ns_internal_get_handle(fetch->host))) {
+ if (!fetch_initiate_fetch(fetch, fetch_get_handle(fetch->host))) {
RING_INSERT(queue_ring, fetch); /* Put it back on the end of the queue */
return false;
} else {
@@ -527,7 +527,7 @@
* We don't check the overall dispatch size here because we're not called unless
* there is room in the fetch queue for us.
*/
-static bool ns_internal_choose_and_dispatch(void)
+static bool fetch_choose_and_dispatch(void)
{
struct fetch *queueitem;
queueitem = queue_ring;
@@ -539,7 +539,7 @@
RING_COUNTBYHOST(struct fetch, fetch_ring, countbyhost, queueitem->host);
if (countbyhost < option_max_fetchers_per_host) {
/* We can dispatch this item in theory */
- return ns_internal_dispatch_job(queueitem);
+ return fetch_dispatch_job(queueitem);
}
queueitem = queueitem->r_next;
} while (queueitem != queue_ring);
@@ -549,7 +549,7 @@
/**
* Dispatch as many jobs as we have room to dispatch.
*/
-static void ns_internal_dispatch_jobs(void)
+static void fetch_dispatch_jobs(void)
{
int all_active, all_queued;
@@ -558,7 +558,7 @@
RING_GETSIZE(struct fetch, fetch_ring, all_active);
while( all_queued && all_active < option_max_fetchers ) {
LOG(("%d queued, %d fetching", all_queued, all_active));
- if (ns_internal_choose_and_dispatch()) {
+ if (fetch_choose_and_dispatch()) {
all_queued--;
all_active++;
} else {
@@ -572,7 +572,7 @@
* Cache a CURL handle for the provided host (if wanted)
*
*/
-static void ns_internal_cache_handle(CURL *handle, char *host)
+static void fetch_cache_handle(CURL *handle, char *host)
{
struct cache_handle *h = 0;
int c;
@@ -738,7 +738,7 @@
f->curl_handle);
assert(codem == CURLM_OK);
/* Put this curl handle into the cache if wanted. */
- ns_internal_cache_handle(f->curl_handle, f->host);
+ fetch_cache_handle(f->curl_handle, f->host);
f->curl_handle = 0;
/* Remove this from the active set of fetches (if it's still there) */
RING_REMOVE(fetch_ring, f);
@@ -751,7 +751,7 @@
if (!fetch_ring && !queue_ring)
fetch_active = false;
else if (queue_ring)
- ns_internal_dispatch_jobs();
+ fetch_dispatch_jobs();
}
16 years, 9 months
r2536 jmb - /trunk/netsurf/desktop/browser.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Apr 16 11:22:53 2006
New Revision: 2536
URL: http://svn.semichrome.net?rev=2536&view=rev
Log:
Fix utter stupidity
Modified:
trunk/netsurf/desktop/browser.c
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=2536&r1=253...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Sun Apr 16 11:22:53 2006
@@ -325,15 +325,17 @@
browser_window_set_status(bw, c->status_message);
if (bw->history_add) {
history_add(bw->history, c, bw->frag_id);
- if (!urldb_add_url(c->url))
- LOG(("urldb_add_url failed"));
-
- urldb_set_url_title(c->url,
+ if (urldb_add_url(c->url)) {
+ urldb_set_url_title(c->url,
c->title ? c->title : c->url);
- urldb_update_url_visit_data(c->url);
- urldb_set_url_content_type(c->url, c->type);
- /* This is safe as we've just added the URL */
- global_history_add(urldb_get_url(c->url));
+ urldb_update_url_visit_data(c->url);
+ urldb_set_url_content_type(c->url,
+ c->type);
+ /* This is safe as we've just
+ * added the URL */
+ global_history_add(
+ urldb_get_url(c->url));
+ }
}
switch (c->type) {
case CONTENT_HTML:
16 years, 9 months
r2535 jmb - /trunk/netsurf/content/urldb.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Apr 15 19:57:57 2006
New Revision: 2535
URL: http://svn.semichrome.net?rev=2535&view=rev
Log:
Ignore scheme when performing partial match
Modified:
trunk/netsurf/content/urldb.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=2535&r1=2534&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sat Apr 15 19:57:57 2006
@@ -1061,11 +1061,16 @@
{
char host[256];
char buf[260]; /* max domain + "www." */
- const char *slash;
+ const char *slash, *scheme_sep;
struct search_node *tree;
const struct host_part *h;
assert(prefix && callback);
+
+ /* strip scheme */
+ scheme_sep = strstr(prefix, "://");
+ if (scheme_sep)
+ prefix = scheme_sep + 3;
slash = strchr(prefix, '/');
16 years, 9 months
r2534 jmb - in /trunk/netsurf: content/urldb.c content/urldb.h desktop/browser.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Apr 15 19:53:20 2006
New Revision: 2534
URL: http://svn.semichrome.net?rev=2534&view=rev
Log:
Use database's copy of URL for new global history entries
Modified:
trunk/netsurf/content/urldb.c
trunk/netsurf/content/urldb.h
trunk/netsurf/desktop/browser.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=2534&r1=2533&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Sat Apr 15 19:53:20 2006
@@ -838,6 +838,25 @@
}
/**
+ * Extract an URL from the db
+ *
+ * \param url URL to extract
+ * \return Pointer to database's copy of URL or NULL if not found
+ */
+const char *urldb_get_url(const char *url)
+{
+ struct path_data *p;
+
+ assert(url);
+
+ p = urldb_find_url(url);
+ if (!p)
+ return NULL;
+
+ return p->url;
+}
+
+/**
* Look up authentication details in database
*
* \param url Absolute URL to search for
Modified: trunk/netsurf/content/urldb.h
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.h?rev=2534&r1=2533&...
==============================================================================
--- trunk/netsurf/content/urldb.h (original)
+++ trunk/netsurf/content/urldb.h Sat Apr 15 19:53:20 2006
@@ -38,6 +38,7 @@
void urldb_update_url_visit_data(const char *url);
void urldb_reset_url_visit_data(const char *url);
const struct url_data *urldb_get_url_data(const char *url);
+const char *urldb_get_url(const char *url);
/* Authentication modification / lookup */
void urldb_set_auth_details(const char *url, const char *realm,
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=2534&r1=253...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Sat Apr 15 19:53:20 2006
@@ -332,7 +332,8 @@
c->title ? c->title : c->url);
urldb_update_url_visit_data(c->url);
urldb_set_url_content_type(c->url, c->type);
- global_history_add(c->url);
+ /* This is safe as we've just added the URL */
+ global_history_add(urldb_get_url(c->url));
}
switch (c->type) {
case CONTENT_HTML:
16 years, 9 months