annotate uicc/pberase.c @ 173:df4bf4e06221

doc: several articles moved to other repositories
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Sep 2023 06:51:05 +0000
parents 43463dc91431
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
147
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the pb-erase command.
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <string.h>
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <strings.h>
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 cmd_pb_erase(argc, argv)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char **argv;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int rc;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned recno;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 u_char record[255];
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned pb_record_len, pb_record_count;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 rc = phonebook_op_common(argv[1], &pb_record_len, &pb_record_count);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (rc < 0)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return(rc);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 memset(record, 0xFF, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 for (recno = 1; recno <= pb_record_count; recno++) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 rc = update_rec_op(recno, 0x04, record, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rc < 0)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return(rc);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return(0);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 cmd_pb_erase_one(argc, argv)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 char **argv;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 int rc;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 unsigned recno;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 u_char record[255];
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 unsigned pb_record_len, pb_record_count;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 rc = phonebook_op_common(argv[1], &pb_record_len, &pb_record_count);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (rc < 0)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(rc);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 recno = strtoul(argv[2], 0, 0);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (recno < 1 || recno > pb_record_count) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 fprintf(stderr, "error: specified record number is invalid\n");
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return(-1);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 memset(record, 0xFF, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return update_rec_op(recno, 0x04, record, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 cmd_pb_erase_range(argc, argv)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 char **argv;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 int rc;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 unsigned recno, startrec, endrec;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 u_char record[255];
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 unsigned pb_record_len, pb_record_count;
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 rc = phonebook_op_common(argv[1], &pb_record_len, &pb_record_count);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (rc < 0)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return(rc);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 startrec = strtoul(argv[2], 0, 0);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (startrec < 1 || startrec > pb_record_count) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 fprintf(stderr,
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 "error: specified starting record number is invalid\n");
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return(-1);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 endrec = strtoul(argv[3], 0, 0);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 if (endrec < 1 || endrec > pb_record_count) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 fprintf(stderr,
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 "error: specified final record number is invalid\n");
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 return(-1);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (startrec > endrec) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 fprintf(stderr, "error: reverse record range specified\n");
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return(-1);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 memset(record, 0xFF, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 for (recno = startrec; recno <= endrec; recno++) {
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 rc = update_rec_op(recno, 0x04, record, pb_record_len);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 if (rc < 0)
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 return(rc);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 return(0);
43463dc91431 fc-uicc-tool: pb-erase commands ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 }