changeset 43:52ec2d3eb851

encode_phone_number_arg() now supports both encoding modes
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Feb 2021 23:36:47 +0000
parents 2714d379edc2
children f4eb1e83b4b3
files libcommon/number_encode.c simtool/pbupd_imm.c simtool/pbupd_immhex.c
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/number_encode.c	Fri Feb 12 23:02:09 2021 +0000
+++ b/libcommon/number_encode.c	Fri Feb 12 23:36:47 2021 +0000
@@ -53,7 +53,7 @@
 	}
 }
 
-encode_phone_number_arg(arg, fixp)
+encode_phone_number_arg(arg, fixp, mode)
 	char *arg;
 	u_char *fixp;
 {
@@ -83,10 +83,13 @@
 		}
 		digits[ndigits] = c;
 	}
+	if (mode)
+		fixp[0] = ndigits;
 	if (ndigits & 1)
 		digits[ndigits++] = 0xF;
 	num_digit_bytes = ndigits >> 1;
-	fixp[0] = num_digit_bytes + 1;
+	if (!mode)
+		fixp[0] = num_digit_bytes + 1;
 	pack_digit_bytes(digits, fixp + 2, num_digit_bytes);
 	if (*cp == ',') {
 		cp++;
--- a/simtool/pbupd_imm.c	Fri Feb 12 23:02:09 2021 +0000
+++ b/simtool/pbupd_imm.c	Fri Feb 12 23:36:47 2021 +0000
@@ -26,7 +26,7 @@
 	}
 	memset(record, 0xFF, curfile_record_len);
 	fixp = record + curfile_record_len - 14;
-	rc = encode_phone_number_arg(argv[3], fixp);
+	rc = encode_phone_number_arg(argv[3], fixp, 0);
 	if (rc < 0)
 		return(rc);
 	if (argv[4]) {
--- a/simtool/pbupd_immhex.c	Fri Feb 12 23:02:09 2021 +0000
+++ b/simtool/pbupd_immhex.c	Fri Feb 12 23:36:47 2021 +0000
@@ -56,7 +56,7 @@
 	}
 	memset(record, 0xFF, curfile_record_len);
 	fixp = record + curfile_record_len - 14;
-	rc = encode_phone_number_arg(argv[3], fixp);
+	rc = encode_phone_number_arg(argv[3], fixp, 0);
 	if (rc < 0)
 		return(rc);
 	rc = decode_alphatag_arg_hex(argv[4], record, curfile_record_len - 14);