Wolfgang Ortmann 9 жил өмнө
parent
commit
945311793d

+ 16 - 16
src/expiretools.cpp

@@ -12,27 +12,27 @@ using namespace std;
 
 
 void debugPrint(const std::string& s);
 void debugPrint(const std::string& s);
 
 
-void readSetRules(const KindConfig &conf,
-		    map<string, pair<time_t, time_t> > &ruleSet,
-		    map<string, string> &backupSetRule)
+void readSetRules(const KindConfig& conf,
+                  map<string, pair<time_t, time_t> >& ruleSet,
+                  map<string, string>& backupSetRule)
 {
 {
   Strings setRules = conf.getStrings("setRules");
   Strings setRules = conf.getStrings("setRules");
   if (!setRules.empty())
   if (!setRules.empty())
     {
     {
       for (const string& rule : setRules)
       for (const string& rule : setRules)
-	{
-	  Strings splittedRule;
-	  split(rule, splittedRule, ':');
-	  if (splittedRule.size() != 3)
-	    throw Exception("config", "Error in setRule: " + rule);
-	  string name = splittedRule[0];
-	  if (name == "expire")
-	    throw Exception("config", "Use of reserved name expire in setRule is forbidden");
-	  backupSetRule[name] = rule;
-	  time_t distance = stot(splittedRule[1]);
-	  time_t keep = stot(splittedRule[2]);
-	  ruleSet[name] = pair<time_t, time_t>(distance, keep);
-	}
+        {
+          Strings splittedRule;
+          split(rule, splittedRule, ':');
+          if (splittedRule.size() != 3)
+            throw Exception("config", "Error in setRule: " + rule);
+          string name = splittedRule[0];
+          if (name == "expire")
+            throw Exception("config", "Use of reserved name expire in setRule is forbidden");
+          backupSetRule[name] = rule;
+          time_t distance = stot(splittedRule[1]);
+          time_t keep = stot(splittedRule[2]);
+          ruleSet[name] = pair<time_t, time_t>(distance, keep);
+        }
     }
     }
 }
 }
 
 

+ 3 - 3
src/expiretools.h

@@ -5,9 +5,9 @@
 #include "DateTime.h"
 #include "DateTime.h"
 #include "KindConfig.h"
 #include "KindConfig.h"
 
 
-void readSetRules(const KindConfig &conf,
-		  std::map<std::string, std::pair<time_t, time_t> > &ruleSet,
-		  std::map<std::string, std::string> &backupSetRule);
+void readSetRules(const KindConfig& conf,
+                  std::map<std::string, std::pair<time_t, time_t> >& ruleSet,
+                  std::map<std::string, std::string>& backupSetRule);
 
 
 DateTime imageDate(const std::string& image);
 DateTime imageDate(const std::string& image);
 
 

+ 6 - 6
src/kind.ag

@@ -391,7 +391,7 @@ void backupVault(const string& vault,
 
 
       if (conf.hasKey("setRules"))
       if (conf.hasKey("setRules"))
         {
         {
-	  readSetRules(conf,ruleSet,backupSetRule);
+          readSetRules(conf, ruleSet, backupSetRule);
           if (!ruleSet.empty())
           if (!ruleSet.empty())
             {
             {
               backupNow = false;
               backupNow = false;
@@ -400,8 +400,8 @@ void backupVault(const string& vault,
               map<string, DateTime> nextBackup;
               map<string, DateTime> nextBackup;
 
 
               // find time for next backup
               // find time for next backup
-              // set default time for next Backup to now 
-	      //    (if there is no image yet)
+              // set default time for next Backup to now
+              //    (if there is no image yet)
               for (auto rule : ruleSet)
               for (auto rule : ruleSet)
                 nextBackup[rule.first] = imageTime;
                 nextBackup[rule.first] = imageTime;
 
 
@@ -439,7 +439,7 @@ void backupVault(const string& vault,
 
 
       verbosePrint("backup to \"" + imageFullName + "\"");
       verbosePrint("backup to \"" + imageFullName + "\"");
       if (!currentSet.empty())
       if (!currentSet.empty())
-	verbosePrint("backup set is \"" + currentSet + "\"");
+        verbosePrint("backup set is \"" + currentSet + "\"");
 
 
       if (backupNow)
       if (backupNow)
         {
         {
@@ -457,12 +457,12 @@ void backupVault(const string& vault,
 
 
           if (!dryRun)
           if (!dryRun)
             {
             {
-	      // set symlink to last image
+              // set symlink to last image
               string lastLink = vaultpath + "/last";
               string lastLink = vaultpath + "/last";
               unlink(lastLink.c_str());
               unlink(lastLink.c_str());
               symlink(imageFullName.c_str(), lastLink.c_str());
               symlink(imageFullName.c_str(), lastLink.c_str());
 
 
-	      // write expire date to file
+              // write expire date to file
               DateTime expireTime;
               DateTime expireTime;
               string rule;
               string rule;
               if (currentSet == "expire")
               if (currentSet == "expire")

+ 43 - 43
src/kind.cpp

@@ -503,7 +503,7 @@ void doBackup(const string& vault,
 # 248 "kind.ag"
 # 248 "kind.ag"
       string userAtHost = conf.getString("user") + "@" +
       string userAtHost = conf.getString("user") + "@" +
 # 249 "kind.ag"
 # 249 "kind.ag"
-                          conf.getString("host");
+      conf.getString("host");
 # 250 "kind.ag"
 # 250 "kind.ag"
       string rshCommand = remoteShell;
       string rshCommand = remoteShell;
 # 251 "kind.ag"
 # 251 "kind.ag"
@@ -663,9 +663,9 @@ void doBackup(const string& vault,
 # 328 "kind.ag"
 # 328 "kind.ag"
       if (rc == 0 ||
       if (rc == 0 ||
 # 329 "kind.ag"
 # 329 "kind.ag"
-          rc == 24 || // "no error" or "vanished source files" (ignored)
+      rc == 24 || // "no error" or "vanished source files" (ignored)
 # 330 "kind.ag"
 # 330 "kind.ag"
-          rc == 6144) // workaround for wrong exit code ??!!
+      rc == 6144) // workaround for wrong exit code ??!!
 # 331 "kind.ag"
 # 331 "kind.ag"
         {
         {
 # 332 "kind.ag"
 # 332 "kind.ag"
@@ -793,7 +793,7 @@ void backupVault(const string& vault,
 # 393 "kind.ag"
 # 393 "kind.ag"
         {
         {
 # 394 "kind.ag"
 # 394 "kind.ag"
-	  readSetRules(conf,ruleSet,backupSetRule);
+          readSetRules(conf, ruleSet, backupSetRule);
 # 395 "kind.ag"
 # 395 "kind.ag"
           if (!ruleSet.empty())
           if (!ruleSet.empty())
 # 396 "kind.ag"
 # 396 "kind.ag"
@@ -811,9 +811,9 @@ void backupVault(const string& vault,
 # 402 "kind.ag"
 # 402 "kind.ag"
               // find time for next backup
               // find time for next backup
 # 403 "kind.ag"
 # 403 "kind.ag"
-              // set default time for next Backup to now 
+              // set default time for next Backup to now
 # 404 "kind.ag"
 # 404 "kind.ag"
-	      //    (if there is no image yet)
+              //    (if there is no image yet)
 # 405 "kind.ag"
 # 405 "kind.ag"
               for (auto rule : ruleSet)
               for (auto rule : ruleSet)
 # 406 "kind.ag"
 # 406 "kind.ag"
@@ -889,7 +889,7 @@ void backupVault(const string& vault,
 # 441 "kind.ag"
 # 441 "kind.ag"
       if (!currentSet.empty())
       if (!currentSet.empty())
 # 442 "kind.ag"
 # 442 "kind.ag"
-	verbosePrint("backup set is \"" + currentSet + "\"");
+        verbosePrint("backup set is \"" + currentSet + "\"");
 # 443 "kind.ag"
 # 443 "kind.ag"
 
 
 # 444 "kind.ag"
 # 444 "kind.ag"
@@ -925,7 +925,7 @@ void backupVault(const string& vault,
 # 459 "kind.ag"
 # 459 "kind.ag"
             {
             {
 # 460 "kind.ag"
 # 460 "kind.ag"
-	      // set symlink to last image
+              // set symlink to last image
 # 461 "kind.ag"
 # 461 "kind.ag"
               string lastLink = vaultpath + "/last";
               string lastLink = vaultpath + "/last";
 # 462 "kind.ag"
 # 462 "kind.ag"
@@ -935,7 +935,7 @@ void backupVault(const string& vault,
 # 464 "kind.ag"
 # 464 "kind.ag"
 
 
 # 465 "kind.ag"
 # 465 "kind.ag"
-	      // write expire date to file
+              // write expire date to file
 # 466 "kind.ag"
 # 466 "kind.ag"
               DateTime expireTime;
               DateTime expireTime;
 # 467 "kind.ag"
 # 467 "kind.ag"
@@ -1035,7 +1035,7 @@ void expireVault(const string& vault, KindConfig conf, DateTime now)
 # 514 "kind.ag"
 # 514 "kind.ag"
       if (imageTime != now &&          // ignore just created image
       if (imageTime != now &&          // ignore just created image
 # 515 "kind.ag"
 # 515 "kind.ag"
-          image.name != lastValidImage // ignore last valid image
+      image.name != lastValidImage // ignore last valid image
 # 516 "kind.ag"
 # 516 "kind.ag"
          )
          )
 # 517 "kind.ag"
 # 517 "kind.ag"
@@ -1153,15 +1153,15 @@ void usage()
   exit(1);
   exit(1);
 }
 }
 
 
-void error(const string &msg)
+void error(const string& msg)
 {
 {
   cout << endl << ag_programName << " - error: " << msg << endl << endl;
   cout << endl << ag_programName << " - error: " << msg << endl << endl;
   usage();
   usage();
 }
 }
 
 
-int ptoi(const char *para)
+int ptoi(const char* para)
 {
 {
-  char *end;
+  char* end;
   int res = strtol(para, &end, 10);
   int res = strtol(para, &end, 10);
   if (end == para)
   if (end == para)
     error(string("no int: ") + para);
     error(string("no int: ") + para);
@@ -1170,9 +1170,9 @@ int ptoi(const char *para)
   return res;
   return res;
 }
 }
 
 
-double ptod(const char *para)
+double ptod(const char* para)
 {
 {
-  char *end;
+  char* end;
   double res = strtod(para, &end);
   double res = strtod(para, &end);
   if (end == para)
   if (end == para)
     error(string("no double: ") + para);
     error(string("no double: ") + para);
@@ -1181,15 +1181,15 @@ double ptod(const char *para)
   return res;
   return res;
 }
 }
 
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
 {
-bool fullImage = false;
-string masterConfig = "";
-bool doBackup = false;
-bool doExpire = false;
-bool listConfig = false;
+  bool fullImage = false;
+  string masterConfig = "";
+  bool doBackup = false;
+  bool doExpire = false;
+  bool listConfig = false;
 
 
-string vault = "";
+  string vault = "";
   static struct option ag_long_options[] =
   static struct option ag_long_options[] =
   {
   {
     {"full", no_argument, 0, 'f' },
     {"full", no_argument, 0, 'f' },
@@ -1218,44 +1218,44 @@ string vault = "";
           error("Expecting option parameter");
           error("Expecting option parameter");
           break;
           break;
         case 'f':
         case 'f':
-              fullImage = true;
-              break;
+          fullImage = true;
+          break;
 
 
         case 'c':
         case 'c':
-              masterConfig = optarg;
-              break;
+          masterConfig = optarg;
+          break;
 
 
         case 'B':
         case 'B':
-              doBackup = true;
-              break;
+          doBackup = true;
+          break;
 
 
         case 'E':
         case 'E':
-              doExpire = true;
-              break;
+          doExpire = true;
+          break;
 
 
         case 'C':
         case 'C':
-              listConfig = true;
-              break;
+          listConfig = true;
+          break;
 
 
         case 'D':
         case 'D':
-              dryRun = true;
-              break;
+          dryRun = true;
+          break;
 
 
         case 'v':
         case 'v':
-              verbose = true;
-              break;
+          verbose = true;
+          break;
 
 
         case 'd':
         case 'd':
-              debug = true;
-              break;
+          debug = true;
+          break;
 
 
         case 'q':
         case 'q':
-              quiet = true;
-              break;
+          quiet = true;
+          break;
 
 
         case 'h':
         case 'h':
-              usage();
-              break;
+          usage();
+          break;
 
 
         default:
         default:
           error("error in options");
           error("error in options");
@@ -1265,7 +1265,7 @@ string vault = "";
     vault = argv[optind++];
     vault = argv[optind++];
   else error("Parameter vault_or_group needed");
   else error("Parameter vault_or_group needed");
 
 
-/*AppGen:MainEnd*/
+  /*AppGen:MainEnd*/
 # 564 "kind.ag"
 # 564 "kind.ag"
 
 
 # 565 "kind.ag"
 # 565 "kind.ag"

+ 5 - 5
src/stringtools.h

@@ -13,7 +13,7 @@ std::string trim(const std::string& s);
 
 
 // reduce each occurence of char to one char
 // reduce each occurence of char to one char
 //   if a char is used as delimiter and may be doubled
 //   if a char is used as delimiter and may be doubled
-//   this function 
+//   this function
 void reduceToOne(std::string& s, char c);
 void reduceToOne(std::string& s, char c);
 
 
 // replace each occurence of c1 with character c2
 // replace each occurence of c1 with character c2
@@ -21,17 +21,17 @@ void substitute(std::string& s, char c1, char c2);
 
 
 // split in parts
 // split in parts
 // uses del as delimiter to split a string in parts
 // uses del as delimiter to split a string in parts
-// if expectedParts is given and not zero a wrong 
+// if expectedParts is given and not zero a wrong
 // number of parts causes an exception
 // number of parts causes an exception
 int split(const std::string& s, Strings& parts,
 int split(const std::string& s, Strings& parts,
           char del, int expectedParts = 0);
           char del, int expectedParts = 0);
 
 
 // functions for parsing of string
 // functions for parsing of string
-// parsing starts at position i and sets i to the 
+// parsing starts at position i and sets i to the
 // position after end of read part
 // position after end of read part
 // white space after read part is skipped
 // white space after read part is skipped
 
 
-// skip white spaces 
+// skip white spaces
 void skipWS(const std::string& s, unsigned  int& i);
 void skipWS(const std::string& s, unsigned  int& i);
 
 
 // read int value
 // read int value
@@ -54,7 +54,7 @@ bool startsWith(const std::string& s, const std::string& start);
 // converts a given string to a time period (in seconds)
 // converts a given string to a time period (in seconds)
 time_t stot(const std::string& s);
 time_t stot(const std::string& s);
 
 
-// replaces in string template the placeholder string with the 
+// replaces in string template the placeholder string with the
 // string given as content
 // string given as content
 // "my name is %name","%name","Wolfgang" -> "my name is Wolfgang"
 // "my name is %name","%name","Wolfgang" -> "my name is Wolfgang"
 void replacePlaceHolder(std::string& templ,
 void replacePlaceHolder(std::string& templ,