aboutsummaryrefslogtreecommitdiffstats
path: root/src/sim
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2024-04-05 21:47:57 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2024-04-05 21:47:57 +0200
commit470fc4934100d44fef1d243ae88a8e100b3947ee (patch)
tree6916a732cd0ab279a62c55c22c368ff6fc96e4c3 /src/sim
parent17123595ec25304f30221506cfc0300262b2720f (diff)
C-Netz SIM: Fix entering card numbers with leading zeroes
Numbers for the SIM card can be entered with zeroes in the front. This will not change numbers to octal. The Bosch OF 7 phone will not accept numbers in the phone book with less than 4 digits, so it is essential to allow entering numbers with zeroes in front. Also state that in the documents.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/sim.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/sim/sim.c b/src/sim/sim.c
index 086519e..b6446ae 100644
--- a/src/sim/sim.c
+++ b/src/sim/sim.c
@@ -31,7 +31,9 @@
#ifdef ARDUINO
#define LOGP(cat, level, fmt, arg...) while(0)
#define EINVAL 22
-static uint32_t my_strtoul(const char *nptr, char **endptr, int base)
+#endif
+
+static uint32_t my_strtoul(const char *nptr, char __attribute__((unused)) **endptr, int __attribute__((unused)) base)
{
uint32_t number = 0;
@@ -40,9 +42,6 @@ static uint32_t my_strtoul(const char *nptr, char **endptr, int base)
return number;
}
-#else
-#define my_strtoul strtoul
-#endif
static void my_ultostr(char *nptr, uint32_t value, int zeros)
{
@@ -143,7 +142,7 @@ int encode_ebdt(uint8_t *data, const char *futln, const char *sicherung, const c
if (futln[i] < '0' || futln[i] > '9')
break;
}
- temp = my_strtoul(futln, NULL, 0);
+ temp = my_strtoul(futln, NULL, 10);
if (i < 5 || temp > 65535) {
LOGP(DSIM7, LOGL_NOTICE, "Given FUTLN '%s' has invalid last digits. (Must be '00000' .. '65535')\n", futln);
return -EINVAL;
@@ -153,7 +152,7 @@ int encode_ebdt(uint8_t *data, const char *futln, const char *sicherung, const c
}
if (sicherung) {
- temp = my_strtoul(sicherung, NULL, 0);
+ temp = my_strtoul(sicherung, NULL, 10);
if (temp > 65535) {
LOGP(DSIM7, LOGL_NOTICE, "Given security code '%s' has invalid digits. (Must be '0' .. '65535')\n", sicherung);
return -EINVAL;
@@ -163,7 +162,7 @@ int encode_ebdt(uint8_t *data, const char *futln, const char *sicherung, const c
}
if (karten) {
- temp = my_strtoul(karten, NULL, 0);
+ temp = my_strtoul(karten, NULL, 10);
if (temp > 7) {
LOGP(DSIM7, LOGL_NOTICE, "Given card number '%s' has invalid digit. (Must be '0' .. '7')\n", karten);
return -EINVAL;
@@ -172,7 +171,7 @@ int encode_ebdt(uint8_t *data, const char *futln, const char *sicherung, const c
}
if (sonder) {
- temp = my_strtoul(sonder, NULL, 0);
+ temp = my_strtoul(sonder, NULL, 10);
if (temp > 8191) {
LOGP(DSIM7, LOGL_NOTICE, "Given spacial code '%s' has invalid digits. (Must be '0' .. '8191')\n", sonder);
return -EINVAL;
@@ -182,7 +181,7 @@ int encode_ebdt(uint8_t *data, const char *futln, const char *sicherung, const c
}
if (wartung) {
- temp = my_strtoul(wartung, NULL, 0);
+ temp = my_strtoul(wartung, NULL, 10);
if (temp > 65535) {
LOGP(DSIM7, LOGL_NOTICE, "Given maintenance code '%s' has invalid digits. (Must be '0' .. '65535')\n", wartung);
return -EINVAL;