00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <Basics.H>
00031 #include <Text.H>
00032 #include <VestaConfig.H>
00033 #include <VestaSource.H>
00034 #include "ReposUI.H"
00035
00036 #if !defined(__sun__)
00037 extern "C" {
00038 #include <getopt.h>
00039 }
00040 #endif
00041
00042 using std::cout;
00043 using std::cerr;
00044 using std::endl;
00045
00046 Text program_name;
00047
00048 void usage()
00049 {
00050 cerr << "Usage: " << program_name << endl
00051 << " [-h hints]" << endl
00052 << " [path]" << endl << endl;
00053 exit(1);
00054 }
00055
00056 int
00057 main(int argc, char* argv[])
00058 {
00059 program_name = argv[0];
00060
00061 try {
00062
00063
00064
00065 Text defpkgpar = VestaConfig::get_Text("UserInterface",
00066 "DefaultPackageParent");
00067 Text defhints;
00068 (void) VestaConfig::get("UserInterface", "DefaultHints", defhints);
00069
00070 Text path, hints;
00071
00072 opterr = 0;
00073 for (;;) {
00074 int c = getopt(argc, argv, "h:");
00075 if (c == EOF) break;
00076 switch (c) {
00077 case 'h':
00078 hints = optarg;
00079 break;
00080 case '?':
00081 default:
00082 usage();
00083 }
00084 }
00085
00086 hints = hints + " " + defhints;
00087
00088 switch (argc - optind) {
00089 case 1:
00090 path = argv[optind];
00091 break;
00092 case 0:
00093 path = ".";
00094 break;
00095 default:
00096 usage();
00097
00098 }
00099
00100
00101 Text cpath;
00102 cpath = ReposUI::canonicalize(path, defpkgpar);
00103
00104
00105 VestaSource *vs = ReposUI::filenameToMasterVS(cpath, hints);
00106
00107
00108 cout << vs->host() << ":" << vs->port() << endl;
00109
00110 } catch (VestaConfig::failure f) {
00111 cerr << program_name << ": " << f.msg << endl;
00112 exit(2);
00113 } catch (SRPC::failure f) {
00114 cerr << program_name
00115 << ": SRPC failure; " << f.msg << " (" << f.r << ")" << endl;
00116 exit(2);
00117 } catch (ReposUI::failure f) {
00118 cerr << program_name << ": " << f.msg << endl;
00119 exit(2);
00120 }
00121
00122 return 0;
00123 }