#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
require 5.005;
use strict;
use warnings;
use Time::localtime;
$cmd = "mkdemo";
$chapfile = "chapters";
$htmlfile = "index.html";
sub chaps_read {
my $fatal;
my %hash;
open(CHAPS, "$chapfile");
while (<CHAPS>) {
my $field;
my $value;
chop;
if (/^#/) {
next;
}
if (!/:/) {
if (exists $hash{'name'}) {
print "$cmd: chapter $hash{'name'} ";
print "has two entries.\n";
$fatal = 1;
}
%hash = ();
next;
}
%hash = ();
next;
}
if ($field eq "descr") {
$value .= " ";
}
}
if ($fatal) {
print "$cmd: fatal errors; cannot proceed.\n";
exit;
}
close (CHAPS);
}
sub chaps_ascending {
}
sub demo_process {
my $chap = $_[0];
my $demo = $_[1];
while (<DEMO>) {
print OUT $_;
*
*
*
*
*
}
}
close (DEMO);
close (OUT);
}
sub demo_find {
my $demo = $_[0];
my $chap;
if (!stat("$chap/$demo")) {
next;
}
return;
}
die "Couldn't find $demo in any chapter";
}
sub chaps_process {
my $outfile = $_[0];
my $chap;
print HTML "<html>\n<head>\n";
print HTML "<title>Example DTrace Scripts</title>\n";
print HTML "</head>\n<body bgcolor=\"#ffffff\">\n";
print HTML "<table width=\"85%\" border=0 align=\"center\"><tr><td>";
print HTML "<h2>DTrace Examples</h2>\n";
print HTML "<hr><p>\n";
print HTML "Here are the <a href=\"$dtrace_url\">DTrace</a> scripts\n";
print HTML "that are used as examples in the\n";
print HTML "<a href=\"$chaps{book}{url}\">$chaps{book}{title}</a>. ";
print HTML "For more information on any one script, follow the link\n";
print HTML "to its corresponding chapter.\n";
print HTML "<p>\n<hr><p>\n";
print HTML "<left><table width=\"85%\" border=1 cellpadding=4 ";
print HTML "cellspacing=0 align=\"center\" bgcolor=\"#ffffff\">\n";
print HTML "<tr bgcolor=\"#5882a1\"><td width=\"50%\">";
print HTML "<font color=\"#ffffff\"><b>Chapter</b></td></font>\n";
print HTML "<td><font color=\"#ffffff\"><b>Script</b></td>\n";
print HTML "</font></tr>\n";
my @demos;
my $demo;
#
# Open the directory associated with the chapter.
#
next;
}
closedir(DEMOS);
print HTML "<tr>\n";
print HTML "<td align=left>";
print HTML "<a href=\"$chaps{$chap}{url}\">";
print HTML "$chaps{$chap}{title}</a></td>\n";
print HTML "<td><table border=0>\n";
if ($demo !~ /^[a-z].*\.d$/) {
next;
}
print HTML "<tr><td><a href=\"$demo\">$demo</a>";
print HTML "</td></tr>\n";
}
print HTML "</table></td></tr>\n";
}
print HTML "</table>\n</td>\n<p>\n\n";
print HTML "</td></tr>\n";
print HTML "<tr><td><hr><small>Copyright ";
print HTML " Sun Microsystems</small>\n";
print HTML "</table>\n";
print HTML "</body>\n</html>\n";
close HTML;
}
chaps_read();
} else {
}