diff --git a/second/load.c b/second/load.c new file mode 100644 index 0000000..67aedf0 --- /dev/null +++ b/second/load.c @@ -0,0 +1,45 @@ +/* + * + * (c) 2004 Laurent Vivier + * + */ + +#include +#include +#include "glue.h" +#include "load.h" + +char* load_image(unsigned long offset, unsigned long size) +{ + int err; + char* image; + ParamBlockRec_t param_block; + + if (size == 0) + return NULL; + + image = malloc(size); + if (image == 0) + { + free(image); + return NULL; + } + + memset(¶m_block, 0, sizeof(param_block)); + + param_block.ioBuffer = (unsigned long)image; + param_block.ioVRefNum = 1; + param_block.ioRefNum = -5; + param_block.ioReqCount = size; + param_block.ioPosMode = fsFromStart; + param_block.ioPosOffset = offset; + + err = PBReadSync(¶m_block); + if (err != noErr) + { + free(image); + return NULL; + } + + return image; +} diff --git a/second/load.h b/second/load.h new file mode 100644 index 0000000..8a8a929 --- /dev/null +++ b/second/load.h @@ -0,0 +1,7 @@ +/* + * + * (c) 2004 Laurent Vivier + * + */ + +extern char* load_image(unsigned long offset, unsigned long size);