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 #include <Basics.H>
00030
00031
00032 #include <CacheConfig.H>
00033 #include <Debug.H>
00034
00035
00036 #include "DebugC.H"
00037
00038 using std::ostream;
00039 using std::cout;
00040 using std::cerr;
00041 using std::endl;
00042
00043 static void ExitClient() throw ()
00044 {
00045 cerr << "SYNTAX: FlushCache [ -n ]" << endl;
00046 cerr.flush();
00047 exit(1);
00048 }
00049
00050 static void PrintSRPCFailure(ostream &os, SRPC::failure &f) throw ()
00051 {
00052 os << "SRPC Failure (code " << f.r << "):" << endl;
00053 os << " " << f.msg << endl << endl;
00054 os.flush();
00055 }
00056
00057 static void FlushAll() throw ()
00058 {
00059 DebugC debug;
00060
00061
00062 cout << Debug::Timestamp() << "CALLING FlushAll" << endl;
00063 cout << endl;
00064
00065
00066 try {
00067 debug.FlushAll();
00068 } catch (SRPC::failure &f) {
00069 PrintSRPCFailure(cerr, f);
00070 }
00071
00072
00073 cout << Debug::Timestamp() << "RETURNED FlushAll" << endl;
00074 cout << endl;
00075 }
00076
00077 int main(int argc, char *argv[])
00078 {
00079 bool doIt = true;
00080
00081
00082 if (argc > 4) {
00083 cerr << "Error: too many arguments" << endl;
00084 ExitClient();
00085 }
00086 for (int arg = 1; arg < argc; arg++) {
00087 if (!strcmp(argv[arg], "-n")) {
00088 doIt = false;
00089 } else if (*argv[arg] == '-') {
00090 cerr << "Error: unrecognized option: " << argv[arg] << endl;
00091 ExitClient();
00092 } else {
00093 cerr << "Error: invalid command-line" << endl;
00094 ExitClient();
00095 }
00096 }
00097
00098
00099 cout << Debug::Timestamp() << "Flushing cache:" << endl;
00100 cout << " Host = " << Config_Host << endl;
00101 cout << " Port = " << Config_Port << endl << endl;
00102 cout.flush();
00103
00104
00105 if (doIt) {
00106 FlushAll();
00107 cout << Debug::Timestamp() << "Done!" << endl;
00108 cout.flush();
00109 } else {
00110 cout << "NOTE: No action taken at your request." << endl;
00111 cout.flush();
00112 }
00113 return 0;
00114 }