home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / upc12b22.zip / getuupc.cmd < prev    next >
OS/2 REXX Batch file  |  1993-05-10  |  4KB  |  116 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       g e t u u p c                                                */
  3. /*                                                                    */
  4. /*       Get UUPC/extended configuration variable                     */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Copyright (c) 1992-1993 by Kendra Electronic Wonderworks, all   */
  9. /*    rights reserved except those granted by the UUPC/extended       */
  10. /*    license.                                                        */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*
  14.  *       $Id: GETUUPC.CMD 1.4 1993/05/10 11:35:05 ahd Exp $
  15.  *
  16.  *       $Log: GETUUPC.CMD $
  17.  *      Revision 1.4  1993/05/10  11:35:05  ahd
  18.  *      Drop extra parse command which broken selected sewarches
  19.  *
  20.  *      Revision 1.3  1993/05/09  14:10:26  ahd
  21.  *      Don't perform user level lookup unless asked
  22.  *
  23.  *      Revision 1.2  1993/05/04  00:25:58  ahd
  24.  *      Support personal.rc to allow su.cmd
  25.  *
  26. *        Revision 1.1  1993/04/04  05:01:49  ahd
  27. *        Initial revision
  28. *
  29.  */
  30.  
  31. signal on novalue
  32. parse upper arg keyword,answer,uupcusrrc
  33.  
  34. /*--------------------------------------------------------------------*/
  35. /*                     Get the UUPC.RC file name                      */
  36. /*--------------------------------------------------------------------*/
  37.  
  38. uupcrc = value('UUPCSYSRC',,'OS2ENVIRONMENT')
  39. if  uupcrc == '' then
  40. do
  41.    'UUPCSYSRC not set, cannot continue'
  42.    exit
  43. end
  44.  
  45. confdir = translate(filespec('D',uupcrc) || filespec('P',uupcrc),'\','/');
  46.  
  47. answer = search( keyword, answer, confdir, uupcrc );
  48.  
  49. if uupcusrrc <> '' then
  50. do;
  51.    uupcusrrc = translate( uupcusrrc , '\', '/');
  52.  
  53.    if verify( uupcusrrc, '\/', 'N') == 0 then
  54.       uupcusrrc = confdir || '\' || uupcusrrc;
  55.  
  56.    answer = search( keyword, answer, confdir, uupcusrrc );
  57. end;
  58.  
  59. if left(answer,1) == '\' then
  60.    answer = filespec('D',uupcrc) || answer;
  61. return answer;
  62.  
  63. search:procedure
  64. parse arg keyword,answer,confdir,uupcrc
  65. /*--------------------------------------------------------------------*/
  66. /*     Read the file, then scope the contents a line at the time      */
  67. /*--------------------------------------------------------------------*/
  68.  
  69. xrc = SysFileSearch( keyword || '=',uupcrc,'data.')
  70. if xrc \= 0 then
  71. do
  72.    say 'SysFileSearch error' xrc 'searching' uupcrc 'for' keyword
  73.    if ( answer == '' ) then
  74.       exit
  75.    else
  76.       return answer
  77. end
  78.  
  79. do count = 1 to data.0
  80.    parse var data.count newkey'='string
  81.  
  82.    if translate(newkey) = keyword then
  83.       answer = string
  84. end
  85.  
  86. /*--------------------------------------------------------------------*/
  87. /*    Return the value if found, return directories if we can         */
  88. /*    generate the directory name, otherwise return default input.    */
  89. /*--------------------------------------------------------------------*/
  90.  
  91. select;
  92.    when ( answer \= '' ) then
  93.       return translate(answer,'\','/')
  94.    when ( keyword = 'CONFDIR' ) then
  95.       return confdir;
  96.    when ( keyword = 'SPOOLDIR' ) then
  97.       return confdir || 'spool';
  98.    when ( keyword = 'NEWSDIR' ) then
  99.       return confdir || 'news';
  100.    when ( keyword = 'ARCHIVEDIR' ) then
  101.       return confdir || 'archive';
  102.    when ( keyword = 'MAILDIR' ) then
  103.       return confdir || 'mail';
  104.    when ( keyword = 'TEMPDIR' ) then
  105.    do;
  106.       tempdir = value('TEMP',,'OS2ENVIRONMENT')
  107.       if tempdir = '' then
  108.          tempdir = value('TMP',,'OS2ENVIRONMENT')
  109.       if tempdir = '' then
  110.          tempdir = confdir || 'tmp';
  111.       return tempdir;
  112.    end;
  113.    otherwise
  114.       return translate(answer,'\','/')
  115. end;
  116.