#! /bin/sh # This is a shell archive. The files and directories it contains # may be unpacked by running it through /bin/sh. # Packaged by ctour at sundae on Mon Aug 22 12:10:47 PDT 1994 # Contents: # -rw-rw-rw- 1 andrew 8401 Aug 22 11:57 hlptohtmlv1.c # -rw-rw-rw- 1 andrew 7626 Aug 22 11:58 hlptohtml.for # -rw-rw-rw- 1 andrew 2407 Aug 22 12:10 hlptohtml.html if test -f hlptohtmlv1.c then echo 'shar: hlptohtmlv1.c -- file exists' else echo x - hlptohtmlv1.c sed 's/^|//' > hlptohtmlv1.c << 'eof' | main(int argc, char **argv) { |/* program hlptohtml ; |/* read .HLP file, convert to .HTML hierarchy ; |/* A.Daviel, TRIUMF, 16-FEB-1994 ; |/* modifications by Jerome Lauret |/* some changes derived from FORTRAN version 22-Aug-94 AD |*/ | | char **desc_pp ; | char *descrip[] = { | "HLPTOHTML: This program converts Digital's DCL HELP files ", | "(.HLP suffix) to HTLM, the Hypertext Markup Language used", | "by Mosaic. Separate files are produced for different levels", | "in the HELP hierarchy, preserving the hierarchical nature", | "of the Help information, and allowing use of the Mosaic", | "Back command. The Hypertext ouput may be generated with the", | "pre-formatted flag set (
); the user may remove this",
|	"and refine the presentation after conversion. Alternatively,",
|	"pairs of 
 and 
directives may be pre-inserted", | "in the HELP file to protect tables, etc., and formatted", | "output produced (the default)."," ", | "Usage : the program expects a Help file prefix, eg. 'FOOBAR'.", | "It will then read FOOBAR.HLP, creating the Hypertext files", | "FOOBAR.HTML,FOOBAR_1.HTML,FOOBAR_2.HTML, etc. plus FOOBAR.HREF, a", | "list of the references created which may be used to add", | "further cross-references manually.", | "Depending on the format of the original HLP file, the", | "hypertext output may start either in FOOBAR.HTML or in", | "FOOBAR_1.HTML"," ", | "Options: -pre Force pre-format flag", | " -path filepath Insert filepath before filenames", | " in references.", | 0 } ; | |#include math |#include stdio.h |#include stdlib.h /* for EXIT_SUCCESS and EXIT_FAILURE */ | |#define Lline 132 | |#define maxlevel 9 /* max. no. of levels in HLP file */ | FILE *unit[maxlevel], *Frefs, *Finp ; |#define Lfilenm 80 | char filenm[Lfilenm] ; |#define Loption 5 | char option[Loption] ; |#define Lpath 80 | char path[Lpath] ; | int pathn ; |# define Lprefix 30 | char prefix[Lprefix] ; |# define Lword 80 | char word[Lword] ; | char line[Lline],line2[Lline] ; | int nch, ni ; | | char **c_pp ; | | int level = 0, prev_level = 0 ; | int k,j,nl ; | int partn = 0, refn = 0 ; |# define Lpart 34 | char part[Lpart],parts[Lpart][maxlevel] ; |# define Lref 7 | char ref[Lref] ; | int nquotes = 0 ; | char inch[1] ; | int pre_flag = 0 ; | char *pos ; | int nexta = 1 ; |/*==*/ | path[0] = 0 ; | for (k = 1 ; k < argc ; k++) { | if(argv[k][0] == '-') { | nexta = k+1 ; | strcpy(option,argv[k]) ; | pos = strstr("-help",option) ; | if (pos) { | for (desc_pp = descrip; *desc_pp; desc_pp++) | printf("%s\n",*desc_pp) ; | printf("\n") ; | exit(EXIT_SUCCESS) ; | } | else if (!strcmp(option,"-pre"))pre_flag = 1 ; | else if (!strcmp(option,"-path")) | if (k+1 < argc) { | strcpy(path,argv[k+1]) ; | nexta++ ; |/* printf("path=%s\n",path); */ | } | else { | fprintf(stderr,"Path missing\n") ; | exit(EXIT_FAILURE) ; | } | else fprintf(stderr,"Unrecognized option %s\n",option) ; | } /*argv - */ | } /*for k*/ | | if (argc < 2) { | printf("Usage: hlptohtml [-h[elp]][-pre][-path path] file_prefix\n") ; | exit(EXIT_SUCCESS) ; | } | | if (nexta > argc-1) { | fprintf(stderr,"Missing argument\n") ; | exit(EXIT_FAILURE) ; | } | strcpy(prefix,argv[nexta]) ; | | strcpy(filenm, prefix) ; | strcat(filenm, ".hlp") ; | Finp = fopen(filenm, "r"); | if (!Finp) { |/* lib$signal(Finp); */ | fprintf(stderr, "Unable to open input file '%s'\n", filenm); | exit(EXIT_FAILURE) /* exit (Finp) */ ; | } | strcpy(filenm,path) ; | strcat(filenm, prefix) ; | strcat(filenm, ".href") ; | Frefs = fopen(filenm, "w"); | if (!Frefs) { | lib$signal(Frefs); | fprintf(stderr, "Unable to open href file '%s'\n", filenm); | } | fprintf(Frefs, "List of references for '%s'\n",prefix) ; | /* create base level file */ | strcpy(filenm,prefix) ; | strcat(filenm,".html") ; | printf("Creating file %s\n",filenm) ; | unit[level] = fopen(filenm, "w"); | if (!unit[level]) { | lib$signal(unit[level]); | fprintf(stderr, "Unable to open output file '%s'\n", filenm); | } |/* write header for new file */ | fprintf(unit[level], "\n\n") ; | fprintf(unit[level], " %s.hlp\n\n",prefix) ; | fprintf(unit[level], "\n") ; | if (pre_flag) fprintf(unit[level], "
\n") ; /* default pre-formatted  */
|
|L2:	fgets(line,Lline,Finp) ;
|	if (feof(Finp)) goto L99 ;
|	nl = nl + 1 ;
|	nch = strlen(line) ; if (nch>0) line[--nch] = 0 ; /* strip off \n */
|	/* if input line is zero-length or spaces, put a para. */
|	if ((nch <= 0) || (!strncmp(line,"       ",nch))) { 
|	    if (level > 0) fprintf(unit[level], "

\n") ; /* paragraph */ | goto L2 ; | } ; | if ((line[0] < '1') || (line[0] > '9')) goto L3 ; | ni = sscanf(line,"%d",&level) ; if (ni < 1) goto L3 ; | strncpy(word,&line[1],nch) ; /* nch-1 +1 for null */ | if (level < prev_level) { | for (k = prev_level; k >= level+1 ; --k) { | if (pre_flag) fprintf(unit[k], "

\n") ; | fprintf(unit[k], "\n") ; | fprintf(unit[k], "\n") ; /* close <>"s in file */ | fclose(unit[k]) ; /* close all intermediate level files */ | printf("Closing unit %d\n",k) ; | } ; |/* printf("DEBUG1::%d %s %s ",level,part,parts[level]); */ | sprintf(part,"%s_%d",prefix,level) ; |/* printf("DEBUG2::%s \n",part); */ |/* strcpy(part,parts[level]) ;*/ /*! restore filename to old level */ | strcpy(filenm,path) ; | strcat(filenm,part) ; | strcat(filenm,".html") ; | fprintf(unit[level], "\n") ; /* close list */ | if (pre_flag) fprintf(unit[level],"
\n") ; /* restore pre-formatting  */
|	} ;
|	if (level > prev_level+1) 
|	    fprintf(stderr,"ERROR - skipped level in HELP file\n") ;
|	if (level > prev_level) {
|	    partn = partn + 1 ;
|	    sprintf(part,"%s_%d",prefix,partn) ;
|	    strcpy(parts[level],part) ;
|	    strcpy(filenm,path) ;
|	    strcat(filenm,part) ;
|	    strcat(filenm,".html") ;
|	    printf("Creating file %s\n",filenm) ;
|	    unit[level] = fopen(filenm, "w");
|	    if (!unit[level]) {
|	        lib$signal(unit[level]);
|	        fprintf(stderr, "Unable to open output file '%s'\n", filenm);
|	    } 
|/*	write header for new file */
|	    fprintf(unit[level], "\n\n") ;
|	    fprintf(unit[level], " %s.hlp\n\n",prefix) ;
|	    fprintf(unit[level], "\n") ;
|	     if (pre_flag) fprintf(unit[level], "
\n") ; /* default pre-formatted  */
|	    if (pre_flag) fprintf(unit[prev_level],"
\n") ; | if (level > 1) fprintf(unit[prev_level], | "

Additional Information on:

\n") ; | else fprintf(unit[prev_level], | "

Information available on:

\n") ; | } /* (level > prev_level) */ | refn = refn + 1 ; | sprintf(ref,"Ref%d",refn) ; |/* write keyword in new file as heading and name */ | fprintf(unit[level], "

%s

\n",ref,word) ; |/* write keyword in parent file as href and list item */ | fprintf(unit[level-1], | "
  • %s\n",filenm,ref,word) ; |/* write in list of references */ | fprintf(Frefs, | "%s\n",filenm,ref,word) ; | prev_level=level ; | goto L2 ; | |/* support for pre-conditioning of HLP file formatting */ | |L3: if ( (strstr(line,"
    ") != 0 || strstr(line,"
    ") != 0) 
    |	  ||  (strstr(line,"
    ") != 0 || strstr(line,"
    ") != 0) | || (strstr(line,"&") == 0 && | strstr(line,">") == 0 && strstr(line,"<") == 0) ) { | | fprintf(unit[level],"%s\n",line) ; | goto L2 ; | } else { |/* quote HTML reserved characters */ | j = 0 ; | for (k = 0; k <= nch; ++k) { | if (line[k] == '&') { | strcpy(&line2[j],"&") ; | j = j + 5 ; | } else if(line[k] == '<') { | strcpy(&line2[j],"<") ; | j = j + 4 ; | } else if(line[k] == '>') { | strcpy(&line2[j],">") ; | j = j + 4 ; | } else { | line2[j++] = line[k] ; line2[j] = 0 ; | } ; | } /* for k */ ; | fprintf(unit[level],"%s\n",line2) ; | nquotes = nquotes + 1 ; | goto L2 ; | } /* quote reserved */ ; | |L99: for (k = level; k >= 0; --k) { | if (pre_flag) fprintf(unit[k], "
  • \n") ; | fprintf(unit[k], "\n") ; | fprintf(unit[k], "\n") ; /* close <>"s in file */ | fclose(unit[k]) ; /* close all intermediate level files */ | printf("Closing unit %d\n",k) ; | } ; | printf("HTML reserved characters were quoted on %d lines\n",nquotes) ; | close(Frefs) ; close(Finp) ; | exit(EXIT_SUCCESS) ; |} /* main */ eof if test `wc -c < hlptohtmlv1.c` -ne 8401 then echo 'shar: hlptohtmlv1.c damaged (should be 8401 bytes)' fi fi if test -f hlptohtml.for then echo 'shar: hlptohtml.for -- file exists' else echo x - hlptohtml.for sed 's/^|//' > hlptohtml.for << 'eof' | program hlptohtml |c read .HLP file, convert to .HTML hierarchy |c A.Daviel, TRIUMF, 16-FEB-1994 |c HLPTOHTML | | implicit none | character*66 descrip(21) | data descrip / | 1 'HLPTOHTML: This program converts Digital''s DCL HELP files ', | 1 '(.HLP suffix) to HTLM, the Hypertext Markup Language used', | 1 'by Mosaic. Separate files are produced for different levels', | 1 'in the HELP hierarchy, preserving the hierarchical nature', | 1 'of the Help information, and allowing use of the Mosaic', | 1 'Back command. The Hypertext ouput may be generated with the', | 1 'pre-formatted flag set (
    ); the user may remove this',
    |	1 'and refine the presentation after conversion. Alternatively,', 
    |	1 'pairs of 
     and 
    directives may be pre-inserted', | 1 'in the HELP file to protect tables, etc., and formatted', | 1 'output produced (the default).', | 1 ' ', | 1 'Usage : the program expects a Help file prefix, eg. "FOOBAR".', | 1 'It will then read FOOBAR.HLP, creating the Hypertext files', | 1 'FOOBAR.HTML,FOOBAR_1.HTML,FOOBAR_2.HTML, etc. plus FOOBAR.HREF,', | 1 'a list of the references created which may be used to add', | 1 'further cross-references manually.', | 1 'Depending on the format of the original HLP file, the', | 1 'hypertext output may start either in FOOBAR.HTML or in', | 1 'FOOBAR_1.HTML.', | 1 ' ' / | integer maxlevel | parameter (maxlevel=9) ! max. no. of levels in HLP file | character*80 filenm | character*132 title | character*40 path | integer pathn | character*30 prefix | character*80 word,words(maxlevel) | character*132 line,line2 | integer nch | integer wns(maxlevel) | integer level,prev_level,k,j | integer wn, fln,pxn,tn | integer partn,nl,refn | character*34 part,parts(maxlevel) | character*7 ref | integer nquotes | character*1 pre_flag |c== |1 type *,'Enter Help file prefix (blank for help):' | accept 101,pxn,prefix |100 format(a) | if (prefix.eq.' ') then | type *,descrip | goto 1 | endif | type *,'Default to pre-formatted HTML (y/n) ?' | accept 100,pre_flag | if (pre_flag.eq.'y') pre_flag = 'Y' | type *,'Enter optional href filename path (default blank):' | accept 101,pathn,path | if (pathn.eq.0) then |c avoid trouble with path(1:0); squash will eat extra space | pathn = 1 | path = ' ' | endif | prev_level = 0 | level = 0 | partn = 0 | refn = 0 | nquotes = 0 | open(unit=maxlevel+2,file=prefix//'.hlp',status='old',readonly,err=1) | open(unit=maxlevel+1,file=prefix//'.href',status='new', | 1 carriagecontrol='list') | write(maxlevel+1,*) 'List of references for ',prefix | |c create base file | filenm=path(1:pathn)//prefix//'.html' | call squash(filenm,fln) | type *,'Creating file ',filenm(1:fln) | open(unit=0,file=filenm,status='new', | 1 carriagecontrol='list') |c write header for new file | write(level,100) ' ' | write(level,100) 'Help for ',prefix(1:pxn), | 1 ' ' | write(level,100) '' | if (pre_flag.eq.'Y') write(level,100) '
    ' ! default pre-formatted
    |
    |2	read(maxlevel+2,101,end=99) nch,line
    |101	format(q,a)
    |	nl = nl + 1
    |	if (nch.eq.0.or.line.eq.' ') then
    |	    if (level.gt.0) write(level,100) '

    ' ! paragraph | goto 2 | endif | if ((line(1:1).lt.'1').or.(line(1:1).gt.'9')) goto 3 | read(line,102,err=3) level |102 format(bn,i1) |66 word = line(2:nch) | wn = nch - 1 | wns(level) = wn | words(level) = word |c type *,'Level ',level,' Key "',word(1:wn),'"' | if (level.lt.prev_level) then | do k=prev_level,level+1,-1 | if (pre_flag.eq.'Y') write(k,100) '

    ' | write(k,100) '' | write(k,100) '

    Converted from .HLP to .HTML by ' | write(k,100) | 1 '', | 1 'HLPTOHTML.

    ' | write(k,100) '' ! close <>'s in file | close(unit=k) ! close all intermediate level files | type *,'Closing unit ',k | enddo | part = parts(level) ! restore filename to old level | filenm=path(1:pathn)//part//'.html' | call squash(filenm,fln) | write(level,100) '' ! close list | if (pre_flag.eq.'Y') write(level,100)'

    ' ! restore pre-formatting
    |	endif
    |	if (level.gt.prev_level+1) type *,'ERROR - skipped level in HELP file'
    |	if (level.gt.prev_level) then
    |	    partn = partn + 1
    |	    write(part,103) prefix,partn
    |103	    format(a,'_',i3)
    |	    parts(level) = part
    |	    filenm=path(1:pathn)//part//'.html'
    |	    call squash(filenm,fln)
    |	    type *,'Creating file ',filenm(1:fln)
    |	    open(unit=level,file=filenm(1:fln),status='new',
    |	1	carriagecontrol='list')
    |c	write header for new file
    |	    title= words(1)(1:wns(1))
    |	    tn = wns(1)
    |	    do k=2,level-1
    |	    title= title(1:tn)//':'//words(k)(1:wns(k))
    |	    call squash(title,tn)
    |	    enddo
    |	    write(level,100) ''
    |	    write(level,100)  ''
    |	    write(level,100) '',title(1:tn),''
    |	    write(level,100) ''
    |	    write(level,100) ''
    |	     if (pre_flag.eq.'Y') write(level,100) '
    ' ! default pre-formatted
    |	    if (pre_flag.eq.'Y') write(prev_level,100)'
    ' | if (level.gt.1) then | write(prev_level,100)'

    Additional Information on:

    ' | else | write(prev_level,100)'

    Information available on:

    ' | endif | endif ! (level.gt.prev_level) |c if (level.le.prev_level) then | refn = refn + 1 | write(ref,104) refn |104 format('Ref',i4.4) |c write keyword in new file as heading and name | write(level,100) | 1 '

    '//word(1:wn)//'

    ' |c write keyword in parent file as href and list item | write(level-1,100) | 1 '
  • '// | 1 word(1:wn)//' ' |c write in list of references | write(maxlevel+1,100) | 1 ''// | 1 word(1:wn)//'' | prev_level=level | goto 2 | |3 if (level.lt.0) goto 2 |c support for pre-conditioning of HLP file formatting | if ( (index(line,'
    ').gt.0.or.index(line,'
    ').gt.0)
    |	1 .or. (index(line,'
    ').gt.0.or.index(line,'
    ').gt.0) | 1 .or. (index(line,'&').eq.0.and. | 1 index(line,'>').eq.0.and.index(line,'<').eq.0) ) then | write(level,100) line(1:nch) | goto 2 | else |c quote HTML reserved characters | j = 0 | do k=1,nch | if (line(k:k).eq.'&') then | line2(j+1:j+5) = '&' | j = j + 5 | elseif (line(k:k).eq.'<') then | line2(j+1:j+5) = '<' | j = j + 4 | elseif (line(k:k).eq.'>') then | line2(j+1:j+5) = '>' | j = j + 4 | else | j = j + 1 | line2(j:j) = line(k:k) | endif | enddo | write(level,100) line2(1:j) |c type *,'Reserved characters quoted, line',nl | nquotes = nquotes + 1 | goto 2 | endif | |99 do k=level,0,-1 | if (pre_flag.eq.'Y') write(k,100) '
  • ' | write(k,100) '' | write(k,100) '

    Converted from .HLP to .HTML by ' | write(k,100) | 1 '', | 1 'HLPTOHTML.

    ' | write(k,100) '' ! close <>'s in file | close(unit=k) ! close all intermediate level files | type *,'Closing unit ',k | enddo | type *,'HTML reserved characters were quoted on ',nquotes,' lines' | close(maxlevel+1) | close(maxlevel+2) | end | | | subroutine squash(word,nc) |c remove spaces from char. string | character*(*) word | character*132 cooked | | integer nr,nc,k,j | last= .false. | j = 0 | nr = len(word) | do k=1,nr | if (word(k:k).eq.' '.or.word(k:k).eq.' ') then | if (last) then |c j=j+1 |c cooked(j:j)= '_' | endif | last = .false. | else | j=j+1 | cooked(j:j) = word(k:k) | last = .true. | endif | enddo | nc=j | if (nc.gt.0) word=cooked(1:nc) | return | end | eof if test `wc -c < hlptohtml.for` -ne 7626 then echo 'shar: hlptohtml.for damaged (should be 7626 bytes)' fi fi if test -f hlptohtml.html then echo 'shar: hlptohtml.html -- file exists' else echo x - hlptohtml.html sed 's/^|//' > hlptohtml.html << 'eof' | | |HLPTOHTML | | | | |

    HLPTOHTML: HLP to HTML Converter

    | | This program converts Digital's DCL HELP files | (.HLP suffix) to | HTML, the Hypertext Markup Language used | by Mosaic. Separate files are produced for different levels | in the HELP hierarchy, preserving the hierarchical nature | of the Help information, and allowing use of the Mosaic | Back command. The Hypertext ouput may be generated with the | pre-formatted flag set (<pre>); the user may remove this | and refine the presentation after conversion. Alternatively | the input file may be pre-edited to preserve critical | text formatting using the <pre> and </pre> directives. |

    | | Usage : the program expects a Help file prefix, eg. "FOOBAR". | It will then read FOOBAR.HLP, creating the Hypertext files | FOOBAR.HTML,FOOBAR_1.HTML,FOOBAR_2.HTML, etc. plus FOOBAR.HREF, | a list of the references created which may be used to add | further cross-references manually.

    | Depending on the layout of the original .HLP file, the hypertext | output may start either in FOOBAR.HTML or in FOOBAR_1.HTML.

    | The C version takes the file prefix together with the -pre option | from the command line; the FORTRAN version prompts the user.

    | |

    Demos

    |The following help files have been converted: | | |

    Additional Information

    | For a tutorial introduction to HTML see: | |http://www.ncsa.uiuc.edu/demoweb/html-primer.html.

    |For a reference information on HTML see: | |http://info.cern.ch/hypertext/WWW/MarkUp/MarkUp.html

    |

    Source Code

    |The | | FORTRAN or | |C source code for Vax/VMS is available via ftp. |

    |

    Andrew Daviel
    |
    TRIUMF
    |
    advax@triumf.ca
    | | eof if test `wc -c < hlptohtml.html` -ne 2407 then echo 'shar: hlptohtml.html damaged (should be 2407 bytes)' fi fi exit