Split up main stylesheet (necessary for new examples code)
[Samba.git] / pcp / mkheader.pl
blobad069c544a8e80fae1827196021ad4a5ef761731
1 #!/usr/bin/perl
4 open(PROFILE,"profile.h") || die "Unable to open profile.h\n";
5 @profile = <PROFILE>;
6 close PROFILE;
8 open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n";
10 print METRICS "#define COUNT_TIME_INDOM 0\n";
11 print METRICS "#define BYTE_INDOM 1\n\n";
12 print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n";
13 print METRICS "typedef struct {\n";
14 print METRICS "\tchar *name;\n";
15 print METRICS "\tunsigned offset;\n";
16 print METRICS "} samba_instance;\n\n";
18 @instnames = grep(/unsigned .*_time;/,@profile);
19 foreach $instnames (@instnames) {
20 chomp $instnames;
21 $instnames =~ s/^.*unsigned (.*)_time.*$/$1/;
24 print METRICS "static samba_instance samba_counts[] = {";
25 $first = 1;
26 foreach $1 (@instnames) {
27 if ($first == 1) {
28 $first = 0;
29 print METRICS "\n";
30 } else {
31 print METRICS ",\n";
33 print METRICS "\t{\"$1\", FIELD_OFF($1_count)}";
35 print METRICS "\n};\n\n";
36 print METRICS "static samba_instance samba_times[] = {";
37 $first = 1;
38 foreach $1 (@instnames) {
39 if ($first == 1) {
40 $first = 0;
41 print METRICS "\n";
42 } else {
43 print METRICS ",\n";
45 print METRICS "\t{\"$1\", FIELD_OFF($1_time)}";
47 print METRICS "\n};\n\n";
48 print METRICS "static samba_instance samba_bytes[] = {";
49 @instnames = grep(/unsigned .*_bytes;/,@profile);
50 $first = 1;
51 foreach $_ (@instnames) {
52 if ($first == 1) {
53 $first = 0;
54 print METRICS "\n";
55 } else {
56 print METRICS ",\n";
58 /^.*unsigned (.*)_bytes.*$/;
59 print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}";
61 print METRICS "\n};\n";
63 close METRICS