diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /kxsldbg/kxsldbgpart/libxsldbg/search_cmds.cpp | |
download | tdewebdev-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/search_cmds.cpp')
-rw-r--r-- | kxsldbg/kxsldbgpart/libxsldbg/search_cmds.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/kxsldbg/kxsldbgpart/libxsldbg/search_cmds.cpp b/kxsldbg/kxsldbgpart/libxsldbg/search_cmds.cpp new file mode 100644 index 00000000..1dc65190 --- /dev/null +++ b/kxsldbg/kxsldbgpart/libxsldbg/search_cmds.cpp @@ -0,0 +1,88 @@ + +/*************************************************************************** + search_cmds.c - search related commands for xsldbg + ------------------- + begin : Wed Nov 21 2001 + 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 "debugXSL.h" +#include "options.h" +#include "search.h" + +/* ----------------------------------------- + + Seach related commands + + ------------------------------------------- */ + + +/** + * xslDbgShellSearch: + * @styleCtxt: Is valid + * @style: Is valid + * @arg: The xpath query to use for searching dataBase and in UTF-8 + * + * Displays the result of performing a query on the search dataBase + * + * Returns 1 if able to run query with @arg, + * 0 otherwise + */ +int +xslDbgShellSearch(xsltTransformContextPtr styleCtxt, + xsltStylesheetPtr style, xmlChar * arg) +{ + int result = 0; + xmlChar buff[DEBUG_BUFFER_SIZE]; + const xmlChar *sortOption = (xmlChar *) "-sort "; + int sortOptionLen = xmlStrLen(sortOption); + + if (optionsGetStringOption(OPTIONS_DOCS_PATH) == NULL) { + xsldbgGenericErrorFunc(i18n("Error: No path to documentation; aborting searching.\n")); +#ifdef USE_DOCS_MACRO + xsldbgGenericErrorFunc(i18n("Error: Error in value of USE_DOCS_MACRO; look at Makefile.am.\n")); +#else + xsldbgGenericErrorFunc(i18n("Error: Required environment variable %1 not set to the directory of xsldbg documentation.\n").arg((const char*)XSLDBG_DOCS_DIR_VARIABLE)); +#endif + return result; /* failed */ + } + + if (!styleCtxt || !style) { + xsldbgGenericErrorFunc(i18n("Error: Stylesheet not valid, files not loaded yet?\n")); + return result; + } + + result = updateSearchData(styleCtxt, style, NULL, DEBUG_ANY_VAR); + trimString(arg); + if (xmlStrLen(arg) == 0) { + arg = (xmlChar *) "//search/*"; + } + strncpy((char *) buff, (char *) arg, sortOptionLen); + if (xmlStrEqual(buff, sortOption)) { + /* yep do sorting as well */ + if (snprintf + ((char *) buff, DEBUG_BUFFER_SIZE, + "--param dosort 1 --param query \"%s\"", + &arg[sortOptionLen])) { + result = result && searchQuery(NULL, NULL, buff); + } + } else { + if (snprintf + ((char *) buff, DEBUG_BUFFER_SIZE, + "--param dosort 0 --param query \"%s\"", arg)) { + result = result && searchQuery(NULL, NULL, buff); + } + } + return result; +} |