summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/browserhelp.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/wlib/gtklib/browserhelp.c')
-rw-r--r--app/wlib/gtklib/browserhelp.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/app/wlib/gtklib/browserhelp.c b/app/wlib/gtklib/browserhelp.c
index 7d45ea5..6d2ac5d 100644
--- a/app/wlib/gtklib/browserhelp.c
+++ b/app/wlib/gtklib/browserhelp.c
@@ -17,12 +17,13 @@
*
* 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"
@@ -45,7 +46,8 @@ extern wBool_t CheckHelpTopicExists(const char * topic);
"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
@@ -54,20 +56,29 @@ extern wBool_t CheckHelpTopicExists(const char * topic);
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
@@ -79,22 +90,22 @@ TopicToUrl(char **helpUrl, const char *topic)
void wHelp(const char * topic)
{
- int rc;
- char *url;
- char *currentPath;
+ int rc;
+ char *url;
+// char *currentPath;
- assert(topic != NULL);
- assert(strlen(topic));
+ assert(topic != NULL);
+ assert(strlen(topic));
- if (!CheckHelpTopicExists(topic)) return;
-
- 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);
}