2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
43 void loader_init(char* filename
){
44 //zzip_dir = zzip_dir_open(filename, 0);
46 // report_error("loader: unable to open game data in %s (%s)\n",
47 // filename, strerror( errno ) );
53 //zzip_dir_close(zzip_dir);
56 reader
* loader_open(char* filename
){
57 char buf
[1024] = "data/";
59 strncpy(buf
+L
,filename
,1024-L
);
62 reader
* rd
= malloc(sizeof(reader
));
65 //rd->f = zzip_file_open(zzip_dir, buf, 0);
66 rd
->f
= zzip_open(buf
, 0);
68 //report_error("loader: unable to open %s (%s)\n",
69 // filename, zzip_strerror_of( zzip_dir ) );
70 report_error("loader: unable to open %s (%s)\n",
71 filename
, strerror( errno
) );
79 void loader_close(reader
* rd
){
80 //zzip_file_close(rd->f);
86 int loader_read(reader
* rd
, void* buf
, int count
){
87 //return zzip_file_read(rd->f, buf, count);
88 return zzip_read(rd
->f
, buf
, count
);
91 unsigned char* loader_readall(char* filename
, int* size
){
93 reader
* rd
= loader_open(filename
);
95 if(zzip_fstat(rd
->f
, &zs
) < 0){
96 report_error("loader: stat error on %s\n",filename
);
100 unsigned char* buf
= malloc(N
);
102 report_error("loader: out of memory\n");
105 loader_read(rd
,buf
,N
);
112 int loader_scanline(reader
* rd
, char* format
, ...){
119 /* get next character */
120 if(rd
->next_c
!= -1){
125 loader_read(rd
, &c
, 1);
128 /* see if it is a end of line sequence */
130 loader_read(rd
, &c
, 1);
144 //printf("loader_scanline: %s\n",buf);
147 va_start(ap
, format
);
149 int ret
= vsscanf(buf
,format
,ap
);