/*
*
* ProLinga-Run
*
* Copyright (C) 2002-2008 Xobas Software.
* All rights reserved.
*
* This file is part of ProLinga-Run.
*
* ProLinga-Run 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 3 of the License, or
* (at your option) any later version.
*
* ProLinga-Run is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProLinga-Run. If not, see .
*
* More information is available at the following addresses:
*
* Website : http://www.prolinga.org
*
* Email : prolinga-list@prolinga.org
*
*
*/
#include "RunCommon.h"
#include
#include
#include
#include "Runner.hpp"
int RunLoad(xmlDocPtr docVal, xmlDocPtr* doc)
{
xmlNodePtr cur, curVal;
xmlXPathContextPtr ctxVal;
xmlXPathObjectPtr resVal;
*doc = xmlNewDoc((const xmlChar *)"1.0");
(*doc)->children = xmlNewDocNode(*doc, NULL, (const xmlChar *)"ProLinga", NULL);
cur = xmlDocGetRootElement(*doc);
/* Init XPath */
xmlXPathInit();
/* Create XPath environment */
ctxVal = xmlXPathNewContext(docVal);
resVal = xmlXPathEval((const xmlChar *)"/ProLinga/Repository/Command/Object/RunControl/Runner", ctxVal);
curVal = resVal->nodesetval->nodeTab[0];
xmlAddChildList(cur, xmlCopyNodeList(curVal));
//xmlXPathFreeObject(resVal);
//xmlXPathFreeContext(ctxVal);
return 0;
/*
bufRep = xmlBufferCreate();
cur = xmlDocGetRootElement(*doc);
xmlNodeDump(bufRep, *doc, cur, 0, 1);
printf("!!!!!!!!!!!!\n%s\n", (char *)xmlBufferContent(bufRep));
xmlBufferFree(bufRep);
*/
}
int RunOpen(const char* fileName, xmlDocPtr* doc)
{
xmlNodePtr cur;
*doc = xmlParseFile(fileName);
if (*doc == NULL)
{
fprintf(stderr, "Error parsing document. \n");
xmlFreeDoc(*doc);
return 12345;
}
cur = xmlDocGetRootElement(*doc);
if (cur == NULL)
{
fprintf(stderr, "Empty document. \n");
xmlFreeDoc(*doc);
return 12345;
}
if (xmlStrcmp(cur->name, (const xmlChar *) ROOT_ELEMENT))
{
fprintf(stderr, "Invalid Runner File");
xmlFreeDoc(*doc);
return 12345;
}
return 0;
}
void RunCleanup(xmlDocPtr* doc)
{
xmlFreeDoc(*doc);
}