From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 19-AUG-1989 20:44
To:	MRGATE::"ARISIA::EVERHART"
Subj:	VMS MORE 2 OF 7

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 18 AUG 89 22:11:34 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 18 Aug 89 21:54:31 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA29176; Fri, 18 Aug 89 21:49:51 -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:56:17 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 2 OF 7
Message-Id: <2321@jhunix.HCF.JHU.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X                        `125
X                        else`123
X                          i -=2; /*reset file counter */
X                          ClrEOL(); standout();
X                          printf("Previous file:");
X                          standend();
X                          printf("%s\n",nargv`091i+1`093);
X                          printf("press any key to continue...");
X                          getkey();
X                        `125
X                        break;
X                  case 101:  /* ASCII e: end of file */
X                        ClrEOL(); standout();
X                        printf("End of File:");
X                        standend();
X                        printf("%s\n",nargv`091i`093);
X                        if(i!=nargc)`123
X                                printf("press any key to continue...");
X                                getkey();
X                        `125
X                        break;
X`009`009case 100: /* ith file */
X`009`009`009ClrEOL(); standout();
X`009`009`009printf("%dth file:",ithfile);
X`009`009`009standend();
X`009`009`009printf(" %s\n",nargv`091ithfile`093);
X`009`009`009printf("Press any key to continue...");
X`009`009`009getkey();
X`009`009`009i=ithfile-1;
X`009`009`009break;
X                default:
X                        if(i<nargc)`123
X                          ClrEOL();
X                          printf("\nNext file:%s\n",nargv`091i+1`093);
X                          printf("press any key to continue...");
X                          getkey();
X`032
X                        `125
X                `125/*switch*/
X`009`009releasemem();
X                fclose(fp);
X        `125/*for*/
X`009if(!narrow) narrow_width();
X`125  /* main */
$ CALL UNPACK MAIN.C;2 1645286893
$ create/nolog 'f'
X/* global variables */
X#include stdio
X#include string
X#include descrip
X`032
X#define TRUE  1
X#define FALSE 0
X#define EOS '\0'
X`032
X#define MAXNAME    254
X#define MAXFILES   200
X
Xchar Terminal_Open();
Xvoid clrs();
Xvoid ClrEOL();
Xvoid standend();
Xvoid descriptor();
Xstruct dsc$descriptor_s *descr();
Xvoid standout();
Xint  getkey();
X#ifdef UNIX_TO_VMS
Xchar *convert_unix_to_vms();
X#endif UNIX_TO_VMS
X
Xchar *malloc();
Xint more();
Xint  narrow=TRUE,flag=FALSE;
Xint  nargc,ithfile,line_pt,line_end,curfile;
Xchar *nargv`091MAXFILES+1`093;
$ CALL UNPACK MAIN.H;1 1764367163
$ create/nolog 'f'
X/*VMS MORE V1.5*/
X#include stdio
X#define MAXLINES 20000
Xstatic char  *lpt`091MAXLINES`093;
Xextern int line_pt,line_end;
Xstatic char  str`091256`093;
X
Xmaptomemory(fp)
XFILE *fp;
X`123`009
X`009line_pt=1;
X`009lpt`091line_pt`093=(char *)malloc(256);`032
X`009if(fgets(str,256,fp)==NULL)`123
X`009`009`009lpt`091line_pt`093=NULL;
X`009`009`009return;
X`009`125
X`009strcpy(lpt`091line_pt`093,str);
X`009while(1)`123
X`009`009line_pt++;
X`009`009lpt`091line_pt`093=(char *)malloc(256);
X`009`009if(fgets(str,256,fp)!=NULL)`123
X`009`009`009strcpy(lpt`091line_pt`093,str);
X`009`009`125
X`009`009else `123
X`009`009`009lpt`091line_pt`093=(char *)NULL;
X`009`009`009line_end=line_pt;
X`009`009`009break;
X`009`009`125
X`009`125
X`125
X
X
Xchar  *fgetline(str)
Xchar *str;
X`123
X`009if(line_pt<1) line_pt=1;
X`009if(line_pt>=line_end) return ((char *)NULL);
X`009strcpy(str,lpt`091line_pt`093);
X`009line_pt++;
X`009return(str);
X`125
X
X
Xint bgetline(str)
Xchar *str;
X`123
X
X`009if(line_pt<1)`123
X`009`009line_pt=1;
X`009`009return ((char *)NULL);
X`009`125
X`009if(line_pt>=line_end) return ((char *)NULL);
X`009strcpy(str,lpt`091line_pt`093);
X`009line_pt--;
X`009return(str);
X`125
X
Xint dgetline(str,d)
Xchar *str;
Xint d;
X`123
X`009if(d>0)  /*forward*/
X`009`009return(fgetline(str));
X`009
X`009else    /*backward */
X`009`009return(bgetline(str));
X`125
X
Xreleasemem()
X`123
X`009int i=1;
X`009while(i<line_end)  free(lpt`091i++`093);
X`125
$ CALL UNPACK MAP.C;1 1014314962
$ create/nolog 'f'
X/*VMS MORE V1.5*/
X#include "more.h"
Xint eof_check();
Xint eof_exit=TRUE, case_sensitive=FALSE;`032
Xint more(fp, fname)
XFILE *fp;
Xchar *fname;
X`123
X        char pattern`09180`093, a_line`091240`093, tmp`09120`093;
X        int  i=0, ch, lastcommand, pat_found;
X`009int  line_pt_save, line_mark=0,direction;
X        long file_size,ftell();
X        struct stat status_block;
X       `032
X#ifdef REXPRESSIONS
X        char *re_comp(),*pmsg;
X#endif REXPRESSIONS
X        int factor=1;
X`009pattern`0910`093='\0';
X        fstat (fileno (fp), &status_block);
X        file_size = status_block.st_size;
X        clrs();
X        if (prwindow(Screen_Height - 1)==NULL)
X                return(101); /* window #0 */ /*101: End of file*/
X        while(TRUE)
X        `123
X                standout();
X                printf("\r--More--(%s, %d%%)", fname,
X`009`009`009(int)((double)line_pt/(double)line_end*100.0));
X`009`009
X                standend();
X                i=0;
X                tmp`0910`093='\0';
X                while (isdigit(ch = getkey()))
X                `123      `032
X                        tmp`091i++`093=ch;
X                        tmp`091i`093='\0';
X                `125
X                if(tmp`0910`093!='\0') `123
X                        factor=atoi(tmp);
X                        tmp`0910`093='\0';
X                `125
X                if( ch == '.' ) ch=lastcommand;
X                switch ( ch,lastcommand=ch )
X                `123
X                case '\r':    /*down factor lines */
X                case '+':
X                case 'j':
X`009`009case 'J':
X`009`009case 275:     /*down arrow */
X`009`009case 14 :     /*ctrl-n */
X`009`009`009ClrEOL();
X                        if (prline(factor)==NULL)
X`009`009`009`009if(eof_check(fname)) return;
X                        factor=1;
X                        break;
X`009`009case '-':
X`009`009case 16 :   /* ctrl-p */
X`009`009case 274:   /*up arrow*/
X`009`009case 'k':
X`009`009case 'K':
X`009`009`009if(line_pt<=Screen_Height) break;
X`009`009`009if(scroll_r())`123   char tmp`091240`093;
X`009`009`009`009line_pt_save=line_pt;
X`009`009`009`009line_pt=line_pt-Screen_Height;
X`009`009`009`009fgetline(tmp);
X`009`009`009`009printf("%s",tmp);
X`009`009`009`009line_pt=line_pt_save-1;
X`009`009`009`009cursor(Screen_Height,1);
X`009`009`009`009
X`009`009`009`125
X`009`009`009else  `032
X`009`009`009`009message("No such capabiliby!");
X`009`009`009break;
X`009`009case 'c':
X`009`009case 'C':
X`009`009`009config();
X`009`009`009clrs();
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X`009`009`009if(prwindow(Screen_Height-1)==NULL)
X`009`009`009`009if(eof_check(fname)) return;
X`009`009`009break;
X                case ' ':       /*next screen*/
X                case 'f':
X`009`009case 'F':
X`009`009case 316:   /*for my vt100 terminal:Next_screen*/
X`009`009case 22 :   /*ctrl-v */
X                        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009if(eof_check(fname)) return;
X                        break;
X                case 'd':`032
X`009`009case 'D':
X`009`009`009no_clrs=TRUE; `032
X                        if (prwindow(Screen_Height / 2)==NULL)`123
X`009`009`009`009no_clrs=FALSE;;
X`009`009`009`009eof_check(fname);
X`009`009`009`125
X`009`009`009no_clrs=FALSE;
X                        break;
X                case 's':`032
X`009`009case 'S':    /*skip forward*/
X                        standout();
X                        printf("\nSkipping forward %d lines.\n",
X                        factor * (Screen_Height - 1));
X                        standend();
X`009`009`009for(i=1; i<=factor*(Screen_Height-1); i++)`123
X                                if (fgetline(a_line)==NULL)`123
X`009`009`009`009   if(eof_check(fname)) return;
X`009`009`009`009break;
X`009`009`009`009`125
X`009`009`009`125
X                        factor=1;
X                        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009if(eof_check(fname)) return;
X                        break;
X                case '/':
X`009`009case '?':
X`009`009case  311: /*find key: for vt100 terminal */
X                        ClrEOL();
X`009`009`009if( (ch=='/')  `124`124 (ch==311) )`123
X`009                        putchar('/');
X`009`009`009`009direction=1;
X`009`009`009`125
X`009`009`009if(ch=='?')`123
X`009`009`009`009putchar('?');
X`009`009`009`009direction=(-1);`032
X`009`009`009`125
X`009
X                        get_pattern(pattern);
X`009`009`009if(( ch=='?') && (pattern`0910`093=='\0') )`123
X`009                        more_help ();
X`009`009`009`009line_pt=line_pt-(Screen_Height-1);
X                `009        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009`009if(eof_check(fname))return;
X                        `009break;
X`009`009`009`125
X`009`009case 'n':
X`009`009case 'N':`009
X
X#ifdef REXPRESSIONS
X                        if(pmsg=re_comp(pattern))`123
X`009`009`009`009message(pmsg);
X                                break;
X                        `125
X#endif REXPRESSIONS
X`009`009`009if( ((ch=='n') `124`124 (ch=='N')) && (pattern`0910`093=='\0') )
V`123
X`009`009`009`009   message("No previous pattern!");
X`009`009`009`009   break;
X`009`009`009`125
X`009`009`009search=TRUE;
X`009`009`009line_pt_save=line_pt;
X`009`009`009if(direction<0)`123 /*skip current screen*/
X`009`009`009`009  line_pt=line_pt-(Screen_Height)-1;
X`009`009`009`009  if(line_pt<=0)`123
X`009`009`009`009`009line_pt=line_pt_save;
X`009`009`009`009`009message("At top of the file!");
X`009`009`009`009`009break;
X`009`009`009`009  `125
X`009`009`009`125
X`009`009`009while (dgetline(a_line,direction)!=NULL)`123
X                                if (find(pattern,a_line))`123
X`009`009`009`009`009pat_found=TRUE;
X`009`009`009`009`009break;
X`009`009`009`009`125
X                        `125
X`009`009`009if(pat_found)`123
X`009`009`009`009pat_found=FALSE;
X`009                        ClrEOL();
X       `009`009                standout ();
X               `009`009        printf("%s",a_line);
X                       `009`009standend ();
X`009`009`009`009if(direction<0) line_pt=line_pt+2;
X        `009                if (prwindow(Screen_Height - 2)==NULL)
X`009`009`009`009if(eof_check(fname))return;
X       `009                `009break;
X`009`009`009`125
X`009`009`009else `123
X`009`009`009`009line_pt=line_pt_save;
X`009`009`009`009ClrEOL();
X`009`009`009`009message("String not found");
X                        `009break;
X`009`009`009`125
X                case 't':
X`009`009case 'T':
X`009`009`009line_pt=1;
X                        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009if(eof_check(fname))return;
X                        break;
X                case 'b':
X`009`009case 'B':
X`009`009case 315:  /*prev_screen: vt100 terminal*/
X`009`009`009if(end_file)`123
X`009        `009        line_pt=line_pt-(Screen_Height-1);
X`009`009`009`009end_file=FALSE;
X`009`009`009`125else
X`009    `009        line_pt=line_pt-(1+factor)*(Screen_Height-1);
X                        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009if(eof_check(fname))return;
X                        factor=1;
X                        break;
X                case 'h':
X`009`009case 'H':
X                        more_help ();
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X                        if (prwindow(Screen_Height - 1)==NULL)
X`009`009`009`009if(eof_check(fname))return;
X                        break;
X`009`009case 'g':
X`009`009case 'G':
X`009`009`009ClrEOL();putchar('g');
X`009`009`009line_pt_save=line_pt;
X`009`009`009line_pt=getint();
X`009`009`009line_pt=line_pt<=0?1:line_pt;
X`009`009`009if(line_pt>=line_end)`123
X`009`009`009`009message("Line number is too large!");
X`009`009`009`009line_pt=line_pt_save;
X`009`009`009`009break;
X`009`009`009`125
X                        if (prwindow(Screen_Height - 1)==NULL)
X                                if(eof_check(fname))return;
X`009`009`009break;
X`009`009case '%':
X`009`009`009ClrEOL();putchar('%');
X`009`009`009line_pt=(int)
X`009`009`009   ( (double)getint()*(double)line_end/(double)100);
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X`009`009`009line_pt=line_pt<=0?1:line_pt;
X                        if (prwindow(Screen_Height - 1)==NULL)
X                                if(eof_check(fname))return;
X`009`009`009break;
X`009`009case 'm':
X`009`009case 'M':
X`009`009`009line_mark=line_pt-1;
X`009`009`009break;
X`009`009case '\007':
X`009`009case '\047':
X`009`009`009if(line_mark==0) `123
X`009`009`009`009message("You have to mark line first!");
X`009`009`009`009break;
X`009`009`009`125
X`009`009`009else`032
X`009`009`009`009line_pt=line_mark;
X                        if (prwindow(Screen_Height - 1)==NULL)
X                                if(eof_check(fname))return;
X                        break;
X`009`009case '\014': /* `094L */
X                       `032
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X`009`009`009clrs();
X                        if (prwindow(Screen_Height - 1)==NULL)
X                                if(eof_check(fname))return;
X                        break;
X`009`009case '\027':   /*ctr-w */
X`009`009`009`009if(narrow) `123
X`009`009`009`009`009Screen_Width=132;
X`009`009`009`009`009if(set_width(Screen_Width))
X`009`009`009`009`009`009narrow=FALSE;
X`009`009`009`009`125
X`009`009`009`009else `123
X`009`009`009`009`009Screen_Width=80;
X`009`009`009`009`009set_width(Screen_Width);
X`009`009`009`009`009narrow=TRUE;
X`009`009`009`009`125
X                       `032
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X                        if (prwindow(Screen_Height - 1)==NULL)
X                                if(eof_check(fname))return;
X`009`009`009break;
X`009`009case 'l':
X`009`009case 'L':
X`009`009`009if(listfile()!=0)  return(100);
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X`009`009`009if( prwindow(Screen_Height-1)==NULL)
X`009`009`009`009if(eof_check(fname))return;
X`009`009`009break;
X                case '!':
X                        spawn(); clrs();
X`009`009`009line_pt=line_pt-(Screen_Height-1);
X                        if (prwindow(Screen_Height - 1)==NULL)
X                              if(eof_check(fname))return;
X                        break;
X                case '#':
X                        return(110); /* ASCII n : next file */
X                case 'q':
X`009`009case 'Q':
+-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-

