annotate rvinterf/etmsync/fsmisc.c @ 411:d7f409493eb6

loadagent: intel-rewrite-sector implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 17 Jun 2014 04:31:16 +0000
parents 8dd522a8d60e
children 091ebd46a9cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
300
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Miscellaneous (dangerous!) FFS2 operations
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
301
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
6 #include <ctype.h>
300
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "etm.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "ffs.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "tmffs2.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "limits.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "ffslimits.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "localtypes.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #include "localstruct.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 #include "exitcodes.h"
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 extern u_char rvi_msg[];
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 extern int rvi_msg_len;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 cmd_format(argc, argv)
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 char **argv;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 int rc, slen;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 slen = strlen(argv[1]);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if (slen >= TMFFS_STRING_SIZE) {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 printf("error: argument exceeds string length limit\n");
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 return;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 dp = cmdpkt + 1;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 *dp++ = ETM_FFS2;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 *dp++ = TMFFS_FORMAT;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 *dp++ = slen + 1;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 strcpy(dp, argv[1]);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 dp += slen + 1;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 /* magic is 0x2BAD, 16-bit little-endian */
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 *dp++ = 0xAD;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 *dp++ = 0x2B;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 if (rc)
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 return(rc);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 if (rvi_msg_len != 5) {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 printf("error: TMFFS_FORMAT response has wrong length\n");
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 return(ERROR_TARGET);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 if (rvi_msg[3]) {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 report_ffs_err("format", rvi_msg[3]);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 return(ERROR_TARGET);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 return(0);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 cmd_preformat()
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 u_char cmdpkt[6];
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 int rc;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 cmdpkt[1] = ETM_FFS2;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 cmdpkt[2] = TMFFS_PREFORMAT;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 /* magic is 0xDEAD, 16-bit little-endian */
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 cmdpkt[3] = 0xAD;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 cmdpkt[4] = 0xDE;
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 rc = etm_pkt_exch(cmdpkt, 4);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 if (rc)
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 return(rc);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 if (rvi_msg_len != 5) {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 printf("error: TMFFS_PREFORMAT response has wrong length\n");
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 return(ERROR_TARGET);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 if (rvi_msg[3]) {
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 report_ffs_err("preformat", rvi_msg[3]);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 return(ERROR_TARGET);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 return(0);
19b846c8abed fc-fsio: format and preformat commands added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 }
301
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
80
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
81 cmd_set_imeisv(argc, argv)
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
82 char **argv;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
83 {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
84 char *filename, *cp, digits[16];
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
85 u_char bytes[8];
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
86 int pcm_order, i;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
87
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
88 if (!strcmp(argv[1], "pcm")) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
89 filename = "/pcm/IMEI";
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
90 pcm_order = 1;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
91 } else if (!strcmp(argv[1], "fc")) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
92 filename = "/etc/IMEISV";
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
93 pcm_order = 0;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
94 } else {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
95 fprintf(stderr,
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
96 "error: IMEISV storage type argument must be \"pcm\" or \"fc\"\n");
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
97 return(ERROR_USAGE);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
98 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
99 cp = argv[2];
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
100 if (!isdigit(*cp)) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
101 inv: fprintf(stderr,
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
102 "error: 2nd argument must have 16 decimal digits\n");
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
103 return(ERROR_USAGE);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
104 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
105 for (i = 0; i < 16; i++) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
106 if (ispunct(*cp))
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
107 cp++;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
108 if (!isdigit(*cp))
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
109 goto inv;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
110 digits[i] = *cp++ - '0';
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
111 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
112 if (*cp)
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
113 goto inv;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
114 for (i = 0; i < 8; i++)
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
115 bytes[i] = pcm_order ? digits[i*2+1] << 4 | digits[i*2]
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
116 : digits[i*2] << 4 | digits[i*2+1];
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
117 printf("Writing \"%02X %02X %02X %02X %02X %02X %02X %02X\" into %s\n",
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
118 bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5],
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
119 bytes[6], bytes[7], filename);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
120 return do_short_fwrite(filename, bytes, 8);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
121 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
122
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
123 cmd_set_pcm_string(argc, argv)
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
124 char **argv;
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
125 {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
126 char filename[16];
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
127
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
128 if (strcmp(argv[1], "CGMI") && strcmp(argv[1], "CGMM") &&
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
129 strcmp(argv[1], "CGMR") && strcmp(argv[1], "CGSN")) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
130 fprintf(stderr,
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
131 "error: \"%s\" is not a recognized PCM string file name\n",
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
132 argv[1]);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
133 return(ERROR_USAGE);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
134 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
135 sprintf(filename, "/pcm/%s", argv[1]);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
136 if (strlen(argv[2]) > 20) {
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
137 fprintf(stderr,
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
138 "error: %s string may not exceed 20 characters\n",
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
139 filename);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
140 return(ERROR_USAGE);
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
141 }
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
142 return do_short_fwrite(filename, argv[2], strlen(argv[2]));
8dd522a8d60e fc-fsio: set-imeisv and set-pcm-string added from fc-tmsh
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 300
diff changeset
143 }