Commit b62e6d7d authored by Elliot Lee's avatar Elliot Lee

Fixups for VFS usage. Search info path for files.



* components/html/ntl-web-browser.c: Fixups for VFS usage.
* components/help/converters/gnome-info2html2/main.c: Search info path for files.
parent e8c96238
2000-02-16 Elliot Lee <sopwith@redhat.com>
* components/html/ntl-web-browser.c: Fixups for VFS usage.
* components/help/converters/gnome-info2html2/main.c: Search info path for files.
* components/help/hyperbola-nav-index.c: Fix warning.
* components/history/ntl-history-view.c: Update for Bonobo UIH changes.
* components/html/main.c: Update repo ID for Bonobo changes.
......
......@@ -5,6 +5,10 @@
#include <string.h>
#include <gnome.h>
#include <zlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include "data.h"
#include "html.h"
......@@ -24,6 +28,13 @@ static struct poptOption options[] = {
{NULL}
};
static int
file_exists(const char *fn)
{
struct stat sbuf;
return (stat(fn, &sbuf) == 0);
}
int
main(int argc, char **argv)
{
......@@ -32,23 +43,74 @@ main(int argc, char **argv)
poptContext ctx;
int result;
int foundit=0;
int i, n;
char convanc[1024];
NODE *node;
const char **args;
char *fixup_args[512];
int curarg;
if (!be_quiet)
printf("info2html Version %s\n",INFO2HTML_VERSION);
ctx = poptGetContext("gnome-info2html2", argc, argv, options, 0);
ctx = poptGetContext("gnome-info2html2", argc, (const char **)argv, options, 0);
while(poptGetNextOpt(ctx) >= 0)
/**/ ;
args = poptGetArgs(ctx);
curarg = 0;
if(!args)
return 1;
for(n = 0; args[n]; n++) /* */;
if(n == 1 && !file_exists(args[0]))
{
char *ctmp, *infopath = getenv("INFOPATH");
char *dirs[64], *ext;
int ndirs;
char buf[PATH_MAX];
/* First, find the directory that the info file is in. */
dirs[0] = "/usr/info";
if(infopath)
for(ndirs = 0, ctmp = strtok((char *)args[0], ":"); ndirs < 64 && ctmp; ndirs++, ctmp = strtok(NULL, ":"))
dirs[ndirs] = strdup(ctmp);
for(i = 0; i < ndirs; i++)
{
ext = "";
sprintf(buf, "%s/%s.info", dirs[i], args[0]);
if(file_exists(buf))
break;
ext = ".gz";
sprintf(buf, "%s/%s.info.gz", dirs[i], args[0]);
if(file_exists(buf))
break;
}
if(i >= ndirs)
return 2;
n = i;
for(i = 0; ; i++)
{
if(i)
sprintf(buf, "%s/%s.info-%d%s", dirs[n], args[0], i, ext);
else
sprintf(buf, "%s/%s.info%s", dirs[n], args[0], ext);
if(!file_exists(buf))
{
fixup_args[i] = NULL;
break;
}
fixup_args[i] = strdup(buf);
}
args = (const char **)fixup_args;
}
if(requested_nodename)
{
......@@ -72,7 +134,6 @@ main(int argc, char **argv)
work_line_number = 0;
/* hack, just send to stdout for now */
fprintf(stdout, "<BODY><HTML>\n");
......
......@@ -84,6 +84,13 @@ canonicalize_url (const char *in_url, const char *base_url)
{
char *cwd;
if(in_url)
{
ctmp = strchr(in_url, ':');
if(ctmp) /* OK, it's some funky URL scheme without any /'s */
return g_strdup(in_url);
}
cwd = g_get_current_dir();
ctmp = g_strconcat("file://", cwd, "/", in_url, NULL);
g_free(cwd);
......@@ -98,7 +105,9 @@ canonicalize_url (const char *in_url, const char *base_url)
/* Now fix up the /. and /.. pieces */
ctmp = strstr(retval, "://");
g_assert(ctmp);
if(!ctmp)
return retval;
ctmp += 3;
ctmp = strchr(ctmp, '/');
if(!ctmp) {
......@@ -307,7 +316,7 @@ browser_do_post(HTRequest *request, HTStream *stream)
}
}
static char vfs_read_buf[4096];
static char vfs_read_buf[40960];
static void
browser_vfs_read_callback(GnomeVFSAsyncHandle *h, GnomeVFSResult res, gpointer buffer,
......@@ -335,15 +344,24 @@ browser_vfs_callback(GnomeVFSAsyncHandle *h, GnomeVFSResult res, gpointer data)
{
VFSHandle *vfsh = data;
g_message("browser_vfs_callback");
g_message("browser_vfs_callback, res was %s", gnome_vfs_result_to_string(res));
if(res != GNOME_VFS_OK)
{
Nautilus_ProgressRequestInfo pri;
memset(&pri, 0, sizeof(pri));
pri.type = Nautilus_PROGRESS_DONE_ERROR;
nautilus_view_frame_request_progress_change(vfsh->bi->view_frame, &pri);
gtk_html_end(GTK_HTML(vfsh->bi->htmlw), vfsh->sh, GTK_HTML_STREAM_ERROR);
g_free(vfsh);
}
else
gnome_vfs_async_read(h, vfs_read_buf, sizeof(vfs_read_buf), browser_vfs_read_callback, vfsh);
{
res = gnome_vfs_async_read(h, vfs_read_buf, sizeof(vfs_read_buf), browser_vfs_read_callback, vfsh);
g_message("Did read, result was %s", gnome_vfs_result_to_string(res));
}
}
static void
......@@ -397,6 +415,8 @@ browser_url_requested(GtkWidget *htmlw, const char *url, GtkHTMLStreamHandle han
if(HTLoad(request, NO) == NO)
{
g_warning("Load failed");
do_vfs_load(vfsh);
writer->handle = NULL;
HTRequest_delete(request);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment