$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On  5-JUN-1992 08:43:44.06   By user GOATHUNTER (@WKUVX1.BITNET)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 3 PARTS, TO KEEP EACH PART
$!  BELOW 60 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. [.UNARJ_SRC]DECODE.C;1
$!       2. [.UNARJ_SRC]ENVIRON.C;1
$!       3. [.UNARJ_SRC]MAKEFILE.;1
$!       4. [.UNARJ_SRC]MAKE_VMS.COM;1
$!       5. [.UNARJ_SRC]OS2UNARJ.MAK;1
$!       6. [.UNARJ_SRC]QCLUNARJ.MAK;1
$!       7. [.UNARJ_SRC]README.DOC;1
$!       8. [.UNARJ_SRC]TCCUNARJ.MAK;1
$!       9. [.UNARJ_SRC]TECHNOTE.DOC;1
$!      10. [.UNARJ_SRC]UNARJ.C;1
$!      11. [.UNARJ_SRC]UNARJ.DEF;1
$!      12. [.UNARJ_SRC]UNARJ.DOC;1
$!      13. [.UNARJ_SRC]UNARJ.H;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X/* DECODE.C, UNARJ, R JUNG, 05/04/91
X * Decode ARJ archive
X * Copyright (c) 1991 by Robert K Jung.  All rights reserved.
X *
X *   This code may be freely used in programs that are NOT ARJ archivers
X *   (both compress and extract ARJ archives).
X *
X *   If you wish to distribute a modified version of this program, you
X *   MUST indicate that it is a modified version both in the program and
X *   source code.
X *
X *   If you modify this program, I would appreciate a copy of the new
X *   source code.  I am holding the copyright on the source code, so
X *   please do not delete my name from the program files or from the
X *   documentation.
X *
X * Modification history:
X * Date      Programmer  Description of modification.
X * 04/05/91  R. Jung`09 Rewrote code.
X * 04/23/91  M. Adler`09 Portabilized.
X * 04/29/91  R. Jung`09 Made GETBIT independent of short size.
X * 05/04/91  R. Jung`09 Simplified use of start`5Blen`5D.
X *
X */
X
X#include "unarj.h"
X
X#ifdef MODERN
X#include <stdlib.h>
X#else /* !MODERN */
Xextern void free();
X#endif /* ?MODERN */
X
X#define THRESHOLD    3
X#define DDICSIZ      26624
X#define MAXDICBIT   16
X#define MATCHBIT     8
X#define MAXMATCH   256
X#define NC`09    (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
X#define NP`09    (MAXDICBIT + 1)
X#define CBIT`09     9
X#define NT`09    (CODE_BIT + 3)
X#define PBIT`09     5
X#define TBIT`09     5
X
X#if NT > NP
X#define NPT NT
X#else
X#define NPT NP
X#endif
X
X#define CTABLESIZE  4096
X
X#define STRTP`09       9
X#define STOPP`09      13
X
X#define STRTL`09       0
X#define STOPL`09       7
X
X/* Local functions */
X
X#ifdef MODERN
Xstatic void   make_table(int nchar, uchar *bitlen, int tablebits, ushort *ta
Vble);
Xstatic void   read_pt_len(int nn, int nbit, int i_special);
Xstatic void   read_c_len(void);
Xstatic ushort decode_c(void);
Xstatic ushort decode_p(void);
Xstatic void   decode_start(void);
Xstatic short  decode_ptr(void);
Xstatic short  decode_len(void);
X#endif /* MODERN */
X
X/* Local variables */
X
Xstatic short  getlen;
Xstatic short  getbuf;
X
Xstatic ushort left`5B2 * NC - 1`5D;
Xstatic ushort right`5B2 * NC - 1`5D;
Xstatic uchar  c_len`5BNC`5D;
Xstatic uchar  pt_len`5BNPT`5D;
X
Xstatic ushort c_table`5BCTABLESIZE`5D;
Xstatic ushort pt_table`5B256`5D;
Xstatic ushort blocksize;
X
X/* Huffman decode routines */
X
Xstatic void
Xmake_table(nchar, bitlen, tablebits, table)
Xint    nchar;
Xuchar  *bitlen;
Xint    tablebits;
Xushort *table;
X`7B
X    ushort count`5B17`5D, weight`5B17`5D, start`5B18`5D, *p;
X    uint i, k, len, ch, jutbits, avail, nextcode, mask;
X
X    for (i = 1; i <= 16; i++)
X`09count`5Bi`5D = 0;
X    for (i = 0; (int)i < nchar; i++)
X`09count`5Bbitlen`5Bi`5D`5D++;
X
X    start`5B1`5D = 0;
X    for (i = 1; i <= 16; i++)
X`09start`5Bi + 1`5D = start`5Bi`5D + (count`5Bi`5D << (16 - i));
X    if (start`5B17`5D != (ushort) (1 << 16))
X`09error(M_BADTABLE, "");
X
X    jutbits = 16 - tablebits;
X    for (i = 1; (int)i <= tablebits; i++)
X    `7B
X`09start`5Bi`5D >>= jutbits;
X`09weight`5Bi`5D = 1 << (tablebits - i);
X    `7D
X    while (i <= 16)
X    `7B
X`09weight`5Bi`5D = 1 << (16 - i);
X`09i++;
X    `7D
X
X    i = start`5Btablebits + 1`5D >> jutbits;
X    if (i != (ushort) (1 << 16))
X    `7B
X`09k = 1 << tablebits;
X`09while (i != k)
X`09    table`5Bi++`5D = 0;
X    `7D
X
X    avail = nchar;
X    mask = 1 << (15 - tablebits);
X    for (ch = 0; (int)ch < nchar; ch++)
X    `7B
X`09if ((len = bitlen`5Bch`5D) == 0)
X`09    continue;
X`09k = start`5Blen`5D;
X`09nextcode = k + weight`5Blen`5D;
X`09if ((int)len <= tablebits)
X`09`7B
X`09    for (i = start`5Blen`5D; i < nextcode; i++)
X`09`09table`5Bi`5D = ch;
X`09`7D
X`09else
X`09`7B
X`09    p = &table`5Bk >> jutbits`5D;
X`09    i = len - tablebits;
X`09    while (i != 0)
X`09    `7B
X`09`09if (*p == 0)
X`09`09`7B
X`09`09    right`5Bavail`5D = left`5Bavail`5D = 0;
X`09`09    *p = avail++;
X`09`09`7D
X`09`09if (k & mask)
X`09`09    p = &right`5B*p`5D;
X`09`09else
X`09`09    p = &left`5B*p`5D;
X`09`09k <<= 1;
X`09`09i--;
X`09    `7D
X`09    *p = ch;
X`09`7D
X`09start`5Blen`5D = nextcode;
X    `7D
X`7D
X
Xstatic void
Xread_pt_len(nn, nbit, i_special)
Xint nn;
Xint nbit;
Xint i_special;
X`7B
X    int i, n;
X    short c;
X    ushort mask;
X
X    n = getbits(nbit);
X    if (n == 0)
X    `7B
X`09c = getbits(nbit);
X`09for (i = 0; i < nn; i++)
X`09    pt_len`5Bi`5D = 0;
X`09for (i = 0; i < 256; i++)
X`09    pt_table`5Bi`5D = c;
X    `7D
X    else
X    `7B
X`09i = 0;
X`09while (i < n)
X`09`7B
X`09    c = bitbuf >> (13);
X`09    if (c == 7)
X`09    `7B
X`09`09mask = 1 << (12);
X`09`09while (mask & bitbuf)
X`09`09`7B
X`09`09    mask >>= 1;
X`09`09    c++;
X`09`09`7D
X`09    `7D
X`09    fillbuf((c < 7) ? 3 : (int)(c - 3));
X`09    pt_len`5Bi++`5D = (uchar)c;
X`09    if (i == i_special)
X`09    `7B
X`09`09c = getbits(2);
X`09`09while (--c >= 0)
X`09`09    pt_len`5Bi++`5D = 0;
X`09    `7D
X`09`7D
X`09while (i < nn)
X`09    pt_len`5Bi++`5D = 0;
X`09make_table(nn, pt_len, 8, pt_table);
X    `7D
X`7D
X
Xstatic void
Xread_c_len()
X`7B
X    short i, c, n;
X    ushort mask;
X
X    n = getbits(CBIT);
X    if (n == 0)
X    `7B
X`09c = getbits(CBIT);
X`09for (i = 0; i < NC; i++)
X`09    c_len`5Bi`5D = 0;
X`09for (i = 0; i < CTABLESIZE; i++)
X`09    c_table`5Bi`5D = c;
X    `7D
X    else
X    `7B
X`09i = 0;
X`09while (i < n)
X`09`7B
X`09    c = pt_table`5Bbitbuf >> (8)`5D;
X`09    if (c >= NT)
X`09    `7B
X`09`09mask = 1 << (7);
X`09`09do
X`09`09`7B
X`09`09    if (bitbuf & mask)
X`09`09`09c = right`5Bc`5D;
X`09`09    else
X`09`09`09c = left`5Bc`5D;
X`09`09    mask >>= 1;
X`09`09`7D while (c >= NT);
X`09    `7D
X`09    fillbuf((int)(pt_len`5Bc`5D));
X`09    if (c <= 2)
X`09    `7B
X`09`09if (c == 0)
X`09`09    c = 1;
X`09`09else if (c == 1)
X`09`09    c = getbits(4) + 3;
X`09`09else
X`09`09    c = getbits(CBIT) + 20;
X`09`09while (--c >= 0)
X`09`09    c_len`5Bi++`5D = 0;
X`09    `7D
X`09    else
X`09`09c_len`5Bi++`5D = (uchar)(c - 2);
X`09`7D
X`09while (i < NC)
X`09    c_len`5Bi++`5D = 0;
X`09make_table(NC, c_len, 12, c_table);
X    `7D
X`7D
X
Xstatic ushort
Xdecode_c()
X`7B
X    ushort j, mask;
X
X    if (blocksize == 0)
X    `7B
X`09blocksize = getbits(16);
X`09read_pt_len(NT, TBIT, 3);
X`09read_c_len();
X`09read_pt_len(NP, PBIT, -1);
X    `7D
X    blocksize--;
X    j = c_table`5Bbitbuf >> 4`5D;
X    if (j >= NC)
X    `7B
X`09mask = 1 << (3);
X`09do
X`09`7B
X`09    if (bitbuf & mask)
X`09`09j = right`5Bj`5D;
X`09    else
X`09`09j = left`5Bj`5D;
X`09    mask >>= 1;
X`09`7D while (j >= NC);
X    `7D
X    fillbuf((int)(c_len`5Bj`5D));
X    return j;
X`7D
X
Xstatic ushort
Xdecode_p()
X`7B
X    ushort j, mask;
X
X    j = pt_table`5Bbitbuf >> (8)`5D;
X    if (j >= NP)
X    `7B
X`09mask = 1 << (7);
X`09do
X`09`7B
X`09    if (bitbuf & mask)
X`09`09j = right`5Bj`5D;
X`09    else
X`09`09j = left`5Bj`5D;
X`09    mask >>= 1;
X`09`7D while (j >= NP);
X    `7D
X    fillbuf((int)(pt_len`5Bj`5D));
X    if (j != 0)
X    `7B
X`09j--;
X`09j = (1 << j) + getbits((int)j);
X    `7D
X    return j;
X`7D
X
Xstatic void
Xdecode_start()
X`7B
X    blocksize = 0;
X    init_getbits();
X`7D
X
Xvoid
Xdecode()
X`7B
X    short i;
X    short j;
X    short c;
X    short r;
X    uchar *text;
X    long count;
X
X    text = (uchar *)malloc_msg(DDICSIZ);
X
X    disp_clock();
X    decode_start();
X    count = 0;
X    r = 0;
X
X    while (count < origsize)
X    `7B
X`09if ((c = decode_c()) <= UCHAR_MAX)
X`09`7B
X`09    text`5Br`5D = (uchar) c;
X`09    count++;
X`09    if (++r >= DDICSIZ)
X`09    `7B
X`09`09r = 0;
X`09`09disp_clock();
X`09`09fwrite_txt_crc(text, DDICSIZ);
X`09    `7D
X`09`7D
X`09else
X`09`7B
X`09    j = c - (UCHAR_MAX + 1 - THRESHOLD);
X`09    count += j;
X`09    i = decode_p();
X`09    if ((i = r - i - 1) < 0)
X`09`09i += DDICSIZ;
X`09    if (r > i && r < DDICSIZ - MAXMATCH - 1)
X`09    `7B
X`09`09while (--j >= 0)
X`09`09    text`5Br++`5D = text`5Bi++`5D;
X`09    `7D
X`09    else
X`09    `7B
X`09`09while (--j >= 0)
X`09`09`7B
X`09`09    text`5Br`5D = text`5Bi`5D;
X`09`09    if (++r >= DDICSIZ)
X`09`09    `7B
X`09`09`09r = 0;
X`09`09`09disp_clock();
X`09`09`09fwrite_txt_crc(text, DDICSIZ);
X`09`09    `7D
X`09`09    if (++i >= DDICSIZ)
X`09`09`09i = 0;
X`09`09`7D
X`09    `7D
X`09`7D
X    `7D
X    if (r != 0)
X`09fwrite_txt_crc(text, r);
X
X    free((char *)text);
X`7D
X
X/* Macros */
X
X#define BFIL `7Bgetbuf`7C=bitbuf>>getlen;fillbuf(CODE_BIT-getlen);getlen=COD
VE_BIT;`7D
X#define GETBIT(c) `7Bif(getlen<=0)BFIL c=(getbuf&0x8000)!=0;getbuf<<=1;getle
Vn--;`7D
X#define BPUL(l) `7Bgetbuf<<=l;getlen-=l;`7D
X#define GETBITS(c,l) `7Bif(getlen<l)BFIL c=(ushort)getbuf>>(CODE_BIT-l);BPUL
V(l)`7D
X
Xstatic short
Xdecode_ptr()
X`7B
X    short c;
X    short width;
X    short plus;
X    short pwr;
X
X    plus = 0;
X    pwr = 1 << (STRTP);
X    for (width = (STRTP); width < (STOPP) ; width++)
X    `7B
X`09GETBIT(c);
X`09if (c == 0)
X`09    break;
X`09plus += pwr;
X`09pwr <<= 1;
X    `7D
X    if (width != 0)
X`09GETBITS(c, width);
X    c += plus;
X    return c;
X`7D
X
Xstatic short
Xdecode_len()
X`7B
X    short c;
X    short width;
X    short plus;
X    short pwr;
X
X    plus = 0;
X    pwr = 1 << (STRTL);
X    for (width = (STRTL); width < (STOPL) ; width++)
X    `7B
X`09GETBIT(c);
X`09if (c == 0)
X`09    break;
X`09plus += pwr;
X`09pwr <<= 1;
X    `7D
X    if (width != 0)
X`09GETBITS(c, width);
X    c += plus;
X    return c;
X`7D
X
Xvoid
Xdecode_f()
X`7B
X    short i;
X    short j;
X    short c;
X    short r;
X    short pos;
X    long count;
X    uchar *text;
X
X    text = (uchar *)malloc_msg(DDICSIZ);
X
X    disp_clock();
X    init_getbits();
X    getlen = getbuf = 0;
X    count = 0;
X    r = 0;
X
X    while (count < origsize)
X    `7B
X`09c = decode_len();
X`09if (c == 0)
X`09`7B
X`09    GETBITS(c, CHAR_BIT);
X`09    text`5Br`5D = (uchar)c;
X`09    count++;
X`09    if (++r >= DDICSIZ)
X`09    `7B
X`09`09r = 0;
X`09`09disp_clock();
X`09`09fwrite_txt_crc(text, DDICSIZ);
X`09    `7D
X`09`7D
X`09else
X`09`7B
X`09    j = c - 1 + THRESHOLD;
X`09    count += j;
X`09    pos = decode_ptr();
X`09    if ((i = r - pos - 1) < 0)
X`09`09i += DDICSIZ;
X`09    while (j-- > 0)
X`09    `7B
X`09`09text`5Br`5D = text`5Bi`5D;
X`09`09if (++r >= DDICSIZ)
X`09`09`7B
X`09`09    r = 0;
X`09`09    disp_clock();
X`09`09    fwrite_txt_crc(text, DDICSIZ);
X`09`09`7D
X`09`09if (++i >= DDICSIZ)
X`09`09    i = 0;
X`09    `7D
X`09`7D
X    `7D
X    if (r != 0)
X`09fwrite_txt_crc(text, r);
X
X    free((char *)text);
X`7D
X
X/* end DECODE.C */
$ CALL UNPACK [.UNARJ_SRC]DECODE.C;1 156876650
$ create 'f'
X/* ENVIRON.C, UNARJ, R JUNG, 07/07/91
X * Implementation dependent routines
X * Copyright (c) 1991 by Robert K Jung.  All rights reserved.
X *
X *   This code may be freely used in programs that are NOT ARJ archivers
X *   (both compress and extract ARJ archives).
X *
X *   If you wish to distribute a modified version of this program, you
X *   MUST indicate that it is a modified version both in the program and
X *   source code.
X *
X *   If you modify this program, I would appreciate a copy of the new
X *   source code.  I am holding the copyright on the source code, so
X *   please do not delete my name from the program files or from the
X *   documentation.
X *
X *   The vanilla section of this file was tested with UNIX in mind.
X *
X * Modification history:
X * Date      Programmer  Description of modification.
X * 04/09/91  R. Jung`09 Rewrote code.
X * 04/23/91  M. Adler`09 Portabilized.
X * 04/29/91  R. Jung`09 Added get_mode_str().
X * 05/08/91  R. Jung`09 Combined set_ftime() and set_fmode().
X * 06/03/91  R. Jung     Changed arguments in get_mode_str() and
X *                       set_ftime_mode().
X * 07/07/91  R. Jung     Added default_case_path() and UNIX section.
X * 25/05/92  I. Mandrichenko
X *                       Ported to VMS
X *
X */
X
X#include "unarj.h"
X
X#ifdef __TURBOC__
X
X#define SUBS_DEFINED
X
X#include <string.h>
X#include <dos.h>
X#include <io.h>
X#include <fcntl.h>
X#include <alloc.h>
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    return fopen(name, mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek(stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xvoidp *
Xxmalloc(size)
Xint size;
X`7B
X    return (voidp *)malloc((size_t) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    return (access(name, 0) == 0);
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X`09str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X`09str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X`09str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X`09str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    FILE *fd;
X    int code;
X
X    if ((fd = fopen(name, "r+b")) == NULL)
X`09return -1;
X    code = setftime(fileno(fd), (struct ftime *) &tstamp);
X    fclose(fd);
X    if (host == OS)
X    `7B
X`09if (_chmod(name, 1, attribute) == -1)
X`09    return -1;
X    `7D
X    return code;
X`7D
X
X#endif
X
X#ifdef _QC
X
X#define SUBS_DEFINED
X
X#include <string.h>
X#include <dos.h>
X#include <io.h>
X#include <fcntl.h>
X#include <malloc.h>
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    return fopen(name, mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek(stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xvoidp *
Xxmalloc(size)
Xint size;
X`7B
X    return (voidp *)malloc((size_t) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    return (access(name, 0) == 0);
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X`09str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X`09str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X`09str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X`09str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    FILE *fd;
X    int code;
X    uint date_stamp, time_stamp;
X
X    date_stamp = (uint)(tstamp >> 16);
X    time_stamp = (uint)(tstamp & 0xFFFF);
X    if ((fd = fopen(name, "r+b")) == NULL)
X`09return -1;
X    code = _dos_setftime(fileno(fd), date_stamp, time_stamp);
X    fclose(fd);
X    if (host == OS)
X    `7B
X`09if (_dos_setfileattr(name, attribute))
X`09    return -1;
X    `7D
X    return code;
X`7D
X
X#endif
X
X#ifdef _OS2
X
X#define SUBS_DEFINED
X
X#include <string.h>
X#define INCL_DOSFILEMGR
X#include <os2.h>
X#include <io.h>
X#include <fcntl.h>
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    return fopen(name, mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek(stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (size_t) size, (size_t) nitems, stream);
X`7D
X
Xvoidp *
Xxmalloc(size)
Xint size;
X`7B
X    return (voidp *)malloc((size_t) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X    strupper(name);
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    return (access(name, 0) == 0);
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X        str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X        str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X        str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X        str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    int code;
X    FDATE date_stamp;
X    FTIME time_stamp;
X    HFILE handle;
X    FILESTATUS info;
X    USHORT action;
X
X    date_stamp.day = ts_day (tstamp);
X    date_stamp.month = ts_month (tstamp);
X    date_stamp.year = ts_year (tstamp) - 1980;
X    time_stamp.twosecs = ts_sec (tstamp) / 2;
X    time_stamp.minutes = ts_min (tstamp);
X    time_stamp.hours = ts_hour (tstamp);
X    if (DosOpen (name, &handle, &action, 0L, 0, FILE_OPEN,
X`09`09 OPEN_ACCESS_READWRITE`7COPEN_SHARE_DENYREADWRITE, 0L) != 0)
X`09return -1;
X    info.fdateCreation = date_stamp;
X    info.ftimeCreation = time_stamp;
X    info.fdateLastAccess = date_stamp;
X    info.ftimeLastAccess = time_stamp;
X    info.fdateLastWrite = date_stamp;
X    info.ftimeLastWrite = time_stamp;
X    info.cbFile = 0;
X    info.cbFileAlloc = 0;
X    info.attrFile = 0;
X    code = (int)DosSetFileInfo (handle, 1, (PBYTE)&info, sizeof (info));
X    (void)DosClose (handle);
X    if (host == OS)
X    `7B
X`09if (DosSetFileMode (name, attribute, 0L))
X`09    return -1;
X    `7D
X    return code;
X`7D
X
X#endif
X
X#ifdef UNIX
X`09`09`09   /* specifically tested under SUN UNIX */
X#define SUBS_DEFINED
X
Xextern char *strcpy();
Xextern voidp *malloc();
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    return fopen(name, mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (int) size, (int) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek(stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (int) size, (int) nitems, stream);
X`7D
X
Xvoidp *
Xxmalloc(size)
Xint size;
X`7B
X    return (voidp *)malloc((uint) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X    strlower(name);
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    FILE *fd;
X
X    if ((fd = fopen(name, "rb")) == NULL)
X`09return 0;
X    fclose(fd);
X    return 1;
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X`09str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X`09str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X`09str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X`09str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    return 0;
X`7D
X
X#endif  /* end of UNIX section */
X
X#ifdef VMS
X
X#define SUBS_DEFINED
X
Xextern char *strcpy();
Xextern char *malloc();
Xextern char *strchr();
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    char mode_tmp`5B5`5D;
X    strcpy(mode_tmp,mode);
X    if( strchr(mode_tmp,'b') != NULL )
X    `7B`09*strchr(mode_tmp,'b') = 0;
X`09return fopen(name,mode_tmp,"ctx=stm");
X    `7D
X    else
X`09return fopen(name,mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (int) size, (int) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek( stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (int) size, (int) nitems, stream);
X`7D
X
Xchar *
Xxmalloc(size)
Xint size;
X`7B
X    return malloc((uint) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X    strlower(name);
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    FILE *fd;
X
X    if ((fd = fopen(name, "rb")) == NULL)
X`09return 0;
X    fclose(fd);
X    return 1;
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X`09str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X`09str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X`09str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X`09str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    return 0;
X`7D
X
X#endif  /* end of VMS section */
X
X#ifndef SUBS_DEFINED`09   /* vanilla version for other compilers */
X`09`09`09   /* specifically tested under SUN UNIX */
X#ifdef MODERN
X#include <string.h>
X#else /* !MODERN */
Xextern char *strcpy();
Xextern voidp *malloc();
X#endif /* ?MODERN */
X
XFILE *
Xfile_open(name, mode)
Xchar *name;
Xchar *mode;
X`7B
X    return fopen(name, mode);
X`7D
X
Xint
Xfile_read(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fread(buf, (int) size, (int) nitems, stream);
X`7D
X
Xint
Xfile_seek(stream, offset, mode)
XFILE *stream;
Xlong offset;
Xint  mode;
X`7B
X    return fseek(stream, offset, mode);
X`7D
X
Xlong
Xfile_tell(stream)
XFILE *stream;
X`7B
X    return ftell(stream);
X`7D
X
Xint
Xfile_write(buf, size, nitems, stream)
Xchar *buf;
Xint  size;
Xint  nitems;
XFILE *stream;
X`7B
X    return fwrite(buf, (int) size, (int) nitems, stream);
X`7D
X
Xvoidp *
Xxmalloc(size)
Xint size;
X`7B
X    return (voidp *)malloc((uint) size);
X`7D
X
Xvoid
Xcase_path(name)
Xchar *name;
X`7B
X`7D
X
Xvoid
Xdefault_case_path(name)
Xchar *name;
X`7B
X`7D
X
Xint
Xfile_exists(name)
Xchar *name;
X`7B
X    FILE *fd;
X
X    if ((fd = fopen(name, "rb")) == NULL)
X`09return 0;
X    fclose(fd);
X    return 1;
X`7D
X
Xvoid
Xget_mode_str(str, mode)
Xchar *str;
Xuint mode;
X`7B
X    strcpy(str, "---W");
X    if (mode & FA_ARCH)
X`09str`5B0`5D = 'A';
X    if (mode & FA_SYSTEM)
X`09str`5B1`5D = 'S';
X    if (mode & FA_HIDDEN)
X`09str`5B2`5D = 'H';
X    if (mode & FA_RDONLY)
X`09str`5B3`5D = 'R';
X`7D
X
Xint
Xset_ftime_mode(name, tstamp, attribute, host)
Xchar  *name;
Xulong tstamp;
Xuint  attribute;
Xuint  host;
X`7B
X    return 0;
X`7D
X
X#endif`09/* end of vanilla section */
X
X/* end ENVIRON.C */
$ CALL UNPACK [.UNARJ_SRC]ENVIRON.C;1 892221182
$ create 'f'
XCFLAGS=-O -DUNIX
XCC=cc`20
X
Xall:`09      unarj
X
Xunarj.o:      unarj.c`09unarj.h
X
Xdecode.o:     decode.c`09unarj.h
X
Xenviron.o:    environ.c unarj.h
X
Xunarj:`09unarj.o decode.o environ.o`20
X`09$(CC) -o unarj unarj.o decode.o environ.o
X
Xclean:
X`09-rm -f unarj.o decode.o environ.o
$ CALL UNPACK [.UNARJ_SRC]MAKEFILE.;1 1936131311
$ create 'f'
X$!
X$!`09Build UNARJ
X$!
X$ cc environ,decode,unarj
X$ link/exe=unarj unarj,environ,decode,sys$input/opt
Xsys$library:vaxcrtl.exe/share
X$!
X$!`09Test it
X$!
X$ here = f$env("procedure")
X$ here = f$parse(here,,,"device")+f$parse(here,,,"directory")
X$ unarj == "$''here'unarj.exe"
X$ unarj
X$ exit
$ CALL UNPACK [.UNARJ_SRC]MAKE_VMS.COM;1 594032873
$ create 'f'
X# MAKE file for unarj.exe for OS/2 Microsoft C 6.0
X
XCC=cl -AS -W4 -Ze -Oaxz -F 1000 -Lp -D_OS2
X
Xall:`09      unarj.exe
X
Xunarj.obj:    unarj.c`09unarj.h
X
Xdecode.obj:   decode.c`09unarj.h
X
Xenviron.obj:  environ.c unarj.h
X
Xunarj.exe:    unarj.obj decode.obj environ.obj unarj.def
X     $(CC)    unarj decode environ unarj.def
X
X# end of make
$ GOTO PART2
