Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Regulars » Rambles/SplitS/Source/Joinf_c
Rambles/SplitS/Source/Joinf_c
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Regulars |
Filename: | Rambles/SplitS/Source/Joinf_c |
Read OK: | ✔ |
File size: | 582B bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/********************************************************************************/ /* */ /* Joinf.c */ /* Part of Splitf and Joinf distribution */ /* version 1.13, � 1993-1995 Adam Hamilton */ /* See the README file for copyright information */ /* */ /********************************************************************************/ /*********************************/ /* Include required header files */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "config.h" /**********************************/ /* Program macros and definitions */ #define TITLE "File joiner. Version 1.13 - 4th Feburary 1995 by A.Hamilton\n\n" #ifndef Bool # define Bool char #endif #define False 0 #define True !False #define MIN(a, b) (a < b ? a : b) #define MAX(a, b) (a > b ? a : b) /********************************************************************************/ /* */ /* Function : usage */ /* Description : Displays program usage to standard error, and exits. */ /* Arguments : progname - pointer to character string containing the program */ /* name. */ /* Returns : None. */ /* */ /********************************************************************************/ void usage (char *progname) { fprintf (stderr, TITLE); fprintf (stderr, "Usage : %s [options] <filename>\n\n", progname); fprintf (stderr, "Options (can be abbreviated) :\n"); #ifndef PC fprintf (stderr, " -buffersize [buffersize in K] default = 32\n"); #endif fprintf (stderr, " -filename [new filename]\n"); fprintf (stderr, " -interactive\n"); fprintf (stderr, " -info\n"); exit (EXIT_FAILURE); } /********************************************************************************/ /* */ /* Function : examine_filename */ /* Description : Splits filename into component parts. */ /* Arguments : original_name - character array, filename to be examined. */ /* name - pointer to a character array in which to store */ /* file leafname (excluding extention). */ /* path - pointer to a character array in which to store */ /* the destination files path. */ /* Returns : If the destination file has an extention, then return it, */ /* otherwise return "". */ /* */ /********************************************************************************/ char *examine_filename (char original_name[], char *name, char *path) { char main_name[256]; /* Temporary store for leafname. */ char *original; /* Pointer to start of leafname. */ char ext[32]; char *pointer; /* Pointer to any ':' characters found. */ register int i = -1, n; /* Pointer & counter. */ if (COLON) /* If our system uses ':' in */ pointer = strrchr (original_name, ':'); /* the file path, then remember */ else /* where it is. */ pointer = NULL; original = strrchr (original_name, SEPARATOR_SEARCH); /* Find the address where the */ if ((original = MAX (original, pointer)) == NULL) /* leafname starts. */ original = original_name; else { original++; strncpy (path, original_name, original - original_name); /* Get the path. */ path[original - original_name] = '\0'; } do { i++; main_name[i] = original[i]; /* Get files leafname */ } while (main_name[i] != '.' && main_name[i] != '\0'); /* (excluding any extention). */ main_name[i - 2] = '\0'; /* Copy the leafname. */ strcpy (name, main_name); if (main_name[i] == '\0') /* If the file doesn't have an */ return (""); /* extention return an empty string. */ for (n = 0; (ext[n] = original[i]) != '\0'; n++, i++) ; /* Otherwise get the extention */ return (ext); /* and return it. */ } /********************************************************************************/ /* */ /* Function : numtostr */ /* Description : Converts a number into a 2 didget character string. */ /* Arguments : number - number to be converted. */ /* name - pointer to a character array to store the number. */ /* Returns : None. */ /* */ /********************************************************************************/ void numtostr (short number, char *name) { name[0] = (short) (number / 10) + '0'; name[1] = (number % 10) + '0'; name[2] = '\0'; } /********************************************************************************/ /* */ /* Function : main */ /* Description : Main control function. */ /* Arguments : Command line parameters. */ /* Returns : Exit status. */ /* */ /********************************************************************************/ int main (int argc, char *argv[]) { char source_filename[256]; /* Source filename. */ char out_filename[256]; /* Output leafname. */ char in_path[256]; /* Input path. */ char file_ext[32]; /* Output extention. */ char out_name[256]; /* Full output filename. */ char header[50]; /* Output file header. */ char fnum[3]; /* Output part number. */ char *progname; /* Program name. */ char string[256]; /* Input string. */ char type[5]; /* Filetype (Acorn systems only). */ char interactive = 0; /* Interactive status flag. */ char source_name[256]; char check_name[256]; short file_number = 0; /* Current part number. */ short check_number; long read_size = 32 * 1024; /* Buffer size (default 32K). */ long out_position; /* Position within output file. */ long in_position; /* Position within input file. */ long bytes_read; /* Number of bytes read. */ long bytes_written; /* Number of bytes written. */ long file_length; /* Length of source file. */ long *buffer; /* Pointer to buffer. */ int total_number; /* Total number of parts to join. */ int args; /* Number of command line arguments. */ int i, n; /* Counters. */ Bool info = False; /* Display information? */ FILE *source_file; /* Source file ID. */ FILE *out_file; /* Output file ID. */ static char splith1[]="Split:"; /* Part 1 header check string. */ static char splith2[]="Sp:"; /* Part >1 header check string. */ #ifdef ACORN _kernel_swi_regs regs; _kernel_oserror *err; #endif progname = *argv; /* Get the program name. */ in_path[0] = '\0'; /* Set path to CWD. */ out_filename[0] = '\0'; /* Clear destination filename. */ source_filename[0] = '\0'; /* Clear source filename. */ args = argc - 1; /* Initialise count of arguments. */ if (!args) usage (progname); /* If no arguments supplied, show usage.*/ while (args--) { argv++; /* Look at next argument. */ if (!strncmp ("-filename", *argv, MAX (2, strlen (*argv)))) { /* -filename */ if (!args) { fprintf (stderr, "Filename required\n\n"); usage (progname); } strcpy (out_filename, *++argv); /* Read output filename.*/ args--; } #ifndef PC else if (!strncmp ("-buffersize", *argv, MAX (2, strlen (*argv)))) { /* -buffersize */ if (!args) { fprintf (stderr, "Buffer size required\n\n"); usage (progname); } read_size = (long) atoi (*++argv) * 1024; /* Read buffer size. */ args--; } #endif else if (!strncmp ("-interactive", *argv, MAX (2, strlen (*argv)))) /* -interactive */ interactive = 1; else if (!strncmp ("-info", *argv, MAX (3, strlen (*argv)))) /* -info */ info = True; else { strcpy (source_filename, *argv); /* Read source filename.*/ if (args) usage (progname); } } if (source_filename[0] == NULL) { fprintf (stderr, "Source filename required\n\n"); usage (progname); } /* Get file detail from source filename.*/ strcpy (file_ext, examine_filename (source_filename, source_name, in_path)); source_file = fopen (source_filename, "rb"); /* Open read binary source file. */ if (source_file == NULL) { /* Report if error, and stop. */ fprintf (stderr, "Fatal error opening %s for input.\n", source_filename); exit (EXIT_FAILURE); } i = 0; /* Initialise counter. */ while ((header[i++] = fgetc (source_file)) != '|' && i < 300) ; /* Read file header, */ for (i = 0; i < 6; i++) if (header[i] != splith1[i]) { /* and compare with template. */ fprintf (stderr,"Fatal error, no split header in file %s\n", source_filename); fclose (source_file); exit (EXIT_FAILURE); } fseek (source_file, 0L, SEEK_END); /* Set file pointer to end of file, */ file_length = ftell (source_file); /* get file length */ fseek (source_file, 0L, SEEK_SET); /* and reset pointer to the start. */ n = 0; /* Initialise counter. */ #ifdef ACORN while (header[i] != '=') { /* Extract output filename, */ out_name[n++] = (header[i] == '.' ? '/' : header[i]); /* swapping any '.' and '/' */ i++; /* characters. */ } n++; i++; #else while ((out_name[n++] = header[i++]) != '=') ; /* Just extract the filename, */ #endif out_name[--n] = '\0'; /* terminate it properly, */ if (out_filename[0] == '\0') strcpy (out_filename, out_name); /* and copy. */ n = 0; /* Initialise counter. */ while ((fnum[n++] = header[i++]) != '=') ; /* Get the total number of */ fnum[--n] = '\0'; /* parts. */ total_number = atoi (fnum); n = 0; /* Initialise counter. */ while ((type[n++] = header[i++]) != '|') ; /* Read the filetype data. */ type[--n] = '\0'; if (info) { /* If -info selected, only */ printf (TITLE); /* print information. */ printf ("Information :\n\n"); printf (" Output filename is %s", out_filename); #ifdef ACORN if (type[0] == 't') { /* If the file contains */ printf (", filetype "); /* filetype data then show it. */ for (n = 1; type[n] != '\0'; n++) printf ("%c", toupper(type[n])); } #endif printf ("\n"); bytes_read = 0; } else { /* -info not selected, do the joining. */ buffer = (long *) malloc ((size_t) read_size); /* Allocate memory for a buffer. */ if (buffer == NULL) { fprintf (stderr, "Fatal error, unable to allocate memory block of %ld bytes\n", read_size); exit (EXIT_FAILURE); } printf ("Using buffer size of %ld bytes.\n", read_size); #ifdef ACORN regs.r[0] = 7; /* Create the file with SWI */ regs.r[1] = (int) out_filename; /* OS_File 7 */ regs.r[2] = 0xdeaddead; regs.r[3] = 0xdeaddead; regs.r[4] = 0; regs.r[5] = (int) (file_length * (total_number - 0.5)); /* using an estimated size. */ if ((err = _kernel_swi (SWI_OS_File, ®s, ®s)) != NULL) { fprintf (stderr, "Fatal error opening %s for output:\n-- %s\n", out_filename, err->errmess); exit (EXIT_FAILURE); } #endif out_file = fopen (out_filename, "wb"); /* Open output file. */ if (out_file == NULL) { /* Report if error, and stop. */ fprintf (stderr, "Fatal error opening %s for output.\n", out_filename); exit (EXIT_FAILURE); } } out_position = 0; /* Initialise output file position pointer. */ for (file_number = 1; file_number <= total_number; file_number++) { /* for each part */ numtostr (file_number, fnum); while (interactive == 1 && file_number > 1) { /* If -interactive selected, */ printf ("Enter path for %s%s%s (Return for %s) :\n", /* ask for location of next */ source_name, fnum, file_ext, /* part. */ in_path[0] == '\0' ? "current directory" : in_path); gets (string); /* Get output destination. */ if (strchr (string, ' ') != NULL) { printf ("Invalid path name.\n"); continue; } if (string[0] != '\0') { /* If nothing entered, then use the default. */ strcpy (in_path, string); i = strlen (in_path); if (in_path[i - 1] != FILE_SEPARATOR) if (!COLON || (COLON && in_path[i - 1] != ':')) { in_path[i] = FILE_SEPARATOR; in_path[i + 1] = '\0'; } } interactive = interactive | 2; /* Set flag to say data has been accepted. */ } interactive = interactive & 1; /* Mask off unrequired data. */ /* Create the full input filename. */ sprintf (source_filename, "%s%s%s%s", in_path, source_name, fnum, file_ext); if (file_number != 1) { /* If it's not the first part, */ source_file = fopen (source_filename, "rb"); /* Open read binary file. */ if (source_file == NULL) { /* Report if error, and stop. */ fprintf (stderr, "Fatal error opening %s for input.\n", source_filename); exit (EXIT_FAILURE); } i = 0; /* Initialise counter. */ while ((header[i++] = fgetc (source_file)) != '|' && i<300) ; /* Check the header */ for (i = 0; i < 3; i++) if (header[i] != splith2[i]) { /* with a template. */ fprintf (stderr,"Fatal error, bad header in file %s\n", source_filename); fclose (source_file); exit (EXIT_FAILURE); } n = 0; /* Initialise counter. */ #ifdef ACORN while (header[i] != '=') { check_name[n++] = (header[i]=='.' ? '/' : header[i]); /* Swap '.' and '/' */ i++; /* characters and check */ } /* filename. */ n++; i++; #else while ((check_name[n++] = header[i++]) != '=') ; /* Just check filename. */ #endif check_name[--n] = '\0'; if (strcmp (out_name, check_name)) { /* Report if error */ fprintf (stderr,"Fatal error, split file %s does not match.\n", source_filename); fclose (source_file); exit (EXIT_FAILURE); /* and stop. */ } n = 0; /* Initialise counter. */ while ((fnum[n++] = header[i++]) != '|') ; fnum[--n] = '\0'; check_number = atoi (fnum); /* Get the part number */ if (check_number != file_number) { /* and make sure it's */ fprintf (stderr,"Fatal error, incorrect part.\n"); /* one we want. */ fclose (source_file); exit (EXIT_FAILURE); } } in_position = (long) i; /* Initialise the input file position pointer. */ fseek (source_file, 0L, SEEK_END); /* Set file pointer to end of file, */ file_length = ftell (source_file); /* get file length */ fseek (source_file, in_position, SEEK_SET); /* and reset pointer to start of data. */ if (info) { /* If -info just display information. */ printf (" %s...%ld bytes\n", source_filename, file_length - in_position); bytes_read += file_length - in_position; } else { /* Otherwise, do the joining. */ printf ("Reading data from %s.....%ld bytes\n", source_filename, file_length - in_position); while (file_length - in_position > 0) { /* If any data */ bytes_read = fread (buffer, 1, (size_t) read_size, source_file); /* left, read */ bytes_written = fwrite (buffer, 1, (size_t) bytes_read, out_file); /* and write. */ /* Check we've written the correct amount of data. */ if (bytes_written < read_size && bytes_written < file_length-in_position) { fprintf (stderr, "Fatal error while writing %s\n", out_filename); exit (EXIT_FAILURE); /* If unsucessfull, then stop. */ } in_position += bytes_read; /* Update the file position */ out_position += bytes_written; /* pointers. */ } } fclose (source_file); /* Close the source file. */ if (!info && (bytes_written < bytes_read)) { fprintf (stderr, "Fatal error while writing %s\n", out_filename); exit (EXIT_FAILURE); /* If unsucessfull, stop. */ } } if (info) printf ("\nTotal of %ld bytes contained in %d files.\n", bytes_read, total_number); else { fclose (out_file); /* Close output file */ free (buffer); /* and free buffer. */ #ifdef ACORN if (type[0] == 't') { /* If the file had a type */ regs.r[0] = 18; /* set the filetype with SWI */ regs.r[1] = (int) out_filename; /* OS_File 18 */ sscanf (type, "t%x", ®s.r[2]); err = _kernel_swi (SWI_OS_File, ®s, ®s); } #endif /* Report status */ fprintf (stderr, "%ld bytes written to file %s\n", out_position, out_filename); } exit (EXIT_SUCCESS); /* and finish. */ }
00000000 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |/***************| 00000010 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000050 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 20 20 20 |*/./* | 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000000a0 20 20 20 2a 2f 0a 2f 2a 20 4a 6f 69 6e 66 2e 63 | */./* Joinf.c| 000000b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000000f0 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 50 61 72 74 | */./* Part| 00000100 20 6f 66 20 53 70 6c 69 74 66 20 61 6e 64 20 4a | of Splitf and J| 00000110 6f 69 6e 66 20 64 69 73 74 72 69 62 75 74 69 6f |oinf distributio| 00000120 6e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n | 00000130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000140 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 76 | */./* v| 00000150 65 72 73 69 6f 6e 20 31 2e 31 33 2c 20 a9 20 31 |ersion 1.13, . 1| 00000160 39 39 33 2d 31 39 39 35 20 41 64 61 6d 20 48 61 |993-1995 Adam Ha| 00000170 6d 69 6c 74 6f 6e 20 20 20 20 20 20 20 20 20 20 |milton | 00000180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000190 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f | */./| 000001a0 2a 20 53 65 65 20 74 68 65 20 52 45 41 44 4d 45 |* See the README| 000001b0 20 66 69 6c 65 20 66 6f 72 20 63 6f 70 79 72 69 | file for copyri| 000001c0 67 68 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 |ght information | 000001d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000001e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 000001f0 2f 0a 2f 2a 20 20 20 20 20 20 20 20 20 20 20 20 |/./* | 00000200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000240 20 20 2a 2f 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a | */./**********| 00000250 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000290 2a 2a 2a 2a 2a 2a 2f 0a 0a 0a 2f 2a 2a 2a 2a 2a |******/.../*****| 000002a0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| 000002b0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 2f 2a |************/./*| 000002c0 20 49 6e 63 6c 75 64 65 20 72 65 71 75 69 72 65 | Include require| 000002d0 64 20 68 65 61 64 65 72 20 66 69 6c 65 73 20 2a |d header files *| 000002e0 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 |/..#include <std| 000002f0 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c |io.h>.#include <| 00000300 73 74 64 6c 69 62 2e 68 3e 0a 23 69 6e 63 6c 75 |stdlib.h>.#inclu| 00000310 64 65 20 3c 73 74 72 69 6e 67 2e 68 3e 0a 23 69 |de <string.h>.#i| 00000320 6e 63 6c 75 64 65 20 3c 63 74 79 70 65 2e 68 3e |nclude <ctype.h>| 00000330 0a 23 69 6e 63 6c 75 64 65 20 22 63 6f 6e 66 69 |.#include "confi| 00000340 67 2e 68 22 0a 0a 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a |g.h".../********| 00000350 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| 00000360 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 2f 2a 20 50 |**********/./* P| 00000370 72 6f 67 72 61 6d 20 6d 61 63 72 6f 73 20 61 6e |rogram macros an| 00000380 64 20 64 65 66 69 6e 69 74 69 6f 6e 73 20 2a 2f |d definitions */| 00000390 0a 0a 23 64 65 66 69 6e 65 20 54 49 54 4c 45 20 |..#define TITLE | 000003a0 22 46 69 6c 65 20 6a 6f 69 6e 65 72 2e 20 20 56 |"File joiner. V| 000003b0 65 72 73 69 6f 6e 20 31 2e 31 33 20 2d 20 34 74 |ersion 1.13 - 4t| 000003c0 68 20 46 65 62 75 72 61 72 79 20 31 39 39 35 20 |h Feburary 1995 | 000003d0 62 79 20 41 2e 48 61 6d 69 6c 74 6f 6e 5c 6e 5c |by A.Hamilton\n\| 000003e0 6e 22 0a 23 69 66 6e 64 65 66 20 42 6f 6f 6c 0a |n".#ifndef Bool.| 000003f0 23 20 20 64 65 66 69 6e 65 20 42 6f 6f 6c 20 63 |# define Bool c| 00000400 68 61 72 0a 23 65 6e 64 69 66 0a 23 64 65 66 69 |har.#endif.#defi| 00000410 6e 65 20 46 61 6c 73 65 20 20 20 30 0a 23 64 65 |ne False 0.#de| 00000420 66 69 6e 65 20 54 72 75 65 20 20 20 20 21 46 61 |fine True !Fa| 00000430 6c 73 65 0a 23 64 65 66 69 6e 65 20 4d 49 4e 28 |lse.#define MIN(| 00000440 61 2c 20 62 29 20 28 61 20 3c 20 62 20 3f 20 61 |a, b) (a < b ? a| 00000450 20 3a 20 62 29 0a 23 64 65 66 69 6e 65 20 4d 41 | : b).#define MA| 00000460 58 28 61 2c 20 62 29 20 28 61 20 3e 20 62 20 3f |X(a, b) (a > b ?| 00000470 20 61 20 3a 20 62 29 0a 0a 0a 0a 2f 2a 2a 2a 2a | a : b)..../****| 00000480 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 000004c0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 2f 2a |************/./*| 000004d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f | */| 00000520 0a 2f 2a 20 46 75 6e 63 74 69 6f 6e 20 20 20 20 |./* Function | 00000530 3a 20 75 73 61 67 65 20 20 20 20 20 20 20 20 20 |: usage | 00000540 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000570 20 2a 2f 0a 2f 2a 20 44 65 73 63 72 69 70 74 69 | */./* Descripti| 00000580 6f 6e 20 3a 20 44 69 73 70 6c 61 79 73 20 70 72 |on : Displays pr| 00000590 6f 67 72 61 6d 20 75 73 61 67 65 20 74 6f 20 73 |ogram usage to s| 000005a0 74 61 6e 64 61 72 64 20 65 72 72 6f 72 2c 20 61 |tandard error, a| 000005b0 6e 64 20 65 78 69 74 73 2e 20 20 20 20 20 20 20 |nd exits. | 000005c0 20 20 20 20 2a 2f 0a 2f 2a 20 41 72 67 75 6d 65 | */./* Argume| 000005d0 6e 74 73 20 20 20 3a 20 70 72 6f 67 6e 61 6d 65 |nts : progname| 000005e0 20 2d 20 70 6f 69 6e 74 65 72 20 74 6f 20 63 68 | - pointer to ch| 000005f0 61 72 61 63 74 65 72 20 73 74 72 69 6e 67 20 63 |aracter string c| 00000600 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 70 72 |ontaining the pr| 00000610 6f 67 72 61 6d 20 20 2a 2f 0a 2f 2a 20 20 20 20 |ogram */./* | 00000620 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000630 20 20 20 20 20 20 6e 61 6d 65 2e 20 20 20 20 20 | name. | 00000640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000660 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 | */./* | 00000670 52 65 74 75 72 6e 73 20 20 20 20 20 3a 20 4e 6f |Returns : No| 00000680 6e 65 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 |ne. | 00000690 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000006b0 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 000006c0 2f 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |/* | 000006d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000710 2a 2f 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |*/./************| 00000720 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000760 2a 2a 2a 2a 2f 0a 0a 0a 76 6f 69 64 20 75 73 61 |****/...void usa| 00000770 67 65 20 28 63 68 61 72 20 2a 70 72 6f 67 6e 61 |ge (char *progna| 00000780 6d 65 29 0a 7b 0a 20 20 66 70 72 69 6e 74 66 20 |me).{. fprintf | 00000790 28 73 74 64 65 72 72 2c 20 54 49 54 4c 45 29 3b |(stderr, TITLE);| 000007a0 0a 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 |. fprintf (stde| 000007b0 72 72 2c 20 22 55 73 61 67 65 20 3a 20 25 73 20 |rr, "Usage : %s | 000007c0 5b 6f 70 74 69 6f 6e 73 5d 20 3c 66 69 6c 65 6e |[options] <filen| 000007d0 61 6d 65 3e 5c 6e 5c 6e 22 2c 20 70 72 6f 67 6e |ame>\n\n", progn| 000007e0 61 6d 65 29 3b 0a 20 20 66 70 72 69 6e 74 66 20 |ame);. fprintf | 000007f0 28 73 74 64 65 72 72 2c 20 22 4f 70 74 69 6f 6e |(stderr, "Option| 00000800 73 20 28 63 61 6e 20 62 65 20 61 62 62 72 65 76 |s (can be abbrev| 00000810 69 61 74 65 64 29 20 3a 5c 6e 22 29 3b 0a 23 69 |iated) :\n");.#i| 00000820 66 6e 64 65 66 20 50 43 0a 20 20 66 70 72 69 6e |fndef PC. fprin| 00000830 74 66 20 28 73 74 64 65 72 72 2c 20 22 20 20 20 |tf (stderr, " | 00000840 20 2d 62 75 66 66 65 72 73 69 7a 65 20 20 20 5b | -buffersize [| 00000850 62 75 66 66 65 72 73 69 7a 65 20 69 6e 20 4b 5d |buffersize in K]| 00000860 20 20 20 20 20 20 20 20 64 65 66 61 75 6c 74 20 | default | 00000870 3d 20 33 32 5c 6e 22 29 3b 0a 23 65 6e 64 69 66 |= 32\n");.#endif| 00000880 0a 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 |. fprintf (stde| 00000890 72 72 2c 20 22 20 20 20 20 2d 66 69 6c 65 6e 61 |rr, " -filena| 000008a0 6d 65 20 20 20 20 20 5b 6e 65 77 20 66 69 6c 65 |me [new file| 000008b0 6e 61 6d 65 5d 5c 6e 22 29 3b 0a 20 20 66 70 72 |name]\n");. fpr| 000008c0 69 6e 74 66 20 28 73 74 64 65 72 72 2c 20 22 20 |intf (stderr, " | 000008d0 20 20 20 2d 69 6e 74 65 72 61 63 74 69 76 65 5c | -interactive\| 000008e0 6e 22 29 3b 0a 20 20 66 70 72 69 6e 74 66 20 28 |n");. fprintf (| 000008f0 73 74 64 65 72 72 2c 20 22 20 20 20 20 2d 69 6e |stderr, " -in| 00000900 66 6f 5c 6e 22 29 3b 0a 0a 20 20 65 78 69 74 20 |fo\n");.. exit | 00000910 28 45 58 49 54 5f 46 41 49 4c 55 52 45 29 3b 0a |(EXIT_FAILURE);.| 00000920 7d 0a 0a 0a 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |}..../**********| 00000930 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000970 2a 2a 2a 2a 2a 2a 2f 0a 2f 2a 20 20 20 20 20 20 |******/./* | 00000980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000009c0 20 20 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 46 75 | */./* Fu| 000009d0 6e 63 74 69 6f 6e 20 20 20 20 3a 20 65 78 61 6d |nction : exam| 000009e0 69 6e 65 5f 66 69 6c 65 6e 61 6d 65 20 20 20 20 |ine_filename | 000009f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000a10 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f 2a | */./*| 00000a20 20 44 65 73 63 72 69 70 74 69 6f 6e 20 3a 20 53 | Description : S| 00000a30 70 6c 69 74 73 20 66 69 6c 65 6e 61 6d 65 20 69 |plits filename i| 00000a40 6e 74 6f 20 63 6f 6d 70 6f 6e 65 6e 74 20 70 61 |nto component pa| 00000a50 72 74 73 2e 20 20 20 20 20 20 20 20 20 20 20 20 |rts. | 00000a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f | */| 00000a70 0a 2f 2a 20 41 72 67 75 6d 65 6e 74 73 20 20 20 |./* Arguments | 00000a80 3a 20 6f 72 69 67 69 6e 61 6c 5f 6e 61 6d 65 20 |: original_name | 00000a90 2d 20 63 68 61 72 61 63 74 65 72 20 61 72 72 61 |- character arra| 00000aa0 79 2c 20 66 69 6c 65 6e 61 6d 65 20 74 6f 20 62 |y, filename to b| 00000ab0 65 20 65 78 61 6d 69 6e 65 64 2e 20 20 20 20 20 |e examined. | 00000ac0 20 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 20 20 | */./* | 00000ad0 20 20 20 20 20 6e 61 6d 65 20 20 20 20 20 20 20 | name | 00000ae0 20 20 20 2d 20 70 6f 69 6e 74 65 72 20 74 6f 20 | - pointer to | 00000af0 61 20 63 68 61 72 61 63 74 65 72 20 61 72 72 61 |a character arra| 00000b00 79 20 69 6e 20 77 68 69 63 68 20 74 6f 20 73 74 |y in which to st| 00000b10 6f 72 65 20 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 |ore */./* | 00000b20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000b30 20 20 20 20 20 20 20 20 66 69 6c 65 20 6c 65 61 | file lea| 00000b40 66 6e 61 6d 65 20 28 65 78 63 6c 75 64 69 6e 67 |fname (excluding| 00000b50 20 65 78 74 65 6e 74 69 6f 6e 29 2e 20 20 20 20 | extention). | 00000b60 20 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 20 20 20 | */./* | 00000b70 20 20 20 20 20 20 20 20 20 20 20 70 61 74 68 20 | path | 00000b80 20 20 20 20 20 20 20 20 20 2d 20 70 6f 69 6e 74 | - point| 00000b90 65 72 20 74 6f 20 61 20 63 68 61 72 61 63 74 65 |er to a characte| 00000ba0 72 20 61 72 72 61 79 20 69 6e 20 77 68 69 63 68 |r array in which| 00000bb0 20 74 6f 20 73 74 6f 72 65 20 2a 2f 0a 2f 2a 20 | to store */./* | 00000bc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000bd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 | th| 00000be0 65 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 66 69 |e destination fi| 00000bf0 6c 65 73 20 70 61 74 68 2e 20 20 20 20 20 20 20 |les path. | 00000c00 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 00000c10 2f 2a 20 52 65 74 75 72 6e 73 20 20 20 20 20 3a |/* Returns :| 00000c20 20 49 66 20 74 68 65 20 64 65 73 74 69 6e 61 74 | If the destinat| 00000c30 69 6f 6e 20 66 69 6c 65 20 68 61 73 20 61 6e 20 |ion file has an | 00000c40 65 78 74 65 6e 74 69 6f 6e 2c 20 74 68 65 6e 20 |extention, then | 00000c50 72 65 74 75 72 6e 20 69 74 2c 20 20 20 20 20 20 |return it, | 00000c60 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 20 20 20 |*/./* | 00000c70 20 20 20 20 6f 74 68 65 72 77 69 73 65 20 72 65 | otherwise re| 00000c80 74 75 72 6e 20 22 22 2e 20 20 20 20 20 20 20 20 |turn "". | 00000c90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000cb0 20 20 20 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 | */./* | 00000cc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000d00 20 20 20 20 20 20 2a 2f 0a 2f 2a 2a 2a 2a 2a 2a | */./******| 00000d10 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000d50 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 0a 0a 63 68 |**********/...ch| 00000d60 61 72 20 2a 65 78 61 6d 69 6e 65 5f 66 69 6c 65 |ar *examine_file| 00000d70 6e 61 6d 65 20 28 63 68 61 72 20 6f 72 69 67 69 |name (char origi| 00000d80 6e 61 6c 5f 6e 61 6d 65 5b 5d 2c 20 63 68 61 72 |nal_name[], char| 00000d90 20 2a 6e 61 6d 65 2c 20 63 68 61 72 20 2a 70 61 | *name, char *pa| 00000da0 74 68 29 0a 7b 0a 20 20 63 68 61 72 20 6d 61 69 |th).{. char mai| 00000db0 6e 5f 6e 61 6d 65 5b 32 35 36 5d 3b 20 20 20 20 |n_name[256]; | 00000dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00000dd0 20 54 65 6d 70 6f 72 61 72 79 20 73 74 6f 72 65 | Temporary store| 00000de0 20 66 6f 72 20 6c 65 61 66 6e 61 6d 65 2e 20 20 | for leafname. | 00000df0 20 20 20 20 20 20 2a 2f 0a 20 20 63 68 61 72 20 | */. char | 00000e00 2a 6f 72 69 67 69 6e 61 6c 3b 20 20 20 20 20 20 |*original; | 00000e10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000e20 20 2f 2a 20 50 6f 69 6e 74 65 72 20 74 6f 20 73 | /* Pointer to s| 00000e30 74 61 72 74 20 6f 66 20 6c 65 61 66 6e 61 6d 65 |tart of leafname| 00000e40 2e 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 63 68 |. */. ch| 00000e50 61 72 20 65 78 74 5b 33 32 5d 3b 0a 20 20 63 68 |ar ext[32];. ch| 00000e60 61 72 20 2a 70 6f 69 6e 74 65 72 3b 20 20 20 20 |ar *pointer; | 00000e70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000e80 20 20 20 20 2f 2a 20 50 6f 69 6e 74 65 72 20 74 | /* Pointer t| 00000e90 6f 20 61 6e 79 20 27 3a 27 20 63 68 61 72 61 63 |o any ':' charac| 00000ea0 74 65 72 73 20 66 6f 75 6e 64 2e 20 2a 2f 0a 20 |ters found. */. | 00000eb0 20 72 65 67 69 73 74 65 72 20 69 6e 74 20 69 20 | register int i | 00000ec0 3d 20 2d 31 2c 20 6e 3b 20 20 20 20 20 20 20 20 |= -1, n; | 00000ed0 20 20 20 20 20 20 20 2f 2a 20 50 6f 69 6e 74 65 | /* Pointe| 00000ee0 72 20 26 20 63 6f 75 6e 74 65 72 2e 20 20 20 20 |r & counter. | 00000ef0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 00000f00 2f 0a 0a 20 20 69 66 20 28 43 4f 4c 4f 4e 29 20 |/.. if (COLON) | 00000f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000f40 20 20 20 2f 2a 20 49 66 20 6f 75 72 20 73 79 73 | /* If our sys| 00000f50 74 65 6d 20 75 73 65 73 20 27 3a 27 20 69 6e 20 |tem uses ':' in | 00000f60 20 20 20 2a 2f 0a 20 20 20 20 70 6f 69 6e 74 65 | */. pointe| 00000f70 72 20 3d 20 73 74 72 72 63 68 72 20 28 6f 72 69 |r = strrchr (ori| 00000f80 67 69 6e 61 6c 5f 6e 61 6d 65 2c 20 27 3a 27 29 |ginal_name, ':')| 00000f90 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00000fa0 20 20 20 20 20 20 2f 2a 20 74 68 65 20 66 69 6c | /* the fil| 00000fb0 65 20 70 61 74 68 2c 20 74 68 65 6e 20 72 65 6d |e path, then rem| 00000fc0 65 6d 62 65 72 20 2a 2f 0a 20 20 65 6c 73 65 20 |ember */. else | 00000fd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001000 20 20 20 20 20 20 20 20 20 2f 2a 20 77 68 65 72 | /* wher| 00001010 65 20 69 74 20 69 73 2e 20 20 20 20 20 20 20 20 |e it is. | 00001020 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 | */. | 00001030 70 6f 69 6e 74 65 72 20 3d 20 4e 55 4c 4c 3b 0a |pointer = NULL;.| 00001040 0a 20 20 6f 72 69 67 69 6e 61 6c 20 3d 20 73 74 |. original = st| 00001050 72 72 63 68 72 20 28 6f 72 69 67 69 6e 61 6c 5f |rrchr (original_| 00001060 6e 61 6d 65 2c 20 53 45 50 41 52 41 54 4f 52 5f |name, SEPARATOR_| 00001070 53 45 41 52 43 48 29 3b 20 20 20 20 20 20 20 20 |SEARCH); | 00001080 20 2f 2a 20 46 69 6e 64 20 74 68 65 20 61 64 64 | /* Find the add| 00001090 72 65 73 73 20 77 68 65 72 65 20 74 68 65 20 20 |ress where the | 000010a0 20 2a 2f 0a 20 20 69 66 20 28 28 6f 72 69 67 69 | */. if ((origi| 000010b0 6e 61 6c 20 3d 20 4d 41 58 20 28 6f 72 69 67 69 |nal = MAX (origi| 000010c0 6e 61 6c 2c 20 70 6f 69 6e 74 65 72 29 29 20 3d |nal, pointer)) =| 000010d0 3d 20 4e 55 4c 4c 29 20 20 20 20 20 20 20 20 20 |= NULL) | 000010e0 20 20 20 20 2f 2a 20 6c 65 61 66 6e 61 6d 65 20 | /* leafname | 000010f0 73 74 61 72 74 73 2e 20 20 20 20 20 20 20 20 20 |starts. | 00001100 20 20 20 20 2a 2f 0a 20 20 20 20 6f 72 69 67 69 | */. origi| 00001110 6e 61 6c 20 3d 20 6f 72 69 67 69 6e 61 6c 5f 6e |nal = original_n| 00001120 61 6d 65 3b 0a 20 20 65 6c 73 65 20 7b 0a 20 20 |ame;. else {. | 00001130 20 20 6f 72 69 67 69 6e 61 6c 2b 2b 3b 0a 20 20 | original++;. | 00001140 20 20 73 74 72 6e 63 70 79 20 28 70 61 74 68 2c | strncpy (path,| 00001150 20 6f 72 69 67 69 6e 61 6c 5f 6e 61 6d 65 2c 20 | original_name, | 00001160 6f 72 69 67 69 6e 61 6c 20 2d 20 6f 72 69 67 69 |original - origi| 00001170 6e 61 6c 5f 6e 61 6d 65 29 3b 20 20 20 20 2f 2a |nal_name); /*| 00001180 20 47 65 74 20 74 68 65 20 70 61 74 68 2e 20 20 | Get the path. | 00001190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f | */| 000011a0 0a 20 20 20 20 70 61 74 68 5b 6f 72 69 67 69 6e |. path[origin| 000011b0 61 6c 20 2d 20 6f 72 69 67 69 6e 61 6c 5f 6e 61 |al - original_na| 000011c0 6d 65 5d 20 3d 20 27 5c 30 27 3b 0a 20 20 7d 0a |me] = '\0';. }.| 000011d0 0a 20 20 64 6f 20 7b 0a 20 20 20 20 69 2b 2b 3b |. do {. i++;| 000011e0 0a 20 20 20 20 6d 61 69 6e 5f 6e 61 6d 65 5b 69 |. main_name[i| 000011f0 5d 20 3d 20 6f 72 69 67 69 6e 61 6c 5b 69 5d 3b |] = original[i];| 00001200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001220 20 2f 2a 20 47 65 74 20 66 69 6c 65 73 20 6c 65 | /* Get files le| 00001230 61 66 6e 61 6d 65 20 20 20 20 20 20 20 20 20 20 |afname | 00001240 20 2a 2f 0a 20 20 7d 20 77 68 69 6c 65 20 28 6d | */. } while (m| 00001250 61 69 6e 5f 6e 61 6d 65 5b 69 5d 20 21 3d 20 27 |ain_name[i] != '| 00001260 2e 27 20 26 26 20 6d 61 69 6e 5f 6e 61 6d 65 5b |.' && main_name[| 00001270 69 5d 20 21 3d 20 27 5c 30 27 29 3b 20 20 20 20 |i] != '\0'); | 00001280 20 20 20 20 2f 2a 20 28 65 78 63 6c 75 64 69 6e | /* (excludin| 00001290 67 20 61 6e 79 20 65 78 74 65 6e 74 69 6f 6e 29 |g any extention)| 000012a0 2e 20 20 20 2a 2f 0a 0a 20 20 6d 61 69 6e 5f 6e |. */.. main_n| 000012b0 61 6d 65 5b 69 20 2d 20 32 5d 20 3d 20 27 5c 30 |ame[i - 2] = '\0| 000012c0 27 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |'; | 000012d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000012e0 20 20 20 20 20 20 20 20 2f 2a 20 43 6f 70 79 20 | /* Copy | 000012f0 74 68 65 20 6c 65 61 66 6e 61 6d 65 2e 20 20 20 |the leafname. | 00001300 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 73 74 72 | */. str| 00001310 63 70 79 20 28 6e 61 6d 65 2c 20 6d 61 69 6e 5f |cpy (name, main_| 00001320 6e 61 6d 65 29 3b 0a 0a 20 20 69 66 20 28 6d 61 |name);.. if (ma| 00001330 69 6e 5f 6e 61 6d 65 5b 69 5d 20 3d 3d 20 27 5c |in_name[i] == '\| 00001340 30 27 29 20 20 20 20 20 20 20 20 20 20 20 20 20 |0') | 00001350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001360 2f 2a 20 49 66 20 74 68 65 20 66 69 6c 65 20 64 |/* If the file d| 00001370 6f 65 73 6e 27 74 20 68 61 76 65 20 61 6e 20 20 |oesn't have an | 00001380 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 72 | */. r| 00001390 65 74 75 72 6e 20 28 22 22 29 3b 20 20 20 20 20 |eturn (""); | 000013a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000013c0 20 20 20 2f 2a 20 65 78 74 65 6e 74 69 6f 6e 20 | /* extention | 000013d0 72 65 74 75 72 6e 20 61 6e 20 65 6d 70 74 79 20 |return an empty | 000013e0 73 74 72 69 6e 67 2e 20 20 20 20 2a 2f 0a 0a 20 |string. */.. | 000013f0 20 66 6f 72 20 28 6e 20 3d 20 30 3b 20 28 65 78 | for (n = 0; (ex| 00001400 74 5b 6e 5d 20 3d 20 6f 72 69 67 69 6e 61 6c 5b |t[n] = original[| 00001410 69 5d 29 20 21 3d 20 27 5c 30 27 3b 20 6e 2b 2b |i]) != '\0'; n++| 00001420 2c 20 69 2b 2b 29 20 3b 20 20 20 20 20 20 20 2f |, i++) ; /| 00001430 2a 20 4f 74 68 65 72 77 69 73 65 20 67 65 74 20 |* Otherwise get | 00001440 74 68 65 20 65 78 74 65 6e 74 69 6f 6e 20 20 2a |the extention *| 00001450 2f 0a 20 20 72 65 74 75 72 6e 20 28 65 78 74 29 |/. return (ext)| 00001460 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00001470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001490 20 20 2f 2a 20 61 6e 64 20 72 65 74 75 72 6e 20 | /* and return | 000014a0 69 74 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 |it. | 000014b0 20 20 2a 2f 0a 7d 0a 0a 0a 0a 2f 2a 2a 2a 2a 2a | */.}..../*****| 000014c0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00001500 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 2f 2a 20 |***********/./* | 00001510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001550 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 00001560 2f 2a 20 46 75 6e 63 74 69 6f 6e 20 20 20 20 3a |/* Function :| 00001570 20 6e 75 6d 74 6f 73 74 72 20 20 20 20 20 20 20 | numtostr | 00001580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000015b0 2a 2f 0a 2f 2a 20 44 65 73 63 72 69 70 74 69 6f |*/./* Descriptio| 000015c0 6e 20 3a 20 43 6f 6e 76 65 72 74 73 20 61 20 6e |n : Converts a n| 000015d0 75 6d 62 65 72 20 69 6e 74 6f 20 61 20 32 20 64 |umber into a 2 d| 000015e0 69 64 67 65 74 20 63 68 61 72 61 63 74 65 72 20 |idget character | 000015f0 73 74 72 69 6e 67 2e 20 20 20 20 20 20 20 20 20 |string. | 00001600 20 20 20 2a 2f 0a 2f 2a 20 41 72 67 75 6d 65 6e | */./* Argumen| 00001610 74 73 20 20 20 3a 20 6e 75 6d 62 65 72 20 2d 20 |ts : number - | 00001620 6e 75 6d 62 65 72 20 74 6f 20 62 65 20 63 6f 6e |number to be con| 00001630 76 65 72 74 65 64 2e 20 20 20 20 20 20 20 20 20 |verted. | 00001640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001650 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 20 20 20 20 | */./* | 00001660 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 20 20 | name | 00001670 20 2d 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 | - pointer to a | 00001680 63 68 61 72 61 63 74 65 72 20 61 72 72 61 79 20 |character array | 00001690 74 6f 20 73 74 6f 72 65 20 74 68 65 20 6e 75 6d |to store the num| 000016a0 62 65 72 2e 20 20 20 20 20 2a 2f 0a 2f 2a 20 52 |ber. */./* R| 000016b0 65 74 75 72 6e 73 20 20 20 20 20 3a 20 4e 6f 6e |eturns : Non| 000016c0 65 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |e. | 000016d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000016f0 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f | */./| 00001700 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |* | 00001710 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001740 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 00001750 2f 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |/./*************| 00001760 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 000017a0 2a 2a 2a 2f 0a 0a 0a 76 6f 69 64 20 6e 75 6d 74 |***/...void numt| 000017b0 6f 73 74 72 20 28 73 68 6f 72 74 20 6e 75 6d 62 |ostr (short numb| 000017c0 65 72 2c 20 63 68 61 72 20 2a 6e 61 6d 65 29 0a |er, char *name).| 000017d0 7b 0a 20 20 6e 61 6d 65 5b 30 5d 20 3d 20 28 73 |{. name[0] = (s| 000017e0 68 6f 72 74 29 20 28 6e 75 6d 62 65 72 20 2f 20 |hort) (number / | 000017f0 31 30 29 20 2b 20 27 30 27 3b 0a 20 20 6e 61 6d |10) + '0';. nam| 00001800 65 5b 31 5d 20 3d 20 28 6e 75 6d 62 65 72 20 25 |e[1] = (number %| 00001810 20 31 30 29 20 2b 20 27 30 27 3b 0a 20 20 6e 61 | 10) + '0';. na| 00001820 6d 65 5b 32 5d 20 3d 20 27 5c 30 27 3b 0a 7d 0a |me[2] = '\0';.}.| 00001830 0a 0a 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |.../************| 00001840 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00001880 2a 2a 2a 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 |****/./* | 00001890 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000018d0 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 46 75 6e 63 | */./* Func| 000018e0 74 69 6f 6e 20 20 20 20 3a 20 6d 61 69 6e 20 20 |tion : main | 000018f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001920 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 44 | */./* D| 00001930 65 73 63 72 69 70 74 69 6f 6e 20 3a 20 4d 61 69 |escription : Mai| 00001940 6e 20 63 6f 6e 74 72 6f 6c 20 66 75 6e 63 74 69 |n control functi| 00001950 6f 6e 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 |on. | 00001960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001970 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2f | */./| 00001980 2a 20 41 72 67 75 6d 65 6e 74 73 20 20 20 3a 20 |* Arguments : | 00001990 43 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 70 61 72 |Command line par| 000019a0 61 6d 65 74 65 72 73 2e 20 20 20 20 20 20 20 20 |ameters. | 000019b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000019c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 000019d0 2f 0a 2f 2a 20 52 65 74 75 72 6e 73 20 20 20 20 |/./* Returns | 000019e0 20 3a 20 45 78 69 74 20 73 74 61 74 75 73 2e 20 | : Exit status. | 000019f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001a20 20 20 2a 2f 0a 2f 2a 20 20 20 20 20 20 20 20 20 | */./* | 00001a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001a70 20 20 20 20 20 2a 2f 0a 2f 2a 2a 2a 2a 2a 2a 2a | */./*******| 00001a80 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00001ac0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 0a 0a 69 6e 74 |*********/...int| 00001ad0 20 6d 61 69 6e 20 28 69 6e 74 20 61 72 67 63 2c | main (int argc,| 00001ae0 20 63 68 61 72 20 2a 61 72 67 76 5b 5d 29 0a 7b | char *argv[]).{| 00001af0 0a 20 20 63 68 61 72 20 20 73 6f 75 72 63 65 5f |. char source_| 00001b00 66 69 6c 65 6e 61 6d 65 5b 32 35 36 5d 3b 20 20 |filename[256]; | 00001b10 20 20 20 20 20 20 20 20 20 2f 2a 20 53 6f 75 72 | /* Sour| 00001b20 63 65 20 66 69 6c 65 6e 61 6d 65 2e 20 20 20 20 |ce filename. | 00001b30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001b40 20 2a 2f 0a 20 20 63 68 61 72 20 20 6f 75 74 5f | */. char out_| 00001b50 66 69 6c 65 6e 61 6d 65 5b 32 35 36 5d 3b 20 20 |filename[256]; | 00001b60 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f | /* O| 00001b70 75 74 70 75 74 20 6c 65 61 66 6e 61 6d 65 2e 20 |utput leafname. | 00001b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001b90 20 20 20 20 2a 2f 0a 20 20 63 68 61 72 20 20 69 | */. char i| 00001ba0 6e 5f 70 61 74 68 5b 32 35 36 5d 3b 20 20 20 20 |n_path[256]; | 00001bb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 00001bc0 2a 20 49 6e 70 75 74 20 70 61 74 68 2e 20 20 20 |* Input path. | 00001bd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001be0 20 20 20 20 20 20 20 2a 2f 0a 20 20 63 68 61 72 | */. char| 00001bf0 20 20 66 69 6c 65 5f 65 78 74 5b 33 32 5d 3b 20 | file_ext[32]; | 00001c00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001c10 20 20 2f 2a 20 4f 75 74 70 75 74 20 65 78 74 65 | /* Output exte| 00001c20 6e 74 69 6f 6e 2e 20 20 20 20 20 20 20 20 20 20 |ntion. | 00001c30 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 63 | */. c| 00001c40 68 61 72 20 20 6f 75 74 5f 6e 61 6d 65 5b 32 35 |har out_name[25| 00001c50 36 5d 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |6]; | 00001c60 20 20 20 20 20 2f 2a 20 46 75 6c 6c 20 6f 75 74 | /* Full out| 00001c70 70 75 74 20 66 69 6c 65 6e 61 6d 65 2e 20 20 20 |put filename. | 00001c80 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 00001c90 20 20 63 68 61 72 20 20 68 65 61 64 65 72 5b 35 | char header[5| 00001ca0 30 5d 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |0]; | 00001cb0 20 20 20 20 20 20 20 20 2f 2a 20 4f 75 74 70 75 | /* Outpu| 00001cc0 74 20 66 69 6c 65 20 68 65 61 64 65 72 2e 20 20 |t file header. | 00001cd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001ce0 2a 2f 0a 20 20 63 68 61 72 20 20 66 6e 75 6d 5b |*/. char fnum[| 00001cf0 33 5d 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |3]; | 00001d00 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 75 | /* Ou| 00001d10 74 70 75 74 20 70 61 72 74 20 6e 75 6d 62 65 72 |tput part number| 00001d20 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00001d30 20 20 20 2a 2f 0a 20 20 63 68 61 72 20 20 2a 70 | */. char *p| 00001d40 72 6f 67 6e 61 6d 65 3b 20 20 20 20 20 20 20 20 |rogname; | 00001d50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00001d60 20 50 72 6f 67 72 61 6d 20 6e 61 6d 65 2e 20 20 | Program name. | 00001d70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001d80 20 20 20 20 20 20 2a 2f 0a 20 20 63 68 61 72 20 | */. char | 00001d90 20 73 74 72 69 6e 67 5b 32 35 36 5d 3b 20 20 20 | string[256]; | 00001da0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001db0 20 2f 2a 20 49 6e 70 75 74 20 73 74 72 69 6e 67 | /* Input string| 00001dc0 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00001dd0 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 63 68 | */. ch| 00001de0 61 72 20 20 74 79 70 65 5b 35 5d 3b 20 20 20 20 |ar type[5]; | 00001df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001e00 20 20 20 20 2f 2a 20 46 69 6c 65 74 79 70 65 20 | /* Filetype | 00001e10 28 41 63 6f 72 6e 20 73 79 73 74 65 6d 73 20 6f |(Acorn systems o| 00001e20 6e 6c 79 29 2e 20 20 20 20 20 20 20 2a 2f 0a 20 |nly). */. | 00001e30 20 63 68 61 72 20 20 69 6e 74 65 72 61 63 74 69 | char interacti| 00001e40 76 65 20 3d 20 30 3b 20 20 20 20 20 20 20 20 20 |ve = 0; | 00001e50 20 20 20 20 20 20 20 2f 2a 20 49 6e 74 65 72 61 | /* Intera| 00001e60 63 74 69 76 65 20 73 74 61 74 75 73 20 66 6c 61 |ctive status fla| 00001e70 67 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 2a |g. *| 00001e80 2f 0a 20 20 63 68 61 72 20 20 73 6f 75 72 63 65 |/. char source| 00001e90 5f 6e 61 6d 65 5b 32 35 36 5d 3b 0a 20 20 63 68 |_name[256];. ch| 00001ea0 61 72 20 20 63 68 65 63 6b 5f 6e 61 6d 65 5b 32 |ar check_name[2| 00001eb0 35 36 5d 3b 0a 0a 20 20 73 68 6f 72 74 20 66 69 |56];.. short fi| 00001ec0 6c 65 5f 6e 75 6d 62 65 72 20 3d 20 30 3b 20 20 |le_number = 0; | 00001ed0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00001ee0 20 43 75 72 72 65 6e 74 20 70 61 72 74 20 6e 75 | Current part nu| 00001ef0 6d 62 65 72 2e 20 20 20 20 20 20 20 20 20 20 20 |mber. | 00001f00 20 20 20 20 20 20 2a 2f 0a 20 20 73 68 6f 72 74 | */. short| 00001f10 20 63 68 65 63 6b 5f 6e 75 6d 62 65 72 3b 0a 20 | check_number;. | 00001f20 20 6c 6f 6e 67 20 20 72 65 61 64 5f 73 69 7a 65 | long read_size| 00001f30 20 3d 20 33 32 20 2a 20 31 30 32 34 3b 20 20 20 | = 32 * 1024; | 00001f40 20 20 20 20 20 20 20 2f 2a 20 42 75 66 66 65 72 | /* Buffer| 00001f50 20 73 69 7a 65 20 28 64 65 66 61 75 6c 74 20 33 | size (default 3| 00001f60 32 4b 29 2e 20 20 20 20 20 20 20 20 20 20 20 2a |2K). *| 00001f70 2f 0a 20 20 6c 6f 6e 67 20 20 6f 75 74 5f 70 6f |/. long out_po| 00001f80 73 69 74 69 6f 6e 3b 20 20 20 20 20 20 20 20 20 |sition; | 00001f90 20 20 20 20 20 20 20 20 20 20 2f 2a 20 50 6f 73 | /* Pos| 00001fa0 69 74 69 6f 6e 20 77 69 74 68 69 6e 20 6f 75 74 |ition within out| 00001fb0 70 75 74 20 66 69 6c 65 2e 20 20 20 20 20 20 20 |put file. | 00001fc0 20 20 2a 2f 0a 20 20 6c 6f 6e 67 20 20 69 6e 5f | */. long in_| 00001fd0 70 6f 73 69 74 69 6f 6e 3b 20 20 20 20 20 20 20 |position; | 00001fe0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00001ff0 50 6f 73 69 74 69 6f 6e 20 77 69 74 68 69 6e 20 |Position within | 00002000 69 6e 70 75 74 20 66 69 6c 65 2e 20 20 20 20 20 |input file. | 00002010 20 20 20 20 20 2a 2f 0a 20 20 6c 6f 6e 67 20 20 | */. long | 00002020 62 79 74 65 73 5f 72 65 61 64 3b 20 20 20 20 20 |bytes_read; | 00002030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002040 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 62 79 74 |/* Number of byt| 00002050 65 73 20 72 65 61 64 2e 20 20 20 20 20 20 20 20 |es read. | 00002060 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 6c 6f 6e | */. lon| 00002070 67 20 20 62 79 74 65 73 5f 77 72 69 74 74 65 6e |g bytes_written| 00002080 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00002090 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 | /* Number of | 000020a0 62 79 74 65 73 20 77 72 69 74 74 65 6e 2e 20 20 |bytes written. | 000020b0 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 | */. | 000020c0 6c 6f 6e 67 20 20 66 69 6c 65 5f 6c 65 6e 67 74 |long file_lengt| 000020d0 68 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |h; | 000020e0 20 20 20 20 20 20 2f 2a 20 4c 65 6e 67 74 68 20 | /* Length | 000020f0 6f 66 20 73 6f 75 72 63 65 20 66 69 6c 65 2e 20 |of source file. | 00002100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f | */| 00002110 0a 20 20 6c 6f 6e 67 20 20 2a 62 75 66 66 65 72 |. long *buffer| 00002120 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00002130 20 20 20 20 20 20 20 20 20 2f 2a 20 50 6f 69 6e | /* Poin| 00002140 74 65 72 20 74 6f 20 62 75 66 66 65 72 2e 20 20 |ter to buffer. | 00002150 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002160 20 2a 2f 0a 20 20 69 6e 74 20 20 20 74 6f 74 61 | */. int tota| 00002170 6c 5f 6e 75 6d 62 65 72 3b 20 20 20 20 20 20 20 |l_number; | 00002180 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 | /* T| 00002190 6f 74 61 6c 20 6e 75 6d 62 65 72 20 6f 66 20 70 |otal number of p| 000021a0 61 72 74 73 20 74 6f 20 6a 6f 69 6e 2e 20 20 20 |arts to join. | 000021b0 20 20 20 20 2a 2f 0a 20 20 69 6e 74 20 20 20 61 | */. int a| 000021c0 72 67 73 3b 20 20 20 20 20 20 20 20 20 20 20 20 |rgs; | 000021d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 000021e0 2a 20 4e 75 6d 62 65 72 20 6f 66 20 63 6f 6d 6d |* Number of comm| 000021f0 61 6e 64 20 6c 69 6e 65 20 61 72 67 75 6d 65 6e |and line argumen| 00002200 74 73 2e 20 20 20 20 2a 2f 0a 20 20 69 6e 74 20 |ts. */. int | 00002210 20 20 69 2c 20 6e 3b 20 20 20 20 20 20 20 20 20 | i, n; | 00002220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002230 20 20 2f 2a 20 43 6f 75 6e 74 65 72 73 2e 20 20 | /* Counters. | 00002240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002250 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 42 | */. B| 00002260 6f 6f 6c 20 20 69 6e 66 6f 20 3d 20 46 61 6c 73 |ool info = Fals| 00002270 65 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |e; | 00002280 20 20 20 20 20 2f 2a 20 44 69 73 70 6c 61 79 20 | /* Display | 00002290 69 6e 66 6f 72 6d 61 74 69 6f 6e 3f 20 20 20 20 |information? | 000022a0 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 000022b0 20 20 46 49 4c 45 20 20 2a 73 6f 75 72 63 65 5f | FILE *source_| 000022c0 66 69 6c 65 3b 20 20 20 20 20 20 20 20 20 20 20 |file; | 000022d0 20 20 20 20 20 20 20 20 2f 2a 20 53 6f 75 72 63 | /* Sourc| 000022e0 65 20 66 69 6c 65 20 49 44 2e 20 20 20 20 20 20 |e file ID. | 000022f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002300 2a 2f 0a 20 20 46 49 4c 45 20 20 2a 6f 75 74 5f |*/. FILE *out_| 00002310 66 69 6c 65 3b 20 20 20 20 20 20 20 20 20 20 20 |file; | 00002320 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 75 | /* Ou| 00002330 74 70 75 74 20 66 69 6c 65 20 49 44 2e 20 20 20 |tput file ID. | 00002340 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002350 20 20 20 2a 2f 0a 0a 20 20 73 74 61 74 69 63 20 | */.. static | 00002360 63 68 61 72 20 73 70 6c 69 74 68 31 5b 5d 3d 22 |char splith1[]="| 00002370 53 70 6c 69 74 3a 22 3b 20 20 20 20 20 20 20 2f |Split:"; /| 00002380 2a 20 50 61 72 74 20 31 20 68 65 61 64 65 72 20 |* Part 1 header | 00002390 63 68 65 63 6b 20 73 74 72 69 6e 67 2e 20 20 20 |check string. | 000023a0 20 20 20 20 20 20 20 2a 2f 0a 20 20 73 74 61 74 | */. stat| 000023b0 69 63 20 63 68 61 72 20 73 70 6c 69 74 68 32 5b |ic char splith2[| 000023c0 5d 3d 22 53 70 3a 22 3b 20 20 20 20 20 20 20 20 |]="Sp:"; | 000023d0 20 20 2f 2a 20 50 61 72 74 20 3e 31 20 68 65 61 | /* Part >1 hea| 000023e0 64 65 72 20 63 68 65 63 6b 20 73 74 72 69 6e 67 |der check string| 000023f0 2e 20 20 20 20 20 20 20 20 20 2a 2f 0a 0a 0a 23 |. */...#| 00002400 69 66 64 65 66 20 41 43 4f 52 4e 0a 20 20 5f 6b |ifdef ACORN. _k| 00002410 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 72 |ernel_swi_regs r| 00002420 65 67 73 3b 0a 20 20 5f 6b 65 72 6e 65 6c 5f 6f |egs;. _kernel_o| 00002430 73 65 72 72 6f 72 20 2a 65 72 72 3b 0a 23 65 6e |serror *err;.#en| 00002440 64 69 66 0a 0a 20 20 70 72 6f 67 6e 61 6d 65 20 |dif.. progname | 00002450 3d 20 2a 61 72 67 76 3b 20 20 20 20 20 20 20 20 |= *argv; | 00002460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002470 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00002480 47 65 74 20 74 68 65 20 70 72 6f 67 72 61 6d 20 |Get the program | 00002490 6e 61 6d 65 2e 20 20 20 20 20 20 20 20 20 20 20 |name. | 000024a0 20 20 20 20 20 2a 2f 0a 0a 20 20 69 6e 5f 70 61 | */.. in_pa| 000024b0 74 68 5b 30 5d 20 3d 20 27 5c 30 27 3b 20 20 20 |th[0] = '\0'; | 000024c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000024e0 20 2f 2a 20 53 65 74 20 70 61 74 68 20 74 6f 20 | /* Set path to | 000024f0 43 57 44 2e 20 20 20 20 20 20 20 20 20 20 20 20 |CWD. | 00002500 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 6f 75 | */. ou| 00002510 74 5f 66 69 6c 65 6e 61 6d 65 5b 30 5d 20 3d 20 |t_filename[0] = | 00002520 27 5c 30 27 3b 20 20 20 20 20 20 20 20 20 20 20 |'\0'; | 00002530 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002540 20 20 20 20 2f 2a 20 43 6c 65 61 72 20 64 65 73 | /* Clear des| 00002550 74 69 6e 61 74 69 6f 6e 20 66 69 6c 65 6e 61 6d |tination filenam| 00002560 65 2e 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 |e. */. | 00002570 20 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 | source_filename| 00002580 5b 30 5d 20 3d 20 27 5c 30 27 3b 20 20 20 20 20 |[0] = '\0'; | 00002590 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000025a0 20 20 20 20 20 20 20 2f 2a 20 43 6c 65 61 72 20 | /* Clear | 000025b0 73 6f 75 72 63 65 20 66 69 6c 65 6e 61 6d 65 2e |source filename.| 000025c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 000025d0 2f 0a 0a 20 20 61 72 67 73 20 3d 20 61 72 67 63 |/.. args = argc| 000025e0 20 2d 20 31 3b 20 20 20 20 20 20 20 20 20 20 20 | - 1; | 000025f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002600 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 49 6e | /* In| 00002610 69 74 69 61 6c 69 73 65 20 63 6f 75 6e 74 20 6f |itialise count o| 00002620 66 20 61 72 67 75 6d 65 6e 74 73 2e 20 20 20 20 |f arguments. | 00002630 20 20 20 2a 2f 0a 20 20 69 66 20 28 21 61 72 67 | */. if (!arg| 00002640 73 29 20 75 73 61 67 65 20 28 70 72 6f 67 6e 61 |s) usage (progna| 00002650 6d 65 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 |me); | 00002660 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00002670 20 49 66 20 6e 6f 20 61 72 67 75 6d 65 6e 74 73 | If no arguments| 00002680 20 73 75 70 70 6c 69 65 64 2c 20 73 68 6f 77 20 | supplied, show | 00002690 75 73 61 67 65 2e 2a 2f 0a 0a 20 20 77 68 69 6c |usage.*/.. whil| 000026a0 65 20 28 61 72 67 73 2d 2d 29 20 7b 0a 20 20 20 |e (args--) {. | 000026b0 20 61 72 67 76 2b 2b 3b 20 20 20 20 20 20 20 20 | argv++; | 000026c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000026e0 20 20 20 20 20 2f 2a 20 4c 6f 6f 6b 20 61 74 20 | /* Look at | 000026f0 6e 65 78 74 20 61 72 67 75 6d 65 6e 74 2e 20 20 |next argument. | 00002700 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a | */.| 00002710 0a 20 20 20 20 69 66 20 28 21 73 74 72 6e 63 6d |. if (!strncm| 00002720 70 20 28 22 2d 66 69 6c 65 6e 61 6d 65 22 2c 20 |p ("-filename", | 00002730 2a 61 72 67 76 2c 20 4d 41 58 20 28 32 2c 20 73 |*argv, MAX (2, s| 00002740 74 72 6c 65 6e 20 28 2a 61 72 67 76 29 29 29 29 |trlen (*argv))))| 00002750 20 7b 20 20 20 20 20 20 20 2f 2a 20 2d 66 69 6c | { /* -fil| 00002760 65 6e 61 6d 65 20 20 20 20 20 20 20 20 20 20 20 |ename | 00002770 20 2a 2f 0a 20 20 20 20 20 20 69 66 20 28 21 61 | */. if (!a| 00002780 72 67 73 29 20 7b 0a 20 20 20 20 20 20 20 20 66 |rgs) {. f| 00002790 70 72 69 6e 74 66 20 28 73 74 64 65 72 72 2c 20 |printf (stderr, | 000027a0 22 46 69 6c 65 6e 61 6d 65 20 72 65 71 75 69 72 |"Filename requir| 000027b0 65 64 5c 6e 5c 6e 22 29 3b 0a 20 20 20 20 20 20 |ed\n\n");. | 000027c0 20 20 75 73 61 67 65 20 28 70 72 6f 67 6e 61 6d | usage (prognam| 000027d0 65 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 |e);. }. | 000027e0 20 20 73 74 72 63 70 79 20 28 6f 75 74 5f 66 69 | strcpy (out_fi| 000027f0 6c 65 6e 61 6d 65 2c 20 2a 2b 2b 61 72 67 76 29 |lename, *++argv)| 00002800 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00002810 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002820 20 20 20 20 2f 2a 20 52 65 61 64 20 6f 75 74 70 | /* Read outp| 00002830 75 74 20 66 69 6c 65 6e 61 6d 65 2e 2a 2f 0a 20 |ut filename.*/. | 00002840 20 20 20 20 20 61 72 67 73 2d 2d 3b 0a 20 20 20 | args--;. | 00002850 20 7d 0a 0a 23 69 66 6e 64 65 66 20 50 43 0a 20 | }..#ifndef PC. | 00002860 20 20 20 65 6c 73 65 20 69 66 20 28 21 73 74 72 | else if (!str| 00002870 6e 63 6d 70 20 28 22 2d 62 75 66 66 65 72 73 69 |ncmp ("-buffersi| 00002880 7a 65 22 2c 20 2a 61 72 67 76 2c 20 4d 41 58 20 |ze", *argv, MAX | 00002890 28 32 2c 20 73 74 72 6c 65 6e 20 28 2a 61 72 67 |(2, strlen (*arg| 000028a0 76 29 29 29 29 20 7b 20 20 20 20 20 20 20 20 2f |v)))) { /| 000028b0 2a 20 2d 62 75 66 66 65 72 73 69 7a 65 20 20 2a |* -buffersize *| 000028c0 2f 0a 20 20 20 20 20 20 69 66 20 28 21 61 72 67 |/. if (!arg| 000028d0 73 29 20 7b 0a 09 66 70 72 69 6e 74 66 20 28 73 |s) {..fprintf (s| 000028e0 74 64 65 72 72 2c 20 22 42 75 66 66 65 72 20 73 |tderr, "Buffer s| 000028f0 69 7a 65 20 72 65 71 75 69 72 65 64 5c 6e 5c 6e |ize required\n\n| 00002900 22 29 3b 0a 09 75 73 61 67 65 20 28 70 72 6f 67 |");..usage (prog| 00002910 6e 61 6d 65 29 3b 0a 20 20 20 20 20 20 7d 0a 20 |name);. }. | 00002920 20 20 20 20 20 72 65 61 64 5f 73 69 7a 65 20 3d | read_size =| 00002930 20 28 6c 6f 6e 67 29 20 61 74 6f 69 20 28 2a 2b | (long) atoi (*+| 00002940 2b 61 72 67 76 29 20 2a 20 31 30 32 34 3b 20 20 |+argv) * 1024; | 00002950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002960 20 20 20 20 20 20 20 2f 2a 20 52 65 61 64 20 62 | /* Read b| 00002970 75 66 66 65 72 20 73 69 7a 65 2e 20 20 20 20 2a |uffer size. *| 00002980 2f 0a 20 20 20 20 20 20 61 72 67 73 2d 2d 3b 0a |/. args--;.| 00002990 20 20 20 20 7d 0a 23 65 6e 64 69 66 0a 0a 20 20 | }.#endif.. | 000029a0 20 20 65 6c 73 65 20 69 66 20 28 21 73 74 72 6e | else if (!strn| 000029b0 63 6d 70 20 28 22 2d 69 6e 74 65 72 61 63 74 69 |cmp ("-interacti| 000029c0 76 65 22 2c 20 2a 61 72 67 76 2c 20 4d 41 58 20 |ve", *argv, MAX | 000029d0 28 32 2c 20 73 74 72 6c 65 6e 20 28 2a 61 72 67 |(2, strlen (*arg| 000029e0 76 29 29 29 29 20 2f 2a 20 2d 69 6e 74 65 72 61 |v)))) /* -intera| 000029f0 63 74 69 76 65 20 20 20 20 20 20 20 20 20 2a 2f |ctive */| 00002a00 0a 20 20 20 20 20 20 69 6e 74 65 72 61 63 74 69 |. interacti| 00002a10 76 65 20 3d 20 31 3b 0a 0a 20 20 20 20 65 6c 73 |ve = 1;.. els| 00002a20 65 20 69 66 20 28 21 73 74 72 6e 63 6d 70 20 28 |e if (!strncmp (| 00002a30 22 2d 69 6e 66 6f 22 2c 20 2a 61 72 67 76 2c 20 |"-info", *argv, | 00002a40 4d 41 58 20 28 33 2c 20 73 74 72 6c 65 6e 20 28 |MAX (3, strlen (| 00002a50 2a 61 72 67 76 29 29 29 29 20 20 20 20 20 20 20 |*argv)))) | 00002a60 20 2f 2a 20 2d 69 6e 66 6f 20 20 20 20 20 20 20 | /* -info | 00002a70 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 | */. | 00002a80 20 20 69 6e 66 6f 20 3d 20 54 72 75 65 3b 0a 0a | info = True;..| 00002a90 20 20 20 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 | else {. | 00002aa0 20 73 74 72 63 70 79 20 28 73 6f 75 72 63 65 5f | strcpy (source_| 00002ab0 66 69 6c 65 6e 61 6d 65 2c 20 2a 61 72 67 76 29 |filename, *argv)| 00002ac0 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00002ad0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002ae0 20 20 20 2f 2a 20 52 65 61 64 20 73 6f 75 72 63 | /* Read sourc| 00002af0 65 20 66 69 6c 65 6e 61 6d 65 2e 2a 2f 0a 20 20 |e filename.*/. | 00002b00 20 20 20 20 69 66 20 28 61 72 67 73 29 20 75 73 | if (args) us| 00002b10 61 67 65 20 28 70 72 6f 67 6e 61 6d 65 29 3b 0a |age (progname);.| 00002b20 20 20 20 20 7d 0a 20 20 7d 0a 0a 20 20 69 66 20 | }. }.. if | 00002b30 28 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 |(source_filename| 00002b40 5b 30 5d 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 20 |[0] == NULL) {. | 00002b50 20 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 | fprintf (stde| 00002b60 72 72 2c 20 22 53 6f 75 72 63 65 20 66 69 6c 65 |rr, "Source file| 00002b70 6e 61 6d 65 20 72 65 71 75 69 72 65 64 5c 6e 5c |name required\n\| 00002b80 6e 22 29 3b 0a 20 20 20 20 75 73 61 67 65 20 28 |n");. usage (| 00002b90 70 72 6f 67 6e 61 6d 65 29 3b 0a 20 20 7d 0a 0a |progname);. }..| 00002ba0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00002bd0 20 20 20 20 20 20 20 20 2f 2a 20 47 65 74 20 66 | /* Get f| 00002be0 69 6c 65 20 64 65 74 61 69 6c 20 66 72 6f 6d 20 |ile detail from | 00002bf0 73 6f 75 72 63 65 20 66 69 6c 65 6e 61 6d 65 2e |source filename.| 00002c00 2a 2f 0a 20 20 73 74 72 63 70 79 20 28 66 69 6c |*/. strcpy (fil| 00002c10 65 5f 65 78 74 2c 20 65 78 61 6d 69 6e 65 5f 66 |e_ext, examine_f| 00002c20 69 6c 65 6e 61 6d 65 20 28 73 6f 75 72 63 65 5f |ilename (source_| 00002c30 66 69 6c 65 6e 61 6d 65 2c 20 73 6f 75 72 63 65 |filename, source| 00002c40 5f 6e 61 6d 65 2c 20 69 6e 5f 70 61 74 68 29 29 |_name, in_path))| 00002c50 3b 0a 0a 20 20 73 6f 75 72 63 65 5f 66 69 6c 65 |;.. source_file| 00002c60 20 3d 20 66 6f 70 65 6e 20 28 73 6f 75 72 63 65 | = fopen (source| 00002c70 5f 66 69 6c 65 6e 61 6d 65 2c 20 22 72 62 22 29 |_filename, "rb")| 00002c80 3b 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 70 |; /* Op| 00002c90 65 6e 20 72 65 61 64 20 62 69 6e 61 72 79 20 73 |en read binary s| 00002ca0 6f 75 72 63 65 20 66 69 6c 65 2e 20 20 20 20 20 |ource file. | 00002cb0 20 20 20 2a 2f 0a 20 20 69 66 20 28 73 6f 75 72 | */. if (sour| 00002cc0 63 65 5f 66 69 6c 65 20 3d 3d 20 4e 55 4c 4c 29 |ce_file == NULL)| 00002cd0 20 7b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | { | 00002ce0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00002cf0 20 52 65 70 6f 72 74 20 69 66 20 65 72 72 6f 72 | Report if error| 00002d00 2c 20 61 6e 64 20 73 74 6f 70 2e 20 20 20 20 20 |, and stop. | 00002d10 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 66 70 72 | */. fpr| 00002d20 69 6e 74 66 20 28 73 74 64 65 72 72 2c 20 22 46 |intf (stderr, "F| 00002d30 61 74 61 6c 20 65 72 72 6f 72 20 6f 70 65 6e 69 |atal error openi| 00002d40 6e 67 20 25 73 20 66 6f 72 20 69 6e 70 75 74 2e |ng %s for input.| 00002d50 5c 6e 22 2c 20 73 6f 75 72 63 65 5f 66 69 6c 65 |\n", source_file| 00002d60 6e 61 6d 65 29 3b 0a 20 20 20 20 65 78 69 74 20 |name);. exit | 00002d70 28 45 58 49 54 5f 46 41 49 4c 55 52 45 29 3b 0a |(EXIT_FAILURE);.| 00002d80 20 20 7d 0a 0a 20 20 69 20 3d 20 30 3b 20 20 20 | }.. i = 0; | 00002d90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00002dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00002dd0 49 6e 69 74 69 61 6c 69 73 65 20 63 6f 75 6e 74 |Initialise count| 00002de0 65 72 2e 20 20 2a 2f 0a 20 20 77 68 69 6c 65 20 |er. */. while | 00002df0 28 28 68 65 61 64 65 72 5b 69 2b 2b 5d 20 3d 20 |((header[i++] = | 00002e00 66 67 65 74 63 20 28 73 6f 75 72 63 65 5f 66 69 |fgetc (source_fi| 00002e10 6c 65 29 29 20 21 3d 20 27 7c 27 20 26 26 20 69 |le)) != '|' && i| 00002e20 20 3c 20 33 30 30 29 20 3b 20 20 20 20 20 20 20 | < 300) ; | 00002e30 2f 2a 20 52 65 61 64 20 66 69 6c 65 20 68 65 61 |/* Read file hea| 00002e40 64 65 72 2c 20 20 20 20 2a 2f 0a 20 20 66 6f 72 |der, */. for| 00002e50 20 28 69 20 3d 20 30 3b 20 69 20 3c 20 36 3b 20 | (i = 0; i < 6; | 00002e60 69 2b 2b 29 20 69 66 20 28 68 65 61 64 65 72 5b |i++) if (header[| 00002e70 69 5d 20 21 3d 20 73 70 6c 69 74 68 31 5b 69 5d |i] != splith1[i]| 00002e80 29 20 7b 20 20 20 20 20 20 20 20 2f 2a 20 61 6e |) { /* an| 00002e90 64 20 63 6f 6d 70 61 72 65 20 77 69 74 68 20 74 |d compare with t| 00002ea0 65 6d 70 6c 61 74 65 2e 20 20 20 2a 2f 0a 20 20 |emplate. */. | 00002eb0 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 72 | fprintf (stder| 00002ec0 72 2c 22 46 61 74 61 6c 20 65 72 72 6f 72 2c 20 |r,"Fatal error, | 00002ed0 6e 6f 20 73 70 6c 69 74 20 68 65 61 64 65 72 20 |no split header | 00002ee0 69 6e 20 66 69 6c 65 20 25 73 5c 6e 22 2c 20 73 |in file %s\n", s| 00002ef0 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 29 3b |ource_filename);| 00002f00 0a 20 20 20 20 66 63 6c 6f 73 65 20 28 73 6f 75 |. fclose (sou| 00002f10 72 63 65 5f 66 69 6c 65 29 3b 0a 20 20 20 20 65 |rce_file);. e| 00002f20 78 69 74 20 28 45 58 49 54 5f 46 41 49 4c 55 52 |xit (EXIT_FAILUR| 00002f30 45 29 3b 0a 20 20 7d 0a 0a 20 20 66 73 65 65 6b |E);. }.. fseek| 00002f40 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 2c 20 30 | (source_file, 0| 00002f50 4c 2c 20 53 45 45 4b 5f 45 4e 44 29 3b 20 20 20 |L, SEEK_END); | 00002f60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002f70 20 2f 2a 20 53 65 74 20 66 69 6c 65 20 70 6f 69 | /* Set file poi| 00002f80 6e 74 65 72 20 74 6f 20 65 6e 64 20 6f 66 20 66 |nter to end of f| 00002f90 69 6c 65 2c 20 20 20 20 20 2a 2f 0a 20 20 66 69 |ile, */. fi| 00002fa0 6c 65 5f 6c 65 6e 67 74 68 20 3d 20 66 74 65 6c |le_length = ftel| 00002fb0 6c 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 29 3b |l (source_file);| 00002fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002fd0 20 20 20 20 2f 2a 20 67 65 74 20 66 69 6c 65 20 | /* get file | 00002fe0 6c 65 6e 67 74 68 20 20 20 20 20 20 20 20 20 20 |length | 00002ff0 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 | */. | 00003000 20 66 73 65 65 6b 20 28 73 6f 75 72 63 65 5f 66 | fseek (source_f| 00003010 69 6c 65 2c 20 30 4c 2c 20 53 45 45 4b 5f 53 45 |ile, 0L, SEEK_SE| 00003020 54 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |T); | 00003030 20 20 20 20 20 20 20 2f 2a 20 61 6e 64 20 72 65 | /* and re| 00003040 73 65 74 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 |set pointer to t| 00003050 68 65 20 73 74 61 72 74 2e 20 20 20 20 20 20 2a |he start. *| 00003060 2f 0a 0a 20 20 6e 20 3d 20 30 3b 20 20 20 20 20 |/.. n = 0; | 00003070 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000030a0 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 49 6e | /* In| 000030b0 69 74 69 61 6c 69 73 65 20 63 6f 75 6e 74 65 72 |itialise counter| 000030c0 2e 20 20 2a 2f 0a 23 69 66 64 65 66 20 41 43 4f |. */.#ifdef ACO| 000030d0 52 4e 0a 20 20 77 68 69 6c 65 20 28 68 65 61 64 |RN. while (head| 000030e0 65 72 5b 69 5d 20 21 3d 20 27 3d 27 29 20 7b 20 |er[i] != '=') { | 000030f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003110 20 20 20 2f 2a 20 45 78 74 72 61 63 74 20 6f 75 | /* Extract ou| 00003120 74 70 75 74 20 66 69 6c 65 6e 61 6d 65 2c 20 20 |tput filename, | 00003130 20 20 20 2a 2f 0a 20 20 20 20 6f 75 74 5f 6e 61 | */. out_na| 00003140 6d 65 5b 6e 2b 2b 5d 20 3d 20 28 68 65 61 64 65 |me[n++] = (heade| 00003150 72 5b 69 5d 20 3d 3d 20 27 2e 27 20 3f 20 27 2f |r[i] == '.' ? '/| 00003160 27 20 3a 20 68 65 61 64 65 72 5b 69 5d 29 3b 20 |' : header[i]); | 00003170 20 20 20 20 20 20 2f 2a 20 73 77 61 70 70 69 6e | /* swappin| 00003180 67 20 61 6e 79 20 27 2e 27 20 61 6e 64 20 27 2f |g any '.' and '/| 00003190 27 20 20 20 20 20 2a 2f 0a 20 20 20 20 69 2b 2b |' */. i++| 000031a0 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 000031b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000031d0 20 20 20 20 20 20 20 20 20 2f 2a 20 63 68 61 72 | /* char| 000031e0 61 63 74 65 72 73 2e 20 20 20 20 20 20 20 20 20 |acters. | 000031f0 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 7d 0a | */. }.| 00003200 20 20 6e 2b 2b 3b 0a 20 20 69 2b 2b 3b 0a 23 65 | n++;. i++;.#e| 00003210 6c 73 65 0a 20 20 77 68 69 6c 65 20 28 28 6f 75 |lse. while ((ou| 00003220 74 5f 6e 61 6d 65 5b 6e 2b 2b 5d 20 3d 20 68 65 |t_name[n++] = he| 00003230 61 64 65 72 5b 69 2b 2b 5d 29 20 21 3d 20 27 3d |ader[i++]) != '=| 00003240 27 29 20 3b 20 20 20 20 20 20 20 20 20 20 20 20 |') ; | 00003250 20 20 20 20 2f 2a 20 4a 75 73 74 20 65 78 74 72 | /* Just extr| 00003260 61 63 74 20 74 68 65 20 66 69 6c 65 6e 61 6d 65 |act the filename| 00003270 2c 20 20 20 2a 2f 0a 23 65 6e 64 69 66 0a 0a 20 |, */.#endif.. | 00003280 20 6f 75 74 5f 6e 61 6d 65 5b 2d 2d 6e 5d 20 3d | out_name[--n] =| 00003290 20 27 5c 30 27 3b 20 20 20 20 20 20 20 20 20 20 | '\0'; | 000032a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000032b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 000032c0 2a 20 74 65 72 6d 69 6e 61 74 65 20 69 74 20 70 |* terminate it p| 000032d0 72 6f 70 65 72 6c 79 2c 20 20 20 20 20 20 20 2a |roperly, *| 000032e0 2f 0a 20 20 69 66 20 28 6f 75 74 5f 66 69 6c 65 |/. if (out_file| 000032f0 6e 61 6d 65 5b 30 5d 20 3d 3d 20 27 5c 30 27 29 |name[0] == '\0')| 00003300 20 73 74 72 63 70 79 20 28 6f 75 74 5f 66 69 6c | strcpy (out_fil| 00003310 65 6e 61 6d 65 2c 20 6f 75 74 5f 6e 61 6d 65 29 |ename, out_name)| 00003320 3b 20 2f 2a 20 61 6e 64 20 63 6f 70 79 2e 20 20 |; /* and copy. | 00003330 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003340 20 20 2a 2f 0a 0a 20 20 6e 20 3d 20 30 3b 20 20 | */.. n = 0; | 00003350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003380 20 20 20 20 20 20 2f 2a 20 49 6e 69 74 69 61 6c | /* Initial| 00003390 69 73 65 20 63 6f 75 6e 74 65 72 2e 20 20 20 20 |ise counter. | 000033a0 20 20 20 20 20 20 2a 2f 0a 20 20 77 68 69 6c 65 | */. while| 000033b0 20 28 28 66 6e 75 6d 5b 6e 2b 2b 5d 20 3d 20 68 | ((fnum[n++] = h| 000033c0 65 61 64 65 72 5b 69 2b 2b 5d 29 20 21 3d 20 27 |eader[i++]) != '| 000033d0 3d 27 29 20 3b 20 20 20 20 20 20 20 20 20 20 20 |=') ; | 000033e0 20 20 20 20 20 20 20 20 20 2f 2a 20 47 65 74 20 | /* Get | 000033f0 74 68 65 20 74 6f 74 61 6c 20 6e 75 6d 62 65 72 |the total number| 00003400 20 6f 66 20 20 20 20 20 20 2a 2f 0a 20 20 66 6e | of */. fn| 00003410 75 6d 5b 2d 2d 6e 5d 20 3d 20 27 5c 30 27 3b 20 |um[--n] = '\0'; | 00003420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003440 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 70 | /* p| 00003450 61 72 74 73 2e 20 20 20 20 20 20 20 20 20 20 20 |arts. | 00003460 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 | */. | 00003470 20 74 6f 74 61 6c 5f 6e 75 6d 62 65 72 20 3d 20 | total_number = | 00003480 61 74 6f 69 20 28 66 6e 75 6d 29 3b 0a 0a 20 20 |atoi (fnum);.. | 00003490 6e 20 3d 20 30 3b 20 20 20 20 20 20 20 20 20 20 |n = 0; | 000034a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000034c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 000034d0 20 49 6e 69 74 69 61 6c 69 73 65 20 63 6f 75 6e | Initialise coun| 000034e0 74 65 72 2e 20 20 20 20 20 20 20 20 20 20 2a 2f |ter. */| 000034f0 0a 20 20 77 68 69 6c 65 20 28 28 74 79 70 65 5b |. while ((type[| 00003500 6e 2b 2b 5d 20 3d 20 68 65 61 64 65 72 5b 69 2b |n++] = header[i+| 00003510 2b 5d 29 20 21 3d 20 27 7c 27 29 20 3b 20 20 20 |+]) != '|') ; | 00003520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003530 20 2f 2a 20 52 65 61 64 20 74 68 65 20 66 69 6c | /* Read the fil| 00003540 65 74 79 70 65 20 64 61 74 61 2e 20 20 20 20 20 |etype data. | 00003550 20 2a 2f 0a 20 20 74 79 70 65 5b 2d 2d 6e 5d 20 | */. type[--n] | 00003560 3d 20 27 5c 30 27 3b 0a 0a 20 20 69 66 20 28 69 |= '\0';.. if (i| 00003570 6e 66 6f 29 20 7b 20 20 20 20 20 20 20 20 20 20 |nfo) { | 00003580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000035a0 20 20 20 20 20 20 20 20 20 2f 2a 20 49 66 20 2d | /* If -| 000035b0 69 6e 66 6f 20 73 65 6c 65 63 74 65 64 2c 20 6f |info selected, o| 000035c0 6e 6c 79 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 |nly */. | 000035d0 70 72 69 6e 74 66 20 28 54 49 54 4c 45 29 3b 20 |printf (TITLE); | 000035e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003600 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 70 | /* p| 00003610 72 69 6e 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e |rint information| 00003620 2e 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 |. */. | 00003630 20 20 20 70 72 69 6e 74 66 20 28 22 49 6e 66 6f | printf ("Info| 00003640 72 6d 61 74 69 6f 6e 20 3a 5c 6e 5c 6e 22 29 3b |rmation :\n\n");| 00003650 0a 20 20 20 20 70 72 69 6e 74 66 20 28 22 20 20 |. printf (" | 00003660 20 20 4f 75 74 70 75 74 20 66 69 6c 65 6e 61 6d | Output filenam| 00003670 65 20 69 73 20 25 73 22 2c 20 6f 75 74 5f 66 69 |e is %s", out_fi| 00003680 6c 65 6e 61 6d 65 29 3b 0a 0a 23 69 66 64 65 66 |lename);..#ifdef| 00003690 20 41 43 4f 52 4e 0a 20 20 20 20 69 66 20 28 74 | ACORN. if (t| 000036a0 79 70 65 5b 30 5d 20 3d 3d 20 27 74 27 29 20 7b |ype[0] == 't') {| 000036b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000036d0 20 20 20 20 20 20 20 2f 2a 20 49 66 20 74 68 65 | /* If the| 000036e0 20 66 69 6c 65 20 63 6f 6e 74 61 69 6e 73 20 20 | file contains | 000036f0 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 | */. | 00003700 70 72 69 6e 74 66 20 28 22 2c 20 66 69 6c 65 74 |printf (", filet| 00003710 79 70 65 20 22 29 3b 20 20 20 20 20 20 20 20 20 |ype "); | 00003720 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003730 20 20 20 20 20 20 20 20 20 20 2f 2a 20 66 69 6c | /* fil| 00003740 65 74 79 70 65 20 64 61 74 61 20 74 68 65 6e 20 |etype data then | 00003750 73 68 6f 77 20 69 74 2e 20 20 2a 2f 0a 20 20 20 |show it. */. | 00003760 20 20 20 66 6f 72 20 28 6e 20 3d 20 31 3b 20 74 | for (n = 1; t| 00003770 79 70 65 5b 6e 5d 20 21 3d 20 27 5c 30 27 3b 20 |ype[n] != '\0'; | 00003780 6e 2b 2b 29 0a 20 20 20 20 20 20 20 20 70 72 69 |n++). pri| 00003790 6e 74 66 20 28 22 25 63 22 2c 20 74 6f 75 70 70 |ntf ("%c", toupp| 000037a0 65 72 28 74 79 70 65 5b 6e 5d 29 29 3b 0a 20 20 |er(type[n]));. | 000037b0 20 20 7d 0a 23 65 6e 64 69 66 0a 0a 20 20 20 20 | }.#endif.. | 000037c0 70 72 69 6e 74 66 20 28 22 5c 6e 22 29 3b 0a 20 |printf ("\n");. | 000037d0 20 20 20 62 79 74 65 73 5f 72 65 61 64 20 3d 20 | bytes_read = | 000037e0 30 3b 0a 20 20 7d 0a 20 20 65 6c 73 65 20 7b 20 |0;. }. else { | 000037f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003810 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 00003820 2a 20 2d 69 6e 66 6f 20 6e 6f 74 20 73 65 6c 65 |* -info not sele| 00003830 63 74 65 64 2c 20 64 6f 20 74 68 65 20 6a 6f 69 |cted, do the joi| 00003840 6e 69 6e 67 2e 20 20 2a 2f 0a 0a 20 20 20 20 62 |ning. */.. b| 00003850 75 66 66 65 72 20 3d 20 28 6c 6f 6e 67 20 2a 29 |uffer = (long *)| 00003860 20 6d 61 6c 6c 6f 63 20 28 28 73 69 7a 65 5f 74 | malloc ((size_t| 00003870 29 20 72 65 61 64 5f 73 69 7a 65 29 3b 20 20 20 |) read_size); | 00003880 20 20 20 2f 2a 20 41 6c 6c 6f 63 61 74 65 20 6d | /* Allocate m| 00003890 65 6d 6f 72 79 20 66 6f 72 20 61 20 62 75 66 66 |emory for a buff| 000038a0 65 72 2e 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 |er. */. | 000038b0 20 20 69 66 20 28 62 75 66 66 65 72 20 3d 3d 20 | if (buffer == | 000038c0 4e 55 4c 4c 29 20 7b 0a 20 20 20 20 20 20 66 70 |NULL) {. fp| 000038d0 72 69 6e 74 66 20 28 73 74 64 65 72 72 2c 20 22 |rintf (stderr, "| 000038e0 46 61 74 61 6c 20 65 72 72 6f 72 2c 20 75 6e 61 |Fatal error, una| 000038f0 62 6c 65 20 74 6f 20 61 6c 6c 6f 63 61 74 65 20 |ble to allocate | 00003900 6d 65 6d 6f 72 79 20 62 6c 6f 63 6b 20 6f 66 20 |memory block of | 00003910 25 6c 64 20 62 79 74 65 73 5c 6e 22 2c 20 72 65 |%ld bytes\n", re| 00003920 61 64 5f 73 69 7a 65 29 3b 0a 20 20 20 20 20 20 |ad_size);. | 00003930 65 78 69 74 20 28 45 58 49 54 5f 46 41 49 4c 55 |exit (EXIT_FAILU| 00003940 52 45 29 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 |RE);. }.. | 00003950 70 72 69 6e 74 66 20 28 22 55 73 69 6e 67 20 62 |printf ("Using b| 00003960 75 66 66 65 72 20 73 69 7a 65 20 6f 66 20 25 6c |uffer size of %l| 00003970 64 20 62 79 74 65 73 2e 5c 6e 22 2c 20 72 65 61 |d bytes.\n", rea| 00003980 64 5f 73 69 7a 65 29 3b 0a 0a 23 69 66 64 65 66 |d_size);..#ifdef| 00003990 20 41 43 4f 52 4e 0a 20 20 20 20 72 65 67 73 2e | ACORN. regs.| 000039a0 72 5b 30 5d 20 3d 20 37 3b 20 20 20 20 20 20 20 |r[0] = 7; | 000039b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000039d0 20 20 20 20 20 20 20 2f 2a 20 43 72 65 61 74 65 | /* Create| 000039e0 20 74 68 65 20 66 69 6c 65 20 77 69 74 68 20 53 | the file with S| 000039f0 57 49 20 20 20 20 20 2a 2f 0a 20 20 20 20 72 65 |WI */. re| 00003a00 67 73 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |gs.r[1] = (int) | 00003a10 6f 75 74 5f 66 69 6c 65 6e 61 6d 65 3b 20 20 20 |out_filename; | 00003a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003a30 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 53 5f | /* OS_| 00003a40 46 69 6c 65 20 37 20 20 20 20 20 20 20 20 20 20 |File 7 | 00003a50 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 | */. | 00003a60 20 72 65 67 73 2e 72 5b 32 5d 20 3d 20 30 78 64 | regs.r[2] = 0xd| 00003a70 65 61 64 64 65 61 64 3b 0a 20 20 20 20 72 65 67 |eaddead;. reg| 00003a80 73 2e 72 5b 33 5d 20 3d 20 30 78 64 65 61 64 64 |s.r[3] = 0xdeadd| 00003a90 65 61 64 3b 0a 20 20 20 20 72 65 67 73 2e 72 5b |ead;. regs.r[| 00003aa0 34 5d 20 3d 20 30 3b 0a 20 20 20 20 72 65 67 73 |4] = 0;. regs| 00003ab0 2e 72 5b 35 5d 20 3d 20 28 69 6e 74 29 20 28 66 |.r[5] = (int) (f| 00003ac0 69 6c 65 5f 6c 65 6e 67 74 68 20 2a 20 28 74 6f |ile_length * (to| 00003ad0 74 61 6c 5f 6e 75 6d 62 65 72 20 2d 20 30 2e 35 |tal_number - 0.5| 00003ae0 29 29 3b 20 20 20 20 20 2f 2a 20 75 73 69 6e 67 |)); /* using| 00003af0 20 61 6e 20 65 73 74 69 6d 61 74 65 64 20 73 69 | an estimated si| 00003b00 7a 65 2e 20 20 20 20 20 2a 2f 0a 20 20 20 20 69 |ze. */. i| 00003b10 66 20 28 28 65 72 72 20 3d 20 5f 6b 65 72 6e 65 |f ((err = _kerne| 00003b20 6c 5f 73 77 69 20 28 53 57 49 5f 4f 53 5f 46 69 |l_swi (SWI_OS_Fi| 00003b30 6c 65 2c 20 26 72 65 67 73 2c 20 26 72 65 67 73 |le, ®s, ®s| 00003b40 29 29 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 20 20 |)) != NULL) {. | 00003b50 20 20 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 | fprintf (std| 00003b60 65 72 72 2c 20 22 46 61 74 61 6c 20 65 72 72 6f |err, "Fatal erro| 00003b70 72 20 6f 70 65 6e 69 6e 67 20 25 73 20 66 6f 72 |r opening %s for| 00003b80 20 6f 75 74 70 75 74 3a 5c 6e 2d 2d 20 25 73 5c | output:\n-- %s\| 00003b90 6e 22 2c 20 6f 75 74 5f 66 69 6c 65 6e 61 6d 65 |n", out_filename| 00003ba0 2c 20 65 72 72 2d 3e 65 72 72 6d 65 73 73 29 3b |, err->errmess);| 00003bb0 0a 20 20 20 20 20 20 65 78 69 74 20 28 45 58 49 |. exit (EXI| 00003bc0 54 5f 46 41 49 4c 55 52 45 29 3b 0a 20 20 20 20 |T_FAILURE);. | 00003bd0 7d 0a 23 65 6e 64 69 66 0a 0a 20 20 20 20 6f 75 |}.#endif.. ou| 00003be0 74 5f 66 69 6c 65 20 3d 20 66 6f 70 65 6e 20 28 |t_file = fopen (| 00003bf0 6f 75 74 5f 66 69 6c 65 6e 61 6d 65 2c 20 22 77 |out_filename, "w| 00003c00 62 22 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 |b"); | 00003c10 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 70 65 | /* Ope| 00003c20 6e 20 6f 75 74 70 75 74 20 66 69 6c 65 2e 20 20 |n output file. | 00003c30 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 | */. | 00003c40 20 69 66 20 28 6f 75 74 5f 66 69 6c 65 20 3d 3d | if (out_file ==| 00003c50 20 4e 55 4c 4c 29 20 7b 20 20 20 20 20 20 20 20 | NULL) { | 00003c60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003c70 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00003c80 52 65 70 6f 72 74 20 69 66 20 65 72 72 6f 72 2c |Report if error,| 00003c90 20 61 6e 64 20 73 74 6f 70 2e 20 20 20 2a 2f 0a | and stop. */.| 00003ca0 20 20 20 20 20 20 66 70 72 69 6e 74 66 20 28 73 | fprintf (s| 00003cb0 74 64 65 72 72 2c 20 22 46 61 74 61 6c 20 65 72 |tderr, "Fatal er| 00003cc0 72 6f 72 20 6f 70 65 6e 69 6e 67 20 25 73 20 66 |ror opening %s f| 00003cd0 6f 72 20 6f 75 74 70 75 74 2e 5c 6e 22 2c 20 6f |or output.\n", o| 00003ce0 75 74 5f 66 69 6c 65 6e 61 6d 65 29 3b 0a 20 20 |ut_filename);. | 00003cf0 20 20 20 20 65 78 69 74 20 28 45 58 49 54 5f 46 | exit (EXIT_F| 00003d00 41 49 4c 55 52 45 29 3b 0a 20 20 20 20 7d 0a 20 |AILURE);. }. | 00003d10 20 7d 0a 0a 20 20 6f 75 74 5f 70 6f 73 69 74 69 | }.. out_positi| 00003d20 6f 6e 20 3d 20 30 3b 20 20 20 20 20 20 20 20 20 |on = 0; | 00003d30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003d40 20 20 20 20 2f 2a 20 49 6e 69 74 69 61 6c 69 73 | /* Initialis| 00003d50 65 20 6f 75 74 70 75 74 20 66 69 6c 65 20 70 6f |e output file po| 00003d60 73 69 74 69 6f 6e 20 70 6f 69 6e 74 65 72 2e 20 |sition pointer. | 00003d70 20 20 20 20 2a 2f 0a 0a 20 20 66 6f 72 20 28 66 | */.. for (f| 00003d80 69 6c 65 5f 6e 75 6d 62 65 72 20 3d 20 31 3b 20 |ile_number = 1; | 00003d90 66 69 6c 65 5f 6e 75 6d 62 65 72 20 3c 3d 20 74 |file_number <= t| 00003da0 6f 74 61 6c 5f 6e 75 6d 62 65 72 3b 20 66 69 6c |otal_number; fil| 00003db0 65 5f 6e 75 6d 62 65 72 2b 2b 29 20 7b 20 20 20 |e_number++) { | 00003dc0 2f 2a 20 66 6f 72 20 65 61 63 68 20 70 61 72 74 |/* for each part| 00003dd0 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 6e | */. n| 00003de0 75 6d 74 6f 73 74 72 20 28 66 69 6c 65 5f 6e 75 |umtostr (file_nu| 00003df0 6d 62 65 72 2c 20 66 6e 75 6d 29 3b 0a 20 20 20 |mber, fnum);. | 00003e00 20 77 68 69 6c 65 20 28 69 6e 74 65 72 61 63 74 | while (interact| 00003e10 69 76 65 20 3d 3d 20 31 20 26 26 20 66 69 6c 65 |ive == 1 && file| 00003e20 5f 6e 75 6d 62 65 72 20 3e 20 31 29 20 7b 20 20 |_number > 1) { | 00003e30 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00003e40 49 66 20 2d 69 6e 74 65 72 61 63 74 69 76 65 20 |If -interactive | 00003e50 73 65 6c 65 63 74 65 64 2c 20 20 20 20 2a 2f 0a |selected, */.| 00003e60 20 20 20 20 20 20 70 72 69 6e 74 66 20 28 22 45 | printf ("E| 00003e70 6e 74 65 72 20 70 61 74 68 20 66 6f 72 20 25 73 |nter path for %s| 00003e80 25 73 25 73 20 28 52 65 74 75 72 6e 20 66 6f 72 |%s%s (Return for| 00003e90 20 25 73 29 20 3a 5c 6e 22 2c 20 20 20 20 20 20 | %s) :\n", | 00003ea0 2f 2a 20 61 73 6b 20 66 6f 72 20 6c 6f 63 61 74 |/* ask for locat| 00003eb0 69 6f 6e 20 6f 66 20 6e 65 78 74 20 20 20 20 20 |ion of next | 00003ec0 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 73 6f 75 |*/. sou| 00003ed0 72 63 65 5f 6e 61 6d 65 2c 20 66 6e 75 6d 2c 20 |rce_name, fnum, | 00003ee0 66 69 6c 65 5f 65 78 74 2c 20 20 20 20 20 20 20 |file_ext, | 00003ef0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003f00 20 20 20 2f 2a 20 70 61 72 74 2e 20 20 20 20 20 | /* part. | 00003f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003f20 20 20 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 | */. | 00003f30 69 6e 5f 70 61 74 68 5b 30 5d 20 3d 3d 20 27 5c |in_path[0] == '\| 00003f40 30 27 20 3f 20 22 63 75 72 72 65 6e 74 20 64 69 |0' ? "current di| 00003f50 72 65 63 74 6f 72 79 22 20 3a 20 69 6e 5f 70 61 |rectory" : in_pa| 00003f60 74 68 29 3b 0a 0a 20 20 20 20 20 20 67 65 74 73 |th);.. gets| 00003f70 20 28 73 74 72 69 6e 67 29 3b 20 20 20 20 20 20 | (string); | 00003f80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00003fa0 20 20 20 20 20 20 2f 2a 20 47 65 74 20 6f 75 74 | /* Get out| 00003fb0 70 75 74 20 64 65 73 74 69 6e 61 74 69 6f 6e 2e |put destination.| 00003fc0 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 69 | */. i| 00003fd0 66 20 28 73 74 72 63 68 72 20 28 73 74 72 69 6e |f (strchr (strin| 00003fe0 67 2c 20 27 20 27 29 20 21 3d 20 4e 55 4c 4c 29 |g, ' ') != NULL)| 00003ff0 20 7b 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 | {. print| 00004000 66 20 28 22 49 6e 76 61 6c 69 64 20 70 61 74 68 |f ("Invalid path| 00004010 20 6e 61 6d 65 2e 5c 6e 22 29 3b 0a 20 20 20 20 | name.\n");. | 00004020 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0a 20 20 | continue;. | 00004030 20 20 20 20 7d 0a 0a 20 20 20 20 20 20 69 66 20 | }.. if | 00004040 28 73 74 72 69 6e 67 5b 30 5d 20 21 3d 20 27 5c |(string[0] != '\| 00004050 30 27 29 20 7b 20 20 20 20 20 20 20 20 20 20 20 |0') { | 00004060 20 20 20 20 20 20 20 2f 2a 20 49 66 20 6e 6f 74 | /* If not| 00004070 68 69 6e 67 20 65 6e 74 65 72 65 64 2c 20 74 68 |hing entered, th| 00004080 65 6e 20 75 73 65 20 74 68 65 20 64 65 66 61 75 |en use the defau| 00004090 6c 74 2e 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 |lt. */. | 000040a0 20 20 73 74 72 63 70 79 20 28 69 6e 5f 70 61 74 | strcpy (in_pat| 000040b0 68 2c 20 73 74 72 69 6e 67 29 3b 0a 20 20 20 20 |h, string);. | 000040c0 20 20 20 20 69 20 3d 20 73 74 72 6c 65 6e 20 28 | i = strlen (| 000040d0 69 6e 5f 70 61 74 68 29 3b 0a 20 20 20 20 20 20 |in_path);. | 000040e0 20 20 69 66 20 28 69 6e 5f 70 61 74 68 5b 69 20 | if (in_path[i | 000040f0 2d 20 31 5d 20 21 3d 20 46 49 4c 45 5f 53 45 50 |- 1] != FILE_SEP| 00004100 41 52 41 54 4f 52 29 0a 20 20 20 20 20 20 20 20 |ARATOR). | 00004110 20 20 69 66 20 28 21 43 4f 4c 4f 4e 20 7c 7c 20 | if (!COLON || | 00004120 28 43 4f 4c 4f 4e 20 26 26 20 69 6e 5f 70 61 74 |(COLON && in_pat| 00004130 68 5b 69 20 2d 20 31 5d 20 21 3d 20 27 3a 27 29 |h[i - 1] != ':')| 00004140 29 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 |) {. | 00004150 69 6e 5f 70 61 74 68 5b 69 5d 20 3d 20 46 49 4c |in_path[i] = FIL| 00004160 45 5f 53 45 50 41 52 41 54 4f 52 3b 0a 20 20 20 |E_SEPARATOR;. | 00004170 20 20 20 20 20 20 20 20 20 69 6e 5f 70 61 74 68 | in_path| 00004180 5b 69 20 2b 20 31 5d 20 3d 20 27 5c 30 27 3b 0a |[i + 1] = '\0';.| 00004190 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 20 20 20 | }.. | 000041a0 20 20 20 7d 0a 20 20 20 20 20 20 69 6e 74 65 72 | }. inter| 000041b0 61 63 74 69 76 65 20 3d 20 69 6e 74 65 72 61 63 |active = interac| 000041c0 74 69 76 65 20 7c 20 32 3b 20 20 20 20 20 20 20 |tive | 2; | 000041d0 20 20 20 20 20 2f 2a 20 53 65 74 20 66 6c 61 67 | /* Set flag| 000041e0 20 74 6f 20 73 61 79 20 64 61 74 61 20 68 61 73 | to say data has| 000041f0 20 62 65 65 6e 20 61 63 63 65 70 74 65 64 2e 20 | been accepted. | 00004200 20 20 20 20 20 2a 2f 0a 20 20 20 20 7d 0a 20 20 | */. }. | 00004210 20 20 69 6e 74 65 72 61 63 74 69 76 65 20 3d 20 | interactive = | 00004220 69 6e 74 65 72 61 63 74 69 76 65 20 26 20 31 3b |interactive & 1;| 00004230 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004240 20 20 20 20 20 20 2f 2a 20 4d 61 73 6b 20 6f 66 | /* Mask of| 00004250 66 20 75 6e 72 65 71 75 69 72 65 64 20 64 61 74 |f unrequired dat| 00004260 61 2e 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f |a. */| 00004270 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.. | 00004280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000042a0 20 20 20 20 20 20 20 20 20 20 2f 2a 20 43 72 65 | /* Cre| 000042b0 61 74 65 20 74 68 65 20 66 75 6c 6c 20 69 6e 70 |ate the full inp| 000042c0 75 74 20 66 69 6c 65 6e 61 6d 65 2e 20 20 20 20 |ut filename. | 000042d0 20 20 2a 2f 0a 20 20 20 20 73 70 72 69 6e 74 66 | */. sprintf| 000042e0 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d | (source_filenam| 000042f0 65 2c 20 22 25 73 25 73 25 73 25 73 22 2c 20 69 |e, "%s%s%s%s", i| 00004300 6e 5f 70 61 74 68 2c 20 73 6f 75 72 63 65 5f 6e |n_path, source_n| 00004310 61 6d 65 2c 20 66 6e 75 6d 2c 20 66 69 6c 65 5f |ame, fnum, file_| 00004320 65 78 74 29 3b 0a 0a 20 20 20 20 69 66 20 28 66 |ext);.. if (f| 00004330 69 6c 65 5f 6e 75 6d 62 65 72 20 21 3d 20 31 29 |ile_number != 1)| 00004340 20 7b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | { | 00004350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004360 20 20 20 20 20 20 20 2f 2a 20 49 66 20 69 74 27 | /* If it'| 00004370 73 20 6e 6f 74 20 74 68 65 20 66 69 72 73 74 20 |s not the first | 00004380 70 61 72 74 2c 20 20 2a 2f 0a 20 20 20 20 20 20 |part, */. | 00004390 73 6f 75 72 63 65 5f 66 69 6c 65 20 3d 20 66 6f |source_file = fo| 000043a0 70 65 6e 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 |pen (source_file| 000043b0 6e 61 6d 65 2c 20 22 72 62 22 29 3b 20 20 20 20 |name, "rb"); | 000043c0 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4f 70 65 | /* Ope| 000043d0 6e 20 72 65 61 64 20 62 69 6e 61 72 79 20 66 69 |n read binary fi| 000043e0 6c 65 2e 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 |le. */. | 000043f0 20 20 20 69 66 20 28 73 6f 75 72 63 65 5f 66 69 | if (source_fi| 00004400 6c 65 20 3d 3d 20 4e 55 4c 4c 29 20 7b 20 20 20 |le == NULL) { | 00004410 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004420 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00004430 52 65 70 6f 72 74 20 69 66 20 65 72 72 6f 72 2c |Report if error,| 00004440 20 61 6e 64 20 73 74 6f 70 2e 20 20 20 2a 2f 0a | and stop. */.| 00004450 20 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 20 | fprintf | 00004460 28 73 74 64 65 72 72 2c 20 22 46 61 74 61 6c 20 |(stderr, "Fatal | 00004470 65 72 72 6f 72 20 6f 70 65 6e 69 6e 67 20 25 73 |error opening %s| 00004480 20 66 6f 72 20 69 6e 70 75 74 2e 5c 6e 22 2c 20 | for input.\n", | 00004490 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 29 |source_filename)| 000044a0 3b 0a 20 20 20 20 20 20 20 20 65 78 69 74 20 28 |;. exit (| 000044b0 45 58 49 54 5f 46 41 49 4c 55 52 45 29 3b 0a 20 |EXIT_FAILURE);. | 000044c0 20 20 20 20 20 7d 0a 0a 20 20 20 20 20 20 69 20 | }.. i | 000044d0 3d 20 30 3b 20 20 20 20 20 20 20 20 20 20 20 20 |= 0; | 000044e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004510 2f 2a 20 49 6e 69 74 69 61 6c 69 73 65 20 63 6f |/* Initialise co| 00004520 75 6e 74 65 72 2e 20 20 2a 2f 0a 20 20 20 20 20 |unter. */. | 00004530 20 77 68 69 6c 65 20 28 28 68 65 61 64 65 72 5b | while ((header[| 00004540 69 2b 2b 5d 20 3d 20 66 67 65 74 63 20 28 73 6f |i++] = fgetc (so| 00004550 75 72 63 65 5f 66 69 6c 65 29 29 20 21 3d 20 27 |urce_file)) != '| 00004560 7c 27 20 26 26 20 69 3c 33 30 30 29 20 3b 20 20 ||' && i<300) ; | 00004570 20 20 20 2f 2a 20 43 68 65 63 6b 20 74 68 65 20 | /* Check the | 00004580 68 65 61 64 65 72 20 20 20 20 20 2a 2f 0a 20 20 |header */. | 00004590 20 20 20 20 66 6f 72 20 28 69 20 3d 20 30 3b 20 | for (i = 0; | 000045a0 69 20 3c 20 33 3b 20 69 2b 2b 29 20 69 66 20 28 |i < 3; i++) if (| 000045b0 68 65 61 64 65 72 5b 69 5d 20 21 3d 20 73 70 6c |header[i] != spl| 000045c0 69 74 68 32 5b 69 5d 29 20 7b 20 20 20 20 20 20 |ith2[i]) { | 000045d0 20 20 20 20 20 20 2f 2a 20 77 69 74 68 20 61 20 | /* with a | 000045e0 74 65 6d 70 6c 61 74 65 2e 20 20 20 20 20 2a 2f |template. */| 000045f0 0a 20 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 |. fprintf| 00004600 20 28 73 74 64 65 72 72 2c 22 46 61 74 61 6c 20 | (stderr,"Fatal | 00004610 65 72 72 6f 72 2c 20 62 61 64 20 68 65 61 64 65 |error, bad heade| 00004620 72 20 69 6e 20 66 69 6c 65 20 25 73 5c 6e 22 2c |r in file %s\n",| 00004630 20 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 | source_filename| 00004640 29 3b 0a 20 20 20 20 20 20 20 20 66 63 6c 6f 73 |);. fclos| 00004650 65 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 29 3b |e (source_file);| 00004660 0a 20 20 20 20 20 20 20 20 65 78 69 74 20 28 45 |. exit (E| 00004670 58 49 54 5f 46 41 49 4c 55 52 45 29 3b 0a 20 20 |XIT_FAILURE);. | 00004680 20 20 20 20 7d 0a 0a 20 20 20 20 20 20 6e 20 3d | }.. n =| 00004690 20 30 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 | 0; | 000046a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000046c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 000046d0 2a 20 49 6e 69 74 69 61 6c 69 73 65 20 63 6f 75 |* Initialise cou| 000046e0 6e 74 65 72 2e 20 20 2a 2f 0a 23 69 66 64 65 66 |nter. */.#ifdef| 000046f0 20 41 43 4f 52 4e 0a 20 20 20 20 20 20 77 68 69 | ACORN. whi| 00004700 6c 65 20 28 68 65 61 64 65 72 5b 69 5d 20 21 3d |le (header[i] !=| 00004710 20 27 3d 27 29 20 7b 0a 20 20 20 20 20 20 20 20 | '=') {. | 00004720 63 68 65 63 6b 5f 6e 61 6d 65 5b 6e 2b 2b 5d 20 |check_name[n++] | 00004730 3d 20 28 68 65 61 64 65 72 5b 69 5d 3d 3d 27 2e |= (header[i]=='.| 00004740 27 20 3f 20 27 2f 27 20 3a 20 68 65 61 64 65 72 |' ? '/' : header| 00004750 5b 69 5d 29 3b 20 20 20 20 20 20 20 20 20 20 20 |[i]); | 00004760 2f 2a 20 53 77 61 70 20 27 2e 27 20 61 6e 64 20 |/* Swap '.' and | 00004770 27 2f 27 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 |'/' */. | 00004780 20 20 20 69 2b 2b 3b 20 20 20 20 20 20 20 20 20 | i++; | 00004790 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000047c0 20 20 20 2f 2a 20 63 68 61 72 61 63 74 65 72 73 | /* characters| 000047d0 20 61 6e 64 20 63 68 65 63 6b 20 2a 2f 0a 20 20 | and check */. | 000047e0 20 20 20 20 7d 20 20 20 20 20 20 20 20 20 20 20 | } | 000047f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004820 20 20 20 20 20 20 2f 2a 20 66 69 6c 65 6e 61 6d | /* filenam| 00004830 65 2e 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f |e. */| 00004840 0a 20 20 20 20 20 20 6e 2b 2b 3b 0a 20 20 20 20 |. n++;. | 00004850 20 20 69 2b 2b 3b 0a 23 65 6c 73 65 0a 20 20 20 | i++;.#else. | 00004860 20 20 20 77 68 69 6c 65 20 28 28 63 68 65 63 6b | while ((check| 00004870 5f 6e 61 6d 65 5b 6e 2b 2b 5d 20 3d 20 68 65 61 |_name[n++] = hea| 00004880 64 65 72 5b 69 2b 2b 5d 29 20 21 3d 20 27 3d 27 |der[i++]) != '='| 00004890 29 20 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |) ; | 000048a0 20 20 20 20 20 2f 2a 20 4a 75 73 74 20 63 68 65 | /* Just che| 000048b0 63 6b 20 66 69 6c 65 6e 61 6d 65 2e 20 2a 2f 0a |ck filename. */.| 000048c0 23 65 6e 64 69 66 0a 0a 20 20 20 20 20 20 63 68 |#endif.. ch| 000048d0 65 63 6b 5f 6e 61 6d 65 5b 2d 2d 6e 5d 20 3d 20 |eck_name[--n] = | 000048e0 27 5c 30 27 3b 0a 20 20 20 20 20 20 69 66 20 28 |'\0';. if (| 000048f0 73 74 72 63 6d 70 20 28 6f 75 74 5f 6e 61 6d 65 |strcmp (out_name| 00004900 2c 20 63 68 65 63 6b 5f 6e 61 6d 65 29 29 20 7b |, check_name)) {| 00004910 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00004930 20 52 65 70 6f 72 74 20 69 66 20 65 72 72 6f 72 | Report if error| 00004940 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 20 | */. | 00004950 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 72 72 | fprintf (stderr| 00004960 2c 22 46 61 74 61 6c 20 65 72 72 6f 72 2c 20 73 |,"Fatal error, s| 00004970 70 6c 69 74 20 66 69 6c 65 20 25 73 20 64 6f 65 |plit file %s doe| 00004980 73 20 6e 6f 74 20 6d 61 74 63 68 2e 5c 6e 22 2c |s not match.\n",| 00004990 20 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 | source_filename| 000049a0 29 3b 0a 20 20 20 20 20 20 20 20 66 63 6c 6f 73 |);. fclos| 000049b0 65 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 29 3b |e (source_file);| 000049c0 0a 20 20 20 20 20 20 20 20 65 78 69 74 20 28 45 |. exit (E| 000049d0 58 49 54 5f 46 41 49 4c 55 52 45 29 3b 20 20 20 |XIT_FAILURE); | 000049e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004a00 20 20 20 20 20 20 20 20 20 2f 2a 20 61 6e 64 20 | /* and | 00004a10 73 74 6f 70 2e 20 20 20 20 20 20 20 20 20 20 20 |stop. | 00004a20 20 2a 2f 0a 20 20 20 20 20 20 7d 0a 0a 20 20 20 | */. }.. | 00004a30 20 20 20 6e 20 3d 20 30 3b 20 20 20 20 20 20 20 | n = 0; | 00004a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004a70 20 20 20 20 20 2f 2a 20 49 6e 69 74 69 61 6c 69 | /* Initiali| 00004a80 73 65 20 63 6f 75 6e 74 65 72 2e 20 20 2a 2f 0a |se counter. */.| 00004a90 20 20 20 20 20 20 77 68 69 6c 65 20 28 28 66 6e | while ((fn| 00004aa0 75 6d 5b 6e 2b 2b 5d 20 3d 20 68 65 61 64 65 72 |um[n++] = header| 00004ab0 5b 69 2b 2b 5d 29 20 21 3d 20 27 7c 27 29 20 3b |[i++]) != '|') ;| 00004ac0 0a 20 20 20 20 20 20 66 6e 75 6d 5b 2d 2d 6e 5d |. fnum[--n]| 00004ad0 20 3d 20 27 5c 30 27 3b 0a 20 20 20 20 20 20 63 | = '\0';. c| 00004ae0 68 65 63 6b 5f 6e 75 6d 62 65 72 20 3d 20 61 74 |heck_number = at| 00004af0 6f 69 20 28 66 6e 75 6d 29 3b 20 20 20 20 20 20 |oi (fnum); | 00004b00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004b20 20 2f 2a 20 47 65 74 20 74 68 65 20 70 61 72 74 | /* Get the part| 00004b30 20 6e 75 6d 62 65 72 20 20 2a 2f 0a 20 20 20 20 | number */. | 00004b40 20 20 69 66 20 28 63 68 65 63 6b 5f 6e 75 6d 62 | if (check_numb| 00004b50 65 72 20 21 3d 20 66 69 6c 65 5f 6e 75 6d 62 65 |er != file_numbe| 00004b60 72 29 20 7b 20 20 20 20 20 20 20 20 20 20 20 20 |r) { | 00004b70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004b80 20 20 20 20 2f 2a 20 61 6e 64 20 6d 61 6b 65 20 | /* and make | 00004b90 73 75 72 65 20 69 74 27 73 20 20 20 2a 2f 0a 20 |sure it's */. | 00004ba0 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 20 28 | fprintf (| 00004bb0 73 74 64 65 72 72 2c 22 46 61 74 61 6c 20 65 72 |stderr,"Fatal er| 00004bc0 72 6f 72 2c 20 69 6e 63 6f 72 72 65 63 74 20 70 |ror, incorrect p| 00004bd0 61 72 74 2e 5c 6e 22 29 3b 20 20 20 20 20 20 20 |art.\n"); | 00004be0 20 20 20 20 20 20 20 2f 2a 20 6f 6e 65 20 77 65 | /* one we| 00004bf0 20 77 61 6e 74 2e 20 20 20 20 20 20 20 20 20 2a | want. *| 00004c00 2f 0a 20 20 20 20 20 20 20 20 66 63 6c 6f 73 65 |/. fclose| 00004c10 20 28 73 6f 75 72 63 65 5f 66 69 6c 65 29 3b 0a | (source_file);.| 00004c20 20 20 20 20 20 20 20 20 65 78 69 74 20 28 45 58 | exit (EX| 00004c30 49 54 5f 46 41 49 4c 55 52 45 29 3b 0a 20 20 20 |IT_FAILURE);. | 00004c40 20 20 20 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 | }. }.. | 00004c50 69 6e 5f 70 6f 73 69 74 69 6f 6e 20 3d 20 28 6c |in_position = (l| 00004c60 6f 6e 67 29 20 69 3b 20 20 20 20 20 20 20 20 20 |ong) i; | 00004c70 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 49 | /* I| 00004c80 6e 69 74 69 61 6c 69 73 65 20 74 68 65 20 69 6e |nitialise the in| 00004c90 70 75 74 20 66 69 6c 65 20 70 6f 73 69 74 69 6f |put file positio| 00004ca0 6e 20 70 6f 69 6e 74 65 72 2e 20 20 2a 2f 0a 0a |n pointer. */..| 00004cb0 20 20 20 20 66 73 65 65 6b 20 28 73 6f 75 72 63 | fseek (sourc| 00004cc0 65 5f 66 69 6c 65 2c 20 30 4c 2c 20 53 45 45 4b |e_file, 0L, SEEK| 00004cd0 5f 45 4e 44 29 3b 20 20 20 20 20 20 20 20 20 20 |_END); | 00004ce0 20 20 20 20 20 20 20 20 2f 2a 20 53 65 74 20 66 | /* Set f| 00004cf0 69 6c 65 20 70 6f 69 6e 74 65 72 20 74 6f 20 65 |ile pointer to e| 00004d00 6e 64 20 6f 66 20 66 69 6c 65 2c 20 20 20 20 20 |nd of file, | 00004d10 2a 2f 0a 20 20 20 20 66 69 6c 65 5f 6c 65 6e 67 |*/. file_leng| 00004d20 74 68 20 3d 20 66 74 65 6c 6c 20 28 73 6f 75 72 |th = ftell (sour| 00004d30 63 65 5f 66 69 6c 65 29 3b 20 20 20 20 20 20 20 |ce_file); | 00004d40 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 67 65 | /* ge| 00004d50 74 20 66 69 6c 65 20 6c 65 6e 67 74 68 20 20 20 |t file length | 00004d60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004d70 20 20 20 2a 2f 0a 20 20 20 20 66 73 65 65 6b 20 | */. fseek | 00004d80 28 73 6f 75 72 63 65 5f 66 69 6c 65 2c 20 69 6e |(source_file, in| 00004d90 5f 70 6f 73 69 74 69 6f 6e 2c 20 53 45 45 4b 5f |_position, SEEK_| 00004da0 53 45 54 29 3b 20 20 20 20 20 20 20 20 20 2f 2a |SET); /*| 00004db0 20 61 6e 64 20 72 65 73 65 74 20 70 6f 69 6e 74 | and reset point| 00004dc0 65 72 20 74 6f 20 73 74 61 72 74 20 6f 66 20 64 |er to start of d| 00004dd0 61 74 61 2e 20 20 2a 2f 0a 0a 20 20 20 20 69 66 |ata. */.. if| 00004de0 20 28 69 6e 66 6f 29 20 7b 20 20 20 20 20 20 20 | (info) { | 00004df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004e10 20 20 2f 2a 20 49 66 20 2d 69 6e 66 6f 20 6a 75 | /* If -info ju| 00004e20 73 74 20 64 69 73 70 6c 61 79 20 69 6e 66 6f 72 |st display infor| 00004e30 6d 61 74 69 6f 6e 2e 20 20 20 2a 2f 0a 20 20 20 |mation. */. | 00004e40 20 20 20 70 72 69 6e 74 66 20 28 22 20 20 20 20 | printf (" | 00004e50 25 73 2e 2e 2e 25 6c 64 20 62 79 74 65 73 5c 6e |%s...%ld bytes\n| 00004e60 22 2c 20 73 6f 75 72 63 65 5f 66 69 6c 65 6e 61 |", source_filena| 00004e70 6d 65 2c 20 66 69 6c 65 5f 6c 65 6e 67 74 68 20 |me, file_length | 00004e80 2d 20 69 6e 5f 70 6f 73 69 74 69 6f 6e 29 3b 0a |- in_position);.| 00004e90 20 20 20 20 20 20 62 79 74 65 73 5f 72 65 61 64 | bytes_read| 00004ea0 20 2b 3d 20 66 69 6c 65 5f 6c 65 6e 67 74 68 20 | += file_length | 00004eb0 2d 20 69 6e 5f 70 6f 73 69 74 69 6f 6e 3b 0a 20 |- in_position;. | 00004ec0 20 20 20 7d 0a 20 20 20 20 65 6c 73 65 20 7b 20 | }. else { | 00004ed0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004ef0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00004f00 4f 74 68 65 72 77 69 73 65 2c 20 64 6f 20 74 68 |Otherwise, do th| 00004f10 65 20 6a 6f 69 6e 69 6e 67 2e 20 20 20 20 20 20 |e joining. | 00004f20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 70 72 | */. pr| 00004f30 69 6e 74 66 20 28 22 52 65 61 64 69 6e 67 20 64 |intf ("Reading d| 00004f40 61 74 61 20 66 72 6f 6d 20 25 73 2e 2e 2e 2e 2e |ata from %s.....| 00004f50 25 6c 64 20 62 79 74 65 73 5c 6e 22 2c 20 73 6f |%ld bytes\n", so| 00004f60 75 72 63 65 5f 66 69 6c 65 6e 61 6d 65 2c 20 66 |urce_filename, f| 00004f70 69 6c 65 5f 6c 65 6e 67 74 68 20 2d 20 69 6e 5f |ile_length - in_| 00004f80 70 6f 73 69 74 69 6f 6e 29 3b 0a 20 20 20 20 20 |position);. | 00004f90 20 77 68 69 6c 65 20 28 66 69 6c 65 5f 6c 65 6e | while (file_len| 00004fa0 67 74 68 20 2d 20 69 6e 5f 70 6f 73 69 74 69 6f |gth - in_positio| 00004fb0 6e 20 3e 20 30 29 20 7b 20 20 20 20 20 20 20 20 |n > 0) { | 00004fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004fd0 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 49 66 | /* If| 00004fe0 20 61 6e 79 20 64 61 74 61 20 20 2a 2f 0a 09 62 | any data */..b| 00004ff0 79 74 65 73 5f 72 65 61 64 20 3d 20 66 72 65 61 |ytes_read = frea| 00005000 64 20 28 62 75 66 66 65 72 2c 20 31 2c 20 28 73 |d (buffer, 1, (s| 00005010 69 7a 65 5f 74 29 20 72 65 61 64 5f 73 69 7a 65 |ize_t) read_size| 00005020 2c 20 73 6f 75 72 63 65 5f 66 69 6c 65 29 3b 20 |, source_file); | 00005030 20 20 20 20 20 20 20 2f 2a 20 6c 65 66 74 2c 20 | /* left, | 00005040 72 65 61 64 20 20 20 2a 2f 0a 09 62 79 74 65 73 |read */..bytes| 00005050 5f 77 72 69 74 74 65 6e 20 3d 20 66 77 72 69 74 |_written = fwrit| 00005060 65 20 28 62 75 66 66 65 72 2c 20 31 2c 20 28 73 |e (buffer, 1, (s| 00005070 69 7a 65 5f 74 29 20 62 79 74 65 73 5f 72 65 61 |ize_t) bytes_rea| 00005080 64 2c 20 6f 75 74 5f 66 69 6c 65 29 3b 20 20 20 |d, out_file); | 00005090 20 20 20 2f 2a 20 61 6e 64 20 77 72 69 74 65 2e | /* and write.| 000050a0 20 20 20 2a 2f 0a 0a 20 20 20 20 20 20 20 20 20 | */.. | 000050b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000050c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 000050d0 2a 20 43 68 65 63 6b 20 77 65 27 76 65 20 77 72 |* Check we've wr| 000050e0 69 74 74 65 6e 20 74 68 65 20 63 6f 72 72 65 63 |itten the correc| 000050f0 74 20 61 6d 6f 75 6e 74 20 6f 66 20 64 61 74 61 |t amount of data| 00005100 2e 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 |. */. | 00005110 20 20 69 66 20 28 62 79 74 65 73 5f 77 72 69 74 | if (bytes_writ| 00005120 74 65 6e 20 3c 20 72 65 61 64 5f 73 69 7a 65 20 |ten < read_size | 00005130 26 26 20 62 79 74 65 73 5f 77 72 69 74 74 65 6e |&& bytes_written| 00005140 20 3c 20 66 69 6c 65 5f 6c 65 6e 67 74 68 2d 69 | < file_length-i| 00005150 6e 5f 70 6f 73 69 74 69 6f 6e 29 20 7b 0a 20 20 |n_position) {. | 00005160 20 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 20 | fprintf | 00005170 28 73 74 64 65 72 72 2c 20 22 46 61 74 61 6c 20 |(stderr, "Fatal | 00005180 65 72 72 6f 72 20 77 68 69 6c 65 20 77 72 69 74 |error while writ| 00005190 69 6e 67 20 25 73 5c 6e 22 2c 20 6f 75 74 5f 66 |ing %s\n", out_f| 000051a0 69 6c 65 6e 61 6d 65 29 3b 0a 20 20 20 20 20 20 |ilename);. | 000051b0 20 20 20 20 65 78 69 74 20 28 45 58 49 54 5f 46 | exit (EXIT_F| 000051c0 41 49 4c 55 52 45 29 3b 20 20 20 20 20 20 20 20 |AILURE); | 000051d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000051e0 20 20 20 20 20 20 20 20 20 20 2f 2a 20 49 66 20 | /* If | 000051f0 75 6e 73 75 63 65 73 73 66 75 6c 6c 2c 20 74 68 |unsucessfull, th| 00005200 65 6e 20 73 74 6f 70 2e 20 20 2a 2f 0a 20 20 20 |en stop. */. | 00005210 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 69 | }. i| 00005220 6e 5f 70 6f 73 69 74 69 6f 6e 20 2b 3d 20 62 79 |n_position += by| 00005230 74 65 73 5f 72 65 61 64 3b 20 20 20 20 20 20 20 |tes_read; | 00005240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005250 20 20 20 20 20 20 20 2f 2a 20 55 70 64 61 74 65 | /* Update| 00005260 20 74 68 65 20 66 69 6c 65 20 70 6f 73 69 74 69 | the file positi| 00005270 6f 6e 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 |on */. | 00005280 20 20 6f 75 74 5f 70 6f 73 69 74 69 6f 6e 20 2b | out_position +| 00005290 3d 20 62 79 74 65 73 5f 77 72 69 74 74 65 6e 3b |= bytes_written;| 000052a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000052b0 20 20 20 20 20 20 20 20 20 20 2f 2a 20 70 6f 69 | /* poi| 000052c0 6e 74 65 72 73 2e 20 20 20 20 20 20 20 20 20 20 |nters. | 000052d0 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 | */. | 000052e0 20 20 20 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 | }. }.. | 000052f0 66 63 6c 6f 73 65 20 28 73 6f 75 72 63 65 5f 66 |fclose (source_f| 00005300 69 6c 65 29 3b 20 20 20 20 20 20 20 20 20 20 20 |ile); | 00005310 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005320 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 43 | /* C| 00005330 6c 6f 73 65 20 74 68 65 20 73 6f 75 72 63 65 20 |lose the source | 00005340 66 69 6c 65 2e 20 20 20 20 20 20 20 2a 2f 0a 20 |file. */. | 00005350 20 20 20 69 66 20 28 21 69 6e 66 6f 20 26 26 20 | if (!info && | 00005360 28 62 79 74 65 73 5f 77 72 69 74 74 65 6e 20 3c |(bytes_written <| 00005370 20 62 79 74 65 73 5f 72 65 61 64 29 29 20 7b 0a | bytes_read)) {.| 00005380 20 20 20 20 20 20 66 70 72 69 6e 74 66 20 28 73 | fprintf (s| 00005390 74 64 65 72 72 2c 20 22 46 61 74 61 6c 20 65 72 |tderr, "Fatal er| 000053a0 72 6f 72 20 77 68 69 6c 65 20 77 72 69 74 69 6e |ror while writin| 000053b0 67 20 25 73 5c 6e 22 2c 20 6f 75 74 5f 66 69 6c |g %s\n", out_fil| 000053c0 65 6e 61 6d 65 29 3b 0a 20 20 20 20 20 20 65 78 |ename);. ex| 000053d0 69 74 20 28 45 58 49 54 5f 46 41 49 4c 55 52 45 |it (EXIT_FAILURE| 000053e0 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |); | 000053f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005400 20 20 20 20 20 20 20 20 2f 2a 20 49 66 20 75 6e | /* If un| 00005410 73 75 63 65 73 73 66 75 6c 6c 2c 20 73 74 6f 70 |sucessfull, stop| 00005420 2e 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 7d |. */. }| 00005430 0a 20 20 7d 0a 0a 20 20 69 66 20 28 69 6e 66 6f |. }.. if (info| 00005440 29 0a 20 20 20 20 70 72 69 6e 74 66 20 28 22 5c |). printf ("\| 00005450 6e 54 6f 74 61 6c 20 6f 66 20 25 6c 64 20 62 79 |nTotal of %ld by| 00005460 74 65 73 20 63 6f 6e 74 61 69 6e 65 64 20 69 6e |tes contained in| 00005470 20 25 64 20 66 69 6c 65 73 2e 5c 6e 22 2c 20 62 | %d files.\n", b| 00005480 79 74 65 73 5f 72 65 61 64 2c 20 74 6f 74 61 6c |ytes_read, total| 00005490 5f 6e 75 6d 62 65 72 29 3b 0a 0a 20 20 65 6c 73 |_number);.. els| 000054a0 65 20 7b 0a 20 20 20 20 66 63 6c 6f 73 65 20 28 |e {. fclose (| 000054b0 6f 75 74 5f 66 69 6c 65 29 3b 20 20 20 20 20 20 |out_file); | 000054c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000054e0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 43 | /* C| 000054f0 6c 6f 73 65 20 6f 75 74 70 75 74 20 66 69 6c 65 |lose output file| 00005500 20 20 20 20 2a 2f 0a 20 20 20 20 66 72 65 65 20 | */. free | 00005510 28 62 75 66 66 65 72 29 3b 20 20 20 20 20 20 20 |(buffer); | 00005520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005540 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 00005550 2a 20 61 6e 64 20 66 72 65 65 20 62 75 66 66 65 |* and free buffe| 00005560 72 2e 20 20 20 20 20 2a 2f 0a 0a 23 69 66 64 65 |r. */..#ifde| 00005570 66 20 41 43 4f 52 4e 0a 20 20 20 20 69 66 20 28 |f ACORN. if (| 00005580 74 79 70 65 5b 30 5d 20 3d 3d 20 27 74 27 29 20 |type[0] == 't') | 00005590 7b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |{ | 000055a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000055b0 20 20 20 20 20 20 20 20 2f 2a 20 49 66 20 74 68 | /* If th| 000055c0 65 20 66 69 6c 65 20 68 61 64 20 61 20 74 79 70 |e file had a typ| 000055d0 65 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 |e */. | 000055e0 20 72 65 67 73 2e 72 5b 30 5d 20 3d 20 31 38 3b | regs.r[0] = 18;| 000055f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005610 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 73 65 | /* se| 00005620 74 20 74 68 65 20 66 69 6c 65 74 79 70 65 20 77 |t the filetype w| 00005630 69 74 68 20 53 57 49 20 20 20 20 2a 2f 0a 20 20 |ith SWI */. | 00005640 20 20 20 20 72 65 67 73 2e 72 5b 31 5d 20 3d 20 | regs.r[1] = | 00005650 28 69 6e 74 29 20 6f 75 74 5f 66 69 6c 65 6e 61 |(int) out_filena| 00005660 6d 65 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |me; | 00005670 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00005680 20 4f 53 5f 46 69 6c 65 20 31 38 20 20 20 20 20 | OS_File 18 | 00005690 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f | */| 000056a0 0a 20 20 20 20 20 20 73 73 63 61 6e 66 20 28 74 |. sscanf (t| 000056b0 79 70 65 2c 20 22 74 25 78 22 2c 20 26 72 65 67 |ype, "t%x", ®| 000056c0 73 2e 72 5b 32 5d 29 3b 0a 20 20 20 20 20 20 65 |s.r[2]);. e| 000056d0 72 72 20 3d 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 |rr = _kernel_swi| 000056e0 20 28 53 57 49 5f 4f 53 5f 46 69 6c 65 2c 20 26 | (SWI_OS_File, &| 000056f0 72 65 67 73 2c 20 26 72 65 67 73 29 3b 0a 20 20 |regs, ®s);. | 00005700 20 20 7d 0a 23 65 6e 64 69 66 0a 20 20 20 20 20 | }.#endif. | 00005710 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005750 20 20 20 2f 2a 20 52 65 70 6f 72 74 20 73 74 61 | /* Report sta| 00005760 74 75 73 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 |tus */. | 00005770 20 20 66 70 72 69 6e 74 66 20 28 73 74 64 65 72 | fprintf (stder| 00005780 72 2c 20 22 25 6c 64 20 62 79 74 65 73 20 77 72 |r, "%ld bytes wr| 00005790 69 74 74 65 6e 20 74 6f 20 66 69 6c 65 20 25 73 |itten to file %s| 000057a0 5c 6e 22 2c 20 6f 75 74 5f 70 6f 73 69 74 69 6f |\n", out_positio| 000057b0 6e 2c 20 6f 75 74 5f 66 69 6c 65 6e 61 6d 65 29 |n, out_filename)| 000057c0 3b 0a 20 20 7d 0a 20 20 65 78 69 74 20 28 45 58 |;. }. exit (EX| 000057d0 49 54 5f 53 55 43 43 45 53 53 29 3b 20 20 20 20 |IT_SUCCESS); | 000057e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00005810 20 61 6e 64 20 66 69 6e 69 73 68 2e 20 20 20 20 | and finish. | 00005820 20 20 20 20 20 20 2a 2f 0a 7d 0a | */.}.| 0000582b