diff simtool/lndwrite.c @ 10:ddd767f6e15b

fc-simtool ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 07:11:25 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/lndwrite.c	Sun Mar 14 07:11:25 2021 +0000
@@ -0,0 +1,52 @@
+/*
+ * This module implements lnd-write and lnd-erase commands.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+#include <strings.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "curfile.h"
+
+cmd_lnd_write(argc, argv)
+	char **argv;
+{
+	int rc;
+	u_char record[255], *fixp;
+
+	rc = select_ef_lnd();
+	if (rc < 0)
+		return(rc);
+	memset(record, 0xFF, curfile_record_len);
+	fixp = record + curfile_record_len - 14;
+	rc = encode_phone_number_arg(argv[1], fixp, 0);
+	if (rc < 0)
+		return(rc);
+	if (argv[2]) {
+		rc = qstring_arg_to_gsm7(argv[2], record,
+					 curfile_record_len - 14);
+		if (rc < 0)
+			return(rc);
+	}
+	return update_rec_op(0, 0x03, record, curfile_record_len);
+}
+
+cmd_lnd_erase(argc, argv)
+	char **argv;
+{
+	int rc;
+	u_char record[255];
+	unsigned count;
+
+	rc = select_ef_lnd();
+	if (rc < 0)
+		return(rc);
+	memset(record, 0xFF, curfile_record_len);
+	for (count = 0; count < curfile_record_count; count++) {
+		rc = update_rec_op(0, 0x03, record, curfile_record_len);
+		if (rc < 0)
+			return(rc);
+	}
+	return(0);
+}