home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / tvconf2b.zip / tvconfig.cmd < prev    next >
OS/2 REXX Batch file  |  1997-09-29  |  4KB  |  112 lines

  1. /* TVFS.CONF / TVFS Configuration Utility / release 2B    */
  2. /* written by Byron Q. Desnoyers Winmill                  */
  3. /*                                                        */
  4. /* Revision History:                                      */
  5. /* 16-Sep-97 : release 1                                  */
  6. /*     original release                                   */
  7. /* 26-Sep-97 : release 2                                  */
  8. /*     built TVFSCONFIG class                             */
  9. /*     loads TVCTL automagically                          */
  10. /*     numerous parsing fixes                             */
  11. /*     consistent error messages                          */
  12. /*     cleaned up code                                    */
  13. /*     fixed comment bugs                                 */
  14.  
  15. /* todo: make constants more accessable */
  16.  
  17. '@ ECHO OFF'
  18.  
  19. /* Define global constants.           */
  20. TITLE='[tvfs.conf]';
  21.  
  22. /* Parse command line.                */
  23. parse arg conf_file tv_drives
  24.  
  25. tvfs_conf = .TVFSConfig~new(TITLE);
  26. tvfs_conf~work(conf_file, tv_drives);
  27. tvfs_conf~done;
  28.  
  29. exit(0);
  30.  
  31. /* ----------========== ObjectREXX Classes ==========---------- */
  32.  
  33. ::CLASS TVFSConfig                      /* TVFS configuration class.     */
  34.   ::METHOD init                         /* Initializes TVRX extensions.  */
  35.     expose title;
  36.     use arg title;
  37.  
  38.     'tvctl -t -w -f0';
  39.  
  40.     rc = RxFuncAdd('TvLoadFuncs', 'TVRX', 'TvLoadFuncs');
  41.     if ( rc <> 0 ) then do
  42.       say title '| Error calling RxFuncAdd()';
  43.       self~done;
  44.       exit(1);
  45.     end;                           /* if, rc */
  46.  
  47.     rc = TvLoadFuncs();
  48.     if ( rc <> 0 ) then do
  49.       say title '| Error calling TvLoadFuncs()';
  50.       self~done;
  51.       exit(2);
  52.     end;                           /* if, rc */
  53.   return;                          /* method, init */
  54.  
  55.   ::METHOD work                         /* Configures TVFS.              */
  56.     use arg conf_file, tv_drives;
  57.  
  58.     self~mount(tv_drives);
  59.     self~link(conf_file);          /* method, work */
  60.   return;
  61.  
  62.   ::METHOD done                         /* Terminates TVRX extensions.   */
  63.     rc = TvDropFuncs()
  64.   return;                          /* method, done */
  65.  
  66.   ::METHOD mount                        /* Mounts TVFS partitions.       */
  67.     expose title;
  68.     use arg tv_drives;
  69.  
  70.     DIVIDER=',';
  71.  
  72.     do while ( tv_drives~length > 0 )
  73.       parse var tv_drives this_drive (DIVIDER) tv_drives;
  74.       rc = TvMount(this_drive':');
  75.       if ( rc <> 0 ) then say title '| Warning, could not mount 'this_drive':'
  76.     end;                           /* while, tv_drives */
  77.   return;                          /* method, mount */
  78.  
  79.   ::METHOD link                         /* Links TVFS files and paths.   */
  80.     expose title;
  81.     use arg conf_file;
  82.  
  83.     COMMENT='#';
  84.     DISPLAY='!';
  85.  
  86.     conf_stream = .stream~new(conf_file);
  87.     do while ( conf_stream~lines > 0 )
  88.       buffer = conf_stream~linein;
  89.  
  90.       if ( buffer~length > 0 ) then do
  91.         parse var buffer command 2 string;
  92.  
  93.         select
  94.           when ( command = COMMENT ) then
  95.             nop;
  96.           when ( command = DISPLAY ) then
  97.             say title string;
  98.           otherwise
  99.             parse var buffer parameters source destination;
  100.  
  101.             if ( source~length = 0 ) | ( destination~length = 0 ) then
  102.               say title '| Warning, could not link' buffer;
  103.             else do
  104.               rc = TvLink(parameters source destination);
  105.               if ( rc <> 0 ) then say title '| Warning, error' rc 'linking' buffer;
  106.             end;                   /* if: string.source, string.destination */
  107.           end;                     /* select */
  108.       end;                         /* if, buffer */
  109.     end;                           /* while, conf_stream~lines */
  110.     conf_stream~close;
  111.   return;                          /* method, link */
  112.