/** xt_size **/
-struct unit_definition xtype_units_size[] = {
+static struct unit_definition xtype_units_size[] = {
[SIZE_UNIT_BYTE] = { "", 1LLU, 1 },
[SIZE_UNIT_KILOBYTE] = { "KB", 1024LLU, 1 },
[SIZE_UNIT_MEGABYTE] = { "MB", 1024LLU * 1024LLU, 1 },
return mp_printf(pool, "%"PRIu64"%s", curr_val, xtype_units_size[out_units].unit);
}
-static const char * xt_size_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool UNUSED)
+static const char *xt_size_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
{
if(opt_str == NULL) {
return "NULL is not supported as a column argument.";
return NULL;
}
-static const char *xt_size_parse(const char *str, void *dest, struct mempool *pool UNUSED)
+static const char *xt_size_parse(const char *str, void *dest, struct mempool *pool)
{
errno = 0;
char *units_start = NULL;
- u64 parsed = strtol(str, &units_start, 10);
+ u64 parsed = strtoul(str, &units_start, 10);
if(str == units_start) {
return mp_printf(pool, "Invalid value of size: '%s'.", str);
}
int unit_idx = xtype_unit_parser(units_start, xtype_units_size);
if(unit_idx == -1) {
- return mp_printf(pool, "Invalid format of size: '%s'.", str);
+ return mp_printf(pool, "Invalid units: '%s'.", units_start);
}
*(u64*) dest = parsed * xtype_units_size[unit_idx].num;
return mp_printf(pool, "%s", formatted_time_buf);
}
-static const char * xt_timestamp_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
+static const char *xt_timestamp_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
{
if(opt_str == NULL) {
return "NULL is not supported as a column argument.";
return mp_printf(pool, "Invalid column format option: '%s'.", opt_str);
}
-static const char *xt_timestamp_parse(const char *str, void *dest, struct mempool *pool UNUSED)
+static const char *xt_timestamp_parse(const char *str, void *dest, struct mempool *pool)
{
errno = 0;
char *parse_end = NULL;
- u64 parsed = strtol(str, &parse_end, 10);
+ u64 parsed = strtoul(str, &parse_end, 10);
if(str == parse_end) {
return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
}
return NULL;
}
-
struct tm parsed_time;
- //"%Y-%m-%d %H:%M:%S"
- //"%F %T"
- parse_end = strptime("%F %T", "%Y-%m-%d %H:%M:%S", &parsed_time);
+ parse_end = strptime(str, "%F %T", &parsed_time);
if(parse_end == NULL) {
return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
}
+ if(*parse_end != 0) {
+ return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
+ }
time_t tmp_time = mktime(&parsed_time);
*(u64*)dest = (u64) tmp_time;