# HG changeset patch # User Mychaela Falconia # Date 1611631940 0 # Node ID 87d459d9797aa81e82565798d6affa2bd14ab32d # Parent 5bfb5a7262c1ef8273f13d68f1e2f3c174106f0d fc-simtool: pb-erase command implemented diff -r 5bfb5a7262c1 -r 87d459d9797a simtool/Makefile --- a/simtool/Makefile Tue Jan 26 03:22:26 2021 +0000 +++ b/simtool/Makefile Tue Jan 26 03:32:20 2021 +0000 @@ -3,8 +3,8 @@ PROG= fc-simtool OBJS= alpha_decode.o alpha_valid.o apdu.o atr.o cardconnect.o chv.o \ dispatch.o globals.o hexdump.o hexread.o hlread.o main.o names.o \ - pbcommon.o pbdump.o pbupdate.o readcmd.o readops.o saverestore.o \ - select.o telsum.o writecmd.o writeops.o + pbcommon.o pbdump.o pberase.o pbupdate.o readcmd.o readops.o \ + saverestore.o select.o telsum.o writecmd.o writeops.o INSTBIN=/opt/freecalypso/bin all: ${PROG} diff -r 5bfb5a7262c1 -r 87d459d9797a simtool/dispatch.c --- a/simtool/dispatch.c Tue Jan 26 03:22:26 2021 +0000 +++ b/simtool/dispatch.c Tue Jan 26 03:32:20 2021 +0000 @@ -18,6 +18,7 @@ extern int cmd_iccid(); extern int cmd_imsi(); extern int cmd_pb_dump(); +extern int cmd_pb_erase(); extern int cmd_pb_update(); extern int cmd_readbin(); extern int cmd_readef(); @@ -60,6 +61,7 @@ {"iccid", 0, 0, cmd_iccid}, {"imsi", 0, 0, cmd_imsi}, {"pb-dump", 1, 2, cmd_pb_dump}, + {"pb-erase", 1, 1, cmd_pb_erase}, {"pb-update", 2, 2, cmd_pb_update}, {"quit", 0, 0, cmd_exit}, {"readbin", 2, 2, cmd_readbin}, diff -r 5bfb5a7262c1 -r 87d459d9797a simtool/pberase.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simtool/pberase.c Tue Jan 26 03:32:20 2021 +0000 @@ -0,0 +1,31 @@ +/* + * This module implements the pb-erase command. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "globals.h" + +cmd_pb_erase(argc, argv) + char **argv; +{ + int rc; + unsigned recno; + u_char record[255]; + + rc = phonebook_op_common(argv[1]); + if (rc < 0) + return(rc); + memset(record, 0xFF, curfile_record_len); + for (recno = 1; recno <= curfile_record_count; recno++) { + rc = update_rec_op(recno, 0x04, record, curfile_record_len); + if (rc < 0) + return(rc); + } + return(0); +}