summaryrefslogtreecommitdiff
path: root/src/mmo/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mmo/utils.cpp')
-rw-r--r--src/mmo/utils.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/mmo/utils.cpp b/src/mmo/utils.cpp
index a1316d1..f8aff2e 100644
--- a/src/mmo/utils.cpp
+++ b/src/mmo/utils.cpp
@@ -20,12 +20,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <netinet/in.h>
#include <sys/time.h>
#include <algorithm>
-#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
@@ -36,6 +34,9 @@
#include "../poison.hpp"
+
+namespace tmwa
+{
//---------------------------------------------------
// E-mail check: return 0 (not correct) or 1 (valid).
//---------------------------------------------------
@@ -57,9 +58,9 @@ bool e_mail_check(XString email)
return 0;
if (hostname.front() == '.' || hostname.back() == '.')
return 0;
- if (hostname.contains_seq(".."))
+ if (hostname.contains_seq(".."_s))
return 0;
- if (email.contains_any(" ;"))
+ if (email.contains_any(" ;"_s))
return 0;
return email.is_print();
}
@@ -70,18 +71,18 @@ bool e_mail_check(XString email)
//-------------------------------------------------
int config_switch(ZString str)
{
- if (str == "true" || str == "on" || str == "yes"
- || str == "oui" || str == "ja"
- || str == "si")
+ if (str == "true"_s || str == "on"_s || str == "yes"_s
+ || str == "oui"_s || str == "ja"_s
+ || str == "si"_s)
return 1;
- if (str == "false" || str == "off" || str == "no"
- || str == "non" || str == "nein")
+ if (str == "false"_s || str == "off"_s || str == "no"_s
+ || str == "non"_s || str == "nein"_s)
return 0;
int rv;
if (extract(str, &rv))
return rv;
- FPRINTF(stderr, "Fatal: bad option value %s", str);
+ FPRINTF(stderr, "Fatal: bad option value %s"_fmt, str);
abort();
}
@@ -93,17 +94,17 @@ void stamp_time(timestamp_seconds_buffer& out, const TimeT *t)
struct tm when = t ? *t : TimeT::now();
char buf[20];
strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
- out = stringish<timestamp_seconds_buffer>(const_(buf));
+ out = stringish<timestamp_seconds_buffer>(VString<19>(strings::really_construct_from_a_pointer, buf));
}
void stamp_time(timestamp_milliseconds_buffer& out)
{
struct timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
struct tm when = TimeT(tv.tv_sec);
char buf[24];
strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
sprintf(buf + 19, ".%03d", static_cast<int>(tv.tv_usec / 1000));
- out = stringish<timestamp_milliseconds_buffer>(const_(buf));
+ out = stringish<timestamp_milliseconds_buffer>(VString<23>(strings::really_construct_from_a_pointer, buf));
}
void log_with_timestamp(io::WriteFile& out, XString line)
@@ -119,3 +120,4 @@ void log_with_timestamp(io::WriteFile& out, XString line)
out.really_put(": ", 2);
out.put_line(line);
}
+} // namespace tmwa