/* * * ProLinga-Repository * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Repository. * * ProLinga-Repository 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-Repository 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-Repository. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RepCommon.h" #include #include #include "RCDocumentParse.hpp" #include "RepMain.hpp" xmlDocPtr ParseErrorResponse(const int errorId) { xmlDocPtr docResponse; xmlNodePtr curResponse; char errorStringId[10]=""; /* Create Error Response file */ docResponse = xmlNewDoc((const xmlChar *)XML_VERSION); docResponse->children = xmlNewDocNode(docResponse, NULL, (const xmlChar *)ROOT_ELEM, NULL); curResponse = xmlDocGetRootElement(docResponse); xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Repository", (const xmlChar *)""); curResponse = (curResponse)->xmlChildrenNode; xmlNewProp (curResponse, (const xmlChar *)"Version", (const xmlChar *)REP_DOC_VERSION); curResponse = xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Error", (const xmlChar *)""); sprintf(errorStringId, "%d", errorId); xmlNewProp (curResponse, (const xmlChar *)"Id", (const xmlChar *)errorStringId); xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Severity", (const xmlChar *)"Error"); // xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Severity", (const xmlChar *)errorRepSeverity[errorTable10000[errorId-10000].severity]); // xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Description", (const xmlChar *)errorTable10000[errorId-10000].description); xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Description", (const xmlChar *)"Error parsing document"); /* Return */ return docResponse; } int DocumentParse(const char *rcIn, const int docType, xmlDocPtr *doc) { xmlNodePtr cur; if (docType == 0) *doc = xmlParseFile(rcIn); else *doc = xmlParseMemory(rcIn, strlen(rcIn)); /* simple validation, implement XML schemas at later stage */ if (*doc == NULL) return 10001; cur = xmlDocGetRootElement(*doc); if (cur == NULL) return 10002; if (xmlStrcmp(cur->name, (const xmlChar *) ROOT_ELEM)) return 10003; /* ... etc ... */ return 0; }