File: mkheader.pl

package info (click to toggle)
samba-doc-ja 2.2.8a%2Bja1.0-0.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 34,192 kB
  • ctags: 22,693
  • sloc: ansic: 197,587; sh: 8,073; perl: 5,377; makefile: 1,489; awk: 1,146; exp: 1,143; csh: 216
file content (63 lines) | stat: -rwxr-xr-x 1,603 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl


open(PROFILE,"profile.h") || die "Unable to open profile.h\n";
@profile = <PROFILE>;
close PROFILE;

open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n";

print METRICS "#define COUNT_TIME_INDOM 0\n";
print METRICS "#define BYTE_INDOM       1\n\n";
print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n";
print METRICS "typedef struct {\n";
print METRICS "\tchar *name;\n";
print METRICS "\tunsigned offset;\n";
print METRICS "} samba_instance;\n\n";

@instnames = grep(/unsigned .*_time;/,@profile);
foreach $instnames (@instnames) {
    chomp $instnames;
    $instnames =~ s/^.*unsigned (.*)_time.*$/$1/;
}

print METRICS "static samba_instance samba_counts[] = {";
$first = 1;
foreach $1 (@instnames) {
    if ($first == 1) {
	$first = 0;
	print METRICS "\n";
    } else {
	print METRICS ",\n";
    }
    print METRICS "\t{\"$1\", FIELD_OFF($1_count)}";
}
print METRICS "\n};\n\n";
print METRICS "static samba_instance samba_times[] = {";
$first = 1;
foreach $1 (@instnames) {
    if ($first == 1) {
	$first = 0;
	print METRICS "\n";
    } else {
	print METRICS ",\n";
    }
    print METRICS "\t{\"$1\", FIELD_OFF($1_time)}";
}
print METRICS "\n};\n\n";
print METRICS "static samba_instance samba_bytes[] = {";
@instnames = grep(/unsigned .*_bytes;/,@profile);
$first = 1;
foreach $_ (@instnames) {
    if ($first == 1) {
	$first = 0;
	print METRICS "\n";
    } else {
	print METRICS ",\n";
    }
    /^.*unsigned (.*)_bytes.*$/;
    print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}";
}
print METRICS "\n};\n";

close METRICS