FreeCalypso > hg > freecalypso-hwlab
view simtool/pberase.c @ 117:06e2d5c60cbd
fc-simtool: pb-update-imm command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 03:41:06 +0000 |
parents | 0dcd666292e4 |
children | 87b34a244901 |
line wrap: on
line source
/* * This module implements the pb-erase command. */ #include <sys/types.h> #include <string.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> #include <pcsclite.h> #include <winscard.h> #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); } cmd_pb_erase_one(argc, argv) char **argv; { int rc; unsigned recno; u_char record[255]; rc = phonebook_op_common(argv[1]); if (rc < 0) return(rc); recno = strtoul(argv[2], 0, 0); if (recno < 1 || recno > curfile_record_count) { fprintf(stderr, "error: specified record number is invalid\n"); return(-1); } memset(record, 0xFF, curfile_record_len); return update_rec_op(recno, 0x04, record, curfile_record_len); }