#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <getopt.h>
#include <dirent.h>

extern char *optarg;
extern int optind, optopt, opterr;

/* struct atari_dirent {
   unsigned char flag; // bit 7=deleted 6=normal 5=locked 0=open4write
   unsigned char countlo;
   unsigned char counthi;
   unsigned char startlo;
   unsigned char starthi;
   char namelo[8];
   char namehi[3];
};
*/

#define TF_PRINT 1
#define TF_DELETE 2

int load_disk(unsigned char *disk, char *);
int write_disk(unsigned char *disk, char *);

int get_confirm(char *);
void usage(char *);
void print_entry(unsigned char *buf);
/*void dump_links(unsigned char *disk,unsigned char *ent);*/
void traverse_file(unsigned char *disk, unsigned char *ent, int ACTION);
void dump_file(unsigned char *disk, unsigned char *ent, char *);
int parse_filename(char *filename, char *result);
int make_filename(char *filename, char *result);
int make_dir(char *filename);
void dump_sector(unsigned char *disk, int);
void read_sector(unsigned char *disk, int, unsigned char *buf);
void write_sector(unsigned char *disk, int, unsigned char *buf);
void write_blank_disk(char *filename);
void write_file(unsigned char *disk, char *filename);
/*int check_dir(unsigned char *disk,char *filename);*/
int get_dentry(unsigned char *disk);
int get_free_sector(unsigned char *disk);
void mark_used(unsigned char *vtoc_sector, int sector);
void mark_free(unsigned char *vtoc_sector, int sector);
int vtoc_byte(int sector);
int vtoc_bit(int sector);
