ltf.c
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 817 行 · 第 1/2 页
C
817 行
#ifndef lintstatic char *sccsid = "@(#)ltf.c 4.1 ULTRIX 7/17/90";#endif lint/**************************************************************** * * * Copyright (c) 1985 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used * * and copied only in accordance with the terms of such * * license and with the inclusion of the above copyright * * notice. This software or any other copies thereof may * * not be provided or otherwise made available to any other * * person. No title to and ownership of the software is * * hereby transferred. * * * * The information in this software is subject to change * * without notice and should not be construed as a * * commitment by Digital Equipment Corporation. * * * * Digital assumes no responsibility for the use or * * reliability of its software on equipment which is not * * supplied by Digital. * * * ****************************************************************//**//* * Summary of the modules that comprise the Labeled Tape Facility, * (LTF) in alpha-numeric order. * * * NAME Function * ------------ ---------------------------------------- * * filenames.c Contains the routines that deal with * file-name conversions. * * filetype.c Contains the logic to determine the "type" * of Ultrix disk file being processed. * * initvol.c Contains the logic to initialize the * output volume. * * ltf.c The main-line logic of the LTF. Interprets * the command line and calls the appropriate * sub-module to deal with input or output. * * ltfdefs.h Contains the definitions of Global * constants, external declarations, * and data structures. * * NOTE: It also "includes" the system * include files that are required * by all LTF modules so that each * module need only "include" ltfdefs.h * to bring in all required system * includes, correct declarations * and variable definitions. * * ltferrs.h Contains the error message macros and error * messages themselves. * * ltfvars.c Contains the declarations of the Global * variables used by the LTF. * * makefile The MAKEFILE for the LTF. * * mstrcmp.c Contains the logic to compare file names. * ie. Interprets and expands meta-characters * allowed in LTF commands. ("*", "?", etc..) * * odm.c Contains the routines that deal with physical * output device manipulations. * Centralizes the "ioctl" logic that is used on * Ultrix-32, 32m, 11, etc.. * * putdir.c Contains the logic to output directory files * for the LTF. * * putfile.c Contains the routines that output files to * the given volume. * * README.1 Important documentation concerning the design * and implementation of the LTF. Includes file * and ANSI volume/label diagrams. * * scantape.c Scans the input volume for TABLE * and EXTRACT functions. * * xtractf.c Extracts (reads) files from the input volume. *//**//* * GENERAL COMPILE PATH * ----------------------- * * source / GLOBAL defs & externals * \ / * +-------+ +--------------------------+ * | x.c |--#includes--->| ltfdefs.h | * +-------+ +--------------------------+ * | | | * | #includes #includes * | | | * V V V * +-------+ +-----------+ +------------------+ * | x.o | | ltferrs.h | | (system.h | * +-------+ +-----------+ | files) | * / +------------------+ * object / * * * LINKAGE * ------- * * The object modules produced by the above compilations * (see makefile) are linked together producing the * executable file --> ltf *//**//* * * File name: * * ltf.c * * Source file description: * * This module is the main-line logic of/for the * Labeled Tape Facility (LTF). * * * Functions: * * main() The main-line logic. "main" parses the * command line arguments. If any errors are * detected, an appropriate message is output & * an exit back to the system is taken. * If a valid command is entered, control is passed * to the appropriate input -or- output * top-level logic module. * * * expnum() Expands a numeric character string into an * integer with optional "block" or "k" value * multiplication. * * response() Waits for the user to press the RETURN * before proceeding * * showhelp() Displays help messages explaining briefly the * usage of the switches of ltf * * usage() Outputs the desired command format when the * occasion arises. * * Usage: * * General command format is: * * ltf function(s) -qualifiers [ filename ] ... [ filename ] * * The LTF reads & writes ANSI compatible tape formats. * * * Compile: * * cc -O -c ltf.c <- For Ultrix-32/32m * * cc CFLAGS=-DU11-O ltf.c <- For Ultrix-11 * * * In point of fact, the complete ltf can only be built * by its' makefile as the facility is in multi-module * format as opposed to single source. * * * Modification history: * ~~~~~~~~~~~~~~~~~~~~ * * revision comments * -------- ----------------------------------------------- * 01.0 04-Apr-85 Ray Glaser * Create orginal version. * * 01.1 22-Aug-85 Suzanne Logcher * Reorganize ltf.c to look more like tar. * * 01.2 28-Oct-85 Suzanne Logcher * Add tar's magtape defaults * * 01.3 20-Mar-86 Suzanne Logcher * Change logic that handles unit numbers *//**//* * -> Local defines "required for / defined by" this module * * NOTE: This statement must come before the local * includes to correctly define the compilation * of GLOBALS.. * */#define MAINC /* So that we don't doubly define message * strings and other global variables when * we compile/link sub-modules. *//* * -> Local includes */#include "ltfdefs.h" /* Common GLOBAL constants & structs *//**//* * * Function: * * main * * Function Description: * * Processes the command line, rejects invalid commands, and * calls appropriate top-level routine for input/output. * * Arguments: * * int argc Argument count * char *argv[] Pointer to array of pointers to args * * * Return values: * * n/a * * * Side Effects: * * n/a * */main (argc, argv) int argc; char *argv[];{/* * -> Local variables */char *a; /* pointer to *argv */int dumpflag = 0; /* Flags word used to set up * f_flags in filestat structure * indicating dump mode of this * file */int iflag = 0; /* The I option. iflag = 0 if * no arguments othan ther the * command-line arguments are * to be processed. iflag = -1 * if the standard input is to * be read for more file names. * iflag = 1 if a file * containing additional file * arguments is given. */FILE *ifp; /* File pointer to inputfile * (if iflag = 1) */char inputfile[MAXPATHLEN+1]; /* If iflag = 1, inputfile is * the file containing additional * file arguments. If iflag = -1, * inputfile[0] = '-' to indicate * that the user is to be * prompted for the other file * names; otherwise, inputfile[0] = 0 * for no prompting. */int mag = 0; /* Flag to check if f qualifier used */char magtape[MAXPATHLEN+1]; /* magtape name from switches */char *nmbr1; /* Temporary variable for use with * strings read in to be converted to * numbers */int pflag = 0; /* Flag to check that P is only used * with EXTRACT */int ret = TRUE; /* Boolean to check success of * rec_file */#ifdef U11char unit = -1; /* Unit number of named tape device */#elsechar unit[3]; /* Unit number of named tape device */int unit_int = 0; /* Integer form of unit[3] */int unit_nums = 0; /* Count of # of unit number digits */#endif/**//*------*\ Code\*------*//* Copy default tape name from default set in mtio.h */#ifndef U11strcpy(Magtdev, DEFTAPE_RH);#endif/* Set warning on if all links to a file are not resolved */Rep_misslinks = NO;for (i=0; i < BUFSIZE; i++) Spaces[i] = ' ';/* So that error routines know the name of this program */Progname = argv[0];if (--argc <= 0) usage();else { Func = NO; argc--; argv++; for (a = *argv++; *a; a++) { switch(*a) { /* Optional '-' in front of functions */ case '-': break; /* List a help message with all * functions, switches, and qualifiers */ case 'H': showhelp(); /* Create a new volume (output) * of files and directories. */ case 'c': if (Func != NO) { PERROR "\n%s: %s\n", Progname, CONFF); usage(); } Func = CREATE; break; /* Provide a table of contents * (index) of an input volume. */ case 't': if (Func != NO) { PERROR "\n%s: %s\n", Progname, CONFF); usage(); } Func = TABLE; break; /* Extract (read in) files and * and directories from an * input volume. */ case 'x': if (Func != NO) { PERROR "\n%s: %s\n", Progname, CONFF); usage(); } Func = EXTRACT; break; /* Output ANSI version 3 volume */ case 'a': Ansiv = '3'; break;#ifdef U11 /* Select 6250 GCR device */ case 'g': strcpy(magtape, "/dev/rgt0"); mag = 1; break;#endif /* Output the file a symbolic link * points to instead of the link file */ case 'h': Nosym = TRUE; break;#ifdef U11 /* Select TK50 device */ case 'k': strcpy(magtape, "/dev/rtk0"); mag = 1; break; /* Select 800 bpi tape */ case 'n': strcpy(magtape, "/dev/rmt0"); mag = 1; break;#endif /* Omit directory blocks from output
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?