Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

vaccessrefresh.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 //
00020 // vaccessrefresh.C
00021 // Last modified on Sun Jun  5 21:50:08 EDT 2005 by ken@xorian.net
00022 //      modified on Wed Jul 11 22:03:49 PDT 2001 by mann
00023 //
00024 // Ask the repository to refresh its access tables.
00025 //
00026 
00027 #include <Basics.H>
00028 #include <Text.H>
00029 #include <VestaConfig.H>
00030 #include <VestaSource.H>
00031 #include <VDirSurrogate.H>
00032 #if !defined(__sun__)
00033 extern "C" {
00034 #include <getopt.h>
00035 }
00036 #endif
00037 
00038 using std::cout;
00039 using std::cerr;
00040 using std::endl;
00041 
00042 Text program_name;
00043 
00044 void
00045 Usage()
00046 {
00047     cerr << "Usage: " << program_name <<
00048       " [-R repos]" << endl << endl;
00049     exit(3);
00050 }
00051 
00052 int
00053 main(int argc, char* argv[])
00054 {
00055     try {
00056         program_name = argv[0];
00057         Text repos;
00058 
00059         int c;
00060         for (;;) {
00061             c = getopt(argc, argv, "h?R:");
00062             if (c == EOF) break;
00063             switch (c) {
00064               case 'R': repos = optarg; break;
00065               case 'h':
00066               case '?':
00067               default:
00068                 Usage();
00069             }
00070         }
00071 
00072         Text lhost(VDirSurrogate::defaultHost());
00073         Text lport(VDirSurrogate::defaultPort());
00074         if (repos != "") {
00075           int colon = repos.FindCharR(':');
00076           if (colon == -1) {
00077             lhost = repos;
00078             repos = repos + ":" + lport;
00079           } else {
00080             lhost = repos.Sub(0, colon);
00081             lport = repos.Sub(colon+1);
00082           }
00083         }
00084 
00085         // Note that we always pass NULL for "who", so there's no way
00086         // to override the user who's requesting the refresh.
00087         VDirSurrogate::refreshAccessTables(NULL, lhost, lport);
00088 
00089         // If we don't get an SRPC::failure, we succeeded.
00090         cout << "Repository access tables refreshed." << endl;
00091 
00092     } catch (VestaConfig::failure f) {
00093         cerr << program_name << ": " << f.msg << endl;
00094         exit(1);
00095     } catch (SRPC::failure f) {
00096         cerr << program_name
00097           << ": SRPC failure; " << f.msg << " (" << f.r << ")" << endl;
00098         exit(2);
00099     }
00100 
00101     return 0;
00102 }
00103 

Generated on Mon May 8 00:48:55 2006 for Vesta by  doxygen 1.4.2