#!/usr/local/bin/perl # Yeah, I know, probably 1000 other persons already wrote a script like # this, but I'll tell ya: # THEY DON'T FIT ME :-) # Get readme file as parameter: my $README = $ARGV[0]; if($README eq "") { print "usage: mkreadme.pl [-c] < manpage\n"; exit; } push @out, " _ _ ____ _ \n"; push @out, " Project ___| | | | _ \\| | \n"; push @out, " / __| | | | |_) | | \n"; push @out, " | (__| |_| | _ <| |___ \n"; push @out, " \\___|\\___/|_| \\_\\_____|\n"; my $head=0; while () { $line = $_; # this kind should be removed first: $line =~ s/_//g; # then this: $line =~ s/.//g; if($line =~ /^curl/i) { # cut off the page headers $head=1; next; } if($line =~ /^[ \t]*\n/) { $wline++; # we only make one empty line max next; } if($wline) { $wline = 0; if(!$head) { push @out, "\n"; } $head =0; } push @out, $line; } push @out, "\n"; # just an extra newline open(READ, "<$README") || die "couldn't read the README infile $README"; while() { push @out, $_; } close(READ); # if compressed if($c) { my @test = `gzip --version 2>&1`; if($test[0] =~ /gzip/) { open(GZIP, "|gzip -9 >dumpit.gz") || die "can't run gzip, try without -c"; binmode GZIP; for(@out) { print GZIP $_; $gzip += length($_); } close(GZIP); open(GZIP, ") { push @gzip, $_; $gzipped += length($_); } close(GZIP); unlink("dumpit.gz"); } else { # no gzip, no compression! undef $c; print STDERR "MEEEP: Couldn't find gzip, disable compression\n"; } } $now = localtime; print < HEAD ; if($c) { print "/* gzip shrunk this data from $gzip to $gzipped bytes */\n", "#include \nstatic const unsigned char hugehelpgz[] = {\n "; my $c=0; for(@gzip) { my @all=split(//, $_); for(@all) { my $num=ord($_); printf("0x%02x, ", 0+$num); if(++$c>11) { print "\n "; $c=0; } } } print "\n};\n"; print < 500) { # terminate and make another fputs() call here print ", stdout);\n fputs(\n"; $outsize=length($new)+1; } printf("\"%s\\n\"\n", $new); } print ", stdout) ;\n}\n"