Submitted-By: Soenke Behrens (sbeh...@contech.demon.co.uk)
Posting-number: Volume 1, Source 102
Archive-Name: gno/util/udl.02
Architecture: 2gs,UNIX
Version-Number: 1.14
REPOST to eliminate control characters in udl.online.
[This will teach me not to read every bit of a package.]
=udl.online
-
-
-UDL (1) Commands and Applications UDL (1)
-
-
-
-
-NAME
- udl - convert text files between different architectures
-
-SYNOPSIS
- udl -u|m|g [ -Rvp ] file1 [ file2 ... ]
-
-DESCRIPTION
- udl converts files between different computer systems by
- changing the EOL (End-Of-Line) character.
-
- On the Apple IIgs, udl will skip any file that is not of type
- TXT or SRC. No notice is given of this unless the -v flag is
- used. Since Unix file systems do not have file types udl is
- limited in the types of checks which it can carry out, so the
- user must take care that it is not invoked on object files or
- the like. On both platforms, if file appears to be a binary
- file (that is, no EOL is found in the first part of the file)
- then file will be skipped. Again, no notice is given of this
- unless the -v flag is used.
-
- During file conversion udl creates a temporary file in the same
- directory as the original file. The temporary file is close to
- or exactly the same size as the original file.
-
- When running under Byteworks' ORCA shell, the Orca shell
- wildcards = and ? are properly expanded in file names.
-
-OPTIONS
-
- -u
- Convert to use LF as EOL (Unix/Amiga).
-
- -m
- Convert to use CR/LF as EOL (MS-DOS).
-
- -g
- Convert to use CR as EOL (Apple).
-
- -p
- Be pedantic, only affects Unix<->Apple conversions, see
- below.
-
- -R
- Recurse through subdirectories.
-
- -v
- Be verbose, show the file udl is currently working on.
-
- If you specify the -p switch, udl is pedantic while doing the
- conversion. This means: The input file may contain bytes with a
- value of zero (0), and the input file may contain different EOL
- characters (ie: MS-DOS and Unix style might be mixed in one
- file). For conversions to or from MS-DOS udl is always
-
-
-
-7 February 1995 Version 1.14 Page 1
-
-
-
-
-UDL (1) Commands and Applications UDL (1)
-
-
-
- pedantic, so this only affects conversions from Unix to Apple or
- vice versa. Being pedantic slows udl down by a factor of 1.5.
-
-LIMITATIONS
- When running under Gno on the Apple IIgs, there is a limit to
- the nesting depth when recusing on subdirectories. This is
- because the routine that is responsible for this behavior is
- itself recursive. The default 2k stack size will allow about 33
- levels of nested directories, so this limit should not normally
- be a problem. If the limit is exceeded, udl will exit with an
- error message before any files are changed, and before the stack
- actually overflows.
-
-BUGS
- Bug reports should be directed to one of the two addresses
- below.
-
-AUTHOR
- Soenke Behrens <sbeh...@contech.demon.co.uk> with contributions
- by Devin Reade <g...@myrias.ab.ca>.
-
-VERSION
- This is udl version 1.14.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7 February 1995 Version 1.14 Page 2
-
-
=udl.rez
-#include "types.rez"
-
-data rVersion (0x1, purgeable1, nocrossbank) {
- $"00A0 1401 0200 0375 646C 2F43 6F70 7972" /* .......udl/Copyr */
- $"6967 6874 2031 3939 332D 3139 3935 2C0D" /* ight 1993-1995,. */
- $"539A 6E6B 6520 4265 6872 656E 732C 2044" /* S.nke Behrens, D */
- $"6576 696E 2052 6561 6465" /* evin Reade */
-};
-
-data rComment (0x1) {
- $"5465 7874 2046 696C 6520 436F 6E76 6572" /* Text File Conver */
- $"7369 6F6E 2050 726F 6772 616D 0D43 6F6E" /* sion Program.Con */
- $"7665 7274 7320 6669 6C65 7320 6265 7477" /* verts files betw */
- $"6565 6E20 4352 2C20 4352 2F4C 4620 616E" /* een CR, CR/LF an */
- $"6420 4C46 2E0D 2841 7070 6C65 2C20 4D53" /* d LF..(Apple, MS */
- $"2D44 4F53 2061 6E64 2055 6E69 7829" /* -DOS and Unix) */
-};
-
-data rComment (0x2) {
- $"5265 7175 6972 6573 204F 5243 412F 5368" /* Requires ORCA/Sh */
- $"656C 6C20 6F72 2047 4E4F 2F4D 45" /* ell or GNO/ME */
-};
=udl.unix.c
-/*
- * udl - Convert EOL formats freely between MS-DOS (CR/LF), Unix/Amiga (LF),
- * and Apple (CR).
- *
- * Unix specific routines.
- *
- * $Id: udl.unix.c,v 1.6 1995/02/08 06:12:47 gdr Exp $
- *
- * Copyright (c) 1993-1995 Soenke Behrens, Devin Reade
- */
-
-#include "common.h"
-
-extern char *strdup(const char *);
-
-int main(int argc,char *argv[]) {
- FILE *infile, *outfile;
- int Tunix = FALSE;
- int Messy = FALSE;
- int GS = FALSE;
- int careful = FALSE;
- int converted;
- int c;
- int R_flag = FALSE;
-
- verbose = FALSE;
- program_name = NULL;
- tempfile = NULL;
- current_file = NULL;
- in_buffer = out_buffer = NULL;
- pathSlotsUsed = 0;
- pathSlots = 0;
- pathList = NULL;
- *currentDirectory = '\0';
- recursionDepth=0;
-
- /* In case of exit(), free the mem I allocated */
-#ifdef HAS_ATEXIT
- atexit (cleanup);
-#endif
-
- if ((program_name = strdup (argv[0])) == NULL) {
- fprintf(stderr,"%s: memory allocation failure\n",argv[0]);
- exit (EXIT_FAILURE);
- }
-
- if (argc < 3) {
- usage();
- exit (EXIT_FAILURE);
- }
-
- /* Get and process arguments */
-
- opterr = 1;
- while ((c = getopt (argc, argv, "pvugmR")) != EOF) {
- switch (c) {
- case 'v':
- verbose = TRUE;
- break;
-
- case 'p':
- careful = TRUE;
- break;
-
- case 'u':
- if (Tunix == TRUE || Messy == TRUE || GS == TRUE) {
- fprintf(stderr, "%s: You may not "
- "specify more than one conversion option\n",program_name);
- exit (EXIT_FAILURE);
- }
- Tunix = TRUE;
- break;
-
- case 'm':
- if (Tunix == TRUE || Messy == TRUE || GS == TRUE) {
- fprintf(stderr, "%s: You may not specify more than one "
- "conversion option\n",program_name);
- exit (EXIT_FAILURE);
- }
- Messy = TRUE;
- break;
-
- case 'g':
- if (Tunix == TRUE || Messy == TRUE || GS == TRUE) {
- fprintf(stderr, "%s: You may not specify more than one "
- "conversion option\n",program_name);
- exit (EXIT_FAILURE);
- }
- GS = TRUE;
- break;
-
- case 'R':
- R_flag++;
- break;
-
- case '?':
- usage();
- exit (EXIT_FAILURE);
-
- default:
- fprintf (stderr, "%s: Internal getopt error\n", program_name);
- exit (EXIT_FAILURE);
- break;
- }
- }
-
- /* no files specified */
- if (optind == argc) {
- usage();
- exit (EXIT_FAILURE);
- }
-
- if (Tunix == FALSE && GS == FALSE && Messy == FALSE) {
- fprintf(stderr,"%s: You have to specify a destination "
- "format.\n",program_name);
- exit (EXIT_FAILURE);
- }
-
- if (verbose == TRUE) {
- printf ("%s %s\n",program_name,UDL_VERSION);
- }
-
- /* Now process the files I got */
-
- if ((in_buffer = malloc(BUFFERSIZE+1)) == NULL ||
- (out_buffer = malloc(BUFFERSIZE+1)) == NULL) {
- fprintf(stderr,"%s: Unable to buffer files\n",program_name);
- exit (EXIT_FAILURE);
- }
-
- /* save the directory we're in */
- if (getwd(rootdir)==NULL) {
- fprintf(stderr,"%s: Couldn't stat .\n",program_name);
- exit (EXIT_FAILURE);
- }
-
- /* set the directory separator character. */
- dirbrk = '/';
-
- /* build the list of files to process */
- for (; optind<argc; optind++) {
- build_file_list(argv[optind],R_flag);
- chdir(rootdir);
- *currentDirectory = '\0';
- }
-
- /* files were all directories and no -R flag given */
- if (!pathList) {
- if (verbose) printf("%s: no files to process\n",program_name);
- exit(EXIT_SUCCESS);
- }
-
- for (c=0; pathList[c]; c++) {
- if((current_file = strdup(pathList[c])) == NULL) {
- fprintf(stderr,"%s: memory allocation failure\n", program_name);
- exit (EXIT_FAILURE);
- }
-
- if (verbose == TRUE) {
- printf("%s: Working on %s\n",program_name,
- current_file);
- }
-
- infile = tryopen(current_file,"rwb");
- tempfile = mktemp(strcat(get_path(current_file), "udltmpXX"));
- outfile = tryopen(tempfile,"wb");
-
- if (careful) {
- converted = TRUE; /* always */
-
- if (GS)
- convert_gs(infile,outfile);
- else if (Tunix)
- convert_tunix(infile,outfile);
- else
- convert_messy(infile,outfile);
- } else {
- if (GS)
- converted = convert_fast_gs(infile,outfile);
- else if (Tunix)
- converted = convert_fast_tunix(infile,outfile);
- else
- converted = convert_fast_messy(infile,outfile);
- }
-
- if (fclose (infile) == EOF || fclose (outfile) == EOF) {
- perror ("closing files");
- exit (EXIT_FAILURE);
- }
-
- if (converted) { /* Temp file contains converted data */
- if (remove (current_file) != 0) {
- perror ("removing original file");
- exit (EXIT_FAILURE);
- }
-
- if (rename (tempfile,current_file) != 0) {
- perror ("cannot rename temporary file");
- exit (EXIT_FAILURE);
- }
- } else
- remove (tempfile);
-
- free (tempfile); tempfile = NULL;
- free(current_file);
- current_file = NULL;
-
- } /* for (c=0; pathList[c]; c++) */
-
- return (EXIT_SUCCESS);
-}
-
-/* End Of File */
=udluse.c
-/*
- * udl - Convert EOL formats freely between MS-DOS (CR/LF), Unix/Amiga (LF),
- * and Apple (CR).
- *
- * Usage strings.
- *
- * $Id: udluse.c,v 1.6 1995/02/08 06:12:49 gdr Exp $
- *
- * Copyright (c) 1993-1995 Soenke Behrens, Devin Reade
- */
-
-#ifdef GNO
-#pragma noroot
-#endif
-
-char use1 [] =
-"udl 1.14 by Soenke Behrens, Devin Reade\n"
-"Usage: udl -u|g|m [-Rvp] file1 [file2 ...]\n\n"
-"Options:\n"
-" -u Convert file to use LF as EOL character.\n"
-" -g Convert file to use CR as EOL character.\n"
-" -m Convert file to use LF/CR as EOL character.\n"
-" -R Recurse through subdirectories.\n"
-" -p Be pedantic.\n"
-" -v Be verbose about it.\n\n"
-"udl creates a temporary file in the directory of the original file.\n"
-"The original file is overwritten after conversion.\n";
-
-char use2 [] =
-"\nFiles may contain ORCA/Shell style wildcards.\n";
-
-/* End Of File */
+ END OF ARCHIVE