comparison target-utils/libtiffs/rdinmem.c @ 224:2900fe603f8a

beginning of MPFFS->TIFFS naming convention change
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Jan 2014 07:59:00 +0000
parents target-utils/libmpffs/rdinmem.c@ac310ee73788
children
comparison
equal deleted inserted replaced
223:0848c7f419fd 224:2900fe603f8a
1 #include <sys/types.h>
2 #include "types.h"
3 #include "struct.h"
4 #include "globals.h"
5 #include "macros.h"
6
7 mpffs_read_into_ram(pathname, buf, maxlen, lenrtn)
8 char *pathname;
9 u8 *buf;
10 size_t maxlen, *lenrtn;
11 {
12 int stat, cont;
13 u8 *chunk_start;
14 size_t chunk_size, real_len, roomleft;
15
16 stat = mpffs_find_file(pathname, &chunk_start, &chunk_size, &cont);
17 if (stat < 0)
18 return(stat);
19 if (chunk_size > maxlen) {
20 toobig: printf("Error: %s is bigger than the read buffer\n", pathname);
21 return(-1);
22 }
23 real_len = chunk_size;
24 bcopy(chunk_start, buf, chunk_size);
25 buf += chunk_size;
26 roomleft = maxlen - chunk_size;
27 while (cont) {
28 stat = mpffs_get_segment(cont, &chunk_start, &chunk_size,
29 &cont);
30 if (stat < 0)
31 return(stat);
32 if (chunk_size > roomleft)
33 goto toobig;
34 real_len += chunk_size;
35 bcopy(chunk_start, buf, chunk_size);
36 buf += chunk_size;
37 roomleft -= chunk_size;
38 }
39 if (lenrtn)
40 *lenrtn = real_len;
41 return(0);
42 }