annotate target-utils/libtiffs/rdinmem.c @ 980:a0879ce32d2c

fc-tmsh omr command: always interpret both arguments as hex
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Thu, 10 Dec 2015 04:28:52 +0000
parents 2900fe603f8a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
103
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include "types.h"
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include "struct.h"
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 #include "globals.h"
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include "macros.h"
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 mpffs_read_into_ram(pathname, buf, maxlen, lenrtn)
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 char *pathname;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 u8 *buf;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 size_t maxlen, *lenrtn;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 {
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 int stat, cont;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 u8 *chunk_start;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 size_t chunk_size, real_len, roomleft;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 stat = mpffs_find_file(pathname, &chunk_start, &chunk_size, &cont);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 if (stat < 0)
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 return(stat);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 if (chunk_size > maxlen) {
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 toobig: printf("Error: %s is bigger than the read buffer\n", pathname);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 return(-1);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 }
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 real_len = chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 bcopy(chunk_start, buf, chunk_size);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 buf += chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 roomleft = maxlen - chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 while (cont) {
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 stat = mpffs_get_segment(cont, &chunk_start, &chunk_size,
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 &cont);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if (stat < 0)
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 return(stat);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 if (chunk_size > roomleft)
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 goto toobig;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 real_len += chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 bcopy(chunk_start, buf, chunk_size);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 buf += chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 roomleft -= chunk_size;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 if (lenrtn)
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 *lenrtn = real_len;
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 return(0);
ac310ee73788 target-utils/libmpffs: minor refactoring, read into RAM implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 }