You are on page 1of 5

H DFTACTGRP(*NO) BNDDIR('QC2LE' : 'XTOOLS') H OPTION(*NODEBUGIO:*SRCSTMT) **************************************************************** ** PGM: VIEWSRC - Read Source and write it to the browser.

**************************************************************** FQSRC IF F 240 DISK USROPN INFDS(INFDS) /COPY /COPY /COPY /COPY /COPY /COPY /COPY /COPY D D D D D D XTOOLS/QCPYSRC,cprotos XTOOLS/QCPYSRC,apiprotos XTOOLS/QCPYSRC,cgi XTOOLS/QCPYSRC,lists XTOOLS/QCPYSRC,utils QSYSINC/QRPGLESRC,QUSEC QSYSINC/QRPGLESRC,QUSLMBR QSYSINC/QRPGLESRC,QUSRMBRD DS 83 93 129 125 156 PR 10A 10A PR 10A 10A 10A S S S S S S C Const Const Const Const Const 92A 102A 138A 126I 0 159I 0

INFDS szRTFileName szRTFileLib szRTMbr nSrcRecLen nSrcRecCnt

D DspMbrList D szSrcFile D szSrcLib D D D D DspSrcMbr szSrcFile szSrcLib szSrcMbr

D nTailSize D nRecLen D D D D D D D D D D D D D D D szSrcFile szSrcLib szSrcMbr szSrcOvr szOvr

10I 0 Inz(12) 10I 0 10A 10A 10A 256A

Varying 'OVRDBF FILE(QSRC) + MBR(%s) + TOFILE(%s/%s) LVLCHK(*NO) + SECURE(*YES)' 'Content-type: text/plain' 'Content-type: text/html\n\n' 'CONTENT-TYPE:' 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

ContentTypePlain... C ContentTypeHtml... C CTHDR C LOWER C UPPER C S NS 512A

D szHTML IQSRC I C

VARYING

1 240 SRCDATA Move *ON *INLR

C C C C C C C C C C C C C C C C C C P D D D D D D D D D D D D D D D D D D DspMbrList DspMbrList szSrcFile szSrcLib nPos nMbrs ds9 LastChg LastChg_Cent LastChg_DTS Century ISOdts ISODate ChgDts ChgDate ChgTime QMBRLIST QMBRDESC S S S S S C B PI

callp eval eval eval if eval endif if eval endif if eval endif if callp else callp endif

cgiInit szSrcFile = cgiGetVarUpper('FILE') szSrcLib = cgiGetVarUpper('LIB') szSrcMbr = cgiGetVarUpper('MBR') szSrcLib = ' ' szSrcLib = '*LIBL' szSrcMbr = ' ' szSrcMbr = '*FIRST' szSrcFile = ' ' szSrcFile = 'QRPGLESRC' %subst(szSrcMbr:1:4) = '*MBR' DspMbrList(szSrcFile:szSrcLib) DspSrcMbr(szSrcFile:szSrcLib:szSrcMbr)

10A 10A S S DS 10I 0 10I 0

Const Const

S DS

13A 1S 0 OVERLAY(LastChg) 12A OVERLAY(LastChg:*NEXT) 2S 0 20S 0 Inz(0) 14A OVERLAY(ISODts) Z D T Like(QUSL010000) Like(QUSM0200) '<TD>%s</TD>+ <TD>%s</TD>+ <TD>%s</TD>+ <TD>%s</TD>+ <TD>%s</TD>+ <TD>%s</TD>+ </TR>\n' '<html>\n+ <head> \n+ <title>xTools Member List</title>\n+ </head>\n+ <body>\n+ <h1>Source Code Viewer</h1>\n+ <p><i><font size="2">Powered by + </font></i> \n +

D mbrRow D D D D D D D htmlTop D D D D D D D

D D D D D D D D D D D D D D D D D D D D D D D D D htmlBot D D D D D D mbrlink D D D D badReq D D D D D D D D D D D D D D D C

<font size="2" color="#FF0000">+ <b><i>x</i></b></font>+ <font size="2">Tools</font><i>+ <a href="http://www.rpgxtools.com/">+ <font size="2"> find out more + </font></a></i></p>\n+ <p>Click on any member name to view + the source for that member.<BR>\n+ <font face="Arial" size="1"> + Source Viewer &COPY; 2004 + Robert Cozzi, Jr. All rights + reserved.</font></p>\n + <table border="1" \n+ style="border-collapse: collapse"\n+ width ="100%" id="table1">\n+ <tr>\n+ <td>Member</td>\n+ <td>File</td>\n+ <td>Library</td>\n+ <td>Src Type</td>\n+ <td>Records</td>\n+ <td>Last Changed Date</td>\n+ <td>Text</td>\n+ </tr>' '</table>\n+ <p><a href=+ "javascript:history.back()">\n+ Go back</a></p>\n+ </body>\n + </html>' '<TR><TD>+ <a href="+ %s/viewsrc?FILE=%s&LIB=%s&MBR=%s">+ %s</a></TD>' '<html>\n+ <head>\n+ <title>Member not found</title>\n+ </head>\n+ <body>\n+ <h1>No Member List Available</h1>\n+ <p>No members are detected for + requested source file and + library, or you are not + authorized to the requested + object.</p> \n+ <p><a href=+ "javascript:history.back()">\n+ Go back</a></p>\n+ </body>\n+ </html>\n'

** To restrict this program so that it only displays source ** from a single library, set the RESTRICTLIB constant to ** the library name you want to expose. If RestrictLib is ** blank, then any library that is available (authorized) ** may be specified. D RestrictLib C 'RPGLAB'

*********************************************************************** ** USER CHANGE REQUIRED ----------------------------------------- ** ** --------------------------------------------------------------- ** ** Change the MYDOMAIN named constant to the domain and ScriptAlias ** ** for your web server instance. This should be the only change ** ** necessary to make this program work on your webserver. ** ** --------------------------------------------------------------- ** *********************************************************************** D myDomain C 'http://www.rpgiv.com/cgi-rpg' C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C P DspMbrList P D D D DspSrcMbr DspSrcMbr szSrcFile szSrcLib E B PI 10A 10A Const Const eval callp callP if callp return endif callP Dow eval clear callp(e) eval eval nMbrs = CrtMbrList('*':szSrcFile+szSrcLib) WrtJoblog('%s mbrs in %s/%s': %char(nMbrs): %trimr(szSrcLib):%trimr(szSrcFile)) cgiStdOut(ContentTypeHtml) nMbrs <= 0 or (RestrictLib <> *BLANKS and szSrcLib <> RestrictLib) cgiStdOut(badReq)

callP eval eval eval MOVE MOVE MOVE eval

cgiStdOut(htmlTop) GetNextEntry('*': nPos : QMBRLIST) > 0 QUSL010000 = QMbrList QUSEC qRtvMbrD(QMbrDesc:%size(QMbrDesc):'MBRD0200': szSrcFile+szSrcLib: QUSMN00 :'0':QUSEC) QUSM0200 = qMbrDesc szHtml = FmtText(mbrLink: %Trim(myDomain): %TrimR(QUSDFILN00): %TrimR(QUSDFILL00): %TrimR(QUSMN03): %TrimR(QUSMN03)) cgiStdOut(szHTML) LastChg = QUSSCD Century = 19+ LastChg_Cent ISODate = %char(Century)+LastChg_Dts ISODts ChgDts ChgDts ChgDate ChgDts ChgTime szHtml = FmtText(mbrRow: QUSDFILN00:QUSDFILL00:QUSST01: %char(QUSNBRCR): %char(ChgDate)+' '+%char(Chgtime): %TrimR(QUSTD04)) cgiStdOut(szHTML) cgiStdOut(htmlBot)

*ISO

callP enddo callP return

D szSrcMbr D nCounter C C C C C C C C C C

S eval

10A Const 10I 0 szSrcOvr = FmtText(szOvr:%TrimR(szSrcMbr) : %TrimR(szSrcLib) : %TrimR(szSrcFile)) WrtJobLog(szSrcOvr) system(szSrcOvr) QSRC NOT %OPEN(QSRC)

CallP CallP OPEN(E) if return endif eval

nRecLen = nSrcRecLen - nTailSize

** If the first record is "Content-type:" then do NOT ** generate an automatic plain/text content-type header. C Read QSRC C eval szHTML = C %Trim(%Subst(SRCDATA:nTailSize+1:nRecLen)) C Lower:Upper XLATE szHTML szHTML C if %len(szHTML) >= %size(CTHDR) C if %subst(szHtml:1:%size(CTHDR)) <> CTHDR C eval szHTML = ContentTypePlain+X'25' C *START SETLL QSRC C endif C endif ** In this DSPSRCMBR routine, we avoid the translation of ** embedded \n synbols by calling the low-level CGI API. C Dow NOT %EOF C Eval szHtml = szHtml + X'25' C clear QUSEC C callP QtmhWrStout(szHtml: %Len(szHtml): QUSEC) C Read QSRC C eval szHTML = C %TrimR(%Subst(SRCDATA:nTailSize+1:nRecLen)) C enddo C if %OPEN(QSRC) C close(e) QSRC C endif C return P DspSrcMbr E

You might also like