summaryrefslogtreecommitdiff
path: root/easytool
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-08-14 21:55:32 +0800
committerHarald Welte <laforge@gnumonks.org>2010-08-14 21:55:32 +0800
commit741be6949bd7d00ee7b6c47e31942b7c650cf8fc (patch)
tree12149b447cac5d969b492135fcb501d5fb896a27 /easytool
parent67f1385a353b0a89ceb3cb11a31161e0bee6680e (diff)
add function to alter the 'sum of the day'
Diffstat (limited to 'easytool')
-rw-r--r--easytool/easycard.c13
-rw-r--r--easytool/easycard.h5
2 files changed, 18 insertions, 0 deletions
diff --git a/easytool/easycard.c b/easytool/easycard.c
index 32c71f3..1f9572d 100644
--- a/easytool/easycard.c
+++ b/easytool/easycard.c
@@ -63,6 +63,19 @@ int easy_update_log_rec(struct easy_log_rec *elr, int16_t delta)
return 0;
}
+/* apply a delta to the 'sum of day' record in Sector 15 Block 2 */
+int easy_update_sum_of_day(struct easy_sect15blk2 *s15b2, int16_t delta)
+{
+ int32_t sum = s15b2->sum_of_day + delta;
+
+ if (sum < 0 || sum > 0xffff)
+ return -ERANGE;
+
+ s15b2->sum_of_day = sum;
+
+ return 0;
+}
+
static char tsbuf[64];
char *easy_asc_timestamp(const uint8_t *timestamp)
{
diff --git a/easytool/easycard.h b/easytool/easycard.h
index e6ce806..c421bc2 100644
--- a/easytool/easycard.h
+++ b/easytool/easycard.h
@@ -44,4 +44,9 @@ struct easy_log_rec {
time_t easy_timestamp2time(const uint8_t *easy_ts);
+/* apply a telta (positive or negative) to a EasyCard log record */
+int easy_update_log_rec(struct easy_log_rec *elr, int16_t delta);
+/* apply a delta to the 'sum of day' record in Sector 15 Block 2 */
+int easy_update_sum_of_day(struct easy_sect15blk2 *s15b2, int16_t delta);
+
#endif /* EASYCARD_H */
personal git repositories of Harald Welte. Your mileage may vary