summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--include/configreader.h2
-rw-r--r--include/extern.h2
-rw-r--r--src/config.c9
-rw-r--r--src/misc.c8
5 files changed, 18 insertions, 4 deletions
diff --git a/Changes b/Changes
index a7237d06c..594569858 100644
--- a/Changes
+++ b/Changes
@@ -16,6 +16,7 @@ F Partial patch by Adam, commenting fix for #1006 for future reference.
F Forward-port r1946: Patch by Adam fixing #1006 (originally caused by #922): modes set by ChanServ are reversed. Thanks!
Provided by DukePyrolator <dukepyrolator@gmx.de> - 2009
+F Add 'w' and 'y' support to dotime(), also prevent an overflow.
F Allow NS STATUS from unregistered users, thanks DP!
F Wild pointers do not a happy Anope make. Thanks DP :)
F Allow NS REGISTER to unregistered nicks, silly oversight. Thanks DP! :)
diff --git a/include/configreader.h b/include/configreader.h
index b85bd7293..0e4700325 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -61,6 +61,8 @@ class ValueItem
ValueItem(const char *);
/** Initialize with an std::string */
ValueItem(const std::string &);
+ /** Initialize with time_t **/
+ ValueItem(time_t);
/** Change value to a char pointer */
//void Set(char *);
/** Change value to a const char pointer */
diff --git a/include/extern.h b/include/extern.h
index 06ba4cb9b..553e94ea1 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -630,7 +630,7 @@ E const char *merge_args(int argc, const char **argv);
// Use Anope::Match() instead of these.
E int match_wild(const char *pattern, const char *str) MARK_DEPRECATED;
E int match_wild_nocase(const char *pattern, const char *str) MARK_DEPRECATED;
-E int dotime(const char *s);
+E time_t dotime(const char *s);
E const char *duration(NickCore *nc, char *buf, int bufsize, time_t seconds);
E const char *expire_left(NickCore *nc, char *buf, int len, time_t expires);
E int doValidHost(const char *host, int type);
diff --git a/src/config.c b/src/config.c
index 6cc27aff9..42086cfae 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1159,7 +1159,7 @@ int ServerConfig::Read(bool bail)
if (ConfValue(config_data, static_cast<std::string>(MultiValues[Index].tag),
static_cast<std::string>(MultiValues[Index].items[valuenum]),
static_cast<std::string>(MultiValues[Index].items_default[valuenum]), tagnum, item, allow_newlines)) {
- int time = dotime(item.c_str());
+ time_t time = dotime(item.c_str());
vl.push_back(ValueItem(time));
}
else vl.push_back(ValueItem(0));
@@ -1515,6 +1515,13 @@ ValueItem::ValueItem(int value) : v("")
v = n.str();
}
+ValueItem::ValueItem(time_t value) : v("")
+{
+ std::stringstream n;
+ n << value;
+ v = n.str();
+}
+
ValueItem::ValueItem(bool value) : v("")
{
std::stringstream n;
diff --git a/src/misc.c b/src/misc.c
index 9de7cfdca..2acbb6087 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -325,9 +325,9 @@ int process_numlist(const char *numstr, int *count_ret,
* of seconds), or an integer followed by one of these characters:
* "s" (seconds), "m" (minutes), "h" (hours), or "d" (days).
* @param s String to convert
- * @return int
+ * @return time_t
*/
-int dotime(const char *s)
+time_t dotime(const char *s)
{
int amount;
@@ -346,6 +346,10 @@ int dotime(const char *s)
return amount * 3600;
case 'd':
return amount * 86400;
+ case 'w':
+ return amount * 86400 * 7;
+ case 'y':
+ return amount * 86400 * 365;
default:
return -1;
}