home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ppwizard.zip / ftplike.ih < prev    next >
Text File  |  2000-02-19  |  15KB  |  314 lines

  1. ;----------------------------------------------------------------------------
  2. ;     MODULE NAME:   FTPLIKE.IH
  3. ;
  4. ;         $Author:   Dennis_Bareis  $
  5. ;       $Revision:   1.13  $
  6. ;           $Date:   19 Feb 2000 15:05:50  $
  7. ;        $Logfile:   E:/DB/PVCS.IT/OS2/PPWIZARD/FTPLIKE.IHV  $
  8. ;
  9. ;     DESCRIPTION:   Please see End of the "FTPLIKEI.IH" file for
  10. ;                    details.
  11. ;----------------------------------------------------------------------------
  12.  
  13. ;--- First time through? ----------------------------------------------------
  14. #ifndef _FTPLIKE_INITIALIZED
  15.         #define  FTPLIKE_CALLED_CORRECTLY
  16.         #include "FTPLIKEI.IH"              ;;Perform initialization
  17. #endif
  18.  
  19. ;--- Simple processing message ----------------------------------------------
  20. #evaluate '' ^ShortOutName = _filespec('Name', '<?OutputFile>')^
  21. #info ^Generating <??ShortOutName> <= <$FTPLIKE_DIRECTORY>^
  22.  
  23.  
  24. ;--- Initialization for this FTP page ---------------------------------------
  25. #RexxVar FtpDirCnt  = 0          ;;Number of directories on this html page
  26. #RexxVar FtpFileCnt = 0          ;;Number of files       on this html page
  27.  
  28.  
  29. ;--- Generate start of HTML -------------------------------------------------
  30. #if    <?OutputLevel> <> FtpStartLevel | defined('FTPLIKE_NO_HEADER_FOOTER_ON_1ST_PAGE') = 'N'
  31.        <$FTPLIKE_START_HTML_PAGE>
  32. #endif
  33. <$FTPLIKE_START_PAGE_AFTER_TITLE>
  34.  
  35. ;--- Process directories? (need to be careful as we include ourself) --------
  36. #ifdef  FTPLIKE_FOLLOW_SUBDIRECTORIES
  37.          ;--- Want ".." (parent) link? --------------------------------------
  38.          #if <?OutputLevel> = FtpStartLevel
  39.              #define+ InDirTable  NO
  40.          #elseif
  41.              ;--- Start HTML table ------------------------------------------
  42.              <$FTPLIKE_BEFORE_ALL_DIRS>
  43.              #define+ InDirTable  YES
  44.  
  45.              ;--- Generate ".." ---------------------------------------------
  46.              <$FTPLIKE_GENERATE_DOT_DOT URL="<$ParentHtml>">
  47.         #endif
  48.  
  49.         ;--- Get a directory list -------------------------------------------
  50.         #DefineRexx ''
  51.                ;--- Get list of directories ---------------------------------
  52.                FtpArray<?OutputLevel>.0 = 0;
  53.                call _SysFileTree '<$FTPLIKE_DIRECTORY $$SQx2><?DirSlash><$FTPLIKE_DIR_MASKS>', 'FtpArray<?OutputLevel>', 'DO';
  54.  
  55.                ;--- Set defaults for these "primary" directories ------------
  56.                do  DirIndex = 1 to FtpArray<?OutputLevel>.0
  57.                    ;--- This is not a virtual link --------------------------
  58.                    FtpArray<?OutputLevel>.DirIndex.!RealDirTree = '';
  59.  
  60.                    ;--- No description --------------------------------------
  61.                    FtpArray<?OutputLevel>.DirIndex.!Description = '';
  62.                end;
  63.  
  64.                ;--- Add any linked directories -----------------------------
  65.                FtpKey = DirStore || 'ADDDIRS';
  66.                if  RexxVarDefined(FtpKey) then
  67.                do
  68.                    DirList = _valueG(FtpKey);
  69.                    TheCnt  = FtpArray<?OutputLevel>.0;
  70.                    do  while DirList <> ''
  71.                        ;--- Get next dir ------------------------------------
  72.                        parse var DirList NextDir '00'x DirList;
  73.                        TheCnt = TheCnt + 1;
  74.  
  75.                        ;--- Override description (shortname/EA attrib)? -----
  76.                        if  left(NextDir, 1) <> '|' then
  77.                            DirDescription = '';        ;;No override
  78.                        else
  79.                        do
  80.                            ;--- We want to override description -------------
  81.                            EndPos = pos('|', NextDir, 2);
  82.                            if  EndPos = 0 then
  83.                                call Error 'The directory description not correctly specified', 'Directory = "' || NextDir || '"';
  84.                            DirDescription = substr(NextDir, 2, EndPos-2);
  85.                            NextDir        = substr(NextDir, EndPos+1);
  86.                        end;
  87.                        FtpArray<?OutputLevel>.TheCnt.!Description = DirDescription;
  88.  
  89.                        ;--- Is it an alias? ---------------------------------
  90.                        if  left(NextDir,1) = '@' then
  91.                        do
  92.                            ;--- It is an alias, resolve it ------------------
  93.                            NextDirKey = substr(NextDir, 2);
  94.                            <$c2x ResultVar="KeyCode" KeyVar="NextDirKey">
  95.                            FullVar = "FtpAlias2Dir.!" || KeyCode;
  96.                            if  symbol(FullVar) <> 'VAR' then
  97.                                error('Trying to link to undefined ALIAS of "' || NextDirKey || '"!');
  98.                            NextDir = _valueG(FullVar);
  99.                        end;
  100.  
  101.                        ;--- This is not a primary directory (its "virtual") ---
  102.                        FtpArray<?OutputLevel>.TheCnt.!RealDirTree = 'N';
  103.  
  104.                        ;--- Add directory to list ---------------------------
  105.                        FtpArray<?OutputLevel>.TheCnt = NextDir;
  106.                    end;
  107.                    FtpArray<?OutputLevel>.0 = TheCnt;
  108.                end;
  109.  
  110.                ;--- Set up some stuff! --------------------------------------
  111.                do  DirIndex = 1 to FtpArray<?OutputLevel>.0
  112.                    ;--- Handle real shortname -------------------------------
  113.                    FtpFile   =  FtpArray<?OutputLevel>.DirIndex;
  114.                    FtpShortR = _filespec('name', FtpFile);
  115.                    FtpArray<?OutputLevel>.DirIndex.!FtpShortR = FtpShortR;
  116.  
  117.                    ;--- Description already specified? If not work it out ---
  118.                    if  FtpArray<?OutputLevel>.DirIndex.!Description = '' then
  119.                    do
  120.                        ;--- No so either use shortname or EA value ----------
  121.                        <$FTPLIKE_GET_SHORT_DESC>;
  122.                        FtpArray<?OutputLevel>.DirIndex.!Description = FtpShortD;
  123.                    end;
  124.  
  125.                    ;--- Set up the sort key ---------------------------------
  126.                    FtpArray<?OutputLevel>.DirIndex.!SortKey = translate(FtpArray<?OutputLevel>.DirIndex.!Description);
  127.                end;
  128.  
  129.                ;--- Sort the directory list ---------------------------------
  130.                if  FtpArray<?OutputLevel>.0 <> 0 then
  131.                do
  132.                    <$FTPLIKE_DIRECTORY_SORT_REXX ArrayName="FtpArray<?OutputLevel>">
  133.                end;
  134.         #DefineRexx
  135.  
  136.         ;--- Any directories to display? ------------------------------------
  137.         #if  [FtpArray<?OutputLevel>.0 <> 0]
  138.            ;--- Save pointer to current directories extra info! -------------
  139.            #RexxVar PUSH  DirStore
  140.  
  141.            ;--- Process DIRECTORIES -----------------------------------------
  142.            #RexxVar FtpIndex<?OutputLevel> = 1
  143.            #{
  144.                ;--- Finished? -----------------------------------------------
  145.                #if [FtpIndex<?OutputLevel> > FtpArray<?OutputLevel>.0]
  146.                    #break
  147.                #endif
  148.  
  149.                ;--- Get Basic Directory information -------------------------
  150.                #RexxVar PUSH  RealDirTree
  151.                #RexxVar Override = FtpArray<?OutputLevel>.FtpIndex<?OutputLevel>.!RealDirTree
  152.                #if [Override <> '']
  153.                    #RexxVar RealDirTree = Override
  154.                #endif
  155.                #RexxVar FtpShortR   = FtpArray<?OutputLevel>.FtpIndex<?OutputLevel>.!FtpShortR
  156.                #RexxVar FtpShortD   = FtpArray<?OutputLevel>.FtpIndex<?OutputLevel>.!Description
  157.                #RexxVar FtpDir      = FtpArray<?OutputLevel>.FtpIndex<?OutputLevel>
  158.  
  159.                ;--- Generate the files --------------------------------------
  160.                #RexxVar FtpDoThisDir = 'Y'
  161.                <$FTPLIKE_DO_THIS_DIR>              ;;User want this dir to be seen?
  162.                #if [FtpDoThisDir = 'Y']
  163.                    ;--- User does want this dir to be seen ------------------
  164.                    #RexxVar FtpDirCnt + 1
  165.                    #if [FtpDirCnt = 1]
  166.                        ;--- Start DIRECTORY output --------------------------
  167.                        #if ['<$InDirTable>' = 'NO']
  168.                            <$FTPLIKE_BEFORE_ALL_DIRS>
  169.                            #define+ InDirTable  YES
  170.                        #endif
  171.                    #endif
  172.  
  173.                    ;--- Do stuff --------------------------------------------
  174.                    #evaluate+  '' "<$FTPLIKE_GET_DIR_HTMLNAME>"
  175.  
  176.                    ;--- Override some directory defaults --------------------
  177.                    <$MacroPush Macro='FTPLIKE_BODY_BG_IMG'>
  178.                    <$MacroPush Macro='FTPLIKE_BODY_BG_COLOR'>
  179.                    <$MacroPush Macro='FTPLIKE_BODY_LINK_COLOR'>
  180.                    <$MacroPush Macro='FTPLIKE_BODY_ALINK_COLOR'>
  181.                    <$MacroPush Macro='FTPLIKE_BODY_VLINK_COLOR'>
  182.                    <$MacroPush Macro='FTPLIKE_BODY_ATTR_OTHER'>
  183.                    <$MacroPush Macro='FTPLIKE_MINI_DIR_IMG_TAG'>
  184.                    <$FTPLIKE_USER_DIR_ATTRIB_PUSH_CHANGE>
  185.                    #evaluate+  '' "<$FTPLIKE_UPDATE_DEFAULT_DIR_INFO>"
  186.  
  187.                    ;--- Save some variables ---------------------------------
  188.                    #RexxVar PUSH  FtpDirCnt FtpFileCnt FtpTotalDirCnt FtpTotalFileCnt
  189.  
  190.                    ;--- Reset totals ----------------------------------------
  191.                    #RexxVar FtpTotalDirCnt  = 0
  192.                    #RexxVar FtpTotalFileCnt = 0
  193.  
  194.                    ;--- Process all subdirectories (generating HTML as we go)
  195.                    <$FTPLIKE_GENERATE_HTML_FOR_DIR_TREE>
  196.  
  197.                    ;--- Remember subdirectory counts ------------------------
  198.                    #RexxVar FtpSubdirTotalFileCnt = FtpTotalFileCnt
  199.                    #RexxVar FtpSubdirTotalDirCnt  = FtpTotalDirCnt
  200.  
  201.                    ;--- Display directory details on this page --------------
  202.                    <$FTPLIKE_DIR_HANDLER>
  203.  
  204.                    ;--- Restore other variables -----------------------------
  205.                    #RexxVar POP  FtpDirCnt FtpFileCnt FtpTotalDirCnt FtpTotalFileCnt
  206.  
  207.                    ;--- Add to totals ---------------------------------------
  208.                    #RexxVar FtpTotalFileCnt + FtpSubdirTotalFileCnt
  209.                    #RexxVar FtpTotalDirCnt  + FtpSubdirTotalDirCnt
  210.  
  211.                    ;--- Restore some directory defaults ---------------------
  212.                    <$FTPLIKE_USER_DIR_ATTRIB_POP>
  213.                    <$MacroPop Macro='FTPLIKE_MINI_DIR_IMG_TAG'>
  214.                    <$MacroPop Macro='FTPLIKE_BODY_ATTR_OTHER'>
  215.                    <$MacroPop Macro='FTPLIKE_BODY_VLINK_COLOR'>
  216.                    <$MacroPop Macro='FTPLIKE_BODY_ALINK_COLOR'>
  217.                    <$MacroPop Macro='FTPLIKE_BODY_LINK_COLOR'>
  218.                    <$MacroPop Macro='FTPLIKE_BODY_BG_COLOR'>
  219.                    <$MacroPop Macro='FTPLIKE_BODY_BG_IMG'>
  220.                #endif
  221.  
  222.                ;--- Restore value -------------------------------------------
  223.                #RexxVar POP  RealDirTree
  224.  
  225.                ;--- Prepare for next directory ------------------------------
  226.                #RexxVar FtpIndex<?OutputLevel> + 1
  227.            #}
  228.  
  229.            ;--- Save pointer to current directories extra info! -------------
  230.            #RexxVar POP  DirStore
  231.         #endif
  232.  
  233.         ;--- Generate end DIRECTORY stuff -----------------------------------
  234.         #if ['<$InDirTable>' = 'YES']
  235.             <$FTPLIKE_AFTER_ALL_DIRS>
  236.             #define+ InDirTable  NO
  237.         #endif
  238.  
  239.         ;--- Hook for displaying stuff --------------------------------------
  240.         <$FTPLIKE_BETWEEN_DIRS_AND_FILES>
  241. #endif
  242.  
  243. ;--- Get sorted list of files -----------------------------------------------
  244. #DefineRexx ''
  245.    ;--- Get List of files ---------------------------------------------------
  246.    FtpArray<?OutputLevel>.0 = 0;
  247.    call _SysFileTree '<$FTPLIKE_DIRECTORY $$SQx2><?DirSlash><$FTPLIKE_FILE_MASKS>', 'FtpArray', 'FO';
  248.  
  249.    ;--- Sort the list -------------------------------------------------------
  250.    <$FTPLIKE_FILE_SORT_REXX ArrayName="FtpArray">
  251. #DefineRexx
  252.  
  253. ;--- Any files in this directory? -------------------------------------------
  254. #if [FtpArray.0 <> 0]
  255.    ;--- Process files -------------------------------------------------------
  256.    #RexxVar FtpIndex = 1
  257.    #{
  258.        ;--- Finished? -------------------------------------------------------
  259.        #if [FtpIndex > FtpArray.0]
  260.            #break
  261.        #endif
  262.  
  263.        ;--- Get Filename ----------------------------------------------------
  264.        #RexxVar FtpFile = FtpArray.FtpIndex
  265.  
  266.        ;--- Generate the files ----------------------------------------------
  267.        #RexxVar FtpDoThisFile = 'Y'
  268.        <$FTPLIKE_DO_THIS_FILE>                 ;;User want this file to be seen?
  269.        #if [FtpDoThisFile = 'Y']
  270.            ;--- User does want this file to be seen -------------------------
  271.            #RexxVar FtpFileCnt + 1
  272.            #if [FtpFileCnt = 1]
  273.                ;--- Start FILE output ---------------------------------------
  274.                <$FTPLIKE_BEFORE_ALL_FILES>
  275.            #endif
  276.  
  277.            ;--- Output details for this file --------------------------------
  278.            <$FTPLIKE_FILE_HANDLER>
  279.            <$FTPLIKE_FILE_DETAILS_HANDLER>
  280.        #endif
  281.  
  282.        ;--- Prepare for next file -------------------------------------------
  283.        #RexxVar FtpIndex + 1
  284.    #}
  285.  
  286.    ;--- Generate end FILES stuff --------------------------------------------
  287.    #if [FtpFileCnt <> 0]
  288.        <$FTPLIKE_AFTER_ALL_FILES>
  289.    #endif
  290. #endif
  291.  
  292.  
  293. ;--- Generate END of HTML ---------------------------------------------------
  294. <$FTPLIKE_END_PAGE_ABOVE_FOOTER>
  295. #if    <?OutputLevel> <> FtpStartLevel | defined('FTPLIKE_NO_HEADER_FOOTER_ON_1ST_PAGE') = 'N'
  296.        ;--- User has not set up their own alternative -----------------------
  297.        <$FTPLIKE_FOOTER>               ;;Footer ends body and html
  298. #endif
  299.  
  300. ;--- Update totals ----------------------------------------------------------
  301. #RexxVar FtpTotalFileCnt + FtpFileCnt
  302. #RexxVar FtpTotalDirCnt  + FtpDirCnt
  303.  
  304. ;--- Output summary ---------------------------------------------------------
  305. #if    [<?OutputLevel> = FtpStartLevel]
  306.        #ifndef   FTPLIKE_FOLLOW_SUBDIRECTORIES
  307.            #info ^FTPLIKE processed <??FtpTotalFileCnt> file(s)^
  308.        #elseif
  309.            #info ^FTPLIKE processed <??FtpTotalFileCnt> file(s) in <??FtpTotalDirCnt> directories^
  310.        #endif
  311. #endif
  312.  
  313.  
  314.