FreeCalypso > hg > fc-pcsc-tools
view simtool/smsp_erase.c @ 184:8d073ff62c48
fc-simtool: imsi command does higher-level parsing,
the old version is now imsi-raw
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Mar 2021 05:44:17 +0000 |
parents | 10030acba82f |
children |
line wrap: on
line source
/* * This module implements the smsp-erase family of commands. */ #include <sys/types.h> #include <string.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> #include "curfile.h" cmd_smsp_erase_all(argc, argv) char **argv; { int rc; unsigned recno; u_char record[255]; rc = select_ef_smsp(); 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_smsp_erase_one(argc, argv) char **argv; { int rc; unsigned recno; u_char record[255]; rc = select_ef_smsp(); if (rc < 0) return(rc); recno = strtoul(argv[1], 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); } cmd_smsp_erase_range(argc, argv) char **argv; { int rc; unsigned recno, startrec, endrec; u_char record[255]; rc = select_ef_smsp(); if (rc < 0) return(rc); startrec = strtoul(argv[1], 0, 0); if (startrec < 1 || startrec > curfile_record_count) { fprintf(stderr, "error: specified starting record number is invalid\n"); return(-1); } if (!strcmp(argv[2], "end")) endrec = curfile_record_count; else { endrec = strtoul(argv[2], 0, 0); if (endrec < 1 || endrec > curfile_record_count) { fprintf(stderr, "error: specified final record number is invalid\n"); return(-1); } if (startrec > endrec) { fprintf(stderr, "error: reverse record range specified\n"); return(-1); } } memset(record, 0xFF, curfile_record_len); for (recno = startrec; recno <= endrec; recno++) { rc = update_rec_op(recno, 0x04, record, curfile_record_len); if (rc < 0) return(rc); } return(0); }