diff options
author | matthijs <matthijs@openttd.org> | 2013-09-19 07:42:13 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2013-09-19 07:42:13 +0000 |
commit | e25844cdf2d243ea62dff53056819887ddfe610f (patch) | |
tree | d4827f8c464da5d179e756381b84fd1b59f19143 /os/dos/exe2coff.c | |
parent | 0e7bfdfbd40168884a4072f1ecd27d70be8b0ceb (diff) | |
download | openttd-e25844cdf2d243ea62dff53056819887ddfe610f.tar.xz |
(svn r25780) -Change: [DOS] Put cwsdpmi and exe2coff files in subdirectories.
- Since these are different components, distributed under a different
license, mixing them in the same directory is confusing.
Diffstat (limited to 'os/dos/exe2coff.c')
-rw-r--r-- | os/dos/exe2coff.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/os/dos/exe2coff.c b/os/dos/exe2coff.c deleted file mode 100644 index aa072e8e4..000000000 --- a/os/dos/exe2coff.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* Updated 2008 to use fread/fopen and friends instead of read/open so it compiles with GCC on Unix (Rubidium) */ -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <string.h> -#include <unistd.h> -#include <ctype.h> - - -static void -exe2aout(char *fname) -{ - unsigned short header[3]; - FILE *ifile; - FILE *ofile; - char buf[4096]; - int rbytes; - char *dot = strrchr(fname, '.'); - if (!dot || strlen(dot) != 4 - || tolower(dot[1]) != 'e' - || tolower(dot[2]) != 'x' - || tolower(dot[3]) != 'e') - { - fprintf(stderr, "%s: Arguments MUST end with a .exe extension\n", fname); - return; - } - - ifile = fopen(fname, "rb"); - if (!ifile) - { - perror(fname); - return; - } - fread(header, sizeof(header), 1, ifile); - if (header[0] == 0x5a4d) - { - long header_offset = (long)header[2]*512L; - if (header[1]) - header_offset += (long)header[1] - 512L; - fseek(ifile, header_offset, SEEK_SET); - header[0] = 0; - fread(header, sizeof(header), 1, ifile); - if ((header[0] != 0x010b) && (header[0] != 0x014c)) - { - fprintf(stderr, "`%s' does not have a COFF/AOUT program appended to it\n", fname); - return; - } - fseek(ifile, header_offset, SEEK_SET); - } - else - { - fprintf(stderr, "`%s' is not an .EXE file\n", fname); - return; - } - - *dot = 0; - ofile = fopen(fname, "w+b"); - if (!ofile) - { - perror(fname); - return; - } - - while ((rbytes=fread(buf, 1, 4096, ifile)) > 0) - { - int wb = fwrite(buf, 1, rbytes, ofile); - if (wb < 0) - { - perror(fname); - break; - } - if (wb < rbytes) - { - fprintf(stderr, "`%s': disk full\n", fname); - exit(1); - } - } - fclose(ifile); - fclose(ofile); -} - -int -main(int argc, char **argv) -{ - int i; - if (argc == 1) printf("Usage: %s <exename>", argv[0]); - for (i=1; i<argc; i++) - exe2aout(argv[i]); - return 0; -} - |