comparison simtool/pbupd_imm.c @ 10:ddd767f6e15b

fc-simtool ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 07:11:25 +0000
parents
children
comparison
equal deleted inserted replaced
9:c9ef9e91dd8e 10:ddd767f6e15b
1 /*
2 * This module implements the pb-update-imm command.
3 */
4
5 #include <sys/types.h>
6 #include <string.h>
7 #include <strings.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "curfile.h"
11
12 cmd_pb_update_imm(argc, argv)
13 char **argv;
14 {
15 int rc;
16 unsigned recno;
17 u_char record[255], *fixp;
18
19 rc = phonebook_op_common(argv[1]);
20 if (rc < 0)
21 return(rc);
22 recno = strtoul(argv[2], 0, 0);
23 if (recno < 1 || recno > curfile_record_count) {
24 fprintf(stderr, "error: specified record number is invalid\n");
25 return(-1);
26 }
27 memset(record, 0xFF, curfile_record_len);
28 fixp = record + curfile_record_len - 14;
29 rc = encode_phone_number_arg(argv[3], fixp, 0);
30 if (rc < 0)
31 return(rc);
32 if (argv[4]) {
33 rc = qstring_arg_to_gsm7(argv[4], record,
34 curfile_record_len - 14);
35 if (rc < 0)
36 return(rc);
37 }
38 return update_rec_op(recno, 0x04, record, curfile_record_len);
39 }