From f9dcbdd176785dfc9d49f3113ec6110199e9a246 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 10 May 2024 17:24:40 -0400 Subject: import ken siders atr utilities. --- ksiders/atrextr.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ksiders/atrextr.c (limited to 'ksiders/atrextr.c') diff --git a/ksiders/atrextr.c b/ksiders/atrextr.c new file mode 100644 index 0000000..2aeb898 --- /dev/null +++ b/ksiders/atrextr.c @@ -0,0 +1,63 @@ +/* Copyright 1997 Ken Siders */ + +#include +#include +#include +#include +#include +#include "atr.h" +#include "atdos.h" + +int main( int argc, char **argv) { + AtrFilePtr atr; + int stat = 0, ret = 0; + char *file = "*.*"; + char *path = NULL; + + printf("AtrExtr Version 0.9u (c)1997 Ken Siders\n"); + printf("Ported and modified by B. Watson, 2007\n"); + printf("This program may be freely distributed\n\n"); + + if(argc < 2 || argc > 4) { + printf("usage: atrextr atrname.atr [file] [dir]\n" + "Wildcards may be used for file (default: *.*)\n" + "dir will be created, if it does not exist\n"); + exit(-1); + } + + atr = OpenAtr(argv[1]); + if(atr == 0) { + printf("Error reading ATR file: %s\n", argv[1]); + CloseAtr(atr); + exit(2); + } + + CloseAtr(atr); + + if(argc >= 3 && argv[2][0]) + file = argv[2]; + + if(argc == 4) { + path = argv[3]; + mkdir(path, 0777); /* ignore errors (ExtractAtariFile() will fail instead) */ + } + + while ( !stat ) { + SetVerbose(1); + stat = ExtractAtariFile( argv[1], file, path ); + SetVerbose(0); + } + + if( stat < 0 ) { + printf("\nError encountered when extracting file(s)\n"); + printf("some files may have been extracted incorrectly\n"); + stat = -stat; + ret = 1; + } + + printf("\n%d file(s) extracted\n", stat); + + exit(ret); +} + + -- cgit v1.2.3