diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mail-scan.c | 13 | ||||
-rw-r--r-- | tools/skrewt.c | 10 | ||||
-rw-r--r-- | tools/utils.c | 17 | ||||
-rw-r--r-- | tools/utils.h | 2 | ||||
-rw-r--r-- | tools/ward.c | 10 |
5 files changed, 16 insertions, 36 deletions
diff --git a/tools/mail-scan.c b/tools/mail-scan.c index 3100ab6..0ed7465 100644 --- a/tools/mail-scan.c +++ b/tools/mail-scan.c @@ -80,18 +80,6 @@ void exeunt(const int sts){ exit(sts); } -string join(const string sep, list<string> stuff){ - string rslt; - if (!stuff.size()) return rslt; - list<string>::const_iterator ptr = stuff.begin(); - rslt = *ptr++; - for (; ptr != stuff.end(); ptr++){ - rslt += sep; - rslt += *ptr; - } - return rslt; -} - class watcher { public: string key; @@ -115,6 +103,7 @@ public: } }; + //////////////////////////////////////////////////////////// int main(int _argc, const char** _argv){ //// pid_t pid = getpid(); diff --git a/tools/skrewt.c b/tools/skrewt.c index 540b1cf..8c07974 100644 --- a/tools/skrewt.c +++ b/tools/skrewt.c @@ -117,16 +117,6 @@ void parse_content(const string type_spec_line, } } -string join(const string sep, const list<string> stuff){ - string rslt; - for (list<string>::const_iterator ptr = stuff.begin(); - ptr != stuff.end(); ptr++){ - if (rslt.length()) rslt += sep; - rslt += *ptr; - } - return rslt; -} - class skrewt{ public: string received_from; // envelope HELO among other things diff --git a/tools/utils.c b/tools/utils.c index 6dbbff4..691070e 100644 --- a/tools/utils.c +++ b/tools/utils.c @@ -1,4 +1,4 @@ -#include <string> +#include "utils.h" #include <sstream> #include <iomanip> #include <stdlib.h> /* for abs() */ @@ -6,8 +6,8 @@ ///// due to lack of interger abs() ///// and ambiguous (and inefficient) promotion #include <ctype.h> /* for isalnum() */ -using namespace std; +using namespace std; // strip off the directory part of a path, leaving just // the basic filename @@ -28,7 +28,6 @@ int prefix(const string shorter, const string longer){ // print a time as (-)hh:mm:ss // string time_out(const int _ttt){ -using namespace std; int ttt(abs(_ttt)); int sec(ttt % 60); int min((ttt / 60) % 60); @@ -76,7 +75,6 @@ string trim(const string foo, const string bar){ static const string Pure_Enough("+-_.,@%~"); string purify(const string arg){ - using namespace std; string rslt(arg); for (string::iterator ptr = rslt.begin(); ptr != rslt.end(); ptr++){ @@ -115,3 +113,14 @@ string noCR(const string bar){ } return foo; } + +// sorta like Perl's join(...) +string join(const string sep, const list<string> stuff){ + string rslt; + for (list<string>::const_iterator ptr = stuff.begin(); + ptr != stuff.end(); ptr++){ + if (rslt.length()) rslt += sep; + rslt += *ptr; + } + return rslt; +} diff --git a/tools/utils.h b/tools/utils.h index 77cff5e..1e6ac9d 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -1,8 +1,10 @@ #include <string> #include <list> +#include <iostream> std::string noCR(const std::string bar); int cmp_casefold(const std::string& a, const std::string& b); +std::string join(const std::string sep, const std::list<std::string> stuff); ///////////////////////////////////////////////////////// // Case insensitive comparison of strings diff --git a/tools/ward.c b/tools/ward.c index 8be9f70..56e626d 100644 --- a/tools/ward.c +++ b/tools/ward.c @@ -74,16 +74,6 @@ int mypid; #include "libskrewt.h" -string join(const string sep, const list<string> stuff){ - string rslt; - for (list<string>::const_iterator ptr = stuff.begin(); - ptr != stuff.end(); ptr++){ - if (rslt.length()) rslt += sep; - rslt += *ptr; - } - return rslt; -} - class skrewt{ public: string received_from; // envelope HELO among other things |