diff options
Diffstat (limited to 'app/wlib/gtklib/browserhelp.c')
-rw-r--r-- | app/wlib/gtklib/browserhelp.c | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/app/wlib/gtklib/browserhelp.c b/app/wlib/gtklib/browserhelp.c index aa8f5c7..6d2ac5d 100644 --- a/app/wlib/gtklib/browserhelp.c +++ b/app/wlib/gtklib/browserhelp.c @@ -17,18 +17,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdlib.h> #include <assert.h> #include <string.h> +#include <limits.h> -#include "misc.h" +//#include "misc.h" #include "gtkint.h" #include "i18n.h" +extern wBool_t CheckHelpTopicExists(const char * topic); + #include "dynstring.h" #define debug 0 @@ -43,7 +46,8 @@ "variable.\n Also make sure that the user has sufficient access rights to read these" \ "files." /** - * Create a fully qualified url from a topic + * Create a fully qualified url from a topic. The library path is converted to + * an absolute path first. The url is then created from that path. * * \param helpUrl OUT pointer to url, free by caller * \param topic IN the help topic @@ -52,20 +56,29 @@ static void TopicToUrl(char **helpUrl, const char *topic) { - DynString url; - DynStringMalloc(&url, 16); - - // build up the url line - DynStringCatCStrs(&url, - "file://", - wGetAppLibDir(), - "/html/", - topic, - ".html", - NULL); - - *helpUrl = strdup(DynStringToCStr(&url)); - DynStringFree(&url); + DynString url; + DynStringMalloc(&url, 16); + char *realPath; + + realPath = realpath(wGetAppLibDir(), NULL); + + if(realPath) { + // build up the url line + DynStringCatCStrs(&url, + "file://", + realPath, + "/html/", + topic, + ".html", + NULL); + + *helpUrl = strdup(DynStringToCStr(&url)); + DynStringFree(&url); + free(realPath); + } else { + wNoticeEx( NT_ERROR, _("Not enough memory for realpath()"), _("Exit"), NULL); + wExit(0); + } } /** * Invoke the system's default browser to display help for <topic>. First the @@ -77,22 +90,22 @@ TopicToUrl(char **helpUrl, const char *topic) void wHelp(const char * topic) { - int rc; - char *url; - char *currentPath; - - assert(topic != NULL); - assert(strlen(topic)); + int rc; + char *url; +// char *currentPath; - if (!CheckHelpTopicExists(topic)) return; + assert(topic != NULL); + assert(strlen(topic)); - TopicToUrl(&url, topic); + if (!CheckHelpTopicExists(topic)) { return; } + TopicToUrl(&url, topic); + printf(">%s<\n", url); rc = wOpenFileExternal(url); if (!rc) { - wNotice(HELPERRORTEXT, _("Cancel"), NULL); - } + wNotice(HELPERRORTEXT, _("Cancel"), NULL); + } - free(url); + free(url); } |