diff --git a/CHANGES b/CHANGES index 29c1503a..5903bec7 100644 --- a/CHANGES +++ b/CHANGES @@ -22,3 +22,15 @@ RELEASE 0.0.6 + Create tokenize_asoft RELEASE 0.0.7 + +18 August 2009 ++ Fix warnings on recent gcc. ++ Audit much of the extisting dos33 code. + +19 August 2009 ++ Add integer basic detokenizer ++ Implement lock/unlock in dos33 ++ Implement undelete in dos33 ++ Implement rename in dos33 + +RELEASE 0.0.8 diff --git a/Makefile b/Makefile index 80fe49a6..245752a9 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,59 @@ CC = gcc -C_FLAGS = -O2 -Wall -L_FLAGS = +CFLAGS = -O2 -Wall +LFLAGS = -all: dos33 asoft_detoken mkdos33fs make_b tokenize_asoft +all: dos33 asoft_detoken mkdos33fs make_b tokenize_asoft \ + dos33_text2ascii integer_detoken asoft_detoken: asoft_detoken.o - $(CC) $(L_FLAGS) -o asoft_detoken asoft_detoken.o + $(CC) $(LFLAGS) -o asoft_detoken asoft_detoken.o asoft_detoken.o: asoft_detoken.c - $(CC) $(C_FLAGS) -c asoft_detoken.c + $(CC) $(CFLAGS) -c asoft_detoken.c + +integer_detoken: integer_detoken.o + $(CC) $(LFLAGS) -o integer_detoken integer_detoken.o + +integer_detoken.o: integer_detoken.c + $(CC) $(CFLAGS) -c integer_detoken.c tokenize_asoft: tokenize_asoft.o - $(CC) $(L_FLAGS) -o tokenize_asoft tokenize_asoft.o + $(CC) $(LFLAGS) -o tokenize_asoft tokenize_asoft.o tokenize_asoft.o: tokenize_asoft.c - $(CC) $(C_FLAGS) -c tokenize_asoft.c + $(CC) $(CFLAGS) -c tokenize_asoft.c dos33: dos33.o - $(CC) $(L_FLAGS) -o dos33 dos33.o + $(CC) $(LFLAGS) -o dos33 dos33.o dos33.o: dos33.c dos33.h - $(CC) $(C_FLAGS) -c dos33.c - + $(CC) $(CFLAGS) -c dos33.c + +dos33_text2ascii: dos33_text2ascii.o + $(CC) $(LFLGAS) -o dos33_text2ascii dos33_text2ascii.o + +dos33_text2ascii.o: dos33_text2ascii.c + $(CC) $(CFLAGS) -c dos33_text2ascii.c + make_b: make_b.o - $(CC) $(L_FLAGS) -o make_b make_b.o + $(CC) $(LFLAGS) -o make_b make_b.o make_b.o: make_b.c - $(CC) $(C_FLAGS) -c make_b.c + $(CC) $(CFLAGS) -c make_b.c mkdos33fs: mkdos33fs.o - $(CC) $(L_FLAGS) -o mkdos33fs mkdos33fs.o + $(CC) $(LFLAGS) -o mkdos33fs mkdos33fs.o mkdos33fs.o: mkdos33fs.c dos33.h - $(CC) $(C_FLAGS) -c mkdos33fs.c + $(CC) $(CFLAGS) -c mkdos33fs.c install: - cp dos33 asoft_detoken mkdos33fs tokenize_asoft make_b /usr/local/bin + cp dos33 asoft_detoken mkdos33fs tokenize_asoft make_b dos33_text2ascii.c integer_detoken /usr/local/bin clean: - rm -f *~ *.o asoft_detoken dos33 make_b mkdos33fs tokenize_asoft + rm -f *~ *.o asoft_detoken dos33 make_b mkdos33fs tokenize_asoft dos33_text2ascii integer_detoken + cd tests && make clean diff --git a/TODO b/TODO index d67ba3b6..d44a83c4 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,21 @@ -check lock before delete ++ Validate that apple filenames are valid in all cases + +FUSE driver ++ How to map permissions to file types? LOCK=w + ++ How to handle file sizes? + No special cases, just always multiples of 256? + Only truncate if in window? + + Enforce in writing "b" type that the fields are correct. + Generic Linux writes are of type "S". + Figure out how to represent in Linux the file types? + defrag utility test-suite test mkdosfs copy over DOS functionality find out why dos33 SAVE puts extra linefeed at end of basic prog? +(turns out that's normal. it is ignored) diff --git a/asoft_detoken.c b/asoft_detoken.c index 3509e4e4..95194a49 100644 --- a/asoft_detoken.c +++ b/asoft_detoken.c @@ -1,5 +1,6 @@ #include #include /* strlen() */ +#include "version.h" /* Starting at 0x80 */ char applesoft_tokens[][8]={ diff --git a/dos33.c b/dos33.c index 259863d5..2cb68913 100644 --- a/dos33.c +++ b/dos33.c @@ -6,11 +6,13 @@ #include /* lseek() */ #include /* toupper() */ -#define VERSION "0.4" +#include "version.h" #include "dos33.h" -int ones_lookup[16]={ +static unsigned char sector_buffer[BYTES_PER_SECTOR]; + +static int ones_lookup[16]={ /* 0x0 = 0000 */ 0, /* 0x1 = 0001 */ 1, /* 0x2 = 0010 */ 1, @@ -29,7 +31,10 @@ int ones_lookup[16]={ /* 0xf = 1111 */ 4, }; -unsigned char dos33_file_type(int value) { +#define FILE_NORMAL 0 +#define FILE_DELETED 1 + +static unsigned char dos33_file_type(int value) { unsigned char result; @@ -48,7 +53,7 @@ unsigned char dos33_file_type(int value) { } -unsigned char dos33_char_to_type(char type,int lock) { +static unsigned char dos33_char_to_type(char type,int lock) { unsigned char result,temp_type; @@ -73,11 +78,11 @@ unsigned char dos33_char_to_type(char type,int lock) { /* dos33 filenames have top bit set on ascii chars */ /* and are padded with spaces */ -char *dos33_filename_to_ascii(unsigned char *dest,unsigned char *src) { - +static char *dos33_filename_to_ascii(char *dest,unsigned char *src,int len) { + int i=0,last_nonspace=0; - for(i=0;i<30;i++) if (src[i]!=0xA0) last_nonspace=i; + for(i=0;i>4)&0xf]; sectors_free+=ones_lookup[bitmap[1]&0xf]; sectors_free+=ones_lookup[(bitmap[1]>>4)&0xf]; - -// printf("%i: 0x%x 0x%x\n",i,bitmap[0],bitmap[1]); - - + } return sectors_free*BYTES_PER_SECTOR; } - -int dos33_get_catalog_ts(int fd,unsigned char *buffer) { - dos33_read_vtoc(fd,buffer); + /* Get a T/S value from a Catalog Sector */ +static int dos33_get_catalog_ts(int fd) { + dos33_read_vtoc(fd); - return TS_TO_INT(buffer[VTOC_CATALOG_T],buffer[VTOC_CATALOG_S]); + return TS_TO_INT(sector_buffer[VTOC_CATALOG_T], + sector_buffer[VTOC_CATALOG_S]); } -int dos33_find_next_file(int fd,int catalog_tsf,unsigned char *buffer) { + /* returns the next valid catalog entry */ + /* after the one passed in */ +static int dos33_find_next_file(int fd,int catalog_tsf) { int catalog_track,catalog_sector,catalog_file; @@ -144,12 +150,12 @@ catalog_loop: /* Read in Catalog Sector */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); i=catalog_file; while(i<7) { - file_track=buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]; + file_track=sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]; /* 0xff means file deleted */ /* 0x0 means empty */ if ((file_track!=0xff) && (file_track!=0x0)){ @@ -157,8 +163,8 @@ catalog_loop: } i++; } - catalog_track=buffer[CATALOG_NEXT_T]; - catalog_sector=buffer[CATALOG_NEXT_S]; + catalog_track=sector_buffer[CATALOG_NEXT_T]; + catalog_sector=sector_buffer[CATALOG_NEXT_S]; if (catalog_sector!=0) { catalog_file=0; goto catalog_loop; @@ -167,7 +173,7 @@ catalog_loop: return -1; } -int dos33_print_file_info(int fd,int catalog_tsf,unsigned char *buffer) { +static int dos33_print_file_info(int fd,int catalog_tsf) { int catalog_track,catalog_sector,catalog_file,i; char temp_string[BUFSIZ]; @@ -179,73 +185,97 @@ int dos33_print_file_info(int fd,int catalog_tsf,unsigned char *buffer) { /* Read in Catalog Sector */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); - if (buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f) { + if (sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f) { printf("*"); } else printf(" "); - printf("%c",dos33_file_type(buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TYPE])); + printf("%c",dos33_file_type(sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TYPE])); printf(" "); - printf("%.3i ",buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+ - (buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8)); + printf("%.3i ",sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+ + (sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8)); - strncpy(temp_string,dos33_filename_to_ascii(temp_string, - buffer+(CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE+FILE_NAME))),BUFSIZ); + strncpy(temp_string, + dos33_filename_to_ascii(temp_string,sector_buffer+(CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE+FILE_NAME)),30), + BUFSIZ); for(i=0;iVTOC_TRACK) && (track_dir!=1)) || - ((start_track-1;byte--) { - bitmap[byte]=buffer[VTOC_FREE_BITMAPS+(i*4)+byte]; + bitmap[byte]=sector_buffer[VTOC_FREE_BITMAPS+(i*4)+byte]; if (bitmap[byte]!=0x00) { found_sector=find_first_one(bitmap[byte]); found_track=i; /* clear bit indicating in use */ - buffer[VTOC_FREE_BITMAPS+(i*4)+byte]&=~(0x1<VTOC_TRACK) buffer[VTOC_ALLOC_DIRECT]=1; - else buffer[VTOC_ALLOC_DIRECT]=-1; + if (found_track>VTOC_TRACK) sector_buffer[VTOC_ALLOC_DIRECT]=1; + else sector_buffer[VTOC_ALLOC_DIRECT]=-1; /* Seek to VTOC */ lseek(fd,DISK_OFFSET(VTOC_TRACK,VTOC_SECTOR),SEEK_SET); /* Write out VTOC */ - write(fd,&buffer,BYTES_PER_SECTOR); + write(fd,§or_buffer,BYTES_PER_SECTOR); return ((found_track<<8)+found_sector); } -int dos33_add_file(int fd,char type,char *filename,char *apple_filename, - unsigned char *buffer) { + /* creates file apple_filename on the image from local file filename */ + /* returns ?? */ +static int dos33_add_file(int fd,char type,char *filename, + char *apple_filename) { - int free_space,file_size; - struct stat file_info; + int free_space,file_size,needed_sectors; + struct stat file_info; int size_in_sectors=0; int initial_ts_list=0,ts_list=0,i,data_ts,x,bytes_read=0,old_ts_list; int catalog_track,catalog_sector,sectors_used=0; int input_fd; + if (apple_filename[0]<64) { + fprintf(stderr,"Error! First char of filename must be ASCII 64 or above!\n"); + exit(3); + } + { + int i; + + for(i=0;ifree_space) { - printf("Error! Not enough free space on disk image\n"); + if (needed_sectors*BYTES_PER_SECTOR>free_space) { + fprintf(stderr,"Error! Not enough free space on disk image (need %d have %d)\n", + needed_sectors*BYTES_PER_SECTOR,free_space); + exit(4); } /* plus one because we need a sector for the tail */ - size_in_sectors=(file_size/BYTES_PER_SECTOR)+1; - printf("Need to allocate %i data sectors\n",size_in_sectors); + size_in_sectors=(file_size/BYTES_PER_SECTOR)+ + ((file_size%BYTES_PER_SECTOR)!=0); +// printf("Need to allocate %i data sectors\n",size_in_sectors); +// printf("Need to allocate %i total sectors\n",needed_sectors); /* Open the local file */ input_fd=open(filename,O_RDONLY); if (input_fd<0) { - printf("Error! could not open %s\n",filename); + fprintf(stderr,"Error! could not open %s\n",filename); return -1; } - - i=0; while (i>8)&0xff,ts_list&0xff),SEEK_SET); - write(fd,buffer,BYTES_PER_SECTOR); + write(fd,sector_buffer,BYTES_PER_SECTOR); if (i==0) initial_ts_list=ts_list; else { @@ -430,19 +486,19 @@ int dos33_add_file(int fd,char type,char *filename,char *apple_filename, /* load in the old t/s list */ lseek(fd,DISK_OFFSET((old_ts_list>>8)&0xff,old_ts_list&0xff),SEEK_SET); - read(fd,&buffer,BYTES_PER_SECTOR); + read(fd,§or_buffer,BYTES_PER_SECTOR); /* point from old ts list to new one we just made */ - buffer[TSL_NEXT_TRACK]=(ts_list>>8)&0xff; - buffer[TSL_NEXT_SECTOR]=(ts_list)&0xff; + sector_buffer[TSL_NEXT_TRACK]=(ts_list>>8)&0xff; + sector_buffer[TSL_NEXT_SECTOR]=(ts_list)&0xff; /* set offset into file */ - buffer[TSL_OFFSET_H]=(((i-122)*256)>>8)&0xff; - buffer[TSL_OFFSET_L]=(((i-122)*256)&0xff); + sector_buffer[TSL_OFFSET_H]=(((i-122)*256)>>8)&0xff; + sector_buffer[TSL_OFFSET_L]=(((i-122)*256)&0xff); /* write out the old t/s list with updated info */ lseek(fd,DISK_OFFSET((old_ts_list>>8)&0xff,old_ts_list&0xff),SEEK_SET); - write(fd,buffer,BYTES_PER_SECTOR); + write(fd,sector_buffer,BYTES_PER_SECTOR); } } @@ -454,14 +510,14 @@ int dos33_add_file(int fd,char type,char *filename,char *apple_filename, if (data_ts<0) return -1; /* clear sector */ - for(x=0;x>8)&0xff,data_ts&0xff),SEEK_SET); - write(fd,buffer,BYTES_PER_SECTOR); + write(fd,sector_buffer,BYTES_PER_SECTOR); // printf("Writing %i bytes to %i/%i\n",bytes_read,(data_ts>>8)&0xff, // data_ts&0xff); @@ -471,15 +527,15 @@ int dos33_add_file(int fd,char type,char *filename,char *apple_filename, /* read in t/s list */ lseek(fd,DISK_OFFSET((ts_list>>8)&0xff,ts_list&0xff),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); /* point to new data sector */ - buffer[((i%TSL_MAX_NUMBER)*2)+TSL_LIST]=(data_ts>>8)&0xff; - buffer[((i%TSL_MAX_NUMBER)*2)+TSL_LIST+1]=(data_ts&0xff); + sector_buffer[((i%TSL_MAX_NUMBER)*2)+TSL_LIST]=(data_ts>>8)&0xff; + sector_buffer[((i%TSL_MAX_NUMBER)*2)+TSL_LIST+1]=(data_ts&0xff); /* write t/s list back out */ lseek(fd,DISK_OFFSET((ts_list>>8)&0xff,ts_list&0xff),SEEK_SET); - write(fd,buffer,BYTES_PER_SECTOR); + write(fd,sector_buffer,BYTES_PER_SECTOR); i++; } @@ -487,22 +543,22 @@ int dos33_add_file(int fd,char type,char *filename,char *apple_filename, /* Add new file to Catalog */ /* read in vtoc */ - dos33_read_vtoc(fd,buffer); + dos33_read_vtoc(fd); - catalog_track=buffer[VTOC_CATALOG_T]; - catalog_sector=buffer[VTOC_CATALOG_S]; + catalog_track=sector_buffer[VTOC_CATALOG_T]; + catalog_sector=sector_buffer[VTOC_CATALOG_S]; continue_parsing_catalog: /* Read in Catalog Sector */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); /* Find empty directory entry */ i=0; while(i<7) { - if ((buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]==0xff) || - (buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]==0x00)) + if ((sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]==0xff) || + (sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]==0x00)) goto got_a_dentry; i++; } @@ -511,12 +567,12 @@ continue_parsing_catalog: /* in theory can only have 105 files */ /* if full, we have no recourse! */ /* can we allocate new catalog sectors and point to them?? */ - printf("Error! No more room for files!\n"); + fprintf(stderr,"Error! No more room for files!\n"); return -1; } - catalog_track=buffer[CATALOG_NEXT_T]; - catalog_sector=buffer[CATALOG_NEXT_S]; + catalog_track=sector_buffer[CATALOG_NEXT_T]; + catalog_sector=sector_buffer[CATALOG_NEXT_S]; goto continue_parsing_catalog; @@ -525,37 +581,38 @@ got_a_dentry: // i,catalog_track,catalog_sector); /* Point entry to initial t/s list */ - buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]=(initial_ts_list>>8)&0xff; - buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)+1]=(initial_ts_list&0xff); + sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)]=(initial_ts_list>>8)&0xff; + sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)+1]=(initial_ts_list&0xff); /* set file type */ - buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)+FILE_TYPE]= + sector_buffer[CATALOG_FILE_LIST+(i*CATALOG_ENTRY_SIZE)+FILE_TYPE]= dos33_char_to_type(type,0); // printf("Pointing T/S to %x/%x\n",(initial_ts_list>>8)&0xff,initial_ts_list&0xff); /* copy over filename */ for(x=0;x>8)&0xff; /* write out catalog sector */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - write(fd,buffer,BYTES_PER_SECTOR); + write(fd,sector_buffer,BYTES_PER_SECTOR); return 0; } -int dos33_load_file(int fd,int fts,char *filename,unsigned char *buffer) { + /* load a file. fts=entry/track/sector */ +static int dos33_load_file(int fd,int fts,char *filename) { int output_fd; int catalog_file,catalog_track,catalog_sector; @@ -563,9 +620,10 @@ int dos33_load_file(int fd,int fts,char *filename,unsigned char *buffer) { unsigned char data_sector[BYTES_PER_SECTOR]; int tsl_pointer=0,output_pointer=0; - output_fd=open(filename,O_WRONLY|O_CREAT,0666); + /* Fix me! Warn if overwriting file! */ + output_fd=open(filename,O_WRONLY|O_CREAT|O_TRUNC,0666); if (output_fd<0) { - printf("Error! could not open %s for local save\n",filename); + fprintf(stderr,"Error! could not open %s for local save\n",filename); return -1; } @@ -576,34 +634,41 @@ int dos33_load_file(int fd,int fts,char *filename,unsigned char *buffer) { /* Read in Catalog Sector */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); - tsl_track=buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TS_LIST_T]; - tsl_sector=buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TS_LIST_S]; - file_type=dos33_file_type(buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+FILE_TYPE]); + tsl_track=sector_buffer[CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE)+FILE_TS_LIST_T]; + tsl_sector=sector_buffer[CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE)+FILE_TS_LIST_S]; + file_type=dos33_file_type(sector_buffer[CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE) + +FILE_TYPE]); - printf("file_type: %c\n",file_type); +// printf("file_type: %c\n",file_type); -keep_savin: +keep_saving: /* Read in TSL Sector */ lseek(fd,DISK_OFFSET(tsl_track,tsl_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); - + read(fd,sector_buffer,BYTES_PER_SECTOR); + tsl_pointer=0; + /* check each track/sector pair in the list */ while(tsl_pointer=0) { +// printf("Truncating file size to %d\n",file_size); ftruncate(output_fd,file_size); } @@ -641,12 +711,120 @@ keep_savin: } + /* lock a file. fts=entry/track/sector */ +static int dos33_lock_file(int fd,int fts,int lock) { + + int catalog_file,catalog_track,catalog_sector; + int file_type; + + catalog_file=fts>>16; + catalog_track=(fts>>8)&0xff; + catalog_sector=(fts&0xff); -int dos33_delete_file(int fd,int fsl,unsigned char *buffer) { + + /* Read in Catalog Sector */ + lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); + read(fd,sector_buffer,BYTES_PER_SECTOR); + + file_type=sector_buffer[CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE) + +FILE_TYPE]; + + if (lock) file_type|=0x80; + else file_type&=0x7f; + + sector_buffer[CATALOG_FILE_LIST+ + (catalog_file*CATALOG_ENTRY_SIZE) + +FILE_TYPE]=file_type; + + /* write back modified catalog sector */ + lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); + write(fd,sector_buffer,BYTES_PER_SECTOR); + + return 0; + +} + + /* rename a file. fts=entry/track/sector */ + /* FIXME: can we rename a locked file? */ + /* FIXME: validate the new filename is valid */ +static int dos33_rename_file(int fd,int fts,char *new_name) { + + int catalog_file,catalog_track,catalog_sector; + int x; + + catalog_file=fts>>16; + catalog_track=(fts>>8)&0xff; + catalog_sector=(fts&0xff); + + /* Read in Catalog Sector */ + lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); + read(fd,sector_buffer,BYTES_PER_SECTOR); + + /* copy over filename */ + for(x=0;x>16; + catalog_track=(fts>>8)&0xff; + catalog_sector=(fts&0xff); + + /* Read in Catalog Sector */ + lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); + read(fd,sector_buffer,BYTES_PER_SECTOR); + + /* get the stored track value, and put it back */ + /* FIXME: should walk file to see if T/s valild */ + /* by setting the track value to FF which indicates deleted file */ + sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)]= + sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+ + FILE_NAME+29]; + + /* restore file name if possible */ + + replacement_char=0xa0; + if (strlen(new_name)>29) replacement_char=new_name[29]^0x80; + + sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+ + FILE_NAME+29]=replacement_char; + + /* write back modified catalog sector */ + lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); + write(fd,sector_buffer,BYTES_PER_SECTOR); + + return 0; + +} + + +static int dos33_delete_file(int fd,int fsl) { int i; int catalog_track,catalog_sector,catalog_entry; int ts_track,ts_sector; + char file_type; /* unpack file/track/sector info */ catalog_entry=fsl>>16; @@ -655,12 +833,21 @@ int dos33_delete_file(int fd,int fsl,unsigned char *buffer) { /* Load in the catalog table for the file */ lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); + + file_type=sector_buffer[CATALOG_FILE_LIST+ + (catalog_entry*CATALOG_ENTRY_SIZE) + +FILE_TYPE]; + if (file_type&0x80) { + fprintf(stderr,"File is locked! Unlock before deleting!\n"); + exit(1); + } + /* get pointer to t/s list */ - ts_track=buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+ + ts_track=sector_buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+ FILE_TS_LIST_T]; - ts_sector=buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+ + ts_sector=sector_buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+ FILE_TS_LIST_S]; keep_deleting: @@ -669,15 +856,15 @@ keep_deleting: /* load in the t/s list info */ lseek(fd,DISK_OFFSET(ts_track,ts_sector),SEEK_SET); - read(fd,buffer,BYTES_PER_SECTOR); + read(fd,sector_buffer,BYTES_PER_SECTOR); /* Free each sector listed by t/s list */ for(i=0;i0x7f? + sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f? "YES":"NO"); printf("\tType = %c\n", - dos33_file_type(buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE])); + dos33_file_type(sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE])); printf("\tSize in sectors = %i\n", - buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+ - (buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8)); + sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+ + (sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8)); repeat_tsl: printf("\tT/S List $%02X/$%02X:\n",ts_t,ts_s); if (deleted) goto continue_dump; @@ -846,19 +1033,14 @@ repeat_tsl: continue_dump:; } - catalog_t=buffer[CATALOG_NEXT_T]; - catalog_s=buffer[CATALOG_NEXT_S]; + catalog_t=sector_buffer[CATALOG_NEXT_T]; + catalog_s=sector_buffer[CATALOG_NEXT_S]; if (catalog_s!=0) { file=0; goto repeat_catalog; } - - - - - - + printf("\n"); @@ -868,14 +1050,25 @@ continue_dump:; int display_help(char *name) { - printf("\n%s version %s\n",name,VERSION); + printf("\ndos33 version %s\n",VERSION); printf("by Vince Weaver \n"); printf("\n"); printf("Usage: %s disk_image COMMAND\n",name); printf(" Where disk_image is a valid dos3.3 disk image\n" " and COMMAND is one of the following:\n"); printf("\tCATALOG\n"); - printf("\tLOAD apple_file \n"); + printf("\tLOAD apple_file \n"); + printf("\tSAVE type loadl_file \n"); + printf("\tDELETE apple_file\n"); + printf("\tLOCK apple_file\n"); + printf("\tUNLOCK apple_file\n"); + printf("\tRENAME apple_file_old apple_file_new\n"); + printf("\tUNDELETE apple_file\n"); + printf("\tDUMP\n"); +#if 0 + printf("\tINIT\n"); + printf("\tCOPY\n"); +#endif printf("\n"); return 0; } @@ -883,20 +1076,15 @@ int display_help(char *name) { #define COMMAND_UNKNOWN 0 #define COMMAND_LOAD 1 #define COMMAND_SAVE 2 -#define COMMAND_BLOAD 3 -#define COMMAND_BSAVE 4 -#define COMMAND_CATALOG 5 -#define COMMAND_DELETE 6 -#define COMMAND_UNDELETE 7 -#define COMMAND_LOCK 8 -#define COMMAND_UNLOCK 9 -#define COMMAND_INIT 10 -#define COMMAND_UPLOAD 11 -#define COMMAND_DNLOAD 12 -#define COMMAND_VERIFY 13 -#define COMMAND_RENAME 14 -#define COMMAND_COPY 15 -#define COMMAND_DUMP 16 +#define COMMAND_CATALOG 3 +#define COMMAND_DELETE 4 +#define COMMAND_UNDELETE 5 +#define COMMAND_LOCK 6 +#define COMMAND_UNLOCK 7 +#define COMMAND_INIT 8 +#define COMMAND_RENAME 9 +#define COMMAND_COPY 10 +#define COMMAND_DUMP 11 int main(int argc, char **argv) { @@ -904,21 +1092,26 @@ int main(int argc, char **argv) { unsigned char type='b'; int dos_fd=0,i; - int command,catalog; + int command,catalog_entry; char temp_string[BUFSIZ]; - char apple_filename[31]; + char apple_filename[31],new_filename[31]; char output_filename[BUFSIZ]; - unsigned char scratch_sector[BYTES_PER_SECTOR]; - + + + /* Check command line arguments */ if (argc<3) { printf("\nInvalid arguments!\n"); display_help(argv[0]); goto exit_program; } + /* Check argument #2 which is command */ strncpy(temp_string,argv[2],BUFSIZ); - for(i=0;i30) { printf("Warning! Truncating %s to 30 chars\n",argv[3]); } strncpy(apple_filename,argv[3],30); - apple_filename[31]='\0'; + apple_filename[30]='\0'; + /* get output filename */ if (argc==5) { strncpy(output_filename,argv[4],BUFSIZ); } @@ -1001,27 +1183,31 @@ int main(int argc, char **argv) { strncpy(output_filename,apple_filename,30); } - catalog=dos33_check_file_exists(dos_fd,apple_filename,scratch_sector); - if (catalog<0) { + /* get the entry/track/sector for file */ + catalog_entry=dos33_check_file_exists(dos_fd, + apple_filename, + FILE_NORMAL); + if (catalog_entry<0) { printf("Error! %s not found!\n",apple_filename); goto exit_and_close; } - dos33_load_file(dos_fd,catalog,output_filename,scratch_sector); + dos33_load_file(dos_fd,catalog_entry,output_filename); - break; + case COMMAND_CATALOG: /* get first catalog */ - catalog=dos33_get_catalog_ts(dos_fd,scratch_sector); + catalog_entry=dos33_get_catalog_ts(dos_fd); - printf("\nDISK VOLUME %i\n\n",scratch_sector[VTOC_DISK_VOLUME]); - while(catalog>0) { - catalog=dos33_find_next_file(dos_fd,catalog,scratch_sector); - if (catalog>0) { - dos33_print_file_info(dos_fd,catalog,scratch_sector); - catalog+=(1<<16); + printf("\nDISK VOLUME %i\n\n",sector_buffer[VTOC_DISK_VOLUME]); + while(catalog_entry>0) { + catalog_entry=dos33_find_next_file(dos_fd,catalog_entry); + if (catalog_entry>0) { + dos33_print_file_info(dos_fd,catalog_entry); + catalog_entry+=(1<<16); + /* dos33_find_next_file() handles wrapping issues */ } } printf("\n"); @@ -1029,13 +1215,14 @@ int main(int argc, char **argv) { case COMMAND_SAVE: - /* argv3 == type == A,B,T,I, N,L etc */ + /* argv3 == type == A,B,T,I,N,L etc */ /* argv4 == name of local file */ /* argv5 == optional name of file on disk image */ if (argc<5) { printf("Error! Need type and file_name\n"); - printf("%s %s SAVE type file_name apple_filename\n",argv[0],image); + printf("%s %s SAVE type file_name apple_filename\n", + argv[0],image); goto exit_and_close; } @@ -1046,18 +1233,38 @@ int main(int argc, char **argv) { printf("Warning! Truncating filename to 30 chars!\n"); } strncpy(apple_filename,argv[5],30); - apple_filename[31]=0; + apple_filename[30]=0; } else { - if (strlen(argv[4])>30) { - printf("Warning! Truncating filename to 30 chars!\n"); - } - strncpy(apple_filename,argv[4],30); - apple_filename[31]=0; + /* If no filename specified for apple name */ + /* Then use the input name. Note, we strip */ + /* everything up to the last slash so useless */ + /* path info isn't used */ + { + char *temp; + temp=argv[4]+(strlen(argv[4])-1); + + while(temp!=argv[4]) { + temp--; + if (*temp == '/') { + temp++; + break; + } + } + + if (strlen(temp)>30) { + printf("Warning! Truncating filename to 30 chars!\n"); + } + + strncpy(apple_filename,temp,30); + apple_filename[30]=0; + } } - catalog=dos33_check_file_exists(dos_fd,apple_filename,scratch_sector); - if (catalog>=0) { + catalog_entry=dos33_check_file_exists(dos_fd,apple_filename, + FILE_NORMAL); + + if (catalog_entry>=0) { printf("Warning! %s exists!\n",apple_filename); printf("Over-write (y/n)?"); fgets(temp_string,BUFSIZ,stdin); @@ -1066,14 +1273,12 @@ int main(int argc, char **argv) { goto exit_and_close; } printf("Deleting previous version...\n"); - dos33_delete_file(dos_fd,catalog,scratch_sector); + dos33_delete_file(dos_fd,catalog_entry); } - dos33_add_file(dos_fd,type,argv[4],apple_filename,scratch_sector); - - + dos33_add_file(dos_fd,type,argv[4],apple_filename); + break; - case COMMAND_BSAVE: case COMMAND_DELETE: if (argc<4) { @@ -1081,27 +1286,117 @@ int main(int argc, char **argv) { printf("%s %s DELETE apple_filename\n",argv[0],image); goto exit_and_close; } - catalog=dos33_check_file_exists(dos_fd,argv[3],scratch_sector); - if (catalog<0) { + catalog_entry=dos33_check_file_exists(dos_fd,argv[3],FILE_NORMAL); + if (catalog_entry<0) { printf("Error! File %s does not exist\n",argv[3]); goto exit_and_close; } - dos33_delete_file(dos_fd,catalog,scratch_sector); + dos33_delete_file(dos_fd,catalog_entry); break; - - case COMMAND_UNDELETE: - case COMMAND_LOCK: - case COMMAND_UNLOCK: - case COMMAND_INIT: - case COMMAND_UPLOAD: - case COMMAND_DNLOAD: - case COMMAND_VERIFY: - case COMMAND_RENAME: - case COMMAND_COPY: + case COMMAND_DUMP: printf("Dumping %s!\n",argv[1]); - dos33_dump(dos_fd,scratch_sector); + dos33_dump(dos_fd); break; + + case COMMAND_LOCK: + case COMMAND_UNLOCK: + /* check and make sure we have apple_filename */ + if (argc<4) { + printf("Error! Need apple file_name\n"); + printf("%s %s LOCK apple_filename\n",argv[0],image); + goto exit_and_close; + } + + /* Truncate filename if too long */ + if (strlen(argv[3])>30) { + printf("Warning! Truncating %s to 30 chars\n",argv[3]); + } + strncpy(apple_filename,argv[3],30); + apple_filename[30]='\0'; + + /* get the entry/track/sector for file */ + catalog_entry=dos33_check_file_exists(dos_fd, + apple_filename, + FILE_NORMAL); + if (catalog_entry<0) { + printf("Error! %s not found!\n",apple_filename); + goto exit_and_close; + } + + dos33_lock_file(dos_fd,catalog_entry,command==COMMAND_LOCK); + + break; + + case COMMAND_RENAME: + /* check and make sure we have apple_filename */ + if (argc<5) { + printf("Error! Need two filenames\n"); + printf("%s %s LOCK apple_filename_old apple_filename_new\n", + argv[0],image); + goto exit_and_close; + } + + /* Truncate filename if too long */ + if (strlen(argv[3])>30) { + printf("Warning! Truncating %s to 30 chars\n",argv[3]); + } + strncpy(apple_filename,argv[3],30); + apple_filename[30]='\0'; + + /* Truncate filename if too long */ + if (strlen(argv[4])>30) { + printf("Warning! Truncating %s to 30 chars\n",argv[4]); + } + strncpy(new_filename,argv[4],30); + new_filename[30]='\0'; + + /* get the entry/track/sector for file */ + catalog_entry=dos33_check_file_exists(dos_fd, + apple_filename, + FILE_NORMAL); + if (catalog_entry<0) { + printf("Error! %s not found!\n",apple_filename); + goto exit_and_close; + } + + dos33_rename_file(dos_fd,catalog_entry,new_filename); + + break; + + case COMMAND_UNDELETE: + /* check and make sure we have apple_filename */ + if (argc<4) { + printf("Error! Need apple file_name\n"); + printf("%s %s LOCK apple_filename\n",argv[0],image); + goto exit_and_close; + } + + /* Truncate filename if too long */ + /* what to do about last char ? */ + if (strlen(argv[3])>30) { + printf("Warning! Truncating %s to 30 chars\n",argv[3]); + } + strncpy(apple_filename,argv[3],30); + apple_filename[30]='\0'; + + /* get the entry/track/sector for file */ + catalog_entry=dos33_check_file_exists(dos_fd, + apple_filename, + FILE_DELETED); + if (catalog_entry<0) { + printf("Error! %s not found!\n",apple_filename); + goto exit_and_close; + } + + dos33_undelete_file(dos_fd,catalog_entry,apple_filename); + + break; + + case COMMAND_INIT: + /* use common code from mkdos33fs? */ + case COMMAND_COPY: + /* use temp file? Walking a sector at a time seems a pain */ default: printf("Sorry, unsupported command\n"); goto exit_and_close; diff --git a/dos33_text2ascii.c b/dos33_text2ascii.c index 8605a9b9..60b59d3b 100644 --- a/dos33_text2ascii.c +++ b/dos33_text2ascii.c @@ -1,5 +1,7 @@ #include +#include "version.h" + int main(int argc, char **argv) { int ch; @@ -7,14 +9,14 @@ int main(int argc, char **argv) { ch=fgetc(stdin); if (feof(stdin)) return 0; + /* clear high byte */ ch=ch&0x7f; + /* convert apple carriage-return to unix linefeed */ if (ch=='\r') ch=('\n'); fputc(ch,stdout); } return 0; - - } diff --git a/integer_detoken.c b/integer_detoken.c new file mode 100644 index 00000000..55a3ede2 --- /dev/null +++ b/integer_detoken.c @@ -0,0 +1,120 @@ +#include +#include /* strlen() */ +#include /* isalnum() */ + +#include "version.h" + +/* with help from code by Paul Schlyter */ + +/* detokenizes Apple 2 integer basic programs */ +/* re-tokenizing is hard, as some with same name */ +/* such as PRINT have different tokens depending */ +/* on arguments */ + +/* Integer Basic */ +char integer_tokens[128][8]={ + +/* 00 */ "HIMEM:", "<$01>", "_", ":", + "LOAD ", "SAVE ", "CON ", "RUN", /* direct */ +/* 08 */ "RUN", "DEL ", ",", "NEW", + "CLR", "AUTO", ",", "MAN", +/* 10 */ "HIMEM:", "LOMEM:", "+", "-", /* binary */ + "*", "/", "=", "#", +/* 18 */ ">=", ">", "<=", "<>", + "<", " AND ", " OR ", " MOD ", +/* 20 */ "^", "+", "(", ",", + " THEN ", " THEN ", ",", ",", +/* 28 */ "\"", "\"", "(", "!", + "!", "(", " PEEK ", "RND", +/* 30 */ "SGN", "ABS", "PDL", "RNDX", + "(", "+", "-", " NOT ", /* unary */ +/* 38 */ "(", "=", "#", "LEN(", + "ASC(", "SCRN(", ",", "(", +/* 40 */ "$", "$", "(", ",", + ",", ";", ";", ";", +/* 48 */ ",", ",", ",", "TEXT", /* Statements */ + "GR", "CALL ", "DIM ", "DIM ", +/* 50 */ "TAB ", "END", "INPUT ", "INPUT ", + "INPUT ", "FOR ", "=", " TO ", +/* 58 */ "STEP ", "NEXT ", ",", "RETURN", + "GOSUB ", "REM ", "LET ", "GOTO ", +/* 60 */ "IF ", "PRINT ", "PRINT ", "PRINT ", + "POKE ", ",", "COLOR=", "PLOT ", +/* 68 */ ",", "HLIN ", ",", " AT ", + "VLIN ", ",", " AT ", "VTAB ", +/* 70 */ "=", "=", ")", ")", + "LIST", ",", "LIST", "POP", +/* 78 */ "NODSP", "DSP", "NOTRACE","DSP", + "DSP", "TRACE", "PR#", "IN#" +}; + + +#define REM_TOKEN 0x5D +#define UNARY_PLUS 0x35 +#define UNARY_MINUS 0x36 +#define QUOTE_START 0x28 +#define QUOTE_END 0x29 + + +int main(int argc, char **argv) { + + int ch1; + int size1,size2; + int line_length; + int line1,line2; + int int1,int2; + int in_rem=0,in_quote=0,last_was_alpha=0,last_was_token=0; + + /* read size, first two bytes */ + size1=fgetc(stdin); + size2=fgetc(stdin); + + while(!feof(stdin)) { + + in_rem=0; + in_quote=0; + last_was_alpha=0; + last_was_token=0; + + line_length=fgetc(stdin); + + /* line number is little endian 16-bit value */ + line1=fgetc(stdin); + line2=fgetc(stdin); + if (feof(stdin)) goto the_end; + printf("%4d ",((line2)<<8)+line1); + + /* repeat until EOL character (1) */ + while( (ch1=fgetc(stdin))!=0x1 ) { + + /* if < 0x80 it's a token */ + if (ch1<0x80) { + printf("%s",integer_tokens[ch1]); + if (ch1==REM_TOKEN) in_rem=1; + if (ch1==QUOTE_START) in_quote=1; + if (ch1==QUOTE_END) in_quote=0; + last_was_alpha=0; + last_was_token=1; + } + /* integer contant */ + else if ((!in_rem) && (!in_quote) && (!last_was_alpha) && + (ch1>=0xb0) && (ch1<=0xb9)) { + int1=fgetc(stdin); + int2=fgetc(stdin); + + printf("%d",(int2<<8)+int1); + last_was_token=0; + } + /* otherwise it is an ascii char */ + else { + fputc(ch1&0x7f,stdout); + last_was_alpha=isalnum(ch1&0x7f); + last_was_token=0; + } + + } + printf("\n"); + } + the_end:; + return 0; +} diff --git a/make_b.c b/make_b.c index 6ee70e3b..88c9f833 100644 --- a/make_b.c +++ b/make_b.c @@ -4,6 +4,8 @@ #include /* open() */ #include /* close() */ +#include "version.h" + int main(int argc, char **argv) { int in_fd,out_fd,offset; @@ -14,7 +16,8 @@ int main(int argc, char **argv) { struct stat file_info; if (argc!=4) { - printf("Usage: %s in_file out_file offset\n\n",argv[0]); + printf("MAKE_B version %s\b",VERSION); + printf(" Usage: %s in_file out_file offset\n\n",argv[0]); printf("\tin_file : input file\n"); printf("\tout_file : output file\n"); printf("\toffset : offset which file should be loaded\n\n"); diff --git a/mkdos33fs.c b/mkdos33fs.c index a5043dbf..97654993 100644 --- a/mkdos33fs.c +++ b/mkdos33fs.c @@ -3,11 +3,10 @@ #include /* open() */ #include /* close() */ #include /* strtol() */ +#include "version.h" #include "dos33.h" -#define VERSION "0.0.1" - void usage(char *binary,int help) { printf("\n%s - version %s\n",binary,VERSION); diff --git a/tests/GR b/tests/GR deleted file mode 100644 index 424281ff..00000000 Binary files a/tests/GR and /dev/null differ diff --git a/tests/LL_6502 b/tests/LL_6502 new file mode 100644 index 00000000..5316daea Binary files /dev/null and b/tests/LL_6502 differ diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 00000000..2c600686 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,5 @@ +all: + +clean: + rm -f *.out *~ test.dsk + diff --git a/tests/TB_6502 b/tests/TB_6502 new file mode 100644 index 00000000..04b8fcf5 Binary files /dev/null and b/tests/TB_6502 differ diff --git a/tests/TODO b/tests/TODO new file mode 100644 index 00000000..c4b5b9ab --- /dev/null +++ b/tests/TODO @@ -0,0 +1,2 @@ +Test copy +Test over-writing existing file diff --git a/tests/empty.dsk b/tests/empty.dsk new file mode 100644 index 00000000..cae574f6 Binary files /dev/null and b/tests/empty.dsk differ diff --git a/tests/test.int b/tests/test.int new file mode 100644 index 00000000..8c62745d Binary files /dev/null and b/tests/test.int differ diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 00000000..e7c4ead8 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +echo "Testing dos33..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save a SINCOS SINCOS +../dos33 ./test.dsk save t YOU.LOGO +../dos33 ./test.dsk save b LL_6502 +../dos33 ./test.dsk save b TB_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk load SINCOS sincos.out +../dos33 ./test.dsk load YOU.LOGO you.logo.out +../dos33 ./test.dsk load LL_6502 ll_6502.out +../dos33 ./test.dsk load TB_6502 tb_6502.out + +diff SINCOS sincos.out +diff YOU.LOGO you.logo.out +diff LL_6502 ll_6502.out +diff TB_6502 tb_6502.out diff --git a/tests/test_delete.sh b/tests/test_delete.sh new file mode 100755 index 00000000..30d83901 --- /dev/null +++ b/tests/test_delete.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo "Testing dos33 Delete..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save b LL_6502 +../dos33 ./test.dsk save b TB_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk delete LL_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save a SINCOS +../dos33 ./test.dsk save i test.int +../dos33 ./test.dsk save b LL_6502 + +../dos33 ./test.dsk catalog diff --git a/tests/test_large_files.sh b/tests/test_large_files.sh new file mode 100755 index 00000000..8c36775b --- /dev/null +++ b/tests/test_large_files.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "Testing large files..." + +cp empty.dsk test.dsk + +dd if=/dev/urandom of=blah.out bs=1k count=116 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save r blah.out big.1 +../dos33 ./test.dsk save r blah.out big.2 + +../dos33 ./test.dsk load big.1 blah2.out + +diff blah.out blah2.out + +../dos33 ./test.dsk catalog diff --git a/tests/test_lock.sh b/tests/test_lock.sh new file mode 100755 index 00000000..18aea8a8 --- /dev/null +++ b/tests/test_lock.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +echo "Testing dos33 Lock/Unlock..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save b LL_6502 +../dos33 ./test.dsk save b TB_6502 +../dos33 ./test.dsk save a SINCOS +../dos33 ./test.dsk save i test.int + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk lock LL_6502 +../dos33 ./test.dsk lock SINCOS + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk unlock LL_6502 + +../dos33 ./test.dsk catalog + + diff --git a/tests/test_lots_of_files.sh b/tests/test_lots_of_files.sh new file mode 100755 index 00000000..5ec8e2f3 --- /dev/null +++ b/tests/test_lots_of_files.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "Test lots of files..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save a SINCOS SIN1 +../dos33 ./test.dsk save a SINCOS SIN2 +../dos33 ./test.dsk save a SINCOS SIN3 +../dos33 ./test.dsk save a SINCOS SIN4 +../dos33 ./test.dsk save a SINCOS SIN5 +../dos33 ./test.dsk save a SINCOS SIN6 +../dos33 ./test.dsk save a SINCOS SIN7 +../dos33 ./test.dsk save a SINCOS SIN8 +../dos33 ./test.dsk save a SINCOS SIN9 +../dos33 ./test.dsk save a SINCOS SIN10 +../dos33 ./test.dsk save a SINCOS SIN11 +../dos33 ./test.dsk save a SINCOS SIN12 +../dos33 ./test.dsk save a SINCOS SIN13 +../dos33 ./test.dsk save a SINCOS SIN14 +../dos33 ./test.dsk save a SINCOS SIN15 +../dos33 ./test.dsk save a SINCOS SIN16 + + + + +../dos33 ./test.dsk catalog diff --git a/tests/test_odd_filenames.sh b/tests/test_odd_filenames.sh new file mode 100755 index 00000000..71251348 --- /dev/null +++ b/tests/test_odd_filenames.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Testing odd file names..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save a ././SINCOS +../dos33 ./test.dsk save a SINCOS this_is_a_very_very_long_filename +../dos33 ./test.dsk save a SINCOS \~CrAzY\%\$F\*\{\( +../dos33 ./test.dsk save a SINCOS 679-8329 +../dos33 ./test.dsk save a SINCOS SPACES\ ARE\ OK +../dos33 ./test.dsk save a SINCOS Commas,are,not + +../dos33 ./test.dsk catalog diff --git a/tests/test_rename.sh b/tests/test_rename.sh new file mode 100755 index 00000000..345d81bf --- /dev/null +++ b/tests/test_rename.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +echo "Testing dos33 Rename..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save b TB_6502 +../dos33 ./test.dsk save a SINCOS +../dos33 ./test.dsk save i test.int +../dos33 ./test.dsk save b LL_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk rename TB_6502 "tom bombem" +../dos33 ./test.dsk rename test.int "Integer Basic Test" + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk rename "tom bombem" "tb1" + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk load "tb1" "tb1.out" + +diff TB_6502 tb1.out diff --git a/tests/test_undelete.sh b/tests/test_undelete.sh new file mode 100755 index 00000000..db574b3f --- /dev/null +++ b/tests/test_undelete.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "Testing dos33 Undelete..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save b LL_6502 +../dos33 ./test.dsk save b TB_6502 +../dos33 ./test.dsk save a SINCOS +../dos33 ./test.dsk save i test.int + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk delete LL_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk undelete LL_6502 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk load LL_6502 ll.out + +diff LL_6502 ll.out + + + diff --git a/tests/test_undelete2.sh b/tests/test_undelete2.sh new file mode 100755 index 00000000..4f62ef24 --- /dev/null +++ b/tests/test_undelete2.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "Testing dos33 Undelete..." + +cp empty.dsk test.dsk + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk save b LL_6502 L123456789012345678901234567890 +../dos33 ./test.dsk save b TB_6502 +../dos33 ./test.dsk save a SINCOS +../dos33 ./test.dsk save i test.int + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk delete L123456789012345678901234567890 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk undelete L123456789012345678901234567890 + +../dos33 ./test.dsk catalog + +../dos33 ./test.dsk load L123456789012345678901234567890 ll.out + +diff LL_6502 ll.out + + + diff --git a/tokenize_asoft.c b/tokenize_asoft.c index 585cc4e7..c2b829bb 100644 --- a/tokenize_asoft.c +++ b/tokenize_asoft.c @@ -2,6 +2,8 @@ #include /* strlen() */ #include /* exit() */ +#include "version.h" + /* TODO */ /* match lowecase tokens as well as upper case ones */ @@ -39,29 +41,6 @@ char applesoft_tokens[][8]={ /* F8 */ "","","","","","(","(","(" }; -#if 0 -/* Integer Basic */ - -char integer_tokens[][8]={ -/* 00 */ "","","",":","LOAD","SAVE","","RUN", -/* 08 */ "","DEL",",","NEW","CLR","AUTO","","MAN", -/* 10 */ "HIMEM:","LOMEM:","+","-","*","/","=","#", -/* 18 */ ">=",">","<=","<>","<"," AND"," OR"," MOD", -/* 20 */ "^","","(",",",""," THEN","",",", -/* 28 */ "\"","\"","(","","","("," PEEK","RND", -/* 30 */ "SGN","ABS","PDL","","(","+","-","NOT", -/* 38 */ "(","=","LEN (","ASC (","SCRN (",","," (", -/* 40 */ "$","(","",",","","",";", -/* 48 */ "",",",",","TEXT","GR","CALL","","DIM", -/* 50 */ "TAB","END","","","INPUT","FOR","=","TO", -/* 58 */ " STEP","NEXT",",","RETURN","GOSUB","REM","LET","GOTO", -/* 60 */ "IF","","PRINT","PRINT"," POKE",",","COLOR=","PLOT", -/* 68 */ ",","HLIN",","," AT","VLIN",","," AT","VTAB", -/* 70 */ "","=",")","","LIST",",","","POP", -/* 78 */ "","NO DSP","NO TRACE","","DSP","TRACE","PR #","IN #" -}; -#endif - #define LOW(_x) ((_x)&0xff) #define HIGH(_x) (((_x)>>8)&0xff) #define MAXSIZE 65535 diff --git a/version.h b/version.h new file mode 100644 index 00000000..e5796040 --- /dev/null +++ b/version.h @@ -0,0 +1 @@ +#define VERSION "0.0.8"