summaryrefslogtreecommitdiff
path: root/int2tap.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2004-08-21 01:15:19 +0000
committerIan C <ianc@noddybox.co.uk>2004-08-21 01:15:19 +0000
commit1c7d0b339d578511be239c175ef2096e6e8aa6e2 (patch)
treee85266d073f05229f579ed84ad7e33f7da86ddfa /int2tap.c
parent666bf8d5ef44953391f4cf08c51175aff3d4dc60 (diff)
Added new files
Diffstat (limited to 'int2tap.c')
-rw-r--r--int2tap.c132
1 files changed, 127 insertions, 5 deletions
diff --git a/int2tap.c b/int2tap.c
index 68902a2..b2fba26 100644
--- a/int2tap.c
+++ b/int2tap.c
@@ -20,6 +20,8 @@
-------------------------------------------------------------------------
+ $Name$
+
*/
static const char id[]="$Id$";
@@ -30,8 +32,11 @@ static const char id[]="$Id$";
#include <time.h>
#include <errno.h>
+#include "intel.h"
+#include "tap.h"
+
-/* ---------------------------------------- MACROS
+/* ---------------------------------------- GLOBALS
*/
#undef TRUE
#undef FALSE
@@ -39,19 +44,136 @@ static const char id[]="$Id$";
#define TRUE 1
#define FALSE 0
-
-/* ---------------------------------------- TYPES
-*/
+const char *progname;
-/* ---------------------------------------- PROTOS
+/* ---------------------------------------- PRIVATE UTILS
*/
+static void Usage(void)
+{
+ fprintf(stderr,"%s: usage %s [ -b ] [ -s ] [ -a address ] "
+ "output-file input-file ... \n",progname,progname);
+}
/* ---------------------------------------- MAIN
*/
int main(int argc, char *argv[])
{
+ unsigned char mem[0x10000];
+ IntelInfo *info;
+ char *outname;
+ unsigned exec_addr;
+ int bin_only;
+ int split;
+ int addr_defined;
+ int base;
+ int no;
+ int f;
+ int done;
+
+ /* Set program name
+ */
+ if ((progname=strrchr(argv[0],'/')))
+ {
+ progname++;
+ }
+ else
+ {
+ progname=argv[0];
+ }
+
+ /* Set defaults and parse args
+ */
+ addr_defined=FALSE;
+ bin_only=FALSE;
+ split=FALSE;
+
+ done=FALSE;
+ f=1;
+
+ while(f<argc && !done)
+ {
+ if (argv[f][0]!='-')
+ {
+ base=f;
+ done=TRUE;
+ }
+ else
+ {
+ switch(argv[f][1])
+ {
+ case 'b':
+ bin_only=TRUE;
+ break;
+
+ case 's':
+ split=TRUE;
+ break;
+
+ case 'a':
+ if (f>argc-2)
+ {
+ Usage();
+ }
+
+ addr_defined=TRUE;
+
+ exec_addr=(unsigned)strtoul(argv[++f],NULL,0);
+
+ break;
+
+ default:
+ Usage();
+ break;
+ }
+
+ f++;
+ }
+ }
+
+ if (base>=argc-1)
+ {
+ Usage();
+ }
+
+ outname=argv[base++];
+
+ no=argc-base;
+
+ if (!(info=malloc(sizeof *info * no)))
+ {
+ fprintf(stderr,"%s: malloc failed\n",progname);
+ }
+
+ /* Process Intel files
+ */
+ for(f=0;f<no;f++)
+ {
+ if (!IntelLoad(argv[base+f],mem,info+f))
+ {
+ free(info);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("Memory altered from 0x%4.4x for 0x%4.4x bytes, base 0x%4.4x\n",
+ info[f].low,info[f].len,info[f].addr);
+ }
+
+ /* TODO: Properly - just a quick test
+ */
+ printf("Creating %s\n",outname);
+
+ if (!TapOpen(outname))
+ {
+ free(info);
+ exit(EXIT_FAILURE);
+ }
+
+ TapWrite(mem,info[0].low,info[0].len,TRUE);
+
+ TapClose();
+
return EXIT_SUCCESS;
}