Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37837382
en ru br
Репозитории ALT
D:2.404.9.7-alt1
5.1: 2.407.cvs20100811-alt1.M51.1
4.1: 2.404.9.7-alt1
4.0: 2.404.9.7-alt0.M40.1
www.altlinux.org/Changes

Группа :: Система/Серверы
Пакет: stargazer

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: stargazer-wildcards_dotconfpp.patch
Скачать


diff -a -u -r1.43 -r1.44
--- stg/projects/stargazer/settings.cpp	9 May 2010 12:38:31 -0000	1.43
+++ stg/projects/stargazer/settings.cpp	19 Aug 2010 11:15:46 -0000	1.44
@@ -23,8 +23,8 @@
  */
 
 /*
-$Revision: 1.43 $
-$Date: 2010/05/09 12:38:31 $
+$Revision: 1.44 $
+$Date: 2010/08/19 11:15:46 $
 $Author: faust $
 */
 
@@ -59,7 +59,6 @@
       showFeeInCash(true)
 
 {
-printfd(__FILE__, "SETTINGS::SETTINGS()\n");
 }
 //-----------------------------------------------------------------------------
 SETTINGS::SETTINGS(const std::string & cd)
@@ -80,7 +79,6 @@
       writeFreeMbTraffCost(false),
       showFeeInCash(true)
 {
-printfd(__FILE__, "SETTINGS::SETTINGS(const std::string &)\n");
 }
 //-----------------------------------------------------------------------------
 SETTINGS::SETTINGS(const SETTINGS & rval)
@@ -94,7 +92,6 @@
       dayFeeIsLastDay(false),
       writeFreeMbTraffCost(false)
 {
-printfd(__FILE__, "SETTINGS::SETTINGS(const SETTINGS &)\n");
 spreadFee = rval.spreadFee;
 pidFile = rval.pidFile;
 stgExecMsgKey = rval.stgExecMsgKey;
@@ -106,7 +103,6 @@
 //-----------------------------------------------------------------------------
 SETTINGS::~SETTINGS()
 {
-printfd(__FILE__, "SETTINGS::~SETTINGS()\n");
 }
 //-----------------------------------------------------------------------------
 int SETTINGS::ParseYesNo(const string & value, bool * val)
@@ -480,9 +476,8 @@
             //printfd(__FILE__, "Module \'%s\'\n", child->getValue(0));
             if (strcasecmp(child->getName(), "Module") != 0)
                 {
-                // Секция имеет имя отличное от Module. А это неправильно
-                strError = "Unexpected \'" + string(child->getName()) + "\'.";
-                return -1;
+                child = child->getNextNode();
+                continue;
                 }
             MODULE_SETTINGS modSettings;
             modSettings.moduleParams.clear();
? stglibs/dotconfpp.lib/.dotconfpp.cpp.swp
? stglibs/dotconfpp.lib/.dotconfpp.h.swp
? stglibs/dotconfpp.lib/deps
Index: stglibs/dotconfpp.lib/dotconfpp.cpp
===================================================================
RCS file: /cvsroot/stglibs/stglibs/dotconfpp.lib/dotconfpp.cpp,v
retrieving revision 1.4
retrieving revision 1.7
diff -a -u -r1.4 -r1.7
--- stg/stglibs/dotconfpp.lib/dotconfpp.cpp	1 Jan 2010 12:48:19 -0000	1.4
+++ stg/stglibs/dotconfpp.lib/dotconfpp.cpp	19 Aug 2010 12:14:24 -0000	1.7
@@ -15,6 +15,10 @@
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#include <libgen.h> // dirname
+#include <glob.h> // glob
+#include <string>
+
 #include "dotconfpp.h"
 
 DOTCONFDocumentNode::DOTCONFDocumentNode():previousNode(NULL), nextNode(NULL), parentNode(NULL), childNode(NULL),
@@ -339,6 +343,19 @@
 
     fileName = strdup(realpathBuf);
 
+    char * forPathName = strdup(realpathBuf);
+
+    if (forPathName == NULL) {
+        error(0, NULL, "Not enought memory to duplicate realpath");
+        return -1;
+    }
+
+    char * _pathName = dirname(forPathName);
+
+    std::string pathName(_pathName);
+
+    free(forPathName); // From strdup
+
     processedFiles.push_back(strdup(realpathBuf));
 
     if(( file = fopen(fileName, "r")) == NULL){
@@ -364,56 +381,90 @@
             if(!cmp_func("IncludeFile", tagNode->name)){
                 vi = 0;
                 while( vi < tagNode->valuesCount ){
-                    if(access(tagNode->values[vi], R_OK) == -1){
-                        error(tagNode->lineNum, tagNode->fileName, "%s: %s", tagNode->values[vi], strerror(errno));
-                        return -1;
+                    glob_t globBuf;
+                    std::string nodeFilePath;
+                    if (*tagNode->values[vi] != '/') {
+                        // Relative path
+                        nodeFilePath = pathName + "/" + tagNode->values[vi];
+                    } else {
+                        // Absolute path
+                       nodeFilePath = tagNode->values[vi];
                     }
-                    if(realpath(tagNode->values[vi], realpathBuf) == NULL){
-                        error(tagNode->lineNum, tagNode->fileName, "realpath(%s) failed: %s", tagNode->values[vi], strerror(errno));
-                        return -1;
-                    }
-
-                    bool processed = false;
-                    for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); itInode++){
-                        if(!strcmp(*itInode, realpathBuf)){
-                            processed = true;
-                            break;
+                    int res = glob(nodeFilePath.c_str(), 0, NULL, &globBuf);
+                    if (res) {
+                        switch (res) {
+                            case GLOB_NOSPACE:
+                                error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': no free space", nodeFilePath.c_str());
+                                return -1;
+                            case GLOB_ABORTED:
+                                // printf("Read error\n");
+                                // Ignore that error
+                                break;
+                            case GLOB_NOMATCH:
+                                // printf("No match\n");
+                                // Ignore that error
+                                break;
+                            default:
+                                error(tagNode->lineNum, tagNode->fileName, "glob call failed for '%s': unknown error", nodeFilePath.c_str());
+                                return -1;
                         }
                     }
-                    if(processed){
-                        break;
-                    }
+                    if (!res) {
+                        for (size_t i = 0; i < globBuf.gl_pathc; ++i) {
+                            std::string nodeFilePath(globBuf.gl_pathv[i]);
+                            if(access(nodeFilePath.c_str(), R_OK) == -1){
+                                error(tagNode->lineNum, tagNode->fileName, "%s: %s", nodeFilePath.c_str(), strerror(errno));
+                                return -1;
+                            }
+                            if(realpath(nodeFilePath.c_str(), realpathBuf) == NULL){
+                                error(tagNode->lineNum, tagNode->fileName, "realpath(%s) failed: %s", nodeFilePath.c_str(), strerror(errno));
+                                return -1;
+                            }
+
+                            bool processed = false;
+                            for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); itInode++){
+                                if(!strcmp(*itInode, realpathBuf)){
+                                    processed = true;
+                                    break;
+                                }
+                            }
+                            if(processed){
+                                break;
+                            }
 
-                    processedFiles.push_back(strdup(realpathBuf));
+                            processedFiles.push_back(strdup(realpathBuf));
 
-                    file = fopen(tagNode->values[vi], "r");
-                    if(file == NULL){
-                        error(tagNode->lineNum, fileName, "failed to open file '%s': %s", tagNode->values[vi], strerror(errno));
-                        return -1;
-                    }
-                    //free(fileName);
-                    fileName = strdup(realpathBuf);
-                    from = nodeTree.end(); from--;
-                    /*
-                    if(tagNode->parentNode){
-                        DOTCONFDocumentNode * nd = tagNode->parentNode->childNode;
-                        while(nd){
-                            if(!nd->nextNode)
-                                break;
-                            nd = nd->nextNode;
+                            file = fopen(nodeFilePath.c_str(), "r");
+                            if(file == NULL){
+                                error(tagNode->lineNum, fileName, "failed to open file '%s': %s", nodeFilePath.c_str(), strerror(errno));
+                                return -1;
+                            }
+                            //free(fileName);
+                            fileName = strdup(realpathBuf);
+                            from = nodeTree.end(); from--;
+                            
+                            if(tagNode->parentNode){
+                                DOTCONFDocumentNode * nd = tagNode->parentNode->childNode;
+                                while(nd){
+                                    if(!nd->nextNode)
+                                        break;
+                                    nd = nd->nextNode;
+                                }
+
+                                curPrev = nd;
+                            }
+                            ret = parseFile(tagNode->parentNode);
+                            
+                            //ret = parseFile(tagNode->parentNode);
+                            (void) fclose(file);
+                            if(ret == -1)
+                                return -1;
+                            if(checkConfig(++from) == -1){
+                                return -1;
+                            }
                         }
-
-                        curPrev = nd;
-                    }
-                    ret = parseFile(tagNode->parentNode);
-                    */
-                    ret = parseFile();
-                    (void) fclose(file);
-                    if(ret == -1)
-                        return -1;
-                    if(checkConfig(++from) == -1){
-                        return -1;
                     }
+                    globfree(&globBuf);
                     vi++;
                 }
             }
Index: stglibs/dotconfpp.lib/dotconfpp.h
===================================================================
RCS file: /cvsroot/stglibs/stglibs/dotconfpp.lib/dotconfpp.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -a -u -r1.4 -r1.5
--- stg/stglibs/dotconfpp.lib/dotconfpp.h	18 Feb 2008 18:39:02 -0000	1.4
+++ stg/stglibs/dotconfpp.lib/dotconfpp.h	19 Aug 2010 09:42:20 -0000	1.5
@@ -60,14 +60,14 @@
     DOTCONFDocumentNode();
     ~DOTCONFDocumentNode();
 
-    const char * getConfigurationFileName()const { return fileName; }
+    const char * getConfigurationFileName() const { return fileName; }
     int getConfigurationLineNumber() const { return lineNum; }
 
     const DOTCONFDocumentNode * getNextNode() const { return nextNode; }
     const DOTCONFDocumentNode * getPreviuosNode() const { return previousNode; }
     const DOTCONFDocumentNode * getParentNode() const { return parentNode; }
     const DOTCONFDocumentNode * getChildNode() const { return childNode; }
-    const char* getValue(int index = 0) const;
+    const char * getValue(int index = 0) const;
     const char * getName() const { return name; }
     const DOTCONFDocument * getDocument() const { return document; }
 };
@@ -83,18 +83,18 @@
     DOTCONFDocumentNode * curPrev;
     int curLine;
     bool quoted;
-    std::list<DOTCONFDocumentNode*> nodeTree;
-    std::list<char*> requiredOptions;
-    std::list<char*> processedFiles;
+    std::list<DOTCONFDocumentNode *> nodeTree;
+    std::list<char *> requiredOptions;
+    std::list<char *> processedFiles;
     FILE * file;
     char * fileName;
-    std::list<char*> words;
-    int (*cmp_func)(const char *, const char *);
+    std::list<char *> words;
+    int (* cmp_func)(const char *, const char *);
 
     int checkRequiredOptions();
     int parseLine();
     int parseFile(DOTCONFDocumentNode * _parent = NULL);
-    int checkConfig(const std::list<DOTCONFDocumentNode*>::iterator & from);
+    int checkConfig(const std::list<DOTCONFDocumentNode *>::iterator & from);
     int cleanupLine(char * line);
     char * getSubstitution(char * macro, int lineNum);
     int macroSubstitute(DOTCONFDocumentNode * tagNode, int valueIndex);
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin