FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/fswrite.c @ 291:69e8ae2b5ba2
fc-fsio: fwrite implementation started
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 01 Mar 2014 02:36:25 +0000 |
parents | 76228aecf0d9 |
children | 3aa03b9519c0 |
rev | line source |
---|---|
290
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * FFS write operation commands |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "etm.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "ffs.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "ffserr.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "tmffs2.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "limits.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "localtypes.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "localstruct.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #include "exitcodes.h" |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 extern u_char rvi_msg[]; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 extern int rvi_msg_len; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 do_mkdir_existok(pathname) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *pathname; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 int rc, slen; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 struct stat_info stat; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 slen = strlen(pathname); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 if (slen >= TMFFS_STRING_SIZE) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 printf("error: pathname arg exceeds string length limit\n"); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return(ERROR_USAGE); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 dp = cmdpkt + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 *dp++ = ETM_FFS2; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 *dp++ = TMFFS_MKDIR; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 *dp++ = slen + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 strcpy(dp, pathname); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 dp += slen + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (rc) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 return(rc); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 if (rvi_msg_len != 5) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 printf("error: mkdir response has wrong length\n"); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 return(ERROR_TARGET); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 if (!rvi_msg[3]) /* success */ |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 return(0); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 if (rvi_msg[3] != TMFFS_ERR_EXISTS) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 report_ffs_err("mkdir", rvi_msg[3]); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 return(ERROR_TARGET); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 /* object already exists: OK if it's a directory, error otherwise */ |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 rc = do_xlstat(pathname, &stat); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (rc) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 return(rc); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 if (stat.type == OT_DIR) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 return(0); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 else { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 printf("error: %s exists and is not a directory\n", pathname); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 return(ERROR_TARGET); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 cmd_mkdir(argc, argv) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 char **argv; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 return do_mkdir_existok(argv[1]); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 cmd_delete(argc, argv) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 char **argv; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 int rc, slen; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 slen = strlen(argv[1]); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 if (slen >= TMFFS_STRING_SIZE) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 printf("error: pathname arg exceeds string length limit\n"); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 return(ERROR_USAGE); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 dp = cmdpkt + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 *dp++ = ETM_FFS2; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 *dp++ = TMFFS_REMOVE; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 *dp++ = slen + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 strcpy(dp, argv[1]); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 dp += slen + 1; |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 if (rc) |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 return(rc); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 if (rvi_msg_len != 5) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 printf("error: TMFFS_REMOVE response has wrong length\n"); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 return(ERROR_TARGET); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 if (rvi_msg[3]) { |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 report_ffs_err("ffs_remove", rvi_msg[3]); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 return(ERROR_TARGET); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 } |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 return(0); |
76228aecf0d9
fc-fsio: mkdir and delete implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 } |
291
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
101 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
102 fwrite_hex_string(pathname, strarg) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
103 char *pathname, *strarg; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
104 { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
105 fprintf(stderr, "This function is not yet implemented\n"); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
106 return(ERROR_BUG); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
107 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
108 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
109 fwrite_from_file(pathname, srcfile) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
110 char *pathname, *srcfile; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
111 { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
112 fprintf(stderr, "This function is not yet implemented\n"); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
113 return(ERROR_BUG); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
114 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
115 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
116 cmd_fwrite(argc, argv) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
117 char **argv; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
118 { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
119 if (!strcmp(argv[2], "ascii")) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
120 return do_short_fwrite(argv[1], argv[3], strlen(argv[3])); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
121 else if (!strcmp(argv[2], "hex")) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
122 return fwrite_hex_string(argv[1], argv[3]); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
123 else if (!strcmp(argv[2], "file")) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
124 return fwrite_from_file(argv[1], argv[3]); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
125 else { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
126 fprintf(stderr, |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
127 "error: middle argument to fwrite cmd must be \"ascii\", \"hex\" or \"file\"\n" |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
128 ); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
129 return(ERROR_USAGE); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
130 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
290
diff
changeset
|
131 } |