home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
phvm.zip
/
mkphvm.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-06-11
|
25KB
|
656 lines
/*****************************************************************************/
/* MKHVM.CMD 1.0 */
/*****************************************************************************/
/* Make your own Personal Hobbes Virtual Mirror */
/*****************************************************************************/
/*****************************************************************************/
/* Permission to use this program for any purpose is hereby granted without */
/* fee, provided that the author's name not be used in advertising or */
/* publicity pertaining to distribution of the software without specific */
/* written prior permision. */
/* */
/* THIS SOFTWARE PACKAGE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED */
/* WARRANTY. */
/* THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE PACKAGE, */
/* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. */
/* IN NO EVENT SHALL THE AUTHOR OR ANY PERSON OR INSTITUTION ASSOCIATED WITH */
/* THIS PRODUCT BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR CONSEQUENTIAL */
/* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR */
/* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS */
/* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE PACKAGE. */
/*****************************************************************************/
/*****************************************************************************/
/* Written by R.H.LindengrĂ¼n in 1998 Internet:rhlindengrun@mail.telepac.pt */
/*****************************************************************************/
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/* MUST CHANGE MUST CHANGE MUST CHANGE MUST CHANGE MUST CHANGE MUST CHANGE */
/* This is the variable where you must your e-mail address as the WebMaster */
/* of this mirror site */
WebMaster='rhlindengrun@mail.telepac.pt'
/* CHANGE AT WILL CHANGE AT WILL CHANGE AT WILL CHANGE AT WILL CHANGE AT WILL*/
/* This variable controls if the files begining with "00", like 00global.txt */
/* shoul be hidden (=1) or not (=0) */
Hide00Files=0
/* This variable controls if pages will be made using the <TABLE> tag (=1) */
/* or not (=0).(Have you noticed any browser not suppoting tables lately ?) */
TableEnable=1
/* This is the name of the first file that will be created. I called it this */
/* name so that my HTTPD could load it by default. */
MainFile='index.html'
/* Where you put your own comments to a file in Hobbes */
CommentsFile='comments.hvm'
/* Where you assign a diferent URL or icon to a file in Hobbes */
LocalFile='local.hvm'
/* Where you assign a diferent icon to each file extension (zip, gif, etc...)*/
IconFile='icon.hvm'
/* UNLIKELY TO CHANGE UNLIKELY TO CHANGE UNLIKELY TO CHANGE UNLIKELY TO CHANG*/
/* The number of words in a date. It could be like "1998/01/01" (=1) word or */
/* like "Jan 01 1998" (=3) words. Check it if some thing goes wrong. */
WordsInDate=1
/* This is the URL pointing to the Hobbes root. */
HobbesRoot='ftp://hobbes.nmsu.edu'
/* This is the name of the file we are analyzing. Don't forget to update the */
/* file often to reflect last changes in Hobbes structure. */
InputFile='00global.txt'
/* YOU'R AT YOUR OWN NOW YOU'R AT YOUR OWN NOW YOU'R AT YOUR OWN NOW YOU'R AT*/
SubDirStem.0=1
SubDirStem.1=MainFile
HVMLastUpdate='?????'
HVMCurDir=''
HVMCurRoot=''
LocalStem.0=0
IconStem.0=0
CommentStem.0=0
CurRecStem.0=6
CurRecStem.icon=''
CurRecStem.name=''
CurRecStem.URL=''
CurRecStem.size=''
CurRecStem.date=''
CurRecStem.info=''
CurPageStem.0=6
CurPageStem.name=MainFile
CurPageStem.title='Root of Hobbes Archive'
CurPageStem.directory=''
CurPageStem.parent=MainFile
CurPageStem.previous=MainFile
CurPageStem.records=0
ArchiveStem.0=0
ArchiveStem.FileID=''
ArchiveStem.PathID=''
ArchiveStem.FoundFile=''
ArchiveStem.Sudjest=''
call Prepare
call MainPage CurPageStem.name
call LineIn InputFile,1,0
do while Lines(InputFile)
call ProccessLine LineIn(InputFile)
end
call MakeFooter
call LineOut InputFile
call ShowLostFiles
return
/*---------------------------------------------------------------------------*/
/* ProccessLine(Line) */
/*...........................................................................*/
/* The main processing logic */
/*---------------------------------------------------------------------------*/
ProccessLine:
parse arg line
/* This is an empty line: Nothing to do */
if line = '' then do
return
end
/* Begins with ' ' or TAB then add to previous line as a multiline comment*/
if substr(line,1,1)=' ' | substr(line,1,1)='09'x then do
call MakeRestOfComments line
return
end
/* We don't need spaces any more */
line=strip(line)
/* If begins with a "." or "/" and ends with a ":" this is a new directory */
if (substr(line,1,1) = '.' | substr(line,1,1) = '/' ) & substr(line,length(line),1)=':' then do
call MakeFooter
call MakeNewPage line
return
end
/* If the first word ends with a "/" then this line is a subdirectory */
if right(subword(line,1,1),1)='/' then do
call RegisterSubDir line
call MakeDirRef line
return
end
/* At this point it must be a regular file record */
call MakeFileRef line
return
/*---------------------------------------------------------------------------*/
/* Prepare */
/*...........................................................................*/
/* Loads configuration files and prepares the running environment */
/*---------------------------------------------------------------------------*/
Prepare:
rc=SysFileTree(InputFile,'file',"O")
HVMCurRoot=translate(substr(file.1,1,lastpos('\',file.1)-1))
say 'Root:'HVMCurRoot
HVMLastUpdate = stream(InputFile,'c','query datetime')
n=1
call LineIn LocalFile,1,0
do while Lines(LocalFile)
ref=strip(LineIn(LocalFile))
if substr(ref,1,2)='./' then do
LocalStem.0=n
LocalStem.n.orig=substr(subword(ref,1,1),3)
LocalStem.n.dest=subword(ref,2,1)
LocalStem.n.icon=subword(ref,3,1)
n=n+1
end
end
call lineout LocalFile
n=1
call LineIn IconFile,1,0
do while Lines(IconFile)
ref=strip(LineIn(IconFile))
if substr(ref,1,1)\='#' then do
IconStem.0=n
IconStem.n.orig=subword(ref,1,1)
IconStem.n.dest=translate(subword(ref,2,1))
n=n+1
end
end
call lineout IconFile
n=1
call LineIn CommentsFile,1,0
do while Lines(CommentsFile)
ref=strip(LineIn(CommentsFile))
if substr(ref,1,2)='./' then do
CommentStem.0=n
CommentStem.n.orig=substr(subword(ref,1,1),3)
CommentStem.n.info=subword(ref,2)
n=n+1
end
end
call lineout CommentsFile
call ListArchived
return
/*---------------------------------------------------------------------------*/
/* ListArchived */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
ListArchived:
rc=SysFileTree('*.*','arch',"DO")
do y=1 to arch.0
rc=SysFileTree(arch.y'\*.*','file',"FOS")
do n=1 to file.0
ArchiveStem.FileID.n=translate(substr(file.n,lastpos('\',file.n)+1))
ArchiveStem.PathID.n=translate(substr(file.n,1,lastpos('\',file.n)-1))
ArchiveStem.PathID.n=substr(ArchiveStem.PathID.n,length(HVMCurRoot)+2)
ArchiveStem.FoundFile.n=0
ArchiveStem.Sudjest.n=''
ArchiveStem.0=n
end
end
return
/*---------------------------------------------------------------------------*/
/* ShowLostFiles */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
ShowLostFiles:
FoundAny=0
say ''
do y=1 to ArchiveStem.0
if ArchiveStem.FoundFile.y=0 then do
if ArchiveStem.Sudjest.y='' then do
say 'Del 'ArchiveStem.PathID.y'\'ArchiveStem.FileID.y
end
else do
say 'Move 'ArchiveStem.PathID.y'\'ArchiveStem.FileID.y' 'ArchiveStem.Sudjest.y'\'ArchiveStem.FileID.y
end
FoundAny=1
end
end
if FoundAny=0 then
say 'Found no lost files'
else
return
/*---------------------------------------------------------------------------*/
/* FindFile */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
FindFile:
FilePath=arg(1)
FileName=arg(2)
FilePath=translate(FilePath)
FilePath=translate(FilePath,'\','/')
FileName=translate(FileName)
retval=0
do y=1 to ArchiveStem.0
if ArchiveStem.FileID.y=FileName then do
if ArchiveStem.PathID.y=FilePath then do
ArchiveStem.FoundFile.y=1
retval=1
leave
end
else do
ArchiveStem.Sudjest.y=FilePath
end
end
end
return retval
/*---------------------------------------------------------------------------*/
/* MakeDirRef(Line) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
MakeDirRef:
parse arg line
if words(line)>1 then do
CurRecStem.name=subword(line,1,1)
CurRecStem.size=subword(line,2,1)
CurRecStem.date=subword(line,3,WordsInDate)
CurRecStem.info=subword(line,3+WordsInDate)
end
else do
CurRecStem.name=subword(line,1,1)
CurRecStem.size=''
CurRecStem.date=''
CurRecStem.info=''
end
CurRecStem.icon='vmfilsub.gif'
if HVMCurdir ='' then
CurRecStem.URL=MakePageName(CurRecStem.name)
else
CurRecStem.URL=MakePageName(HVMCurdir'/'CurRecStem.name)
call MakeLine
return
/*---------------------------------------------------------------------------*/
/* MakeFileRef(Line) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
MakeFileRef:
parse arg line
CurPageStem.records=CurPageStem.records+1
CurRecStem.icon=''
if words(line)>1 then do
CurRecStem.name=subword(line,1,1)
CurRecStem.size=subword(line,2,1)
CurRecStem.date=subword(line,3,WordsInDate)
CurRecStem.info=subword(line,3+WordsInDate)
end
else do
CurRecStem.name=subword(line,1,1)
CurRecStem.size=''
CurRecStem.date=''
CurRecStem.info=''
end
CurRecStem.icon=GetImageFile(CurRecStem.name)
CurRecStem.URL=GetReferenceFile(CurRecStem.name)
call MakeLine
return
/*---------------------------------------------------------------------------*/
/* GetReferenceFile(FileName) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
GetReferenceFile:
parse arg FileName
FilePath=''
if HVMCurdir ='' then
Reference=FileName
else
Reference=HVMCurdir'/'FileName
if LocalStem.0>0 then do
do n=1 to LocalStem.0
if LocalStem.n.orig = Reference then do
if LocalStem.n.dest \= '?' then do
FilePath=LocalStem.n.dest
end
if LocalStem.n.icon \= '' then
CurRecStem.icon=LocalStem.n.icon
leave
end
end
if FilePath='' then
FilePath=HobbesRoot'/'Reference
end
else do
FilePath=HobbesRoot'/'Reference
end
if CommentStem.0>0 then do
do n=1 to CommentStem.0
if CommentStem.n.orig = Reference then do
CurRecStem.info=CurRecStem.info' <BR> 'CommentStem.n.info
leave
end
end
end
return FilePath
/*---------------------------------------------------------------------------*/
/* RegisterSubDir(Line) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
RegisterSubDir:
parse arg line
DirName=subword(line,1,1)
DirInfo=subword(line,2)
found=0
if HVMCurdir = '' then
RealName=DirName
else
RealName=HVMCurdir'/'DirName
CurNum=SubDirStem.0
do n=2 to CurNum
if SubDirStem.n=RealName then do
Found=n
leave
end
end
if found =0 then do
CurNum=CurNum+1
SubDirStem.0=CurNum
SubDirStem.CurNum = RealName
end
return
/*---------------------------------------------------------------------------*/
/* MakePageName(file) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
MakePageName:
parse arg file
RetName=''
do n=2 to SubDirStem.0
if SubDirStem.n=file then do
RetName='HVM'n'.html'
leave
end
end
return RetName
/*---------------------------------------------------------------------------*/
/* MakeNewPage(Line) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
MakeNewPage:
parse arg line
CurPageStem.previous = CurPageStem.name
if substr(line,1,1) = '.' then do
HVMCurdir=substr(line,3,length(line)-3)
end
else do
HVMCurdir=substr(line,2,length(line)-2)
end
if substr(line,1,9) = '/net/ftp/' then do
HVMCurdir=substr(line,10,length(line)-10)
end
CurPageStem.directory = HVMCurdir
CurPageStem.title = HVMCurdir
CurPageStem.name = MakePageName(HVMCurdir'/')
CurPageStem.parent = GetParentFile(HVMCurdir)
CurPageStem.records = 0
call MakeHeader
CurRecStem.icon = 'vmfilpar.gif'
CurRecStem.name = 'Parent Directory'
CurRecStem.URL = CurPageStem.parent
CurRecStem.size = ''
CurRecStem.date = ''
CurRecStem.info = ''
call MakeLine
return
/*---------------------------------------------------------------------------*/
/* GetParentFile(Path) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
GetParentFile:
parse arg path
position=lastpos('/',path)
if position = 0 then do
filename=SubDirStem.1
end
else do
filename=MakePageName(substr(path,1,position))
end
return filename
/*---------------------------------------------------------------------------*/
/* MainPage(FileName) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
MainPage:
parse arg FileName
call MakeHeader
return
/*---------------------------------------------------------------------------*/
/* GetImage(FileName) */
/*...........................................................................*/
/* */
/*---------------------------------------------------------------------------*/
GetImageFile:
parse upper arg FileName
IconFile='vmfilfil.gif'
FileType=substr(FileName,pos('.',FileName)+1)
if IconStem.0>0 then do
do n=1 to IconStem.0
if wordpos(FileType,IconStem.n.dest)>0 then do
IconFile=IconStem.n.orig
leave
end
end
end
return IconFile
/*---------------------------------------------------------------------------*/
/* MakeHeader */
/*...........................................................................*/
/* Builds the page Header */
/*---------------------------------------------------------------------------*/
MakeHeader:
say CurPageStem.name' 'CurPageStem.directory
call SysFileDelete CurPageStem.name
call lineout CurPageStem.name, '<HTML>'
call lineout CurPageStem.name, '<HEAD>'
/* call lineout CurPageStem.name, '<META http-equiv="content-type" content="text/html; charset=ISO-8859-2">' */
call lineout CurPageStem.name, '<TITLE>Personal Hobbes Virtual Mirror ('CurPageStem.title')</TITLE>'
call lineout CurPageStem.name, '</HEAD>'
call lineout CurPageStem.name, ''
call lineout CurPageStem.name, '<BODY background="vmbackgr.gif">'
call lineout CurPageStem.name, '<img src = "vmbanner.jpg" ALT=" ">'
call lineout CurPageStem.name, '<CENTER>'
call lineout CurPageStem.name, '<H1>Personal Hobbes Virtual Mirror</H1>'
call lineout CurPageStem.name, '<H2>'translate(CurPageStem.title)'</H2>'
call lineout CurPageStem.name, '<HR>'
call lineout CurPageStem.name, 'Switch to a different mirror site:<BR>'
call lineout CurPageStem.name, '[ <A HREF = "http://www.columbia.edu/~chs11/hvm/HVMindex.hobbes.html">HVM</A> ] '
call lineout CurPageStem.name, '[ <A HREF = "http://www.teamos2.org/hvm/Hobbes/HVMindex.hobbes.html">Team OS/2</A> ] '
call lineout CurPageStem.name, '[ <A HREF = "http://www.math.fu-berlin.de:80/~rene/os2/hvm/HVMindex.fu-berlin.html">FU Berlin</A> ] '
call lineout CurPageStem.name, '[ <A HREF = "http://sunsite.nus.sg/pub/os2/hvm/HVMindex.hobbes.html">SunSite</A> ] '
call lineout CurPageStem.name, '[ <A HREF = "http://www.uni-leipzig.de/~os2/HVM/HVMindex.uni-leipzig.html">Leipzig</A> ] '
call lineout CurPageStem.name, '[ <A HREF = "http://www.peryt.waw.pl/produkty/software/ibm/hvm/HVMindex.hobbes.html">Peryt</A> ] '
call lineout CurPageStem.name, '<HR>'
call lineout CurPageStem.name, '</CENTER>'
if TableEnable then
call lineout CurPageStem.name, '<TABLE>'
else
call lineout CurPageStem.name, '<PRE>'
return
/*---------------------------------------------------------------------------*/
/* MakeLine */
/*...........................................................................*/
/* Builds each page line */
/*---------------------------------------------------------------------------*/
MakeLine:
if \(Hide00Files = 1 & substr(CurRecStem.name,1,2) = '00') then do
if TableEnable then do
call lineout CurPageStem.name, '<TR VALIGN="top">'
if CurPageStem.directory = '' then do
fname=CurRecStem.name
end
else do
fname=CurPageStem.directory'/'CurRecStem.name
end
call FindFile CurPageStem.directory, CurRecStem.name
rc=SysFileTree(fname,'file',"FO")
if file.0>0 then do
call lineout CurPageStem.name, '<TD><A HREF="'fname'"><IMG SRC="vmfilcas.gif" ALT=" " BORDER=0></A></TD>'
end
else do
call lineout CurPageStem.name, '<TD></TD>'
end
call lineout CurPageStem.name, '<TD ALIGN="center"><IMG SRC="'CurRecStem.icon'" ALT=" "></TD>'
call lineout CurPageStem.name, '<TD NOWRAP="NOWRAP"><A HREF="'CurRecStem.URL'">'CurRecStem.name'</A></TD>'
call lineout CurPageStem.name, '<TD ALIGN="right">'CurRecStem.size'</TD>'
call lineout CurPageStem.name, '<TD NOWRAP="NOWRAP">'CurRecStem.date'</TD>'
call lineout CurPageStem.name, '<TD>'CurRecStem.info'</TD>'
call lineout CurPageStem.name, '</TR>'
end
else do
call lineout CurPageStem.name, '<IMG SRC="'CurRecStem.icon'" ALT=" "><A HREF="'CurRecStem.URL'">'CurRecStem.Name'</A>'CurRecStem.Size' 'CurRecStem.Date' 'CurRecStem.Info
end
end
return
/*---------------------------------------------------------------------------*/
/* MakeRestOfComments(Line) */
/*...........................................................................*/
/* When multiline comment appears */
/*---------------------------------------------------------------------------*/
MakeRestOfComments:
parse arg line
call lineout CurPageStem.name, line
return
/*---------------------------------------------------------------------------*/
/* MakeFooter */
/*...........................................................................*/
/* Builds the page footer */
/*---------------------------------------------------------------------------*/
MakeFooter:
if TableEnable then
call lineout CurPageStem.name, '</TABLE>'
else
call lineout CurPageStem.name, '</PRE>'
call lineout CurPageStem.name, '<P>'
call lineout CurPageStem.name, 'Total: 'CurPageStem.records' Files'
call lineout CurPageStem.name, '<CENTER>'
call lineout CurPageStem.name, '<HR>'
call lineout CurPageStem.name, '<A HREF="'SubDirStem.1'"><img src = "vmbuthom.gif" ALT="[ Home Page ]" BORDER=0></A>'
call lineout CurPageStem.name, '<A HREF="'CurPageStem.parent'"><img src = "vmbutpre.gif" ALT="[ Previous Page ]" BORDER=0></A>'
call lineout CurPageStem.name, '<A HREF="mailto:'WebMaster'"><img src = "vmbutmal.gif" ALT="[ E-mail ]" BORDER=0></A>'
call lineout CurPageStem.name, '<A HREF="PHVM.html#Usage"><img src = "vmbuthlp.gif" ALT="[ Help ]" BORDER=0></A>'
call lineout CurPageStem.name, '<HR>'
call lineout CurPageStem.name, '</CENTER>'
call lineout CurPageStem.name, 'Last update: 'HVMLastUpdate
call lineout CurPageStem.name, '<BR>'
call lineout CurPageStem.name, 'Directory: 'CurPageStem.title
call lineout CurPageStem.name, '<P>'
call lineout CurPageStem.name, 'This index was created using the '
call lineout CurPageStem.name, '<A HREF="PHVM.html"> Personal Hobbes Virtual Mirror</A>'
call lineout CurPageStem.name, ' (PHVM) software.'
call lineout CurPageStem.name, '<BR>'
call lineout CurPageStem.name, 'For more information on PHVM, email to '
call lineout CurPageStem.name, '<A HREF="mailto:rhlindengrun@mail.telepac.pt">Ricardo H. Lindengrun</A>'
call lineout CurPageStem.name, '.'
call lineout CurPageStem.name, ''
call lineout CurPageStem.name, '</BODY>'
call lineout CurPageStem.name, '</HTML>'
call lineout CurPageStem.name
return