summaryrefslogtreecommitdiffstats
path: root/kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp')
-rw-r--r--kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp b/kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp
new file mode 100644
index 00000000..9f95d353
--- /dev/null
+++ b/kxsldbg/kxsldbgpart/libxsldbg/xsldbgmsg.cpp
@@ -0,0 +1,119 @@
+
+/***************************************************************************
+ xsldbg.cpp - send message to console or KXSLDbg
+ -------------------
+ begin : Mon April 26 2004
+ copyright : (C) 2001 by Keith Isdale
+ email : k_isdale@tpg.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program 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; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "xsldbg.h"
+
+#include <libxslt/xsltutils.h>
+
+#ifdef HAVE_READLINE
+#include <readline/readline.h>
+#ifdef HAVE_HISTORY
+#include <readline/history.h>
+#endif
+#endif
+
+#include "xsldbgmsg.h"
+#include "xsldbgio.h"
+#include "options.h"
+
+static int (*notifyXsldbgAppFuncPtr) (XsldbgMessageEnum type, const void *data) = 0;
+
+static int (*notifyStateXsldbgAppFuncPtr)(XsldbgMessageEnum type, int commandId,
+ XsldbgCommandStateEnum commandState,
+ const char *text) = 0;
+
+static int (*notifyTextXsldbgAppFuncPtr)(XsldbgMessageEnum type, const char *text) = 0;
+static xmlChar * (*xslDbgShellReadlineFuncPtr)(xmlChar * prompt) = 0;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void xsldbgSetAppFunc(int (*notifyXsldbgAppFunc) (XsldbgMessageEnum type, const void *data))
+{
+ notifyXsldbgAppFuncPtr = notifyXsldbgAppFunc;
+}
+
+void xsldbgSetAppStateFunc(int (*notifyStateXsldbgAppFunc)(XsldbgMessageEnum type, int commandId,
+ XsldbgCommandStateEnum commandState,
+ const char *text))
+{
+ notifyStateXsldbgAppFuncPtr = notifyStateXsldbgAppFunc;
+}
+
+
+void xsldbgSetTextFunc(int (*notifyTextXsldbgAppFunc)(XsldbgMessageEnum type, const char *text))
+{
+ notifyTextXsldbgAppFuncPtr = notifyTextXsldbgAppFunc;
+}
+
+void xsldbgSetReadlineFunc(xmlChar * (*xslDbgShellReadlineFunc)(xmlChar * prompt))
+{
+ xslDbgShellReadlineFuncPtr = xslDbgShellReadlineFunc;
+}
+
+int notifyXsldbgApp(XsldbgMessageEnum type, const void *data)
+{
+ if (!notifyXsldbgAppFuncPtr)
+ return 1;
+ else
+ return (notifyXsldbgAppFuncPtr)(type, data);
+}
+
+int notifyStateXsldbgApp(XsldbgMessageEnum type, int commandId,
+ XsldbgCommandStateEnum commandState, const char *text)
+{
+ if (!notifyStateXsldbgAppFuncPtr)
+ return 1;
+ else
+ return (notifyStateXsldbgApp)(type, commandId, commandState, text);
+}
+
+int notifyTextXsldbgApp(XsldbgMessageEnum type, const char *text)
+{
+ if (!notifyTextXsldbgAppFuncPtr)
+ return 1;
+ else
+ return (notifyTextXsldbgAppFuncPtr)(type, text);
+}
+
+
+/* use this function instead of the one that was in debugXSL.c */
+/**
+ * xslShellReadline:
+ * @prompt: the prompt value
+ *
+ * Read a string
+ *
+ * Returns a copy of the text inputed or NULL if EOF in stdin found.
+ * The caller is expected to free the returned string.
+ */
+xmlChar *
+xslDbgShellReadline(xmlChar * prompt)
+{
+
+ if (!xslDbgShellReadlineFuncPtr)
+ return 0;
+ else
+ return (xslDbgShellReadlineFuncPtr)(prompt);
+}
+
+#ifdef __cplusplus
+}
+#endif