00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "VestaLog.H"
00024 #include <stdlib.h>
00025 extern "C" {
00026 #include <getopt.h>
00027 }
00028
00029 using std::cin;
00030 using std::cout;
00031 using std::cerr;
00032 using std::endl;
00033
00034 char* program_name;
00035
00036 void
00037 Usage()
00038 {
00039 cerr << "Usage: " << program_name << " [-n lognum] [-l] [logdir]" << endl;
00040 exit(2);
00041 }
00042
00043 int
00044 main(int argc, char* argv[])
00045 {
00046 int lognum = -1;
00047 bool loop = false;
00048 VestaLog VRLog;
00049
00050 program_name = argv[0];
00051
00052 int c;
00053 for (;;) {
00054 c = getopt(argc, argv, "n:l");
00055 if (c == EOF) break;
00056 switch (c) {
00057 case 'n':
00058 lognum = strtol(optarg, NULL, 0);
00059 break;
00060 case 'l':
00061 loop = true;
00062 break;
00063 case '?':
00064 default:
00065 Usage();
00066 }
00067 }
00068
00069 char* dir;
00070 switch (argc - optind) {
00071 case 0:
00072 dir = ".";
00073 break;
00074 case 1:
00075 dir = argv[optind];
00076 break;
00077 default:
00078 Usage();
00079 }
00080
00081 try {
00082 VRLog.open(dir, lognum, true);
00083 } catch (VestaLog::Error) {
00084 cerr << program_name << ": error opening log\n";
00085 exit(1);
00086 }
00087
00088 for (;;) {
00089 char c;
00090
00091 try {
00092 VRLog.get(c);
00093 cout.put(c);
00094 } catch (VestaLog::Error) {
00095 cerr << program_name << ": error getting character from log\n";
00096 exit(1);
00097 } catch (VestaLog::Eof) {
00098 if (!loop || !VRLog.nextLog()) break;
00099 }
00100 }
00101 VRLog.close();
00102
00103 return 0;
00104 }