source: trunk/MagicSoft/Mars/macros/runbook.C@ 3370

Last change on this file since 3370 was 2197, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 1.8 KB
Line 
1void Wrap(TString &str)
2{
3 while (str.Length()>80)
4 {
5 TString ss = str(0, 80);
6 Int_t l = ss.Last(' ');
7 if (l<0)
8 break;
9 cout << str(0, l) << endl;
10 str.Remove(0, l);
11 }
12 cout << str << endl;
13}
14
15void ProcessFile(TString fname, TString date)
16{
17 cout << fname << endl;
18
19 ifstream fin(fname);
20
21 TString line;
22
23 int i=81;
24
25 TRegexp r0("20[0-2][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]");
26 TRegexp r1(date+" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]");
27
28 int lcnt=0;
29
30 int print = 0;
31
32 while (!fin.eof())
33 {
34 char *txt=new char[i];
35 fin.getline(txt, i-1);
36
37 if (lcnt++<4)
38 continue;
39
40 if (!fin)
41 txt[i-1]=0;
42
43 line += txt;
44 delete txt;
45
46 if (line.Length()==0)
47 {
48 if (print)
49 cout << endl;
50 continue;
51 }
52
53 if (!fin)
54 {
55 i *= 2;
56 fin.clear();
57 continue;
58 }
59
60 if (!line(r0).IsNull())
61 print = !line(r1).IsNull();
62
63 if (print)
64 Wrap(line);
65 line = "";
66 i=81;
67 }
68 cout << "DONE." << endl;
69}
70
71void runbook(const char *d="20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]")
72{
73 TString regexp = "20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]";
74
75 if (regexp!=d)
76 {
77 TRegexp r(regexp);
78
79 TString date=d;
80 if (date(r).IsNull())
81 {
82 cout << "ERROR - Date has wrong format (2003-05-06)" << endl;
83 return;
84 }
85 }
86
87 MDirIter Next;
88 Next.AddDirectory("/home/MAGIC/online_data/runbook", "CC_*.rbk");
89
90 TString name;
91 while (1)
92 {
93 name=Next();
94 if (name.IsNull())
95 break;
96
97 ProcessFile(name, d);
98 }
99}
Note: See TracBrowser for help on using the repository browser.