/* * * ProLinga-Data * * Copyright (C) 2002-2009 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Data. * * ProLinga-Data 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-Data 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-Data. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "DatCommon.h" #include #include #include "DCDocumentParse.hpp" #include "DatMain.hpp" void DCParseErrorResponse(const int errorId, xmlDocPtr *docResponse) { xmlNodePtr curResponse; char dummyId[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 *)"Data", (const xmlChar *)""); curResponse = (curResponse)->xmlChildrenNode; xmlNewProp (curResponse, (const xmlChar *)"Version", (const xmlChar *)DAT_DOC_VERSION); curResponse = xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Error", (const xmlChar *)""); sprintf(dummyId, "%d", errorId); xmlNewProp (curResponse, (const xmlChar *)"Id", (const xmlChar *)dummyId); xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Severity", (const xmlChar *)"Error"); // xmlNewTextChild (curResponse, NULL, (const xmlChar *)"Severity", (const xmlChar *)errorSeverity[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"); } int DCDocumentParse(const char *rcIn, const short docType, xmlDocPtr *doc) { xmlNodePtr cur; if (docType == 0) *doc = xmlParseFile(rcIn); else *doc = xmlParseMemory(rcIn, strlen(rcIn)); /* simple validation, implement XML schema 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 */ return 0; }