]> git.stg.codes - stg.git/blobdiff - stglibs/dotconfpp.lib/dotconfpp.cpp
Hide or add proper copy ctor and assignement operator, initialize
[stg.git] / stglibs / dotconfpp.lib / dotconfpp.cpp
index b82ae8182ec5bc903201fb2087646a9198d2f8a7..8ac254405b493b9229005e8da7b5eb0e15786fe2 100644 (file)
@@ -20,6 +20,7 @@
 #include <string>
 
 #include "dotconfpp.h"
 #include <string>
 
 #include "dotconfpp.h"
+#include "mempool.h"
 
 DOTCONFDocumentNode::DOTCONFDocumentNode():previousNode(NULL), nextNode(NULL), parentNode(NULL), childNode(NULL),
     values(NULL), valuesCount(0), 
 
 DOTCONFDocumentNode::DOTCONFDocumentNode():previousNode(NULL), nextNode(NULL), parentNode(NULL), childNode(NULL),
     values(NULL), valuesCount(0), 
@@ -338,7 +339,7 @@ int DOTCONFDocument::setContent(const char * _fileName)
     char realpathBuf[PATH_MAX];
 
     if(realpath(_fileName, realpathBuf) == NULL){
     char realpathBuf[PATH_MAX];
 
     if(realpath(_fileName, realpathBuf) == NULL){
-        error(0, NULL, "realpath(%s) failed: %s", _fileName, strerror(errno));
+        error(0, _fileName, "realpath('%s') failed: %s", _fileName, strerror(errno));
         return -1;
     }
 
         return -1;
     }
 
@@ -397,6 +398,7 @@ int DOTCONFDocument::setContent(const char * _fileName)
                             case GLOB_NOSPACE:
                                 error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': no free space", nodeFilePath.c_str());
                                 return -1;
                             case GLOB_NOSPACE:
                                 error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': no free space", nodeFilePath.c_str());
                                 return -1;
+#ifndef FREE_BSD
                             case GLOB_ABORTED:
                                 // printf("Read error\n");
                                 // Ignore that error
                             case GLOB_ABORTED:
                                 // printf("Read error\n");
                                 // Ignore that error
@@ -405,6 +407,7 @@ int DOTCONFDocument::setContent(const char * _fileName)
                                 // printf("No match\n");
                                 // Ignore that error
                                 break;
                                 // printf("No match\n");
                                 // Ignore that error
                                 break;
+#endif
                             default:
                                 error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': unknown error", nodeFilePath.c_str());
                                 return -1;
                             default:
                                 error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': unknown error", nodeFilePath.c_str());
                                 return -1;
@@ -506,13 +509,17 @@ void DOTCONFDocument::error(int lineNum, const char * fileName, const char * fmt
     va_list args;
     va_start(args, fmt);
 
     va_list args;
     va_start(args, fmt);
 
-    size_t len = (lineNum!=0?strlen(fileName):0) + strlen(fmt) + 50;
+    char msg[256];
+
+    vsnprintf(msg, 256, fmt, args);
+
+    size_t len = (lineNum!=0?strlen(fileName):0) + strlen(msg) + 50;
     char * buf = (char*)mempool->alloc(len);
 
     if(lineNum)
     char * buf = (char*)mempool->alloc(len);
 
     if(lineNum)
-        (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, fmt);
+        (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, msg);
     else
     else
-        (void) snprintf(buf, len, "DOTCONF++: %s\n", fmt);
+        (void) snprintf(buf, len, "DOTCONF++: file '%s':  %s\n", fileName, msg);
 
     if (errorCallback) {
         errorCallback(errorCallbackData, buf);
 
     if (errorCallback) {
         errorCallback(errorCallbackData, buf);