~ubuntu-branches/ubuntu/edgy/net-snmp/edgy-updates

« back to all changes in this revision

Viewing changes to win32/dist/scripts/create-toc

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-03-31 04:21:37 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050331042137-z0vw1grslj6cek9k
Tags: 5.1.2-6ubuntu2
Apply safe-but-hackish patch by Henrique de Moraes Holschuh to
fix the libdir in libsnmp5-dev's .la files (Ubuntu bug #8393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# This program generates an HTML document containing links to man
 
4
# pages already converted to html using man2html3.0.1 
 
5
# (http://search.cpan.org/~ehood/man2html3.0.1/) 
 
6
#
 
7
# Written by:     Alex Burger
 
8
# Date:           March 2nd, 2004
 
9
 
10
################################################################
 
11
# Options
 
12
 
 
13
# Location of man pages to parse
 
14
$man_dir = "/tmp/net-snmp/html/";
 
15
$include_header = 1;
 
16
$include_footer = 1;
 
17
 
 
18
# Output file
 
19
$toc_file = "/tmp/net-snmp/html/toc.hhc";
 
20
 
 
21
#URL up to the name of the man page
 
22
$url = '';
 
23
 
 
24
################################################################
 
25
 
 
26
if ($man_dir =~ /\/$/) {
 
27
  chop $man_dir;
 
28
}
 
29
 
 
30
@files = `find $man_dir`;
 
31
 
 
32
@files = sort @files;
 
33
 
 
34
open (FILE_OUT, ">$toc_file") || die "Could not open file $toc_file for writing. $!";
 
35
select FILE_OUT;
 
36
 
 
37
foreach my $file (@files)
 
38
{
 
39
  chomp $file;
 
40
 
 
41
  # Man pages  
 
42
  if ($file =~ /$man_dir\/man(\d+)-(.*)/)
 
43
  {
 
44
    push (@man_pages, "$1-$2");
 
45
  }
 
46
 
 
47
  # Perl POD files  
 
48
  elsif ($file =~ /$man_dir\/perl-(.*)/) {
 
49
    push (@perl_files, "$1");
 
50
  }
 
51
 
 
52
  # README files
 
53
  elsif ($file =~ /$man_dir\/readme-(.*)/) {
 
54
    push (@readme_files, "$1");
 
55
  }
 
56
}
 
57
 
 
58
@man_pages = sort (@man_pages);
 
59
@perl_files = sort (@perl_files);
 
60
@readme_files = sort (@readme_files);
 
61
 
 
62
# Divide up man pages  
 
63
foreach my $man_page (@man_pages)
 
64
{
 
65
  $man_page =~ /(\d+)-(.*)/;
 
66
 
 
67
  if ($1 == 1) { push (@man1,$2); }
 
68
  elsif ($1 == 2) { push (@man2,$2); }
 
69
  elsif ($1 == 3) { push (@man3,$2); }
 
70
  elsif ($1 == 4) { push (@man4,$2); }
 
71
  elsif ($1 == 5) { push (@man5,$2); }
 
72
  elsif ($1 == 6) { push (@man6,$2); }
 
73
  elsif ($1 == 7) { push (@man7,$2); }
 
74
  elsif ($1 == 8) { push (@man8,$2); }
 
75
  elsif ($1 == 9) { push (@man9,$2); }
 
76
}
 
77
  
 
78
if ($include_header > 0) {
 
79
  print '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">' . "\n";
 
80
  print '<HTML>' . "\n";
 
81
  print '<HEAD>' . "\n";
 
82
  print '<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">' . "\n";
 
83
  print '<!-- Sitemap 1.0 -->' . "\n";
 
84
  print '</HEAD><BODY>' . "\n";
 
85
  print '<OBJECT type="text/site properties">' . "\n";
 
86
  print '       <param name="ImageType" value="Folder">' . "\n";
 
87
  print '</OBJECT>' . "\n";
 
88
  
 
89
  print "<UL>\n";
 
90
}
 
91
print_section("Applications",   "man1-",\@man1);
 
92
print_section("man2",           "man2-",\@man2);
 
93
print_section("API",            "man3-",\@man3);
 
94
print_section("man4",           "man4-",\@man4);
 
95
print_section("Configuration",  "man5-",\@man5);
 
96
print_section("man6",           "man6-",\@man6);
 
97
print_section("man7",           "man7-",\@man7);
 
98
print_section("Servers",        "man8-",\@man8);
 
99
print_section("man9",           "man9-",\@man9);
 
100
 
 
101
print_section("Start Here",     "readme-",\@readme_files);
 
102
print_section("Perl Modules",   "perl-",\@perl_files);
 
103
 
 
104
sub print_section{
 
105
  # Section title, subfolder/prefix, array
 
106
  my $section_name = shift;
 
107
  my $folder = shift;
 
108
  my $man = shift;
 
109
 
 
110
  if (defined(@$man)) {
 
111
      
 
112
    print '     <LI> <OBJECT type="text/sitemap">' . "\n";
 
113
    print "             <param name=\"Name\" value=\"$section_name\">\n";
 
114
    print '             <param name="ImageNumber" value="1">' . "\n";
 
115
    print '             </OBJECT>' . "\n";
 
116
 
 
117
    print "     <UL>\n";
 
118
    foreach my $man_page (@$man)
 
119
    {
 
120
      my $man_page_short;
 
121
      if ($man_page =~ /(.*?)\.\d+\.html/i) {
 
122
        $man_page_short = $1;
 
123
      }
 
124
      else {
 
125
        $man_page =~ /(.*?).html/i;
 
126
        $man_page_short = $1;
 
127
      }
 
128
      print '           <LI> <OBJECT type="text/sitemap">' . "\n";
 
129
      print "                   <param name=\"Name \"value=\"$man_page_short\">\n";
 
130
      print "                   <param name=\"Local\" value=\"$folder$url$man_page\">\n";
 
131
      print '                   </OBJECT>' . "\n";
 
132
    }
 
133
    print "     </UL>\n";
 
134
  }
 
135
}
 
136
 
 
137
if ($include_footer > 0) {
 
138
  print "</UL>\n";
 
139
  print "</BODY>\n";
 
140
  print "</HTML>\n";
 
141
}
 
142
 
 
143
close FILE_OUT;
 
144