aboutsummaryrefslogtreecommitdiffstats
path: root/src/datetime-parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-03-13 01:48:49 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-03-13 01:48:49 +0100
commita2b3551dfb9460470bd79f5648bf597c517c40d4 (patch)
treeb82f50efbd76f581a281d61009811c1afabb0733 /src/datetime-parser.c
parent3ead966f48bc47444d7ec72f46e94e73557695a5 (diff)
downloadblogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.tar.gz
blogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.tar.bz2
blogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.zip
*: use squareball error infrastructure
Diffstat (limited to 'src/datetime-parser.c')
-rw-r--r--src/datetime-parser.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/datetime-parser.c b/src/datetime-parser.c
index 0aeb702..0fa7aaf 100644
--- a/src/datetime-parser.c
+++ b/src/datetime-parser.c
@@ -47,14 +47,14 @@ typedef enum {
char*
blogc_convert_datetime(const char *orig, const char *format,
- blogc_error_t **err)
+ sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
#ifndef HAVE_TIME_H
- *err = blogc_error_new(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new(BLOGC_WARNING_DATETIME_PARSER,
"Your operating system does not supports the datetime functionalities "
"used by blogc. Sorry.");
return NULL;
@@ -80,7 +80,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -91,7 +91,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_THIRD_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -102,7 +102,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FOURTH_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid third digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -111,7 +111,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1900;
if (tmp < 0) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid year. Found %d, must be >= 1900.",
tmp + 1900);
break;
@@ -120,7 +120,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid fourth digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -131,7 +131,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between year and month. "
"Found '%c', must be '-'.", c);
break;
@@ -142,7 +142,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of month. "
"Found '%c', must be integer >= 0 and <= 1.", c);
break;
@@ -151,7 +151,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1;
if (tmp < 0 || tmp > 11) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid month. Found %d, must be >= 1 and <= 12.",
tmp + 1);
break;
@@ -160,7 +160,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of month. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -171,7 +171,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between month and day. "
"Found '%c', must be '-'.", c);
break;
@@ -182,7 +182,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of day. "
"Found '%c', must be integer >= 0 and <= 3.", c);
break;
@@ -191,7 +191,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 1 || tmp > 31) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid day. Found %d, must be >= 1 and <= 31.",
tmp);
break;
@@ -200,7 +200,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SPACE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of day. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -211,7 +211,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between date and time. "
"Found '%c', must be ' ' (empty space).", c);
break;
@@ -222,7 +222,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of hours. "
"Found '%c', must be integer >= 0 and <= 2.", c);
break;
@@ -231,7 +231,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 23) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid hours. Found %d, must be >= 0 and <= 23.",
tmp);
break;
@@ -240,7 +240,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of hours. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -251,7 +251,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between hours and minutes. "
"Found '%c', must be ':'.", c);
break;
@@ -262,7 +262,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of minutes. "
"Found '%c', must be integer >= 0 and <= 5.", c);
break;
@@ -274,7 +274,7 @@ blogc_convert_datetime(const char *orig, const char *format,
// this won't happen because we are restricting the digits
// to 00-59 already, but lets keep the code here for
// reference.
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid minutes. Found %d, must be >= 0 and <= 59.",
tmp);
break;
@@ -283,7 +283,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of minutes. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -294,7 +294,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between minutes and seconds. "
"Found '%c', must be ':'.", c);
break;
@@ -305,7 +305,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of seconds. "
"Found '%c', must be integer >= 0 and <= 6.", c);
break;
@@ -314,7 +314,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 60) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid seconds. Found %d, must be >= 0 and <= 60.",
tmp);
break;
@@ -323,7 +323,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_DONE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of seconds. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -355,7 +355,7 @@ blogc_convert_datetime(const char *orig, const char *format,
case DATETIME_SECOND_MINUTE:
case DATETIME_FIRST_SECOND:
case DATETIME_SECOND_SECOND:
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid datetime string. "
"Found '%s', formats allowed are: 'yyyy-mm-dd hh:mm:ss', "
"'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and 'yyyy-mm-dd'.",
@@ -374,7 +374,7 @@ blogc_convert_datetime(const char *orig, const char *format,
char buf[1024];
if (0 == strftime(buf, sizeof(buf), format, &t)) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Failed to format DATE variable, FORMAT is too long: %s",
format);
return NULL;