changeset 297:c52ad3135bd3

implement reading files
author lost
date Sun, 18 Jan 2009 04:53:57 +0000
parents 14d835cf02d9
children 96a35a4245f3
files src/Makefile.am src/lwlink.c src/lwlink.h src/main.c
diffstat 4 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.am	Sat Jan 17 20:54:58 2009 +0000
+++ b/src/Makefile.am	Sun Jan 18 04:53:57 2009 +0000
@@ -1,3 +1,3 @@
 bin_PROGRAMS = lwlink
-lwlink_SOURCES = main.c lwlink.c util.c
+lwlink_SOURCES = main.c lwlink.c util.c readfiles.c
 EXTRA_DIST = lwlink.h util.h
--- a/src/lwlink.c	Sat Jan 17 20:54:58 2009 +0000
+++ b/src/lwlink.c	Sun Jan 18 04:53:57 2009 +0000
@@ -39,12 +39,13 @@
 int outformat = OUTPUT_DECB;
 char *outfile = NULL;
 
-char **inputfiles = NULL;
+fileinfo_t **inputfiles = NULL;
 int ninputfiles = 0;
 
 void add_input_file(char *fn)
 {
-	inputfiles = lw_realloc(inputfiles, sizeof(char *) * (ninputfiles + 1));
-	inputfiles[ninputfiles++] = lw_strdup(fn);
+	inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1));
+	inputfiles[ninputfiles] = lw_malloc(sizeof(fileinfo_t));
+	inputfiles[ninputfiles++] -> filename = lw_strdup(fn);
 }
 
--- a/src/lwlink.h	Sat Jan 17 20:54:58 2009 +0000
+++ b/src/lwlink.h	Sun Jan 18 04:53:57 2009 +0000
@@ -27,13 +27,21 @@
 #define OUTPUT_DECB		0	// DECB multirecord format
 #define OUTPUT_RAW		1	// raw sequence of bytes
 
+
+typedef struct
+{
+	char *filename;
+	unsigned char *filedata;
+	long filesize;
+} fileinfo_t;
+
 #ifndef __lwlink_c_seen__
 
 extern int debug_level;
 extern int outformat;
 extern char *outfile;
 extern int ninputfiles;
-extern char **inputfiles;
+extern fileinfo_t **inputfiles;
 
 #define __lwlink_E__ extern
 #else
--- a/src/main.c	Sat Jan 17 20:54:58 2009 +0000
+++ b/src/main.c	Sun Jan 18 04:53:57 2009 +0000
@@ -112,6 +112,8 @@
 	"LWLINK, a HD6309 and MC6809 cross-linker"
 };
 
+extern void read_files(void);
+
 // main function; parse command line, set up assembler state, and run the
 // assembler on the first file
 int main(int argc, char **argv)
@@ -122,6 +124,9 @@
 		fprintf(stderr, "No input files\n");
 		exit(1);
 	}
+
+	// read the input files
+	read_files();
 	
 	exit(0);
 }