amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (06/14/91)
Submitted-by: Phil Kernick <phil@adam.adelaide.edu.au> Posting-number: Volume 91, Issue 118 Archive-name: utilities/dog/part01 If you have net access on a unix box, but have to transport software through an ms-dos machine to get is to your amiga, no doubt you hate the fact that ms-dog cannot support full amiga filenames. This is no longer a problem now that you have DOG. #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: dog.c # Wrapped by tadguy@ab20 on Thu Jun 13 19:38:15 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'dog.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dog.c'\" else echo shar: Extracting \"'dog.c'\" \(3384 characters\) sed "s/^X//" >'dog.c' <<'END_OF_FILE' X/* X DOG X X Create a rename script X to unmangle the ms-dog X filenameing convention X X Version 1.1 X X -- X X If you have net access on a unix box, but have to transport software X through an ms-dos machine to get is to your amiga, no doubt you hate X the fact that ms-dog cannot support full amiga filenames. X X This is no longer a problem now that you have DOG. X X Compile DOG on your local unix box, and then run it with the command X line: X DOG [filenames] X X DOG will create a file called !RENAME in the current directory and will X rename all the specified files to have names that are unique to a dos X machine. X X Now transport the files to your amiga, via the dog-box and type the line X on your amiga: X Execute !RENAME X X Now all your files are called what they were originally! X X If you want to un-DOG the files on a unix box instead, then type: X /bin/csh !RENAME X X And the files will be returned. X X -- X X (c) 1991 Phil Kernick / Wizard Software X X This program is freely distributable as long as X the above copyright message is left intact. X X Please send any bugs or comments to: X phil@adam.adelaide.edu.au X X Phil Kernick X 304 South Terrace X Adelaide X SA 5000 X AUSTRALIA X*/ X X#include <stdio.h> X#include <ctype.h> X#include <string.h> X X#define min(a,b) ((a) < (b) ? (a) : (b)) X#define max(a,b) ((a) > (b) ? (a) : (b)) X X#define DUMPFILE "!RENAME" X Xchar doschar[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX!XX$%&'()XXX-.X0123456789XXXXXX@ABCDEFGHIJKLMNOPQRSTUVWXYZXXX^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{X}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; X Xtypedef char (*fnp)[13]; X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X int fname, dot, node, rpt; X char buffer[256], ext[8], *cc, *dd; X fnp dosfile; X FILE *fp; X X dosfile = (fnp) malloc(argc * sizeof(*dosfile)); X X strcpy(dosfile[0], DUMPFILE); X X for (fname = 1; fname < argc; fname++) X { X for (dot = 0, cc = argv[fname], dd = buffer; *cc; cc++, dd++) X *dd = ((*cc == '.') ? (dot++ ? 'X' : '.') : doschar[*cc]); X X *dd = '\0'; X X for (dot = 0, dd = buffer, cc = dosfile[fname]; X (dot < 8) && *dd && (*dd != '.'); dot++) X *cc++ = *dd++; X X node = dd - buffer; X X if (*dd != '.') X for (; *dd && (*dd != '.'); dd++) ; X X for (dot = 0; (dot < 4) && *dd; dot++) X *cc++ = *dd++; X X *cc = '\0'; X X for (dot = 0; dot < fname; dot++) X if (strcmp(dosfile[dot], dosfile[fname]) == 0) X { X if (node != 8) X rpt = 1; X else X { X for (cc = &dosfile[fname][node - 1]; isdigit(*cc); --cc) ; X rpt = atoi(++cc) + 1; X } X sprintf(buffer, "%0d", rpt); X strcpy(ext, &dosfile[fname][node]); X rpt = max(8 - strlen(buffer) - node, 0); X for (dd = buffer + strlen(buffer), cc = dosfile[fname] + 8; X dd >= buffer;) X *cc-- = *dd--; X for (; rpt > 0; rpt--) X *cc-- = '0'; X strcat(dosfile[fname], ext); X dot = -1; X } X } X X for (node = 0, fname = 1; fname < argc; fname++) X if (strcmp(argv[fname], DUMPFILE) != 0) X { X if (strcmp(dosfile[fname], argv[fname]) != 0) X { X if (!node) X { X fp = fopen(DUMPFILE, "w"); X fprintf(fp, "; alias rename mv\n"); X node = !node; X } X fprintf(fp, "rename %s \"%s\"\n", dosfile[fname], argv[fname]); X rename(argv[fname], dosfile[fname]); X } X } X X if (node) X fclose(fp); X X free((char *) dosfile); X} END_OF_FILE if test 3384 -ne `wc -c <'dog.c'`; then echo shar: \"'dog.c'\" unpacked with wrong size! fi # end of 'dog.c' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>. Mail comments to the moderator at <amiga-request@uunet.uu.net>. Post requests for sources, and general discussion to comp.sys.amiga.misc.