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

  1. /*
  2.  *        Name: GOPSRVRP REXX
  3.  *              resolve gopher paths (selector strings) recursively
  4.  *      Author: Rick Troth, Rice University, Information Systems
  5.  *        Date: 1993-Jan-15, 19
  6.  *
  7.  *              This file is part of CMS Gopher.
  8.  */
  9.  
  10. /*
  11.  *      Copyright 1993 Richard M. Troth.   This software was developed
  12.  *      with resources provided by Rice University and is intended
  13.  *      to serve Rice's user community.   Rice has benefitted greatly
  14.  *      from the free distribution of software,  therefore distribution
  15.  *      of unmodified copies of this material is not restricted.
  16.  *      You may change your own copy as needed.   Neither Rice
  17.  *      University nor any of its employees or students shall be held
  18.  *      liable for damages resulting from the use of this software.
  19.  */
  20.  
  21. Parse Source . . arg0 .
  22. Parse Arg nick '/' rest
  23. nick = Strip(nick)
  24. rest = Strip(rest)
  25.  
  26. Do While nick = ""      /*  deal with null parts w/o recursion  */
  27.     If rest = "" Then Do; 'SHORT'; Exit rc; End
  28.     Parse Var rest nick '/' rest
  29.     End  /*  Do  While  */
  30. /*
  31. If nick = "" Then Do    **  deal with null parts by recursion  **
  32.     If rest = "" Then 'SHORT'
  33.                  Else 'CALLPIPE *: |' arg0 rest '| *:'
  34.     Exit rc
  35.     End  **  If  ..  Do  **
  36.  */
  37.  
  38. /*  look for the shortcut on pure LISTFILE ouptut  */
  39. 'PEEKTO RECORD'
  40. If rc ^= 0 Then Exit rc * (rc ^= 12)
  41. If Strip(record) = "" Then Signal SHORTCUT
  42.  
  43. /*  part = nick;  Upper part  */
  44. Parse Upper Var nick part
  45.  
  46. Do Forever
  47.  
  48.     'READTO RECORD'
  49.     If rc ^= 0 Then Leave
  50.     If Left(record,1) = '*' Then Iterate
  51.     If Left(record,1) ^= ' ' Then Leave         /*  short cut  */
  52.  
  53.     Parse Upper Var record fn ft fm fp '"' . "'" . '05'x .
  54.     If Strip(fn) = "" Then Iterate
  55.  
  56.     If  fp = "" Then  Select  /*  ft  */
  57.         When  Index(fn,'*') > 0 Then    fp = fn || '.' || ft
  58.         When  ft = ""   | ft = "*"  | ,
  59.               ft = "FILELIST"   Then    fp = fn
  60.         Otherwise                       fp = fn || '.' || ft
  61.         End  /*  Select  ft  */
  62.     If Strip(fp) ^= part Then Iterate
  63.  
  64. Say "GOPSRVRP: matched" fn ft fm fp
  65.     /*  found it!  */
  66.     /*  Parse Arg nick '/' .  */
  67.     Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'
  68.     If rest = "" Then 'CALLPIPE GOPSRVLS' fn ft fm '| *:'
  69.                  Else 'CALLPIPE GOPSRVLS' fn ft fm '|' arg0 rest '| *:'
  70.     /*  Leave  */  Exit rc
  71.  
  72.     End
  73.  
  74. FALLOUT:
  75. Say "GOPSRVRP: didn't find a match for" nick
  76. /*  fallout;  we didn't find a match in this menu  */
  77. /*  Parse Arg nick  */
  78. nick = nick || '/' || rest
  79. Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'
  80. 'CALLPIPE GOPSRVLS ? ? ? | *:'
  81.  
  82. Exit rc
  83.  
  84. SHORTCUT:
  85. Parse Var
  86. Say "GOPSRVRP: shortcut to" fn ft fm fp
  87.     /*  found it!  */
  88.     /*  Parse Arg nick '/' .  */
  89.     Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'
  90.     If rest = "" Then 'CALLPIPE GOPSRVLS' fn ft fm '| *:'
  91.                  Else 'CALLPIPE GOPSRVLS' fn ft fm '|' arg0 rest '| *:'
  92.     /*  Leave  */  Exit rc
  93.  
  94.  
  95.