User talk:Magicus/Magicus's Tools/Parse-u8.c

From WiiBrew
Jump to navigation Jump to search

Is there a way to repack or join the files back to a U8 archive?

I don't know of a tool that does it yet (I think a few people on the wiibrew channel have done their own), but for the most part it should be pretty simple as the structure is fairly basic. Atacama 03:48, 3 May 2008 (PDT)

Building without Wii.git stuff

Since it's only using the data typedefs and big-endian reader functions, compiling in all of Segher's Wii.git stuff is unnecessary (especially since that also requires OpenSSL). As a workaround, replace

#include "tools.h"


typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

u16 be16(const u8 *p)
	return (p[0] << 8) | p[1];
u32 be32(const u8 *p)
	return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];

(copied from tools.h) and compile with

gcc -g -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -Wall -W -O2 parse-u8.c -o parse-u8

or just

gcc parse-u8.c -o parse-u8

if you don't care about very large files.

Why not use standard C types and functions, rather than rolling your own? inttypes.h or stdint.h can be used to get uint8_t, uint16_t and friends, and the networking functions htonl and htons can be used to convert from native endianness to big endian. Besides being a standard part of POSIX, they will also work correctly if your computer's native byte order is big endian. Not all the world is Intel, you know. Koorogi
I just thought I'd help others build it since it's hugely easier than getting all the dependencies working off-the-shelf. Oh, and I posted it, I just forgot to sign it. Maxim 11:46, 14 May 2008 (PDT)