r12097 tlsa - /trunk/netsurf/render/textplain.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 13:15:32 2011
New Revision: 12097
URL: http://source.netsurf-browser.org?rev=12097&view=rev
Log:
Fix text/plain rendering's plot range calc to take account of vertical plot offset (y).
Modified:
trunk/netsurf/render/textplain.c
Modified: trunk/netsurf/render/textplain.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/textplain.c?rev=12...
==============================================================================
--- trunk/netsurf/render/textplain.c (original)
+++ trunk/netsurf/render/textplain.c Thu Mar 17 13:15:32 2011
@@ -557,8 +557,8 @@
unsigned long line_count = c->data.textplain.physical_line_count;
float line_height = textplain_line_height();
float scaled_line_height = line_height * scale;
- long line0 = clip->y0 / scaled_line_height - 1;
- long line1 = clip->y1 / scaled_line_height + 1;
+ long line0 = (clip->y0 - y) / scaled_line_height - 1;
+ long line1 = (clip->y1 - y) / scaled_line_height + 1;
struct textplain_line *line = c->data.textplain.physical_line;
size_t length;
plot_style_t *plot_style_highlight;
12 years, 6 months
r12096 tlsa - /trunk/netsurf/gtk/font_pango.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 09:12:39 2011
New Revision: 12096
URL: http://source.netsurf-browser.org?rev=12096&view=rev
Log:
Comment out noisy nsfont_width logging.
Modified:
trunk/netsurf/gtk/font_pango.c
Modified: trunk/netsurf/gtk/font_pango.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/font_pango.c?rev=1209...
==============================================================================
--- trunk/netsurf/gtk/font_pango.c (original)
+++ trunk/netsurf/gtk/font_pango.c Thu Mar 17 09:12:39 2011
@@ -104,7 +104,9 @@
pango_font_description_free(desc);
- LOG(("fstyle: %p string:\"%.*s\", length: %u -> %d", fstyle, length, string, length, *width));
+ /* LOG(("fstyle: %p string:\"%.*s\", length: %u, width: %dpx",
+ fstyle, length, string, length, *width));
+ */
return true;
}
12 years, 6 months
r12095 vince - in /trunk/netsurf/framebuffer: filetype.c findfile.c res/adblock.css res/credits.html res/internal.css res/licence.html res/netsurf.png
by netsurf@semichrome.net
Author: vince
Date: Thu Mar 17 07:29:42 2011
New Revision: 12095
URL: http://source.netsurf-browser.org?rev=12095&view=rev
Log:
Fix framebuffer resource: handling
Added:
trunk/netsurf/framebuffer/res/adblock.css (with props)
trunk/netsurf/framebuffer/res/credits.html (with props)
trunk/netsurf/framebuffer/res/internal.css (with props)
trunk/netsurf/framebuffer/res/licence.html (with props)
trunk/netsurf/framebuffer/res/netsurf.png (with props)
Modified:
trunk/netsurf/framebuffer/filetype.c
trunk/netsurf/framebuffer/findfile.c
Modified: trunk/netsurf/framebuffer/filetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/filetype.c?re...
==============================================================================
--- trunk/netsurf/framebuffer/filetype.c (original)
+++ trunk/netsurf/framebuffer/filetype.c Thu Mar 17 07:29:42 2011
@@ -43,6 +43,8 @@
return "image/gif";
if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
return "image/png";
+ if (2 < l && strcasecmp(unix_path + l - 3, "b60") == 0)
+ return "image/png";
if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
return "image/jng";
if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
Modified: trunk/netsurf/framebuffer/findfile.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/findfile.c?re...
==============================================================================
--- trunk/netsurf/framebuffer/findfile.c (original)
+++ trunk/netsurf/framebuffer/findfile.c Thu Mar 17 07:29:42 2011
@@ -59,8 +59,14 @@
char *path_to_url(const char *path)
{
- int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
- char *url = malloc(urllen);
+ int urllen;
+ char *url;
+
+ if (path == NULL)
+ return NULL;
+
+ urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
+ url = malloc(urllen);
if (*path == '/') {
path++; /* file: paths are already absolute */
Added: trunk/netsurf/framebuffer/res/adblock.css
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/res/adblock.c...
==============================================================================
--- trunk/netsurf/framebuffer/res/adblock.css (added)
+++ trunk/netsurf/framebuffer/res/adblock.css Thu Mar 17 07:29:42 2011
@@ -1,0 +1,1 @@
+link ../../!NetSurf/Resources/AdBlock,f79
Propchange: trunk/netsurf/framebuffer/res/adblock.css
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/framebuffer/res/credits.html
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/res/credits.h...
==============================================================================
--- trunk/netsurf/framebuffer/res/credits.html (added)
+++ trunk/netsurf/framebuffer/res/credits.html Thu Mar 17 07:29:42 2011
@@ -1,0 +1,1 @@
+link ../../!NetSurf/Resources/en/credits.html,faf
Propchange: trunk/netsurf/framebuffer/res/credits.html
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/framebuffer/res/internal.css
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/res/internal....
==============================================================================
--- trunk/netsurf/framebuffer/res/internal.css (added)
+++ trunk/netsurf/framebuffer/res/internal.css Thu Mar 17 07:29:42 2011
@@ -1,0 +1,1 @@
+link ../../!NetSurf/Resources/internal.css,f79
Propchange: trunk/netsurf/framebuffer/res/internal.css
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/framebuffer/res/licence.html
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/res/licence.h...
==============================================================================
--- trunk/netsurf/framebuffer/res/licence.html (added)
+++ trunk/netsurf/framebuffer/res/licence.html Thu Mar 17 07:29:42 2011
@@ -1,0 +1,1 @@
+link ../../!NetSurf/Resources/en/licence.html,faf
Propchange: trunk/netsurf/framebuffer/res/licence.html
------------------------------------------------------------------------------
svn:special = *
Added: trunk/netsurf/framebuffer/res/netsurf.png
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/res/netsurf.p...
==============================================================================
--- trunk/netsurf/framebuffer/res/netsurf.png (added)
+++ trunk/netsurf/framebuffer/res/netsurf.png Thu Mar 17 07:29:42 2011
@@ -1,0 +1,1 @@
+link ../../!NetSurf/Resources/netsurf.png,b60
Propchange: trunk/netsurf/framebuffer/res/netsurf.png
------------------------------------------------------------------------------
svn:special = *
12 years, 6 months
r12093 vince - /trunk/netsurf/content/fetchers/about.c
by netsurf@semichrome.net
Author: vince
Date: Thu Mar 17 07:24:40 2011
New Revision: 12093
URL: http://source.netsurf-browser.org?rev=12093&view=rev
Log:
set hidden flag for more about: pages
Modified:
trunk/netsurf/content/fetchers/about.c
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Thu Mar 17 07:24:40 2011
@@ -374,9 +374,9 @@
static bool fetch_about_about_handler(struct fetch_about_context *ctx);
struct about_handlers {
- const char *name;
- fetch_about_handler handler;
- bool duplicate;
+ const char *name; /**< name to match in url */
+ fetch_about_handler handler; /* handler for the url */
+ bool hidden; /* Flag indicating if entry should be show in listing */
};
struct about_handlers about_handler_list[] = {
@@ -386,8 +386,8 @@
{ "config", fetch_about_config_handler, false },
{ "Choices", fetch_about_choices_handler, false },
{ "testament", fetch_about_testament_handler, false },
- { "about", fetch_about_about_handler, false },
- { "blank", fetch_about_blank_handler, false } /* The default */
+ { "about", fetch_about_about_handler, true },
+ { "blank", fetch_about_blank_handler, true } /* The default */
};
#define about_handler_list_len (sizeof(about_handler_list) / sizeof(struct about_handlers))
@@ -429,7 +429,7 @@
for (abt_loop = 0; abt_loop < about_handler_list_len; abt_loop++) {
/* Skip over duplicate entries */
- if (about_handler_list[abt_loop].duplicate)
+ if (about_handler_list[abt_loop].hidden)
continue;
res = snprintf(buffer + slen, sizeof buffer - slen,
12 years, 6 months
r12092 tlsa - /trunk/netsurf/content/fetchers/about.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 07:17:25 2011
New Revision: 12092
URL: http://source.netsurf-browser.org?rev=12092&view=rev
Log:
Less bloated "license" spelling handler.
Modified:
trunk/netsurf/content/fetchers/about.c
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Thu Mar 17 07:17:25 2011
@@ -156,17 +156,6 @@
return true;
}
-static bool fetch_about_license_handler(struct fetch_about_context *ctx)
-{
- /* content is going to return redirect to the noun */
- fetch_set_http_code(ctx->fetchh, 302);
-
- fetch_about_send_callback(FETCH_REDIRECT, ctx, "about:licence",
- 0, FETCH_ERROR_NO_ERROR);
-
- return true;
-}
-
static bool fetch_about_config_handler(struct fetch_about_context *ctx)
{
@@ -393,7 +382,7 @@
struct about_handlers about_handler_list[] = {
{ "credits", fetch_about_credits_handler, false },
{ "licence", fetch_about_licence_handler, false },
- { "license", fetch_about_license_handler, true },
+ { "license", fetch_about_licence_handler, true },
{ "config", fetch_about_config_handler, false },
{ "Choices", fetch_about_choices_handler, false },
{ "testament", fetch_about_testament_handler, false },
12 years, 6 months
r12091 dsilvers - /trunk/netsurf/content/fetchers/about.c
by netsurf@semichrome.net
Author: dsilvers
Date: Thu Mar 17 07:12:55 2011
New Revision: 12091
URL: http://source.netsurf-browser.org?rev=12091&view=rev
Log:
Retabify about.c since I had previously moosed it
Modified:
trunk/netsurf/content/fetchers/about.c
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Thu Mar 17 07:12:55 2011
@@ -294,12 +294,12 @@
typedef struct { const char *leaf; const char modtype; } modification_t;
static bool fetch_about_testament_handler(struct fetch_about_context *ctx)
{
- static modification_t modifications[] = WT_MODIFICATIONS;
+ static modification_t modifications[] = WT_MODIFICATIONS;
char buffer[1024];
int code = 200;
int slen;
- int i;
-
+ int i;
+
/* content is going to return ok */
fetch_set_http_code(ctx->fetchh, code);
@@ -315,63 +315,63 @@
FETCH_ERROR_NO_ERROR))
goto fetch_about_testament_handler_aborted;
- slen = snprintf(buffer, sizeof buffer,
+ slen = snprintf(buffer, sizeof buffer,
#if defined(WT_BRANCHISTRUNK)
- "# This is a *DEVELOPMENT* build from the trunk.\n\n"
+ "# This is a *DEVELOPMENT* build from the trunk.\n\n"
#elif defined(WT_BRANCHISRELEASE)
- "# This is a release build of NetSurf\n\n"
+ "# This is a release build of NetSurf\n\n"
#elif defined(WT_NO_SVN)
- "# This NetSurf was built outside of our revision control environment.\n# This testament is therefore very useful.\n\n"
+ "# This NetSurf was built outside of our revision control environment.\n# This testament is therefore very useful.\n\n"
#else
- "# This NetSurf was built from a branch.\n\n"
+ "# This NetSurf was built from a branch.\n\n"
#endif
- );
-
+ );
+
if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
FETCH_ERROR_NO_ERROR))
goto fetch_about_testament_handler_aborted;
-
+
slen = snprintf(buffer, sizeof buffer,
- "Built by %s (%s) from %s at revision %s\n\n",
- GECOS, USERNAME, WT_BRANCHPATH, WT_REVID);
+ "Built by %s (%s) from %s at revision %s\n\n",
+ GECOS, USERNAME, WT_BRANCHPATH, WT_REVID);
if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
FETCH_ERROR_NO_ERROR))
goto fetch_about_testament_handler_aborted;
-
+
slen = snprintf(buffer, sizeof buffer,
- "Built on %s in %s\n\n",
- WT_HOSTNAME, WT_ROOT);
+ "Built on %s in %s\n\n",
+ WT_HOSTNAME, WT_ROOT);
if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
FETCH_ERROR_NO_ERROR))
goto fetch_about_testament_handler_aborted;
-
- if (WT_MODIFIED > 0) {
- slen = snprintf(buffer, sizeof buffer,
- "Working tree has %d modification%s\n\n",
- WT_MODIFIED, WT_MODIFIED == 1 ? "" : "s");
- } else {
- slen = snprintf(buffer, sizeof buffer,
- "Working tree is not modified.\n");
- }
+
+ if (WT_MODIFIED > 0) {
+ slen = snprintf(buffer, sizeof buffer,
+ "Working tree has %d modification%s\n\n",
+ WT_MODIFIED, WT_MODIFIED == 1 ? "" : "s");
+ } else {
+ slen = snprintf(buffer, sizeof buffer,
+ "Working tree is not modified.\n");
+ }
if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
FETCH_ERROR_NO_ERROR))
goto fetch_about_testament_handler_aborted;
-
- for (i = 0; i < WT_MODIFIED; ++i) {
- slen = snprintf(buffer, sizeof buffer,
- " %c %s\n",
- modifications[i].modtype,
- modifications[i].leaf);
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
- goto fetch_about_testament_handler_aborted;
-
- }
-
+
+ for (i = 0; i < WT_MODIFIED; ++i) {
+ slen = snprintf(buffer, sizeof buffer,
+ " %c %s\n",
+ modifications[i].modtype,
+ modifications[i].leaf);
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+ }
+
fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
FETCH_ERROR_NO_ERROR);
@@ -396,8 +396,8 @@
{ "license", fetch_about_license_handler, true },
{ "config", fetch_about_config_handler, false },
{ "Choices", fetch_about_choices_handler, false },
- { "testament", fetch_about_testament_handler, false },
- { "about", fetch_about_about_handler, false },
+ { "testament", fetch_about_testament_handler, false },
+ { "about", fetch_about_about_handler, false },
{ "blank", fetch_about_blank_handler, false } /* The default */
};
12 years, 6 months
r12090 tlsa - /trunk/netsurf/content/fetchers/about.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 07:09:48 2011
New Revision: 12090
URL: http://source.netsurf-browser.org?rev=12090&view=rev
Log:
Skip duplicates on about:about.
Modified:
trunk/netsurf/content/fetchers/about.c
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Thu Mar 17 07:09:48 2011
@@ -387,17 +387,18 @@
struct about_handlers {
const char *name;
fetch_about_handler handler;
+ bool duplicate;
};
struct about_handlers about_handler_list[] = {
- { "credits", fetch_about_credits_handler },
- { "licence", fetch_about_licence_handler },
- { "license", fetch_about_license_handler },
- { "config", fetch_about_config_handler },
- { "Choices", fetch_about_choices_handler },
- { "testament", fetch_about_testament_handler },
- { "about", fetch_about_about_handler },
- { "blank", fetch_about_blank_handler } /* The default */
+ { "credits", fetch_about_credits_handler, false },
+ { "licence", fetch_about_licence_handler, false },
+ { "license", fetch_about_license_handler, true },
+ { "config", fetch_about_config_handler, false },
+ { "Choices", fetch_about_choices_handler, false },
+ { "testament", fetch_about_testament_handler, false },
+ { "about", fetch_about_about_handler, false },
+ { "blank", fetch_about_blank_handler, false } /* The default */
};
#define about_handler_list_len (sizeof(about_handler_list) / sizeof(struct about_handlers))
@@ -437,6 +438,11 @@
"<ul>\n");
for (abt_loop = 0; abt_loop < about_handler_list_len; abt_loop++) {
+
+ /* Skip over duplicate entries */
+ if (about_handler_list[abt_loop].duplicate)
+ continue;
+
res = snprintf(buffer + slen, sizeof buffer - slen,
"<li><a href=\"about:%s\">about:%s</a></li>\n",
about_handler_list[abt_loop].name,
12 years, 6 months
r12089 tlsa - in /trunk/netsurf: amiga/gui.c atari/gui.c beos/beos_gui.cpp cocoa/gui.m content/fetchers/resource.c content/fetchers/resource.h framebuffer/findfile.c gtk/gui.c monkey/main.c riscos/gui.c windows/gui.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 06:57:09 2011
New Revision: 12089
URL: http://source.netsurf-browser.org?rev=12089&view=rev
Log:
gui_find_resource --> gui_get_resource_url.
Modified:
trunk/netsurf/amiga/gui.c
trunk/netsurf/atari/gui.c
trunk/netsurf/beos/beos_gui.cpp
trunk/netsurf/cocoa/gui.m
trunk/netsurf/content/fetchers/resource.c
trunk/netsurf/content/fetchers/resource.h
trunk/netsurf/framebuffer/findfile.c
trunk/netsurf/gtk/gui.c
trunk/netsurf/monkey/main.c
trunk/netsurf/riscos/gui.c
trunk/netsurf/windows/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=12089&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Thu Mar 17 06:57:09 2011
@@ -431,7 +431,7 @@
/* end Amiupdate */
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
char path[1024];
char filename2[1024];
Modified: trunk/netsurf/atari/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.c?rev=12089&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.c (original)
+++ trunk/netsurf/atari/gui.c Thu Mar 17 06:57:09 2011
@@ -1049,7 +1049,7 @@
}
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
return NULL;
}
Modified: trunk/netsurf/beos/beos_gui.cpp
URL: http://source.netsurf-browser.org/trunk/netsurf/beos/beos_gui.cpp?rev=120...
==============================================================================
--- trunk/netsurf/beos/beos_gui.cpp (original)
+++ trunk/netsurf/beos/beos_gui.cpp Thu Mar 17 06:57:09 2011
@@ -422,7 +422,7 @@
return 0;
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
BString u("rsrc:/");
u << filename;
Modified: trunk/netsurf/cocoa/gui.m
URL: http://source.netsurf-browser.org/trunk/netsurf/cocoa/gui.m?rev=12089&r1=...
==============================================================================
--- trunk/netsurf/cocoa/gui.m (original)
+++ trunk/netsurf/cocoa/gui.m Thu Mar 17 06:57:09 2011
@@ -50,7 +50,7 @@
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
NSString *path = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: filename] ofType: @""];
if (path == nil) return NULL;
Modified: trunk/netsurf/content/fetchers/resource.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/resource...
==============================================================================
--- trunk/netsurf/content/fetchers/resource.c (original)
+++ trunk/netsurf/content/fetchers/resource.c Thu Mar 17 06:57:09 2011
@@ -177,7 +177,7 @@
url_get_components(url, &urlcomp);
- ctx->redirect_url = gui_find_resource(urlcomp.path);
+ ctx->redirect_url = gui_get_resource_url(urlcomp.path);
if (ctx->redirect_url == NULL) {
ctx->handler = fetch_resource_notfound_handler;
} else {
Modified: trunk/netsurf/content/fetchers/resource.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/resource...
==============================================================================
--- trunk/netsurf/content/fetchers/resource.h (original)
+++ trunk/netsurf/content/fetchers/resource.h Thu Mar 17 06:57:09 2011
@@ -48,6 +48,6 @@
* \return A string containing the full URL of the target object or
* NULL if no suitable resource can be found.
*/
-char* gui_find_resource(const char *filename);
+char* gui_get_resource_url(const char *filename);
#endif
Modified: trunk/netsurf/framebuffer/findfile.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/findfile.c?re...
==============================================================================
--- trunk/netsurf/framebuffer/findfile.c (original)
+++ trunk/netsurf/framebuffer/findfile.c Thu Mar 17 06:57:09 2011
@@ -92,7 +92,7 @@
return respath;
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));
Modified: trunk/netsurf/gtk/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gui.c?rev=12089&r1=12...
==============================================================================
--- trunk/netsurf/gtk/gui.c (original)
+++ trunk/netsurf/gtk/gui.c Thu Mar 17 06:57:09 2011
@@ -326,7 +326,7 @@
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));
Modified: trunk/netsurf/monkey/main.c
URL: http://source.netsurf-browser.org/trunk/netsurf/monkey/main.c?rev=12089&r...
==============================================================================
--- trunk/netsurf/monkey/main.c (original)
+++ trunk/netsurf/monkey/main.c Thu Mar 17 06:57:09 2011
@@ -72,7 +72,7 @@
gtk_fetch_filetype_fin();
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));
Modified: trunk/netsurf/riscos/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/gui.c?rev=12089&r1...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Thu Mar 17 06:57:09 2011
@@ -281,24 +281,26 @@
static void ro_msg_window_info(wimp_message *message);
static void ro_gui_view_source_bounce(wimp_message *message);
-char* gui_find_resource(const char *filename)
-{
+char* gui_get_resource_url(const char *filename)
+{
+ const char base_url[] = "file:///NetSurf:/Resources/";
+ size_t filename_len = strlen(filename);
+
/* Find max URL length */
- size_t length = SLEN("file:///NetSurf:/Resources/") + SLEN("xx/") +
- strlen(filename) + 1;
-
- /* Allocate memory for URL (freed by the core) */
+ size_t length = SLEN(base_url) + SLEN("xx/") + filename_len + 1;
+
+ /* Allocate memory for URL (will be owned and freed by the core) */
char *resource_url = malloc(length);
if (resource_url == NULL)
return NULL;
/* Insert base URL */
- resource_url = strcpy(resource_url, "file:///NetSurf:/Resources/");
+ resource_url = strcpy(resource_url, base_url);
/* Add language directory to URL, for translated files */
/* TODO: handle non-en langauages
* handle non-html translated files */
- if (strncmp(filename + strlen(filename) - 5, ".html", 5) == 0) {
+ if (strncmp(filename + filename_len - 5, ".html", 5) == 0) {
resource_url = strcat(resource_url, "en/");
}
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=12089&r...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Thu Mar 17 06:57:09 2011
@@ -2542,7 +2542,7 @@
LOG(("gui_quit"));
}
-char* gui_find_resource(const char *filename)
+char* gui_get_resource_url(const char *filename)
{
return NULL;
}
12 years, 6 months
r12088 tlsa - in /trunk/netsurf: Makefile.sources framebuffer/findfile.c framebuffer/font_freetype.c framebuffer/gui.c gtk/gui.c monkey/main.c utils/filepath.c utils/filepath.h utils/resource.c utils/resource.h
by netsurf@semichrome.net
Author: tlsa
Date: Thu Mar 17 06:26:30 2011
New Revision: 12088
URL: http://source.netsurf-browser.org?rev=12088&view=rev
Log:
Rename utils/resource to utils/filepath to avoid confusion with resource: fetcher.
Added:
trunk/netsurf/utils/filepath.c
- copied, changed from r12085, trunk/netsurf/utils/resource.c
trunk/netsurf/utils/filepath.h
- copied, changed from r12085, trunk/netsurf/utils/resource.h
Removed:
trunk/netsurf/utils/resource.c
trunk/netsurf/utils/resource.h
Modified:
trunk/netsurf/Makefile.sources
trunk/netsurf/framebuffer/findfile.c
trunk/netsurf/framebuffer/font_freetype.c
trunk/netsurf/framebuffer/gui.c
trunk/netsurf/gtk/gui.c
trunk/netsurf/monkey/main.c
Modified: trunk/netsurf/Makefile.sources
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile.sources?rev=1208...
==============================================================================
--- trunk/netsurf/Makefile.sources (original)
+++ trunk/netsurf/Makefile.sources Thu Mar 17 06:26:30 2011
@@ -15,7 +15,7 @@
hubbub_binding.c imagemap.c layout.c list.c table.c textplain.c
S_UTILS := base64.c filename.c hashtable.c http.c locale.c messages.c \
- talloc.c url.c utf8.c utils.c useragent.c resource.c log.c
+ talloc.c url.c utf8.c utils.c useragent.c filepath.c log.c
S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \
mouse.c options.c plot_style.c print.c search.c searchweb.c \
Modified: trunk/netsurf/framebuffer/findfile.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/findfile.c?re...
==============================================================================
--- trunk/netsurf/framebuffer/findfile.c (original)
+++ trunk/netsurf/framebuffer/findfile.c Thu Mar 17 06:26:30 2011
@@ -25,9 +25,9 @@
#include <curl/curl.h>
+#include "utils/filepath.h"
#include "utils/log.h"
#include "utils/url.h"
-#include "utils/resource.h"
#include "content/fetchers/resource.h"
#include "framebuffer/findfile.h"
@@ -47,11 +47,11 @@
char **respath; /* resource paths vector */
const char *lang = NULL;
- pathv = resource_path_to_strvec(resource_path);
+ pathv = filepath_path_to_strvec(resource_path);
- respath = resource_generate(pathv, &lang);
+ respath = filepath_generate(pathv, &lang);
- resource_free_strvec(pathv);
+ filepath_free_strvec(pathv);
return respath;
}
@@ -95,7 +95,7 @@
char* gui_find_resource(const char *filename)
{
char buf[PATH_MAX];
- return path_to_url(resource_sfind(respaths, buf, filename));
+ return path_to_url(filepath_sfind(respaths, buf, filename));
}
/*
Modified: trunk/netsurf/framebuffer/font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/font_freetype...
==============================================================================
--- trunk/netsurf/framebuffer/font_freetype.c (original)
+++ trunk/netsurf/framebuffer/font_freetype.c Thu Mar 17 06:26:30 2011
@@ -26,9 +26,9 @@
#include "css/css.h"
#include "css/utils.h"
#include "render/font.h"
+#include "utils/filepath.h"
#include "utils/utf8.h"
#include "utils/log.h"
-#include "utils/resource.h"
#include "desktop/options.h"
#include "framebuffer/gui.h"
@@ -126,7 +126,7 @@
if (option != NULL) {
newf->fontfile = strdup(option);
} else {
- resource_sfind(respaths, buf, fontname);
+ filepath_sfind(respaths, buf, fontname);
newf->fontfile = strdup(buf);
}
Modified: trunk/netsurf/framebuffer/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/gui.c?rev=120...
==============================================================================
--- trunk/netsurf/framebuffer/gui.c (original)
+++ trunk/netsurf/framebuffer/gui.c Thu Mar 17 06:26:30 2011
@@ -37,7 +37,7 @@
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "desktop/shape.h"
-#include "utils/resource.h"
+#include "utils/filepath.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/schedule.h"
@@ -457,12 +457,12 @@
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
if (option_cookie_file == NULL) {
- option_cookie_file = resource_find(respaths, "Cookies");
+ option_cookie_file = filepath_find(respaths, "Cookies");
LOG(("Using '%s' as Cookies file", option_cookie_file));
}
if (option_cookie_jar == NULL) {
- option_cookie_jar = resource_find(respaths, "Cookies");
+ option_cookie_jar = filepath_find(respaths, "Cookies");
LOG(("Using '%s' as Cookie Jar file", option_cookie_jar));
}
@@ -505,8 +505,8 @@
respaths = fb_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"NETSURF_FB_RESPATH":./framebuffer/res:"NETSURF_FB_FONTPATH);
- options = resource_find(respaths, "Choices");
- messages = resource_find(respaths, "messages");
+ options = filepath_find(respaths, "Choices");
+ messages = filepath_find(respaths, "messages");
netsurf_init(&argc, &argv, options, messages);
Modified: trunk/netsurf/gtk/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gui.c?rev=12088&r1=12...
==============================================================================
--- trunk/netsurf/gtk/gui.c (original)
+++ trunk/netsurf/gtk/gui.c Thu Mar 17 06:26:30 2011
@@ -74,12 +74,12 @@
#include "render/box.h"
#include "render/form.h"
+#include "utils/filepath.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "utils/resource.h"
char *default_stylesheet_url;
char *quirks_stylesheet_url;
@@ -138,13 +138,13 @@
char **pathv; /* resource path string vector */
char **respath; /* resource paths vector */
- pathv = resource_path_to_strvec(resource_path);
+ pathv = filepath_path_to_strvec(resource_path);
langv = g_get_language_names();
- respath = resource_generate(pathv, langv);
-
- resource_free_strvec(pathv);
+ respath = filepath_generate(pathv, langv);
+
+ filepath_free_strvec(pathv);
return respath;
}
@@ -165,7 +165,7 @@
for (frame_num = 0; frame_num < framec; frame_num++) {
snprintf(targetname, PATH_MAX, "throbber/throbber%d.png", frame_num);
- filenames[frame_num] = resource_find(respath, targetname);
+ filenames[frame_num] = filepath_find(respath, targetname);
}
ret = nsgtk_throbber_initialise_from_png(frame_num, filenames);
@@ -191,7 +191,7 @@
snprintf(resname, PATH_MAX, "%s.glade", name);
- filepath = resource_find(respath, resname);
+ filepath = filepath_find(respath, resname);
if (filepath == NULL) {
snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
"Unable to locate %s glade template file.\n", name);
@@ -268,12 +268,12 @@
* values!
*/
if (!option_cookie_file) {
- resource_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
LOG(("Using '%s' as Cookies file", buf));
option_cookie_file = strdup(buf);
}
if (!option_cookie_jar) {
- resource_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
LOG(("Using '%s' as Cookie Jar file", buf));
option_cookie_jar = strdup(buf);
}
@@ -281,13 +281,13 @@
die("Failed initialising cookie options");
if (!option_url_file) {
- resource_sfinddef(respath, buf, "URLs", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/");
LOG(("Using '%s' as URL file", buf));
option_url_file = strdup(buf);
}
if (!option_ca_path) {
- resource_sfinddef(respath, buf, "certs", "/etc/ssl/");
+ filepath_sfinddef(respath, buf, "certs", "/etc/ssl/");
LOG(("Using '%s' as certificate path", buf));
option_ca_path = strdup(buf);
}
@@ -297,12 +297,12 @@
option_downloads_directory = hdir;
}
- resource_sfinddef(respath, buf, "icons/", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/");
LOG(("Using '%s' as Tree icons dir", buf));
tree_set_icon_dir(strdup(buf));
if (!option_hotlist_path) {
- resource_sfinddef(respath, buf, "Hotlist", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/");
LOG(("Using '%s' as Hotlist file", buf));
option_hotlist_path = strdup(buf);
}
@@ -310,7 +310,7 @@
die("Failed initialising hotlist option");
- resource_sfinddef(respath, buf, "Print", "~/.netsurf/");
+ filepath_sfinddef(respath, buf, "Print", "~/.netsurf/");
LOG(("Using '%s' as Print Settings file", buf));
print_options_file_location = strdup(buf);
@@ -329,7 +329,7 @@
char* gui_find_resource(const char *filename)
{
char buf[PATH_MAX];
- return path_to_url(resource_sfind(respaths, buf, filename));
+ return path_to_url(filepath_sfind(respaths, buf, filename));
}
@@ -353,33 +353,33 @@
* however these may be translated which breaks things
* relying on res_dir_location.
*/
- resource_filename = resource_find(respath, "languages");
+ resource_filename = filepath_find(respath, "languages");
resource_filename[strlen(resource_filename) - 9] = 0;
res_dir_location = resource_filename;
/* languages file */
- languages_file_location = resource_find(respath, "languages");
+ languages_file_location = filepath_find(respath, "languages");
/* initialise the glade templates */
nsgtk_init_glade(respath);
/* set default icon if its available */
- resource_filename = resource_find(respath, "netsurf.xpm");
+ resource_filename = filepath_find(respath, "netsurf.xpm");
if (resource_filename != NULL) {
gtk_window_set_default_icon_from_file(resource_filename, NULL);
free(resource_filename);
}
/* Search engine sources */
- search_engines_file_location = resource_find(respath, "SearchEngines");
+ search_engines_file_location = filepath_find(respath, "SearchEngines");
LOG(("Using '%s' as Search Engines file", search_engines_file_location));
/* Default Icon */
- search_default_ico_location = resource_find(respath, "default.ico");
+ search_default_ico_location = filepath_find(respath, "default.ico");
LOG(("Using '%s' as default search ico", search_default_ico_location));
/* Toolbar inicies file */
- toolbar_indices_file_location = resource_find(respath, "toolbarIndices");
+ toolbar_indices_file_location = filepath_find(respath, "toolbarIndices");
LOG(("Using '%s' as custom toolbar settings file", toolbar_indices_file_location));
/* load throbber images */
@@ -389,7 +389,7 @@
/* Initialise completions - cannot fail */
nsgtk_completion_init();
- resource_sfinddef(respath, buf, "mime.types", "/etc/");
+ filepath_sfinddef(respath, buf, "mime.types", "/etc/");
gtk_fetch_filetype_init(buf);
/* set up stylesheet urls */
@@ -482,8 +482,8 @@
/* set standard error to be non-buffering */
setbuf(stderr, NULL);
- options = resource_find(respaths, "Choices");
- messages = resource_find(respaths, "Messages");
+ options = filepath_find(respaths, "Choices");
+ messages = filepath_find(respaths, "Messages");
netsurf_init(&argc, &argv, options, messages);
Modified: trunk/netsurf/monkey/main.c
URL: http://source.netsurf-browser.org/trunk/netsurf/monkey/main.c?rev=12088&r...
==============================================================================
--- trunk/netsurf/monkey/main.c (original)
+++ trunk/netsurf/monkey/main.c Thu Mar 17 06:26:30 2011
@@ -31,7 +31,7 @@
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "desktop/sslcert.h"
-#include "utils/resource.h"
+#include "utils/filepath.h"
#include "utils/url.h"
char *default_stylesheet_url = NULL;
@@ -48,13 +48,13 @@
char **pathv; /* resource path string vector */
char **respath; /* resource paths vector */
- pathv = resource_path_to_strvec(resource_path);
+ pathv = filepath_path_to_strvec(resource_path);
langv = g_get_language_names();
- respath = resource_generate(pathv, langv);
+ respath = filepath_generate(pathv, langv);
- resource_free_strvec(pathv);
+ filepath_free_strvec(pathv);
return respath;
}
@@ -75,7 +75,7 @@
char* gui_find_resource(const char *filename)
{
char buf[PATH_MAX];
- return path_to_url(resource_sfind(respaths, buf, filename));
+ return path_to_url(filepath_sfind(respaths, buf, filename));
}
void
@@ -104,15 +104,15 @@
/* Prep the search paths */
respaths = nsmonkey_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"MONKEY_RESPATH":./monkey/res");
- options = resource_find(respaths, "Choices");
- messages = resource_find(respaths, "Messages");
+ options = filepath_find(respaths, "Choices");
+ messages = filepath_find(respaths, "Messages");
netsurf_init(&argc, &argv, options, messages);
free(messages);
free(options);
- resource_sfinddef(respaths, buf, "mime.types", "/etc/");
+ filepath_sfinddef(respaths, buf, "mime.types", "/etc/");
gtk_fetch_filetype_init(buf);
default_stylesheet_url = strdup("resource:gtkdefault.css");
Copied: trunk/netsurf/utils/filepath.c (from r12085, trunk/netsurf/utils/resource.c)
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/filepath.c?p2=trunk...
==============================================================================
--- trunk/netsurf/utils/resource.c (original)
+++ trunk/netsurf/utils/filepath.c Thu Mar 17 06:26:30 2011
@@ -32,13 +32,13 @@
#include <string.h>
#include "utils/config.h"
-#include "utils/resource.h"
+#include "utils/filepath.h"
/** maximum number of elements in the resource vector */
#define MAX_RESPATH 128
-/* exported interface documented in findresource.h */
-char *resource_vsfindfile(char *str, const char *format, va_list ap)
+/* exported interface documented in filepath.h */
+char *filepath_vsfindfile(char *str, const char *format, va_list ap)
{
char *realpathname;
char *pathname;
@@ -73,21 +73,21 @@
return realpathname;
}
-/* exported interface documented in findresource.h */
-char *resource_sfindfile(char *str, const char *format, ...)
+/* exported interface documented in filepath.h */
+char *filepath_sfindfile(char *str, const char *format, ...)
{
va_list ap;
char *ret;
va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
+ ret = filepath_vsfindfile(str, format, ap);
va_end(ap);
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_findfile(const char *format, ...)
+/* exported interface documented in filepath.h */
+char *filepath_findfile(const char *format, ...)
{
char *str;
char *ret;
@@ -98,7 +98,7 @@
return NULL; /* unable to allocate memory */
va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
+ ret = filepath_vsfindfile(str, format, ap);
va_end(ap);
if (ret == NULL)
@@ -107,8 +107,8 @@
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_sfind(char **respathv, char *filepath, const char *filename)
+/* exported interface documented in filepath.h */
+char *filepath_sfind(char **respathv, char *filepath, const char *filename)
{
int respathc = 0;
@@ -116,7 +116,7 @@
return NULL;
while (respathv[respathc] != NULL) {
- if (resource_sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
+ if (filepath_sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
return filepath;
respathc++;
@@ -125,8 +125,8 @@
return NULL;
}
-/* exported interface documented in findresource.h */
-char *resource_find(char **respathv, const char *filename)
+/* exported interface documented in filepath.h */
+char *filepath_find(char **respathv, const char *filename)
{
char *ret;
char *filepath;
@@ -138,7 +138,7 @@
if (filepath == NULL)
return NULL;
- ret = resource_sfind(respathv, filepath, filename);
+ ret = filepath_sfind(respathv, filepath, filename);
if (ret == NULL)
free(filepath);
@@ -146,8 +146,8 @@
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
+/* exported interface documented in filepath.h */
+char *filepath_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
{
char t[PATH_MAX];
char *ret;
@@ -155,7 +155,7 @@
if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
return NULL;
- ret = resource_sfind(respathv, filepath, filename);
+ ret = filepath_sfind(respathv, filepath, filename);
if ((ret == NULL) && (def != NULL)) {
/* search failed, return the path specified */
@@ -174,9 +174,9 @@
}
-/* exported interface documented in resource.h */
+/* exported interface documented in filepath.h */
char **
-resource_generate(char * const *pathv, const char * const *langv)
+filepath_generate(char * const *pathv, const char * const *langv)
{
char **respath; /* resource paths vector */
int pathc = 0;
@@ -262,9 +262,9 @@
return exp;
}
-/* exported interface documented in resource.h */
+/* exported interface documented in filepath.h */
char **
-resource_path_to_strvec(const char *path)
+filepath_path_to_strvec(const char *path)
{
char **strvec;
int strc = 0;
@@ -302,8 +302,8 @@
return strvec;
}
-/* exported interface documented in resource.h */
-void resource_free_strvec(char **pathv)
+/* exported interface documented in filepath.h */
+void filepath_free_strvec(char **pathv)
{
free(pathv[0]);
free(pathv);
Copied: trunk/netsurf/utils/filepath.h (from r12085, trunk/netsurf/utils/resource.h)
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/filepath.h?p2=trunk...
==============================================================================
--- trunk/netsurf/utils/resource.h (original)
+++ trunk/netsurf/utils/filepath.h Thu Mar 17 06:26:30 2011
@@ -16,12 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file Utility routines to locate file resources. */
+/** \file Utility routines to obtain paths to file resources. */
-#ifndef _NETSURF_UTILS_RESOURCE_H_
-#define _NETSURF_UTILS_RESOURCE_H_
+#ifndef _NETSURF_UTILS_FILEPATH_H_
+#define _NETSURF_UTILS_FILEPATH_H_
#include <stdarg.h>
+
/** Create a normalised file name.
*
@@ -36,20 +37,23 @@
* @return A pointer to the expanded filename or NULL if the file is
* not present or accessible.
*/
-char *resource_vsfindfile(char *str, const char *format, va_list ap);
+char *filepath_vsfindfile(char *str, const char *format, va_list ap);
+
/** Create a normalised file name.
*
* Similar to vsfindfile but takes variadic (printf like) parameters
*/
-char *resource_sfindfile(char *str, const char *format, ...);
+char *filepath_sfindfile(char *str, const char *format, ...);
+
/** Create a normalised file name.
*
* Similar to sfindfile but allocates its own storage for the
* returned string. The caller must free this sorage.
*/
-char *resource_findfile(const char *format, ...);
+char *filepath_findfile(const char *format, ...);
+
/** Searches an array of resource paths for a file.
*
@@ -62,23 +66,27 @@
* @param filename The filename of the resource to search for.
* @return A pointer to filepath if a target is found or NULL if not.
*/
-char *resource_sfind(char **respathv, char *filepath, const char *filename);
+char *filepath_sfind(char **respathv, char *filepath, const char *filename);
+
/** Searches an array of resource paths for a file.
*
- * Similar to resource_sfind except it allocates its own storage for
+ * Similar to filepath_sfind except it allocates its own storage for
* the returned string. The caller must free this sorage.
*/
-char *resource_find(char **respathv, const char *filename);
+char *filepath_find(char **respathv, const char *filename);
+
/** Searches an array of resource paths for a file optionally forcing a default.
*
- * Similar to resource_sfind except if no resource is found the default
+ * Similar to filepath_sfind except if no resource is found the default
* is used as an additional path element to search, if that still
* fails the returned path is set to the concatination of the default
* path and the filename.
*/
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def);
+char *filepath_sfinddef(char **respathv, char *filepath, const char *filename,
+ const char *def);
+
/** Merge two string vectors into a resource search path vector.
*
@@ -87,7 +95,7 @@
* @return A pointer to a NULL terminated string vector of valid
* resource directories.
*/
-char **resource_generate(char * const *pathv, const char * const *langv);
+char **filepath_generate(char * const *pathv, const char * const *langv);
/** Convert a colon separated list of path elements into a string vector.
@@ -96,12 +104,13 @@
* @return A pointer to a NULL terminated string vector of valid
* resource directories.
*/
-char **resource_path_to_strvec(const char *path);
+char **filepath_path_to_strvec(const char *path);
+
/** Free a string vector
*
- * Free a string vector allocated by resource_path_to_strvec
+ * Free a string vector allocated by filepath_path_to_strvec
*/
-void resource_free_strvec(char **pathv);
+void filepath_free_strvec(char **pathv);
-#endif /* _NETSURF_UTILS_RESOURCE_H_ */
+#endif /* _NETSURF_UTILS_FILEPATH_H_ */
Removed: trunk/netsurf/utils/resource.c
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/resource.c?rev=1208...
==============================================================================
--- trunk/netsurf/utils/resource.c (original)
+++ trunk/netsurf/utils/resource.c (removed)
@@ -1,310 +1,0 @@
-/*
- * Copyright 2010 Vincent Sanders <vince(a)kyllikki.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Provides utility functions for finding readable files.
- *
- * These functions are intended to make finding resource files more straightforward.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "utils/config.h"
-#include "utils/resource.h"
-
-/** maximum number of elements in the resource vector */
-#define MAX_RESPATH 128
-
-/* exported interface documented in findresource.h */
-char *resource_vsfindfile(char *str, const char *format, va_list ap)
-{
- char *realpathname;
- char *pathname;
- int len;
-
- pathname = malloc(PATH_MAX);
- if (pathname == NULL)
- return NULL; /* unable to allocate memory */
-
- len = vsnprintf(pathname, PATH_MAX, format, ap);
-
- if ((len < 0) || (len >= PATH_MAX)) {
- /* error or output exceeded PATH_MAX length so
- * operation is doomed to fail.
- */
- free(pathname);
- return NULL;
- }
-
- realpathname = realpath(pathname, str);
-
- free(pathname);
-
- if (realpathname != NULL) {
- /* sucessfully expanded pathname */
- if (access(realpathname, R_OK) != 0) {
- /* unable to read the file */
- return NULL;
- }
- }
-
- return realpathname;
-}
-
-/* exported interface documented in findresource.h */
-char *resource_sfindfile(char *str, const char *format, ...)
-{
- va_list ap;
- char *ret;
-
- va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
- va_end(ap);
-
- return ret;
-}
-
-/* exported interface documented in findresource.h */
-char *resource_findfile(const char *format, ...)
-{
- char *str;
- char *ret;
- va_list ap;
-
- str = malloc(PATH_MAX);
- if (str == NULL)
- return NULL; /* unable to allocate memory */
-
- va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
- va_end(ap);
-
- if (ret == NULL)
- free(str);
-
- return ret;
-}
-
-/* exported interface documented in findresource.h */
-char *resource_sfind(char **respathv, char *filepath, const char *filename)
-{
- int respathc = 0;
-
- if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
- return NULL;
-
- while (respathv[respathc] != NULL) {
- if (resource_sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
- return filepath;
-
- respathc++;
- }
-
- return NULL;
-}
-
-/* exported interface documented in findresource.h */
-char *resource_find(char **respathv, const char *filename)
-{
- char *ret;
- char *filepath;
-
- if ((respathv == NULL) || (respathv[0] == NULL))
- return NULL;
-
- filepath = malloc(PATH_MAX);
- if (filepath == NULL)
- return NULL;
-
- ret = resource_sfind(respathv, filepath, filename);
-
- if (ret == NULL)
- free(filepath);
-
- return ret;
-}
-
-/* exported interface documented in findresource.h */
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
-{
- char t[PATH_MAX];
- char *ret;
-
- if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
- return NULL;
-
- ret = resource_sfind(respathv, filepath, filename);
-
- if ((ret == NULL) && (def != NULL)) {
- /* search failed, return the path specified */
- ret = filepath;
- if (def[0] == '~') {
- snprintf(t, PATH_MAX, "%s/%s/%s", getenv("HOME"), def + 1, filename);
- } else {
- snprintf(t, PATH_MAX, "%s/%s", def, filename);
- }
- if (realpath(t, ret) == NULL) {
- strcpy(ret, t);
- }
-
- }
- return ret;
-}
-
-
-/* exported interface documented in resource.h */
-char **
-resource_generate(char * const *pathv, const char * const *langv)
-{
- char **respath; /* resource paths vector */
- int pathc = 0;
- int langc = 0;
- int respathc = 0;
- struct stat dstat;
- char tmppath[PATH_MAX];
-
- respath = calloc(MAX_RESPATH, sizeof(char *));
-
- while (pathv[pathc] != NULL) {
- if ((stat(pathv[pathc], &dstat) == 0) &&
- S_ISDIR(dstat.st_mode)) {
- /* path element exists and is a directory */
- langc = 0;
- while (langv[langc] != NULL) {
- snprintf(tmppath, sizeof tmppath, "%s/%s", pathv[pathc],langv[langc]);
- if ((stat(tmppath, &dstat) == 0) &&
- S_ISDIR(dstat.st_mode)) {
- /* path element exists and is a directory */
- respath[respathc++] = strdup(tmppath);
- }
- langc++;
- }
- respath[respathc++] = strdup(pathv[pathc]);
- }
- pathc++;
- }
-
- return respath;
-}
-
-/* expand ${} in a string into environment variables */
-static char *
-expand_path(const char *path)
-{
- char *exp = strdup(path);
- int explen;
- int cstart = -1;
- int cloop = 0;
- char *envv;
- int envlen;
- int replen; /* length of replacement */
-
- if (exp == NULL)
- return NULL;
-
- explen = strlen(exp) + 1;
-
- while (exp[cloop] != 0) {
- if ((exp[cloop] == '$') &&
- (exp[cloop + 1] == '{')) {
- cstart = cloop;
- cloop++;
- }
-
- if ((cstart != -1) &&
- (exp[cloop] == '}')) {
- replen = cloop - cstart;
- exp[cloop] = 0;
- envv = getenv(exp + cstart + 2);
- if (envv == NULL) {
- memmove(exp + cstart,
- exp + cloop + 1,
- explen - cloop - 1);
- explen -= replen;
- } else {
- envlen = strlen(envv);
- exp = realloc(exp, explen + envlen - replen);
- memmove(exp + cstart + envlen,
- exp + cloop + 1,
- explen - cloop - 1);
- memmove(exp + cstart, envv, envlen);
- explen += envlen - replen;
- }
- cloop -= replen;
- cstart = -1;
- }
-
- cloop++;
- }
-
- return exp;
-}
-
-/* exported interface documented in resource.h */
-char **
-resource_path_to_strvec(const char *path)
-{
- char **strvec;
- int strc = 0;
-
- strvec = calloc(MAX_RESPATH, sizeof(char *));
- if (strvec == NULL)
- return NULL;
-
- strvec[strc] = expand_path(path);
- if (strvec[strc] == NULL) {
- free(strvec);
- return NULL;
- }
- strc++;
-
- strvec[strc] = strchr(strvec[0], ':');
- while ((strc < (MAX_RESPATH - 2)) &&
- (strvec[strc] != NULL)) {
- /* null terminate previous entry */
- *strvec[strc] = 0;
- strvec[strc]++;
-
- /* skip colons */
- while (*strvec[strc] == ':')
- strvec[strc]++;
-
- if (*strvec[strc] == 0)
- break; /* string is terminated */
-
- strc++;
-
- strvec[strc] = strchr(strvec[strc - 1], ':');
- }
-
- return strvec;
-}
-
-/* exported interface documented in resource.h */
-void resource_free_strvec(char **pathv)
-{
- free(pathv[0]);
- free(pathv);
-}
Removed: trunk/netsurf/utils/resource.h
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/resource.h?rev=1208...
==============================================================================
--- trunk/netsurf/utils/resource.h (original)
+++ trunk/netsurf/utils/resource.h (removed)
@@ -1,107 +1,0 @@
-/*
- * Copyright 2010 Vincent Sanders <vince(a)kyllikki.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file Utility routines to locate file resources. */
-
-#ifndef _NETSURF_UTILS_RESOURCE_H_
-#define _NETSURF_UTILS_RESOURCE_H_
-
-#include <stdarg.h>
-
-/** Create a normalised file name.
- *
- * If the file described by the format exists and is accessible the
- * normalised path is placed in str and a pointer to str returned
- * otherwise NULL is returned. The string in str is always modified.
- *
- * @param str A buffer to contain the normalised file name must be at
- * least PATH_MAX bytes long.
- * @param format A printf format for the filename.
- * @param ap The list of arguments for the format.
- * @return A pointer to the expanded filename or NULL if the file is
- * not present or accessible.
- */
-char *resource_vsfindfile(char *str, const char *format, va_list ap);
-
-/** Create a normalised file name.
- *
- * Similar to vsfindfile but takes variadic (printf like) parameters
- */
-char *resource_sfindfile(char *str, const char *format, ...);
-
-/** Create a normalised file name.
- *
- * Similar to sfindfile but allocates its own storage for the
- * returned string. The caller must free this sorage.
- */
-char *resource_findfile(const char *format, ...);
-
-/** Searches an array of resource paths for a file.
- *
- * Iterates through a vector of resource paths and returns the
- * normalised file name of the first acessible file or NULL if no file
- * can be found in any of the resource paths.
- *
- * @param respathv The resource path vector to iterate.
- * @param filepath The buffer to place the result in.
- * @param filename The filename of the resource to search for.
- * @return A pointer to filepath if a target is found or NULL if not.
- */
-char *resource_sfind(char **respathv, char *filepath, const char *filename);
-
-/** Searches an array of resource paths for a file.
- *
- * Similar to resource_sfind except it allocates its own storage for
- * the returned string. The caller must free this sorage.
- */
-char *resource_find(char **respathv, const char *filename);
-
-/** Searches an array of resource paths for a file optionally forcing a default.
- *
- * Similar to resource_sfind except if no resource is found the default
- * is used as an additional path element to search, if that still
- * fails the returned path is set to the concatination of the default
- * path and the filename.
- */
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def);
-
-/** Merge two string vectors into a resource search path vector.
- *
- * @param pathv A string vector containing path elemets to scan.
- * @param langv A string vector containing language names to enumerate.
- * @return A pointer to a NULL terminated string vector of valid
- * resource directories.
- */
-char **resource_generate(char * const *pathv, const char * const *langv);
-
-
-/** Convert a colon separated list of path elements into a string vector.
- *
- * @param path A colon separated path.
- * @return A pointer to a NULL terminated string vector of valid
- * resource directories.
- */
-char **resource_path_to_strvec(const char *path);
-
-/** Free a string vector
- *
- * Free a string vector allocated by resource_path_to_strvec
- */
-void resource_free_strvec(char **pathv);
-
-#endif /* _NETSURF_UTILS_RESOURCE_H_ */
12 years, 6 months