25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: file.c,v 1.4 2007/05/22 09:49:31 debug Exp $ |
* $Id: file.c,v 1.5 2007/06/23 23:59:14 debug Exp $ |
29 |
* |
* |
30 |
* This module contains functions which load executable images into (emulated) |
* This module contains functions which load executable images into (emulated) |
31 |
* memory. File formats recognized so far are: |
* memory. File formats recognized so far are: |
123 |
{ |
{ |
124 |
int iadd = DEBUG_INDENTATION, old_quiet_mode; |
int iadd = DEBUG_INDENTATION, old_quiet_mode; |
125 |
FILE *f; |
FILE *f; |
126 |
|
char *tmpdir = getenv("TMPDIR") == NULL? |
127 |
|
DEFAULT_TMP_DIR : getenv("TMPDIR"); |
128 |
unsigned char buf[12]; |
unsigned char buf[12]; |
129 |
unsigned char buf2[2]; |
unsigned char buf2[2]; |
130 |
|
char tmpname[400]; |
131 |
size_t len, len2, i; |
size_t len, len2, i; |
132 |
off_t size; |
off_t size; |
133 |
|
|
301 |
* is a "scrambled" raw binary. This code unscrambles it, and loads |
* is a "scrambled" raw binary. This code unscrambles it, and loads |
302 |
* it as a raw binary. |
* it as a raw binary. |
303 |
*/ |
*/ |
304 |
|
snprintf(tmpname, sizeof(tmpname), "%s/gxemul.", tmpdir); |
305 |
if (machine->machine_type == MACHINE_DREAMCAST && |
if (machine->machine_type == MACHINE_DREAMCAST && |
306 |
strncmp(filename, "/tmp/gxemul.", 12) == 0) { |
strncmp(filename, tmpname, strlen(tmpname)) == 0) { |
307 |
char *tmp_filename = malloc(strlen(filename) + 100); |
char *tmp_filename = malloc(strlen(filename) + 100); |
308 |
snprintf(tmp_filename, strlen(filename) + 100, |
snprintf(tmp_filename, strlen(filename) + 100, |
309 |
"%s.descrambled", filename); |
"%s.descrambled", filename); |