STR#2127:

- Applied third version of greg patch adding new external link functionality.
 - Corrected it so that it can compile under linux (minor include problem)
 - Corrected old documentation link to new one (toc.hmmtl is now index.html)
Tested succesfully on linux and mac os x 10.5



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6648 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Fabien Costantini 2009-01-29 21:14:42 +00:00
parent d474e13b03
commit 1a297e1947
2 changed files with 67 additions and 41 deletions

View File

@ -268,8 +268,8 @@ Links to other documents and external links can be embedded with
For further informations about quoting see For further informations about quoting see
http://www.stack.nl/~dimitri/doxygen/htmlcmds.html http://www.stack.nl/~dimitri/doxygen/htmlcmds.html
Bold link text: you can see the <b>\e old online documentation</b> Bold link text: you can see the <b>online documentation</b>
of FLTK 1.3 at \b http://www.fltk.org/doc-1.3/toc.html of FLTK 1.3 at \b http://www.fltk.org/doc-1.3/index.html
see section \ref development_non-ascii see section \ref development_non-ascii
\endcode \endcode
@ -285,8 +285,8 @@ appears as:
For further informations about quoting see For further informations about quoting see
http://www.stack.nl/~dimitri/doxygen/htmlcmds.html http://www.stack.nl/~dimitri/doxygen/htmlcmds.html
Bold link text: you can see the <b>\e old online documentation</b> Bold link text: you can see the <b>online documentation</b>
of FLTK 1.3 at \b http://www.fltk.org/doc-1.3/toc.html of FLTK 1.3 at \b http://www.fltk.org/doc-1.3/index.html
see section \ref development_non-ascii see section \ref development_non-ascii

View File

@ -62,6 +62,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <FL/fl_utf8.h> #include <FL/fl_utf8.h>
#include <FL/filename.H> // fl_open_uri()
#include "flstring.h" #include "flstring.h"
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
@ -3044,6 +3045,50 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target)
char newname[1024]; // New filename buffer char newname[1024]; // New filename buffer
if (strncmp(f, "ftp:", 4) == 0 ||
strncmp(f, "http:", 5) == 0 ||
strncmp(f, "https:", 6) == 0 ||
strncmp(f, "ipp:", 4) == 0 ||
strncmp(f, "mailto:", 7) == 0 ||
strncmp(f, "news:", 5) == 0) {
char urimsg[256];
if ( fl_open_uri(f, urimsg, sizeof(urimsg)) == 0 ) {
clear_selection();
strlcpy(newname, f, sizeof(newname));
if ((target = strrchr(newname, '#')) != NULL)
*target++ = '\0';
if (link_)
localname = (*link_)(this, newname);
else
localname = filename_;
if (!localname)
return (0);
strlcpy(filename_, newname, sizeof(filename_));
strlcpy(directory_, newname, sizeof(directory_));
// Note: We do not support Windows backslashes, since they are illegal
// in URLs...
if ((slash = strrchr(directory_, '/')) == NULL)
directory_[0] = '\0';
else if (slash > directory_ && slash[-1] != '/')
*slash = '\0';
snprintf(error, sizeof(error),
"<HTML><HEAD><TITLE>Error</TITLE></HEAD>"
"<BODY><H1>Error</H1>"
"<P>Unable to follow the link \"%s\" - "
"%s.</P></BODY>",
f, urimsg);
value(error);
//return(-1);
}
return(0);
}
clear_selection(); clear_selection();
strlcpy(newname, f, sizeof(newname)); strlcpy(newname, f, sizeof(newname));
@ -3074,47 +3119,28 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target)
value_ = NULL; value_ = NULL;
} }
if (strncmp(localname, "ftp:", 4) == 0 || if (strncmp(localname, "file:", 5) == 0)
strncmp(localname, "http:", 5) == 0 || localname += 5; // Adjust for local filename...
strncmp(localname, "https:", 6) == 0 ||
strncmp(localname, "ipp:", 4) == 0 || if ((fp = fl_fopen(localname, "rb")) != NULL)
strncmp(localname, "mailto:", 7) == 0 ||
strncmp(localname, "news:", 5) == 0)
{ {
// Remote link wasn't resolved... fseek(fp, 0, SEEK_END);
snprintf(error, sizeof(error), len = ftell(fp);
"<HTML><HEAD><TITLE>Error</TITLE></HEAD>" rewind(fp);
"<BODY><H1>Error</H1>"
"<P>Unable to follow the link \"%s\" - " value_ = (const char *)calloc(len + 1, 1);
"no handler exists for this URI scheme.</P></BODY>", fread((void *)value_, 1, len, fp);
localname); fclose(fp);
value_ = strdup(error);
} }
else else
{ {
if (strncmp(localname, "file:", 5) == 0) snprintf(error, sizeof(error),
localname += 5; // Adjust for local filename... "<HTML><HEAD><TITLE>Error</TITLE></HEAD>"
"<BODY><H1>Error</H1>"
if ((fp = fl_fopen(localname, "rb")) != NULL) "<P>Unable to follow the link \"%s\" - "
{ "%s.</P></BODY>",
fseek(fp, 0, SEEK_END); localname, strerror(errno));
len = ftell(fp); value_ = strdup(error);
rewind(fp);
value_ = (const char *)calloc(len + 1, 1);
fread((void *)value_, 1, len, fp);
fclose(fp);
}
else
{
snprintf(error, sizeof(error),
"<HTML><HEAD><TITLE>Error</TITLE></HEAD>"
"<BODY><H1>Error</H1>"
"<P>Unable to follow the link \"%s\" - "
"%s.</P></BODY>",
localname, strerror(errno));
value_ = strdup(error);
}
} }
format(); format();