ResourceUserHeader
tool-makers: put whatever you like in here!
========================================
*/
struct ResourceUserHeader {
ResourceType TRK; // 'SFX', 'TRK', etc
dword ver; // 0, 1, etc
};
/*
ResourceHeader
tool-makers: put this struct at the top of your resource output files
========================================
*/
struct ResourceHeader {
dword RESOURCE_COOKIE; // must be RESOURCE_COOKIE
ResourceUserHeader user;
};
/*
Resource Sets (RES files)
*/
const int RESOURCE_NAME_MAX = 13; // must be 1 mod 4 (res hides info after
name (doh!))
const int RESOURCE_SET_NAME_MAX = 13;
const dword RESOURCE_SET_COOKIE = 'RST0';
/*
ResourceSetHeader
*/
struct ResourceSetHeader {
dword RESOURCE_SET_COOKIE; // must be RESOURCE_SET_COOKIE
// dword ver;
dword res_count;
dword discard_idx,discard_offset;
};
Hi, when compiling the following:
include <stdio.h>
include <stdlib.h>
include <string.h>
typedef float real;
typedef unsigned long dword;
// _res.h
/*
Individual Resources (STPs, SFXs, WRLs...)
*/
typedef dword ResourceType;
const dword RESOURCE_COOKIE = 'RES0';
/*
ResourceUserHeader
tool-makers: put whatever you like in here!
========================================
*/
struct ResourceUserHeader {
ResourceType TRK; // 'SFX', 'TRK', etc
dword ver; // 0, 1, etc
};
/*
ResourceHeader
tool-makers: put this struct at the top of your resource output files
========================================
*/
struct ResourceHeader {
dword RESOURCE_COOKIE; // must be RESOURCE_COOKIE
ResourceUserHeader user;
};
/*
Resource Sets (RES files)
*/
const int RESOURCE_NAME_MAX = 13; // must be 1 mod 4 (res hides info after
name (doh!))
const int RESOURCE_SET_NAME_MAX = 13;
const dword RESOURCE_SET_COOKIE = 'RST0';
/*
ResourceSetHeader
*/
struct ResourceSetHeader {
dword RESOURCE_SET_COOKIE; // must be RESOURCE_SET_COOKIE
// dword ver;
dword res_count;
dword discard_idx,discard_offset;
};
const dword RESOURCE_MEMORY_COOKIE = 'MGI!';
struct ResourceMemoryHeader;
/*
ResourceTOCEntry
/
struct ResourceTOCEntry {
char name;
ResourceUserHeader user;
dword size; // not including ResourceMemoryHeader
/ runtime /
dword ref_count;
ResourceMemoryHeader res;
bool is_singleton();
};
/ allow zero-sized array /
pragma warning(disable:4200)
/*
ResourceMemoryHeader
/
struct ResourceMemoryHeader {
ResourceTOCEntry toc;
dword RESOURCE_MEMORY_COOKIE; // must be RESOURCE_MEMORY_COOKIE
char mem;
};
define READ(x) if (fread(&x, sizeof x, 1, f) < 1) { printf("Can't read %s\n",
x); exit(1); }
int main(int argc, char argv)
{
if (argc != 3) {
printf("usage: mkres <resname> <reslist.txt> \n");
return -1;
}
FILE f = fopen(argv, "rt");
fgets
if (f) {
ResourceSetHeader rsh;
READ(rsh);
printf("count = %d\n", rsh.res_count);
const int MAX_RES = 1000;
ResourceTOCEntry toc_list;
for (int i = 0; i < rsh.res_count; i++) {
ResourceTOCEntry &toc = toc_list_;
READ(toc);
printf("%d: %s, %d\n", i, toc.name, toc.size);
}
for (int i = 0; i < rsh.res_count; i++) {
ResourceTOCEntry &toc = toc_list_;
ResourceMemoryHeader rmh;
char *buf = new char;
READ(rmh);
fread(buf, toc.size, 1, f);
FILE *out = fopen(toc.name, "wb");
if (out) {
ResourceHeader rh;
rh.RESOURCE_COOKIE = RESOURCE_COOKIE;
rh.user = toc.user;
fwrite(&rh, sizeof rh, 1, out);
ResourceMemoryHeader rmh;
memset(&rmh, 0, sizeof rmh);
rmh.RESOURCE_MEMORY_COOKIE = RESOURCE_MEMORY_COOKIE;
fwrite(&rmh, sizeof rmh, 1, out);
fwrite(buf, toc.size, 1, out);
fclose(out);
}
FILE *list = fopen("reslist.txt", "at");
fwrite(toc.name, sizeof toc.name, 1, list);
fclose(list);
/ printf("out ist: %s\n", out);*/
delete buf;
}
fclose(f);
}
return 0;
}
i get the error messages: 106 expected
;' before "if" and 153 statement is a reference, not call, to function
fgets'What is wrong? When i insert a ; behind fgets, i get
105 statement is a reference, not call, to function `fgets'
Running round in circles, desperate. Please help me!
thomasvaer __
Where are lines 106 and 153?
Sorry, forgot to include th eline numbers.
Line 106 is in this section:
int main(int argc, char argv)
{
if (argc != 3) {
printf("usage: mkres <resname> <reslist.txt> \n");
return -1;
}
FILE f = fopen(argv, "rt");
fgets //<<<<THIS IS LINE 106
if (f) {
ResourceSetHeader rsh;
Line 153 is the last but one: return 0;
Hope you can help me, i need a hint urgently :-)