#include "mempool.h"
DOTCONFDocumentNode::DOTCONFDocumentNode():previousNode(NULL), nextNode(NULL), parentNode(NULL), childNode(NULL),
- values(NULL), valuesCount(0),
+ values(NULL), valuesCount(0),
name(NULL), lineNum(0), fileName(NULL), closed(true)
{
}
*line = ' ';continue;
}
if(*line == '\\' && (*(line+1) == '"' || *(line+1) == '\'')){
- *bg++ = *(line+1);
+ *bg++ = *(line+1);
line+=2; continue;
}
if(*line == '\\' && *(line+1) == 'n'){
- *bg++ = '\n';
+ *bg++ = '\n';
line+=2; continue;
}
if(*line == '\\' && *(line+1) == 'r'){
- *bg++ = '\r';
+ *bg++ = '\r';
line+=2; continue;
}
if(*line == '\\' && (*(line+1) == '\n' || *(line+1) == '\r')){ //multiline
continue;
}
*bg++ = *line++;
- }
+ }
if(quoted && !multiline){
error(curLine, fileName, "unterminated quote");
tagNode->pushValue(nodeValue);
}
}
-
+
return 0;
}
int DOTCONFDocument::parseFile(DOTCONFDocumentNode * _parent)
if(ret == -1){
break;
}
- }
+ }
}
}
}
int DOTCONFDocument::setContent(const char * _fileName)
-{
+{
int ret = 0;
char realpathBuf[PATH_MAX];
}
ret = parseFile();
-
+
(void) fclose(file);
if(!ret){
-
+
if( (ret = checkConfig(nodeTree.begin())) == -1){
return -1;
}
//free(fileName);
fileName = strdup(realpathBuf);
from = nodeTree.end(); --from;
-
+
if(tagNode->parentNode){
DOTCONFDocumentNode * nd = tagNode->parentNode->childNode;
while(nd){
curPrev = nd;
}
ret = parseFile(tagNode->parentNode);
-
+
//ret = parseFile(tagNode->parentNode);
(void) fclose(file);
if(ret == -1)
{
for(std::list<char*>::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ++ci){
bool matched = false;
- for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
+ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
if(!cmp_func((*i)->name, *ci)){
matched = true;
break;
buf = mempool->strdup(subs);
} else {
std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin();
- for(; i!=nodeTree.end(); ++i){
+ for(; i!=nodeTree.end(); ++i){
DOTCONFDocumentNode * tagNode = *i;
if(!cmp_func(tagNode->name, variable)){
if(tagNode->valuesCount != 0){
const DOTCONFDocumentNode * DOTCONFDocument::findNode(const char * nodeName, const DOTCONFDocumentNode * parentNode, const DOTCONFDocumentNode * startNode) const
{
//printf("nodeName=%s, cont=%s, start=%s\n", nodeName, containingNode!=NULL?containingNode->name:"NULL", startNode!=NULL?startNode->name:"NULL");
-
+
std::list<DOTCONFDocumentNode*>::const_iterator i = nodeTree.begin();
if(startNode == NULL)