bagder: curl-www/libcurl/c mkexam.pl,1.2,1.3

[email protected] Thu, 10 Sep 2009 08:32:10 +0000
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/libcurl/c
In directory labb:/tmp/cvs-serv13425

Modified Files:
	mkexam.pl 
Log Message:
fancy links on curl_ functions and CURLOPT_ options to the docs for them


Index: mkexam.pl
===================================================================
RCS file: /cvsroot/curl/curl-www/libcurl/c/mkexam.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mkexam.pl	10 Sep 2009 08:03:34 -0000	1.2
+++ mkexam.pl	10 Sep 2009 08:32:08 -0000	1.3
@@ -1,5 +1,7 @@
 #!/usr/bin/perl
 
+my $manpage="http://curl.haxx.se/libcurl/c";
+
 my $template="_example-templ.html";
 
 my $dir="../../cvssource/docs/examples";
@@ -36,7 +38,8 @@
     close(OUT);
     close(F);
 
-    # now run enscript and extract the PRE part
+    # now run enscript and extract the PRE part and linkify some of the libcurl
+    # stuff
     # 
     open(ET, ">$encfile");
     open(CMD, "$cmd|");
@@ -47,11 +50,28 @@
         }
 
         if($show) {
-            if($_ eq "\n") {
+            my $l=$_;
+
+            # find curl_ function invokes
+            if($l =~ /^(.*)(curl_[a-z_]*)( *\(.*)/) {
+                $l = sprintf "$1<a href=\"%s\">%s</a>$3\n", "$manpage/$2.html", $2;
+            }
+
+            # find CURLOPT_ uses
+            if($l =~ /^(.*)(CURLOPT_[A-Z_]*)(.*)/) {
+                my $cut = $2;
+                my ($pre, $opt, $post) = ($1, $2, $3);
+                
+                $cut =~ s/_//g;
+                $l = sprintf "$pre<a href=\"%s\">%s</a>$post\n",
+                "$manpage/curl_easy_setopt.html#$cut", $opt;
+            }
+
+            if($l eq "\n") {
                 print ET "&nbsp;\n";
             }
             else {
-                print ET $_;
+                print ET $l;
             }
             if($_ =~ /^<\/PRE/) {
                 $show = 0;