Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/vms/cmdline.c  view on Meta::CPAN

**              Revised argv vector construction for better handling of quoted
**              arguments (e.g.: embedded white space); no version num change.
**      02-007          Christian Spieler       04-MAR-1997 22:25
**              Made /CASE_INSENSITIVE common to UnZip and ZipInfo mode;
**              added support for /PASSWORD="decryption_key" argument.
**      02-006          Christian Spieler       11-MAY-1996 22:40
**              Added SFX version of VMSCLI_usage().
**      02-005          Patrick Ellis           09-MAY-1996 22:25
**              Show UNIX style usage screen when UNIX style options are used.
**      02-004          Christian Spieler       06-FEB-1996 02:20
**              Added /HELP qualifier.
**      02-003          Christian Spieler       23-DEC-1995 17:20
**              Adapted to UnZip 5.2.
**      02-002          Hunter Goatley          16-JUL-1994 10:20
**              Fixed some typos.
**      02-001          Cave Newt               14-JUL-1994 15:18
**              Removed obsolete /EXTRACT option; fixed /*TEXT options;
**              wrote VMSCLI usage() function
**      02-000          Hunter Goatley          12-JUL-1994 00:00
**              Original UnZip version (v5.11).
**      01-000          Hunter Goatley          30-JUL-1993 07:54
**              Original version (for Zip v1.9p1).
**
*/

/*    Stand-alone test procedure:
 *
 * cc /define = TEST=1 [.vms]cmdline.c /include = [] /object = [.vms]
 * set command /object = [.vms]unz_cli.obj [.vms]unz_cli.cld
 * link /executable = [] [.vms]cmdline.obj, [.vms]unz_cli.obj
 * EXEC*UTE == "$SYS$DISK:[]'"
 * exec cmdline [ /qualifiers ...] [parameters ...]
 */



/* 2004-12-13 SMS.
 * Disabled the module name macro to accommodate old GNU C which didn't
 * obey the directive, and thus confused MMS/MMK where the object
 * library dependencies need to have the correct module name.
 */
#if 0
#if defined(__DECC) || defined(__GNUC__)
#pragma module module_name module_ident
#else
#module module_name module_ident
#endif
#endif /* 0 */

#define UNZIP_INTERNAL
#include "unzip.h"
#ifndef TEST
#  include "unzvers.h"  /* for VMSCLI_usage() */
#endif /* !TEST */

/* Workaround for broken header files of older DECC distributions
 * that are incompatible with the /NAMES=AS_IS qualifier. */
/* - lib$routines.h definitions: */
#define lib$establish LIB$ESTABLISH
#define lib$get_foreign LIB$GET_FOREIGN
#define lib$get_input LIB$GET_INPUT
#define lib$sig_to_ret LIB$SIG_TO_RET
/* - str$routines.h definitions: */
#define str$concat STR$CONCAT
#define str$find_first_substring STR$FIND_FIRST_SUBSTRING

#include <ssdef.h>
#include <descrip.h>
#include <climsgdef.h>
#include <clidef.h>
#include <lib$routines.h>
#include <str$routines.h>

#ifndef CLI$_COMMA
globalvalue CLI$_COMMA;
#endif

/*
**  "Macro" to initialize a dynamic string descriptor.
*/
#define init_dyndesc(dsc) {\
        dsc.dsc$w_length = 0;\
        dsc.dsc$b_dtype = DSC$K_DTYPE_T;\
        dsc.dsc$b_class = DSC$K_CLASS_D;\
        dsc.dsc$a_pointer = NULL;}

/*
**  Memory allocation step for argv string buffer.
*/
#define ARGBSIZE_UNIT 256

/*
**  Memory reallocation macro for argv string buffer.
*/
#define CHECK_BUFFER_ALLOCATION(buf, reserved, requested) { \
    if ((requested) > (reserved)) { \
        char *save_buf = (buf); \
        (reserved) += ARGBSIZE_UNIT; \
        if (((buf) = (char *) realloc((buf), (reserved))) == NULL) { \
            if (save_buf != NULL) free(save_buf); \
            return (SS$_INSFMEM); \
        } \
    } \
}

/*
**  Define descriptors for all of the CLI parameters and qualifiers.
*/
#if 0
$DESCRIPTOR(cli_extract,        "EXTRACT");             /* obsolete */
#endif
$DESCRIPTOR(cli_text,           "TEXT");                /* -a[a] */
$DESCRIPTOR(cli_text_auto,      "TEXT.AUTO");           /* -a */
$DESCRIPTOR(cli_text_all,       "TEXT.ALL");            /* -aa */
$DESCRIPTOR(cli_text_none,      "TEXT.NONE");           /* ---a */
$DESCRIPTOR(cli_text_stmlf,     "TEXT.STMLF");          /* -S */
$DESCRIPTOR(cli_binary,         "BINARY");              /* -b[b] */
$DESCRIPTOR(cli_binary_auto,    "BINARY.AUTO");         /* -b */
$DESCRIPTOR(cli_binary_all,     "BINARY.ALL");          /* -bb */
$DESCRIPTOR(cli_binary_none,    "BINARY.NONE");         /* ---b */
$DESCRIPTOR(cli_case_insensitive,"CASE_INSENSITIVE");   /* -C */

unzip-6.0/vms/cmdline.c  view on Meta::CPAN

$DESCRIPTOR(cli_junk,           "JUNK");                /* -j */
$DESCRIPTOR(cli_lowercase,      "LOWERCASE");           /* -L */
$DESCRIPTOR(cli_list,           "LIST");                /* -l */
$DESCRIPTOR(cli_brief,          "BRIEF");               /* -l */
$DESCRIPTOR(cli_full,           "FULL");                /* -v */
$DESCRIPTOR(cli_full_diags,     "FULL.DIAGNOSTICS");    /* -vv */
$DESCRIPTOR(cli_existing,       "EXISTING");            /* -o, -oo, -n */
$DESCRIPTOR(cli_exist_newver,   "EXISTING.NEW_VERSION"); /* -o */
$DESCRIPTOR(cli_exist_over,     "EXISTING.OVERWRITE");  /* -oo */
$DESCRIPTOR(cli_exist_noext,    "EXISTING.NOEXTRACT");  /* -n */
$DESCRIPTOR(cli_overwrite,      "OVERWRITE");           /* -o, -n */
$DESCRIPTOR(cli_quiet,          "QUIET");               /* -q */
$DESCRIPTOR(cli_super_quiet,    "QUIET.SUPER");         /* -qq */
$DESCRIPTOR(cli_test,           "TEST");                /* -t */
$DESCRIPTOR(cli_pipe,           "PIPE");                /* -p */
$DESCRIPTOR(cli_password,       "PASSWORD");            /* -P */
$DESCRIPTOR(cli_timestamp,      "TIMESTAMP");           /* -T */
$DESCRIPTOR(cli_uppercase,      "UPPERCASE");           /* -U */
$DESCRIPTOR(cli_update,         "UPDATE");              /* -u */
$DESCRIPTOR(cli_version,        "VERSION");             /* -V */
$DESCRIPTOR(cli_restore,        "RESTORE");             /* -X */
$DESCRIPTOR(cli_restore_own,    "RESTORE.OWNER_PROT");  /* -X */
$DESCRIPTOR(cli_restore_date,   "RESTORE.DATE");        /* -DD */
$DESCRIPTOR(cli_restore_date_all, "RESTORE.DATE.ALL");  /* --D */
$DESCRIPTOR(cli_restore_date_files, "RESTORE.DATE.FILES"); /* -D */
$DESCRIPTOR(cli_dot_version,    "DOT_VERSION");         /* -Y */
$DESCRIPTOR(cli_comment,        "COMMENT");             /* -z */
$DESCRIPTOR(cli_exclude,        "EXCLUDE");             /* -x */
$DESCRIPTOR(cli_ods2,           "ODS2");                /* -2 */
$DESCRIPTOR(cli_traverse,       "TRAVERSE_DIRS");       /* -: */

$DESCRIPTOR(cli_information,    "ZIPINFO");             /* -Z */
$DESCRIPTOR(cli_short,          "SHORT");               /* -Zs */
$DESCRIPTOR(cli_medium,         "MEDIUM");              /* -Zm */
$DESCRIPTOR(cli_long,           "LONG");                /* -Zl */
$DESCRIPTOR(cli_verbose,        "VERBOSE");             /* -Zv */
$DESCRIPTOR(cli_header,         "HEADER");              /* -Zh */
$DESCRIPTOR(cli_totals,         "TOTALS");              /* -Zt */
$DESCRIPTOR(cli_times,          "TIMES");               /* -ZT */
$DESCRIPTOR(cli_one_line,       "ONE_LINE");            /* -Z2 */

$DESCRIPTOR(cli_page,           "PAGE");                /* -M , -ZM */

$DESCRIPTOR(cli_yyz,            "YYZ_UNZIP");

$DESCRIPTOR(cli_zipfile,        "ZIPFILE");
$DESCRIPTOR(cli_infile,         "INFILE");
$DESCRIPTOR(unzip_command,      "unzip ");

static int show_VMSCLI_usage;

#ifndef vms_unzip_cld
#  define vms_unzip_cld VMS_UNZIP_CLD
#endif
#if defined(__DECC) || defined(__GNUC__)
extern void *vms_unzip_cld;
#else
globalref void *vms_unzip_cld;
#endif

/* extern unsigned long LIB$GET_INPUT(void), LIB$SIG_TO_RET(void); */

#ifndef cli$dcl_parse
#  define cli$dcl_parse CLI$DCL_PARSE
#endif
#ifndef cli$present
#  define cli$present CLI$PRESENT
#endif
#ifndef cli$get_value
#  define cli$get_value CLI$GET_VALUE
#endif
extern unsigned long cli$dcl_parse ();
extern unsigned long cli$present ();
extern unsigned long cli$get_value ();

unsigned long vms_unzip_cmdline (int *, char ***);
static unsigned long get_list (struct dsc$descriptor_s *,
                               struct dsc$descriptor_d *, int,
                               char **, unsigned long *, unsigned long *);
static unsigned long check_cli (struct dsc$descriptor_s *);


#ifdef TEST
int
main(int argc, char **argv)
{
    return (vms_unzip_cmdline(&argc, &argv));
}
#endif /* TEST */


unsigned long
vms_unzip_cmdline (int *argc_p, char ***argv_p)
{
/*
**  Routine:    vms_unzip_cmdline
**
**  Function:
**
**      Parse the DCL command line and create a fake argv array to be
**      handed off to Zip.
**
**      NOTE: the argv[] is built as we go, so all the parameters are
**      checked in the appropriate order!!
**
**  Formal parameters:
**
**      argc_p          - Address of int to receive the new argc
**      argv_p          - Address of char ** to receive the argv address
**
**  Calling sequence:
**
**      status = vms_unzip_cmdline (&argc, &argv);
**
**  Returns:
**
**      SS$_NORMAL      - Success.
**      SS$_INSFMEM     - A malloc() or realloc() failed
**      SS$_ABORT       - Bad time value
**
*/

unzip-6.0/vms/cmdline.c  view on Meta::CPAN

        if (status & 1)
            *ptr++ = 'h';

        /*
        **  Junk stored directory names on unzip
        */
        status = cli$present(&cli_junk);
        if (status == CLI$_NEGATED)
            *ptr++ = '-';
        if (status != CLI$_ABSENT)
            *ptr++ = 'j';

        /*
        **  List contents (/BRIEF (default) or /FULL)
        */
        status = cli$present(&cli_list);
        if (status & 1) {
            if (cli$present(&cli_full) & 1) {
               *ptr++ = 'v';
               if (cli$present(&cli_full_diags) & 1)
                   *ptr++ = 'v';
            } else
               *ptr++ = 'l';
        }

        /*
        **  Existing files: new version, overwrite, no extract?
        */
        status = cli$present(&cli_exist_newver);
        if (status == CLI$_PRESENT) {
            *ptr++ = 'o';
        }
        status = cli$present(&cli_exist_over);
        if (status == CLI$_PRESENT) {
            *ptr++ = 'o';
            *ptr++ = 'o';
        }
        status = cli$present(&cli_exist_noext);
        if (status == CLI$_PRESENT) {
            *ptr++ = 'n';
        }

        /*
        **  Overwrite files (deprecated) ?
        */
        status = cli$present(&cli_overwrite);
        if (status == CLI$_NEGATED)
            *ptr++ = 'n';
        else if (status != CLI$_ABSENT)
            *ptr++ = 'o';

        /*
        **  Decryption password from command line?
        */
        status = cli$present(&cli_password);
        if (status == CLI$_PRESENT) {
            status = cli$get_value(&cli_password, &password_arg);
        }

        /*
        **  Pipe files to SYS$OUTPUT with no informationals?
        */
        status = cli$present(&cli_pipe);
        if (status != CLI$_ABSENT)
            *ptr++ = 'p';

        /*
        **  Quiet
        */
        status = cli$present(&cli_quiet);
        if (status & 1) {
            *ptr++ = 'q';
            if ((status = cli$present(&cli_super_quiet)) & 1)
                *ptr++ = 'q';
        }

        /*
        **  Test archive integrity
        */
        status = cli$present(&cli_test);
        if (status == CLI$_NEGATED)
            *ptr++ = '-';
        if (status != CLI$_ABSENT)
            *ptr++ = 't';

        /*
        **  Set archive timestamp according to its newest file.
        */
        status = cli$present(&cli_timestamp);
        if (status & 1)
            *ptr++ = 'T';

        /*
        **  Extract "foo.ext.###" as "foo.ext;###" (treat .### as version number)
        */
        status = cli$present(&cli_dot_version);
        if (status == CLI$_NEGATED)
            *ptr++ = '-';
        if (status != CLI$_ABSENT)
            *ptr++ = 'Y';

        /*
        **  Force conversion of extracted file names to old ODS2 conventions
        */
        status = cli$present(&cli_ods2);
        if (status == CLI$_NEGATED)
            *ptr++ = '-';
        if (status != CLI$_ABSENT)
            *ptr++ = '2';

        /*
        **  Traverse directories (don't skip "../" path components)
        */
        status = cli$present(&cli_traverse);
        if (status == CLI$_NEGATED)
            *ptr++ = '-';
        if (status != CLI$_ABSENT)
            *ptr++ = ':';

        /*
        **  Make (some) names lowercase



( run in 0.824 second using v1.01-cache-2.11-cpan-5735350b133 )