diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-11-27 17:26:50 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-11-27 17:26:50 -0500 |
| commit | 8aec307634ac63cf88e77df0e48fde1de0649b03 (patch) | |
| tree | 09ab1b41d242fe632a8ed916ba2dfd2f10c71b7e | |
| parent | 85770c4b5cb89a8a4420293a2a8b1f0cef851d7e (diff) | |
| download | unalf-8aec307634ac63cf88e77df0e48fde1de0649b03.tar.gz | |
-A (text file conversion) option for alf.
| -rw-r--r-- | TODO.txt | 7 | ||||
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/alf.1 | 33 | ||||
| -rw-r--r-- | src/alf.c | 46 | ||||
| -rw-r--r-- | src/alf.rst | 25 | ||||
| -rw-r--r-- | src/alfusage.c | 6 |
6 files changed, 106 insertions, 13 deletions
@@ -1,10 +1,3 @@ -- more options for alf: - -a - convert tabs/EOLs to atari, in text files - -A - convert tabs/EOLs to atari, all files - -td - use default DZ.COM timestamp - -tz - use zero timestamp - -tg - use GMT for timestamps rather than local time - - unalf -f option (fix, by removing the junk at EOF if found) - rename project. calling it "unalf" when it contains both alf and diff --git a/src/Makefile b/src/Makefile index 06ecbe7..91cb6f0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -69,7 +69,7 @@ f65.o: ../f65/f65.c ../f65/f65.h usage.c: mkusage.pl unalf.rst perl mkusage.pl unalf.rst > usage.c -alfusage.c: mkusage.pl unalf.rst +alfusage.c: mkusage.pl alf.rst perl mkusage.pl alf.rst > alfusage.c unalf.o: unalf.c unalf.h ../f65/f65.h @@ -36,7 +36,7 @@ alf \- create Atari 8-bit ALF archives . .SH SYNOPSIS .sp -alf [\fB\-\-help\fP] | [\fB\-a\fP | \fB\-o\fP ] \fIalf\-file\fP \fIfile\fP [\fIfile\fP ...] +alf [\fB\-\-help\fP] | [\fB\-a\fP | \fB\-o\fP ] [\fB\-t[dgz]\fP] \fIalf\-file\fP \fIfile\fP [\fIfile\fP ...] .SH DESCRIPTION .sp \fBalf\fP creates \fIALF\fP archives. @@ -69,6 +69,16 @@ is made with \fB\-a\fP\&. . .INDENT 0.0 .TP +.B \-A +Convert line endings and tabs from ASCII to ATASCII in all input +files. This will corrupt any executables or non\-text data files, +so use with caution. There is no way to autodetect text files, +unlike \fBunalf\fP\&. +.UNINDENT +.\" convert EOLs and tabs in all input files. +. +.INDENT 0.0 +.TP .B \-h\fP,\fB \-\-help Show built\-in help message. .UNINDENT @@ -83,6 +93,27 @@ Overwrite \fIalf\-file\fP if it exists; do not make a \fB~\fP backup. . .INDENT 0.0 .TP +.BI \-t\fB d +Use default \fBLZ.COM\fP timestamps (8 Dec 82 12:24). +.UNINDENT +.\" use default LZ.COM timestamps. +. +.INDENT 0.0 +.TP +.BI \-t\fB u +Use UTC for timestamps (default is local timezone). +.UNINDENT +.\" use UTC timestamps. +. +.INDENT 0.0 +.TP +.BI \-t\fB z +Use zero for timestamps (0 ??? 80 12:00a). +.UNINDENT +.\" use zero timestamps. +. +.INDENT 0.0 +.TP .B \-V\fP,\fB \-\-version Show \fBunalf\fP version number and exit. .UNINDENT @@ -30,6 +30,10 @@ unsigned int input_len, output_len, out_bitpos; int opt_append = 0; int opt_overwrite = 0; +int opt_zerotime = 0; +int opt_alftime = 0; +int opt_gmtime = 0; +int opt_txtconv = 0; struct stat in_file_stat; @@ -132,7 +136,10 @@ unsigned long get_msdos_date_time(void) { int msdos_year; u16 ms_date, ms_time; - tm = localtime(&t); + if(opt_gmtime) + tm = gmtime(&t); + else + tm = localtime(&t); msdos_year = tm->tm_year + 1900 - 1980; @@ -143,17 +150,25 @@ unsigned long get_msdos_date_time(void) { void create_header(void) { char hdr_filename[13]; + unsigned long time; atarify_filename(hdr_filename); printf("Crunching %s\n", hdr_filename); + if(opt_alftime) + time = 0x03130588; + else if(opt_zerotime) + time = 0; + else + time = get_msdos_date_time(); + output_buf[0] = 0x1a; output_buf[1] = 0x0f; memset(&output_buf[3], 0x20, 13); strncat((char *)&output_buf[2], hdr_filename, 13); output_buf[14] = 0x00; store_quad(15, 0); /* compressed size, fill in later */ - store_quad(19, get_msdos_date_time()); + store_quad(19, time); store_cksum(); store_quad(25, input_len); output_len = 29; @@ -292,6 +307,17 @@ void make_backup(void) { rename(out_filename, bak); } +void convert_eols(void) { + int i; + + for(i = 0; i < input_len; i++) { + if(input_buf[i] == '\n') + input_buf[i] = 0x9b; + else if(input_buf[i] == '\t') + input_buf[i] = 0x7f; + } +} + void crunch_file(const char *filename) { init_table(); @@ -309,6 +335,9 @@ void crunch_file(const char *filename) { return; } + if(opt_txtconv) + convert_eols(); + output_len = 0; fstat(fileno(in_file), &in_file_stat); /* for timestamp */ fclose(in_file); @@ -366,10 +395,21 @@ int main(int argc, char **argv) { /* don't let getopt() print error message for us. */ opterr = 0; - while((opt = getopt(argc, argv, "aoV")) != -1) { + while((opt = getopt(argc, argv, "aAt:oV")) != -1) { switch(opt) { + case 'A': opt_txtconv = 1; break; case 'a': opt_append = 1; opt_overwrite = 1; break; case 'o': opt_overwrite = 1; opt_append = 0; break; + case 't': opt_zerotime = opt_alftime = opt_gmtime = 0; + switch(*optarg) { + case 'z': opt_zerotime = 1; break; + case 'd': opt_alftime = 1; break; + case 'u': opt_gmtime = 1; break; + default: + fprintf(stderr, "%s: fatal: invalid -t suboption '-%c' (try -h or --help)\n", self, *optarg); + exit(1); + } + break; case 'V': puts(VERSION); exit(0); break; default: fprintf(stderr, "%s: fatal: invalid option '-%c' (try -h or --help)\n", self, optopt); diff --git a/src/alf.rst b/src/alf.rst index 879d0da..77c31cd 100644 --- a/src/alf.rst +++ b/src/alf.rst @@ -21,7 +21,7 @@ create Atari 8-bit ALF archives SYNOPSIS ======== -alf [**--help**] | [**-a** | **-o** ] *alf-file* *file* [*file* ...] +alf [**--help**] | [**-a** | **-o** ] [**-t[dgz]**] *alf-file* *file* [*file* ...] DESCRIPTION =========== @@ -55,6 +55,14 @@ OPTIONS .. append to alf file. +-A + Convert line endings and tabs from ASCII to ATASCII in all input + files. This will corrupt any executables or non-text data files, + so use with caution. There is no way to autodetect text files, + unlike **unalf**. + +.. convert EOLs and tabs in all input files. + -h, --help Show built-in help message. @@ -65,6 +73,21 @@ OPTIONS .. overwrite alf file if exists (do not create file~ backup). +-td + Use default **LZ.COM** timestamps (8 Dec 82 12:24). + +.. use default LZ.COM timestamps. + +-tu + Use UTC for timestamps (default is local timezone). + +.. use UTC timestamps. + +-tz + Use zero for timestamps (0 ??? 80 12:00a). + +.. use zero timestamps. + -V, --version Show **unalf** version number and exit. diff --git a/src/alfusage.c b/src/alfusage.c index c8f973d..eae4daf 100644 --- a/src/alfusage.c +++ b/src/alfusage.c @@ -1,5 +1,11 @@ const char *usage_msg[] = { " -a: append to alf file.", + " -A: convert EOLs and tabs in all input files.", + " -h, --help: show this help message.", " -o: overwrite alf file if exists (do not create file~ backup).", + " -td: use default LZ.COM timestamps.", + " -tu: use UTC timestamps.", + " -tz: use zero timestamps.", + " -V, --version: show version number.", (const char*)0 }; |
