home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopsrvls.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-01-20  |  5.8 KB  |  187 lines

  1. /*
  2.  *        Name: GOPSRVLS REXX
  3.  *              list a file or directory, feeding to the next stage
  4.  *      Author: Rick Troth, Rice University, Information Systems
  5.  *        Date: 1993-Jan-15, 19
  6.  */
  7.  
  8. /*
  9.  *      Copyright 1993 Richard M. Troth.   This software was developed
  10.  *      with resources provided by Rice University and is intended
  11.  *      to serve Rice's user community.   Rice has benefitted greatly
  12.  *      from the free distribution of software,  therefore distribution
  13.  *      of unmodified copies of this material is not restricted.
  14.  *      You may change your own copy as needed.   Neither Rice
  15.  *      University nor any of its employees or students shall be held
  16.  *      liable for damages resulting from the use of this software.
  17.  */
  18.  
  19. Parse Source . . arg0 .
  20. Parse Upper Arg fn ft fm . '(' . ')' .
  21. If fn = "" Then fn = '*'
  22. If ft = "" Then ft = '*'
  23. If ft = "FILELIST" & Index(fn,'*') = 0 Then ft = "*"
  24. If fm = "" Then fm = '*'
  25.  
  26. Parse Arg string
  27. Say arg0 || ':' string
  28.  
  29. Address "COMMAND" 'GLOBALV SELECT GOPHERD GET MENU NICK CLIENT'
  30.  
  31. If menu ^= "" Then Do
  32.  
  33.  
  34.     Address "CMS" 'STATE' menu 'NAMES *'
  35.     If rc = 0 Then Do
  36.  
  37.         If nick = "" Then nick = "*"
  38.  
  39.         'CALLPIPE COMMAND NAMEFIND :NICK' nick ':AUTH :PIPE' ,
  40.                 '(FILE' menu '| VAR AUTH | DROP' ,
  41.         '| CHANGE' '00'x || '&0' || '00'x || nick || '00'x ,
  42.         '| CHANGE' '00'x || '&1' || '00'x ||  fn  || '00'x ,
  43.         '| CHANGE' '00'x || '&2' || '00'x ||  ft  || '00'x ,
  44.         '| CHANGE' '00'x || '&3' || '00'x ||  fm  || '00'x ,
  45.         '| CHANGE' '00'x || '&4' || '00'x || menu || '00'x ,
  46.                 '| VAR PIPE'
  47.  
  48.         If rc = 32 Then
  49.         'CALLPIPE COMMAND NAMEFIND :FN' fn ':FT' ft ':AUTH :PIPE' ,
  50.                 '(FILE' menu '| VAR AUTH | DROP' ,
  51.         '| CHANGE' '00'x || '&0' || '00'x || nick || '00'x ,
  52.         '| CHANGE' '00'x || '&1' || '00'x ||  fn  || '00'x ,
  53.         '| CHANGE' '00'x || '&2' || '00'x ||  ft  || '00'x ,
  54.         '| CHANGE' '00'x || '&3' || '00'x ||  fm  || '00'x ,
  55.         '| CHANGE' '00'x || '&4' || '00'x || menu || '00'x ,
  56.                 '| VAR PIPE'
  57.  
  58.         If rc = 32 Then
  59.         'CALLPIPE COMMAND NAMEFIND :NICK * :AUTH :PIPE' ,
  60.                 '(FILE' menu '| VAR AUTH | DROP' ,
  61.         '| CHANGE' '00'x || '&0' || '00'x || nick || '00'x ,
  62.         '| CHANGE' '00'x || '&1' || '00'x ||  fn  || '00'x ,
  63.         '| CHANGE' '00'x || '&2' || '00'x ||  ft  || '00'x ,
  64.         '| CHANGE' '00'x || '&3' || '00'x ||  fm  || '00'x ,
  65.         '| CHANGE' '00'x || '&4' || '00'x || menu || '00'x ,
  66.                 '| VAR PIPE'
  67.  
  68.         If rc = 0 Then Do
  69.  
  70.             /*  if auth non-blank  */
  71.             If ^gopsrvau(client,auth) Then Do
  72.                 /*  "access restricted"  */
  73.                 'CALLPIPE COMMAND XMITMSG 2380' ,
  74.                     '(CALLER GOP ERRMSG' ,
  75.                         '| SPEC /- / 1 1-* NEXT | *:'
  76.                 Exit rc
  77.                 End  /*  If  ..  Do  */
  78.  
  79.             If pipe ^= "" Then Do
  80.                 'CALLPIPE' pipe '| *:'
  81.                 Exit rc
  82.                 End  /*  If  ..  Do  */
  83.  
  84.             End  /*  If  ..  Do  */
  85.  
  86.         End  /*  If  ..  Do  */
  87.  
  88.     End  /*  If  ..  Do  */
  89.  
  90. If ft = '*' Then Do
  91.  
  92.     Address "CMS" 'STATE' fn 'NAMES *'
  93.     If rc = 0 Then Do
  94.  
  95.         'CALLPIPE COMMAND NAMEFIND :NICK . :AUTH :PIPE' ,
  96.                 '(FILE' fn '| VAR AUTH | DROP' ,
  97.         '| CHANGE' '00'x || '&0' || '00'x || nick || '00'x ,
  98.         '| CHANGE' '00'x || '&1' || '00'x ||  fn  || '00'x ,
  99.         '| CHANGE' '00'x || '&2' || '00'x ||  ft  || '00'x ,
  100.         '| CHANGE' '00'x || '&3' || '00'x ||  fm  || '00'x ,
  101.         '| CHANGE' '00'x || '&4' || '00'x || menu || '00'x ,
  102.                 '| VAR PIPE'
  103.  
  104.         If rc = 0 Then Do
  105.  
  106.             /*  if auth non-blank  */
  107.             If ^gopsrvau(client,auth) Then Do
  108.                 /*  "access restricted"  */
  109.                 'CALLPIPE COMMAND XMITMSG 2380' ,
  110.                     '(CALLER GOP ERRMSG' ,
  111.                         '| SPEC /- / 1 1-* NEXT | *:'
  112.                 Exit rc
  113.                 End  /*  If  ..  Do  */
  114.  
  115.             If pipe ^= "" Then Do
  116.                 menu = fn
  117.                 Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT MENU'
  118.                 'CALLPIPE' pipe '| *:'
  119.                 Exit rc
  120.                 End  /*  If  ..  Do  */
  121.  
  122.             End  /*  If  ..  Do  */
  123.  
  124.         End  /*  If  ..  Do  */
  125.  
  126.     End  /*  If  ..  Do  */
  127.  
  128. If Index(fn ft, '*') = 0 Then Do
  129.     Address "CMS" 'STATE' fn ft fm
  130.     If rc = 0 Then Do
  131.         'CALLPIPE <' fn ft fm '| *:'
  132.         Exit rc
  133.         End
  134.     Exit rc
  135.     End
  136.  
  137. If Index(fn,'*') = 0 & ft = '*' Then Do
  138.  
  139.     Address "COMMAND" 'GLOBALV SELECT GOPHERD SET MENU' fn
  140.  
  141.     Address "CMS" 'STATE' fn 'FILELIST' fm
  142.     If  rc = 0  Then Do     /*  menu is a FILELIST  */
  143.         'CALLPIPE <' fn 'FILELIST' fm '| *:'
  144.         Exit rc
  145.         End  /*  If  ..  Do  */
  146.  
  147.     If fm = '*' | fm = "" Then fm = 'A'
  148.     'CALLPIPE COMMAND ACCESS +' || fm || '.' || fn fm
  149.     If rc = 0 Then Do
  150.         /*  menu is an SFS sub-directory  */
  151.         'CALLPIPE' arg0 '* *' fm '| *:'
  152.         lrc = rc
  153.         'CALLPIPE COMMAND ACCESS -' || fm fm
  154.         Exit lrc
  155.         End  /*  If  ..  Do  */
  156.     If rc = 28 | rc = 100 Then Exit rc
  157.     End
  158.  
  159. /*  shortcut for GOPSRVRP on LISTFILE not FILELIST  */
  160. 'OUTPUT' " "
  161. If rc ^= 0 Then Exit rc * (rc ^= 12)
  162.  
  163. /*  list all files in this directory  */
  164. 'ADDPIPE COMMAND LISTFILE' fn ft fm '(ALLFILE ALLOC NOHEADER | *.INPUT:'
  165. If rc ^= 0 Then Do
  166.     'CALLPIPE COMMAND LISTFILE' fn ft fm '(NOHEADER | *:'
  167.     Exit rc
  168.     End  /*  If  ..  Do  */
  169.  
  170. /*  give SFS directories a filetype '*'  */
  171. Do Forever
  172.  
  173.     'PEEKTO RECORD'
  174.     If rc ^= 0 Then Leave
  175.  
  176.     Parse Var record fn ft fm .
  177.     If fm = "DIR" Then 'OUTPUT' "     " fn '*' ft
  178.                   Else 'OUTPUT' "     " fn ft fm
  179.  
  180.     'READTO'
  181.     If rc ^= 0 Then Leave
  182.  
  183.     End  /*  If  ..  Do  Forever  */
  184.  
  185. Exit rc * (rc ^= 12)
  186.  
  187.