2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 # Yeah, I know, probably 1000 other persons already wrote a script like
25 # this, but I'll tell ya:
27 # THEY DON'T FIT ME :-)
29 # Get readme file as parameter:
31 if($ARGV[0] eq "-c") {
36 my $README = $ARGV[0];
39 print "usage: mkreadme.pl [-c] <README> < manpage\n";
44 push @out, " _ _ ____ _\n";
45 push @out, " Project ___| | | | _ \\| |\n";
46 push @out, " / __| | | | |_) | |\n";
47 push @out, " | (__| |_| | _ <| |___\n";
48 push @out, " \\___|\\___/|_| \\_\\_____|\n";
54 # this should be removed:
55 $line =~ s/(
\b.|_
\b)//g;
57 if($line =~ /^([ \t]*\n|curl)/i) {
58 # cut off headers and empty lines
59 $wline++; # count number of cut off lines
64 $text =~ s/^\s+//g; # cut off preceding...
65 $text =~ s/\s+$//g; # and trailing whitespaces
67 $tlen = length($text);
69 if($wline && ($olen == $tlen)) {
70 # if the previous line with contents was exactly as long as
71 # this line, then we ignore the newlines!
73 # We do this magic because a header may abort a paragraph at
74 # any line, but we don't want that to be noticed in the output
81 # we only make one empty line max
87 push @out, "\n"; # just an extra newline
89 open(READ, "<$README") ||
90 die "couldn't read the README infile $README";
99 my @test = `gzip --version 2>&1`;
100 if($test[0] =~ /gzip/) {
101 open(GZIP, ">dumpit") ||
102 die "can't create the dumpit file, try without -c";
110 system("gzip --best --no-name dumpit");
112 open(GZIP, "<dumpit.gz") ||
113 die "can't read the dumpit.gz file, try without -c";
117 $gzipped += length($_);
124 # no gzip, no compression!
126 print STDERR "MEEEP: Couldn't find gzip, disable compression\n";
133 * NEVER EVER edit this manually, fix the mkhelp.pl script instead!
134 * Generation time: $now
137 #include "tool_hugehelp.h"
143 #include "memdebug.h" /* keep this as LAST include */
144 static const unsigned char hugehelpgz[] = {
145 /* This mumbo-jumbo is the huge help text compressed with gzip.
146 Thanks to this operation, the size of this data shrunk from $gzip
147 to $gzipped bytes. You can disable the use of compressed help
148 texts by NOT passing -c to the mkhelp.pl tool. */
154 my @all=split(//, $_);
157 printf(" 0x%02x,", 0+$num);
167 #define BUF_SIZE 0x10000
168 static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size)
171 /* not a typo, keep it calloc() */
172 return (voidpf) calloc(items, size);
174 static void zfree_func(voidpf opaque, voidpf ptr)
179 /* Decompress and send to stdout a gzip-compressed buffer */
183 int status,headerlen;
186 /* Make sure no gzip options are set */
187 if (hugehelpgz[3] & 0xfe)
191 memset(&z, 0, sizeof(z_stream));
192 z.zalloc = (alloc_func)zalloc_func;
193 z.zfree = (free_func)zfree_func;
194 z.avail_in = (unsigned int)(sizeof(hugehelpgz) - headerlen);
195 z.next_in = (unsigned char *)hugehelpgz + headerlen;
197 if (inflateInit2(&z, -MAX_WBITS) != Z_OK)
200 buf = malloc(BUF_SIZE);
203 z.avail_out = BUF_SIZE;
205 status = inflate(&z, Z_SYNC_FLUSH);
206 if (status == Z_OK || status == Z_STREAM_END) {
207 fwrite(buf, BUF_SIZE - z.avail_out, 1, stdout);
208 if (status == Z_STREAM_END)
238 $outsize += length($new)+1; # one for the newline
243 # gcc 2.96 claims ISO C89 only is required to support 509 letter strings
245 # terminate and make another fputs() call here
246 print ", stdout);\n fputs(\n";
247 $outsize=length($new)+1;
249 printf("\"%s\\n\"\n", $new);
253 print ", stdout) ;\n}\n";
259 #else /* !USE_MANUAL */
260 /* built-in manual is disabled, blank function */
261 #include "tool_hugehelp.h"
262 void hugehelp(void) {}
263 #endif /* USE_MANUAL */