#!/usr/bin/perl
# Arguements:
# $0: image format (passed by builddb)
# $1: filename (passed by builddb)
# $2: the section number to use (optional)
use strict;
my($suppress, $filename);
print STDERR "code2db: $ARGV[0] ($ARGV[1]) $ARGV[2]\n";
$suppress = 0;
$filename = $ARGV[1];
if($ARGV[2] ne ""){
print "Code: $filename\n";
}
$filename =~ s/^.*\///;
# Make C code safe for display in docbook
print "\n";
while(){
chomp;
if(/^[ \t]*\/\*\*\*\*\*\*\*\*\*/){
$suppress = 1;
}
elsif($suppress == 0){
s/\r$//;
s/&/&/g;
s/</g;
s/>/>/g;
s/\t/ /g;
print "$_\r\n";
}
if(($suppress == 1) && (/\*\*\*\*\*\*\*\*\*\/$/)){
$suppress = 0;
}
}
print "\n";
if($ARGV[2] ne ""){
print "\n";
}
else{
print "Code: $filename\n";
}