diff libutil/decimal_incr.c @ 25:9c9f6adbaedb

sim-iccid-mkrange utility added
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 15 Mar 2021 09:07:20 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libutil/decimal_incr.c	Mon Mar 15 09:07:20 2021 +0000
@@ -0,0 +1,22 @@
+/*
+ * This module implements a function for incrementing decimal strings,
+ * to be used in producing ranges of ICCID and IMSI numbers.
+ */
+
+#include <sys/types.h>
+
+void
+decimal_string_increment(str, ndigits)
+	u_char *str;
+	unsigned ndigits;
+{
+	u_char *p;
+
+	for (p = str + ndigits; p > str; ) {
+		--p;
+		(*p)++;
+		if (*p < 10)
+			return;
+		*p = 0;
+	}
+}