From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 19-AUG-1989 02:12
To:	MRGATE::"ARISIA::EVERHART"
Subj:	VMS MORE  1 of 7

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 18 AUG 89 22:11:27 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 18 Aug 89 21:54:17 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA29159; Fri, 18 Aug 89 21:49:24 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 19 Aug 89 03:53:21 GMT
From: gem.mps.ohio-state.edu!ginosko!aplcen!jhunix!jhuvms.bitnet@tut.cis.ohio-state.edu  (Xuning Shan)
Organization: Dept. of Chemical Engineering, The Johns Hopkins University
Subject: VMS MORE  1 of 7
Message-Id: <2320@jhunix.HCF.JHU.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On 18-AUG-1989 23:37:27.37   By user SHAN 
$!
$! 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 7 PARTS, TO KEEP EACH PART
$!  BELOW 30 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. BUILDMORE.COM;1
$!       2. CONFIG.C;1
$!       3. DESCRIPTOR.C;1
$!       4. EOF_CHECK.C;1
$!       5. GETINT.C;1
$!       6. LISTFILE.C;1
$!       7. MAIN.C;2
$!       8. MAIN.H;1
$!       9. MAP.C;1
$!      10. MORE.C;1
$!      11. MORE.CLD;2
$!      12. MORE.DOC;2
$!      13. MORE.H;1
$!      14. MORE.HLP;1
$!      15. MORE_HELP.C;1
$!      16. PRLINE.C;1
$!      17. PRWINDOW.C;1
$!      18. REG.C;1
$!      19. RTL.OPT;1
$!      20. SPAWN.C;1
$!      21. STRING.C;1
$!      22. TERMIO.C;1
$!      23. UNIX2VMS.C;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 = "!"
$ if f$getsyi("version") .ges. "V4.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/nolog '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/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ 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");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);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 g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X$!VMS MORE V1.5
X$!
X$!define link libraries  if one chooses to compile this way.
X$!`032
X$!DEFINE LNK$LIBRARY      SYS$LIBRARY:VAXCCURSE
X$!DEFINE LNK$LIBRARY_1    SYS$LIBRARY:VAXCRTLG
X$!DEFINE LNK$LIBRARY_2    SYS$LIBRARY:VAXCRTL
X$!
X$!If you need UNIX to VMS file name conversion, define UNIX_TO_VMS.
X$!If you need regular expression in search,     define REXPRESSIONS.
X$!              for more.c and string.c
X$CC/DEFINE=(VMSV5,REXPRESSIONS)/OPTIMIZE MORE
X$CC/OPTIMIZE  CONFIG
X$CC/OPTIMIZE  DESCRIPTOR
X$CC/OPTIMEZE  EOF_CHECK
X$CC/OPTIMIZE  GETINT
X$CC/OPTIMEZE  LISTFILE
X$CC/OPTIMIZE  MAIN
X$CC/OPTIMIZE  MAP
X$CC/OPTIMIZE  MORE_HELP
X$CC/OPTIMEZE  PRLINE
X$CC/OPTIMEZE  PRWINDOW
X$CC/OPTIMIZE  REG
X$CC/OPTIMIZE  SPAWN
X$CC/OPTIMIZE/DEFINE=REXPRESSIONS   STRING
X$CC/OPTIMIZE  TERMIO
X$CC/OPTIMIZE  UNIX2VMS
X$LINK/EXE=MORE CONFIG, DESCRIPTOR,EOF_CHECK,GETINT,LISTFILE,-
X  MAIN,MAP,MORE,MORE_HELP,PRLINE,PRWINDOW,REG,SPAWN,STRING,TERMIO,-
X  UNIX2VMS,RTL.OPT/OPT
$ CALL UNPACK BUILDMORE.COM;1 906716341
$ create/nolog 'f'
X/*VMS MORE V1.50*/
Xextern int Screen_Height,Screen_Width;`009`009`009
X#define TRUE 1
X#define FALSE 0
X#include stdio
Xextern int eof_exit,case_sensitive;
Xvoid config()
X`123`009
X`009clrs();
X`009cursor(2,1);
X`009if(eof_exit)
X`009`009printf("1:  toggle eof_exit      =  TRUE");
X`009else`032
X`009`009printf("1:  toggle eof_exit      = FALSE");
X`009cursor(3,1);
X`009if(case_sensitive)
X`009`009printf("2:  toggle case_sensitive=  TRUE");
X`009else`032
X`009`009printf("2:  toggle case_sensitive= FALSE");
X`009cursor(4,1);
X`009printf("3:  exit from this menu\n");
X`009printf("q:  quit more\n");
X`009while(TRUE)`123
X`009  cursor(Screen_Height,1);ClrEOL();
X`009  switch(getkey())`123
X`009`009case  '1':`032
X`009`009`009if(eof_exit) `123
X`009`009`009`009eof_exit=FALSE;
X`009`009`009`009cursor(2,28);
X`009`009`009`009printf("FALSE");
X`009`009`009`125`009`009
X`009`009`009else`123
X`009`009`009         eof_exit=TRUE;
X`009`009`009`009 cursor(2,28);
X`009`009`009`009 printf(" TRUE");
X`009`009`009`125
X`009`009`009break;
X`009`009case '2':`032
X`009`009`009if(case_sensitive)`123
X`009`009`009 `009case_sensitive=FALSE;
X`009`009`009`009cursor(3,28);
X`009`009`009`009printf("FALSE");
X`009`009`009`125
X`009`009`009else    `123          `032
X`009`009`009`009case_sensitive=TRUE;
X`009`009`009`009cursor(3,28);
X`009`009`009`009printf(" TRUE");
X`009`009`009`125
X`009`009`009break;
X`009`009case '3':
X`009`009`009return;
X`009`009`009break;
X`009`009case 'q':
X`009`009`009exit();
X`009`009`009break;
X`009`009default:
X`009`009`009putchar('\007');
X`009`009`009break;
X `009  `125/*switch*/
X`009  fflush(stdin);
X`009`125/*while*/
X`125
$ CALL UNPACK CONFIG.C;1 1986331151
$ create/nolog 'f'
X/*VMS MORE V1.5*/
X#include descrip
Xvoid descriptor();
X/*descriptor(): it fills previously declared descriptor. Return nothing */
Xstruct dsc$descriptor_s *descr();
Xvoid descriptor(desc,string)   `032
Xstruct dsc$descriptor_s *desc;
Xchar *string;`032
X`123
X        desc->dsc$w_length=strlen(string);     `032
X        desc->dsc$b_dtype=DSC$K_DTYPE_T;        /* data type code */
X        desc->dsc$b_class=DSC$K_CLASS_S;        /* descriptor class code */
X        desc->dsc$a_pointer=string;     `009/* address of first`032
X`009`009`009`009`009`009byte of data element*/
X`125
X
X/* descr() creates character descriptor and return the address
Xof the descriptor to the caller. */
X# define N_DESCR 10
Xstatic struct dsc$descriptor_s str_desc`091N_DESCR`093;
Xstatic int cur_descr = -1;
X
Xstruct dsc$descriptor_s *descr (string)
Xchar *string;
X`123
X`009
X`009if(++cur_descr >= N_DESCR) cur_descr=-1;
X`009str_desc`091cur_descr`093.dsc$w_length=strlen(string);     `032
X        str_desc`091cur_descr`093.dsc$b_dtype=DSC$K_DTYPE_T;  `032
X        str_desc`091cur_descr`093.dsc$b_class=DSC$K_CLASS_S; `032
X        str_desc`091cur_descr`093.dsc$a_pointer=string;    `032
X`009return (&str_desc`091cur_descr`093);
X`125
X
$ CALL UNPACK DESCRIPTOR.C;1 1030956442
$ create/nolog 'f'
X/*VMS MORE V1.5*/
X#define TRUE 1
X#define FALSE 0
Xextern int end_file,eof_exit;
Xint eof_check(s)
Xchar *s;
X`123
X`009standout();
X        printf("End of File:");    standend();
X        printf(" %s\n",s);
X`009end_file=TRUE;
X`009if(eof_exit)`032
X`009`009return(1);
X`009else
X`009`009return(0);
X
X`125
X
$ CALL UNPACK EOF_CHECK.C;1 1967879253
$ create/nolog 'f'
X/*VMS MORE V1.5
Xgetint(): gets digits, ignoring all other ASCII characters.
XDelete key works.*/
Xextern int Screen_Height;
X#include ctype
Xint getint()
X`123
X`009char tmp`09110`093;
X`009int i=0;
X`009cursor(Screen_Height,1);
X`009while((tmp`091i`093=getkey())!='\r')`123
X`009
X`009`009if(isdigit(tmp`091i`093))`123
X`009`009`009 putchar(tmp`091i++`093);
X`009`009`009 continue;
X`009`009`125
X`009`009else if( tmp`091i`093=='\177') `123
X`009`009`009if(i!=0)`123
X`009`009`009`009i--;
X`009`009`009`009printf("\b \b");
X`009`009`009`125
X`009`009`125
X`009`009else if( (tmp`091i`093=='r') `124`124 (tmp`091i`093=='R') )`123
X`009`009`009return(-1);
X`009`009`125
X`009`009else if( tmp`091i`093==' ')`123
X`009`009`009return(10000);
X`009`009`125
X`009`009else`123
X`009`009  if( (tmp`091i`093 =='q') `124`124 (tmp`091i`093=='Q') `124`124 (tm
Vp`091i`093=='\032') )`032
X`009`009`009`009exit();
X`009`009`125
X`009`125
X`009tmp`091++i`093='\0';
X`009return(atoi(tmp));`009`009
X`125`009
$ CALL UNPACK GETINT.C;1 2116776644
$ create/nolog 'f'
X/*VMS MORE V1.5*/
X#define MAXFILES  200
Xextern char *nargv`091MAXFILES+1`093;
Xextern int nargc,narrow,ithfile,Screen_Height;
Xstatic int get_response();
Xint first=1;
Xint listfile()
X`123`009
X
X`009int i=1,ret,tmpct=0;
X`009clrs();
X`009while(i<=nargc)`123
X`009`009tmpct++;
X`009`009lower_str(nargv`091i`093);
X`009`009printf("%d         %s\n",i,nargv`091i`093);
X`009`009if(tmpct==(Screen_Height-6)) `123
X`009`009`009tmpct=0;  /*reset counter*/
X`009`009`009switch(ret=get_response())`123
X`009`009`009 case 0:`032
X`009`009`009 case 1: `032
X`009`009`009`009   return(0);
X`009`009`009`009   break;    /*no use*/
X`009`009`009 case  10000:              /*space*/
X`009`009`009`009 `032
X`009`009`009`009   clrs();
X`009`009`009 `009   break;
X`009`009`009  default:
X`009`009`009`009return(ret);
X`009`009`009`125/*switch*/
X`009`009`125/*if*/
X`009`009i++;
X`009`125/*while*/
X`009first=0;
X`009switch(ret=get_response())`123
X`009`009 case 0:`032
X`009`009 case 1: `032
X`009   `009`009return(0);
X`009   `009`009break;    /*no use*/
X `009`009 case  10000:              /*space*/
X                        return(0);
X `009   `009`009break;
X`009  `009default:
X`009`009`009return(ret);
X`009`125/*switch*/
X
X`125/*listfile*/
X
Xstatic int get_response()
X`123
X`009int tmp;
X`009printf("\nr                  Return to more\n");
X`009if(first)`123
X`009`009first=0;
X`009`009printf("SPACE              next page\n");
X`009`125
X`009printf("q  or ctrl-Z Exit  from MORE\n");
X`009printf("Make your choice and press <return> ");
X`009tmp=getint();
X`009if( ((tmp<-1) `124`124 (tmp>nargc)) && (tmp!=10000))`123
X`009`009printf("\nNot valid selection. Try again.\n");
X`009`009sleep(1);
X`009`009listfile();
X`009`125
X`009else`123
X`009`009if(tmp==0)`123`032
X`009`009`009return(0);
X`009`009`125
X`009`009else if (tmp==(-1))`123
X`009`009`009return(0);
X`009`009`125
X`009`009else if (tmp==10000)`123
X`009`009`009return(10000);
X`009`009`125
X`009`009else`123
X`009`009`009ithfile=tmp;
X`009`009`009return(tmp);
X`009`009`125
X`009`125
X`125
X
$ CALL UNPACK LISTFILE.C;1 57907646
$ create/nolog 'f'
X/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
X`009VMS MORE: V1.50
X`009Author: Xuning Shan
X`009`009Dept. of Chemical Engineering
X`009`009The Johns Hopkins Univ.
X`009Email : ins_bxs@jhuvms.BITNET
X`009`009shan%che2@jhmail.hcf.jhu.edu
X`009Documentation and modification histroy is in file more.doc`009`009
X */
X#include "main.h"
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X`123
X        int i, j , first=1;
X        char *pn, file_found;
X        FILE *fp;
X        /* next few lines to deal with lib$find_file() */
X        static char name`091MAXNAME`093;
X        $DESCRIPTOR(result,name);
X        struct dsc$descriptor_s name_desc; `032
X        long context;
X        Terminal_Open(); /*create virtual keyboard and more*/
X        if(argc==1)`123                    /*if no file, prompt for it */
X                argv`0911`093=malloc(40);
X                printf("File:");
X                scanf("%s",argv`0911`093);
X                argc++;
X        `125
X`009lower_str(argv`0911`093);
X        if( (strcmp(argv`0911`093,"-c")==0) `124`124 (strncmp(argv`0911`093,
V"/c",2)==0) )`123
X                flag=TRUE;
X                first=2;
X                if(argc==2)`123
X                        argv`0912`093=malloc(40);
X                        printf("File:");
X                        scanf("%s",argv`0912`093);
X                        argc++;
X                `125
X        `125
X        for (i = first, nargc = 0; i < argc && nargc <= MAXFILES; i++)
X        `123
X                context = 0;
X#ifdef UNIX_TO_VMS
X                if (strchr (argv`091i`093, '/') != (char *) NULL)
X                        argv`091i`093 = convert_unix_to_vms (argv`091i`093);
X#endif UNIX_TO_VMS
X                descriptor(&name_desc,argv`091i`093);
X                file_found = FALSE;
X                while (lib$find_file(&name_desc, &result, &context) & 1)
X                `123
X                        file_found = TRUE;
X                        if (nargc >= MAXFILES)`123
X                                fprintf(stderr, "Only %d files will be read\
Vn",
X                                MAXFILES);
X                                break;
X                        `125
X                        nargv`091++nargc`093 = malloc((unsigned)strlen(name)
V + 1);
X                        strcpy(nargv`091nargc`093, result.dsc$a_pointer);
X`009`009`009lower_str(nargv`091nargc`093);
X                `125
X                if (!file_found)
X                        fprintf (stderr, "Couldn't find file %s\n", argv`091
Vi`093);
X                lib$find_file_end(&context);
X        `125
X`009
X        for (i=1; i<=nargc; i++)
X        `123
X                if ((fp = fopen(nargv`091i`093, "r")) == NULL)`123
X                        perror(nargv`091i`093);
X                        continue;
X                `125
X`009`009curfile=i; /*remember current file*/
X                for (pn = nargv`091i`093; *pn != EOS && *pn != '`093'; pn++)
V;
X                if (*pn == '`093') pn++;  /*get file name without path*/
X`009`009maptomemory(fp);
X`009`009line_pt=1; /*move pointer to first line */
X                switch(more(fp, pn))
X                `123    `032
X                  case 112:  /* ASCII p: previous file */
X                        if((i==1) `124`124(nargc==1))`123
X                          ClrEOL();
X                          standout();
X                          printf("No previous file.\n");
X                          standend();
X                          i--;
X                          printf("press any key to continue...");
X                          getkey();
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-

